Skip to content

Commit

Permalink
- Fix the pcreate script so that when the target directory name e…
Browse files Browse the repository at this point in the history
…nds with a

  slash it does not produce a non-working project directory structure.
  Previously saying ``pcreate -s starter /foo/bar/`` produced different output
  than  saying ``pcreate -s starter /foo/bar``.  The former did not work
  properly.
  • Loading branch information
mcdonc committed Oct 2, 2013
1 parent fd07896 commit 073e524
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
9 changes: 9 additions & 0 deletions CHANGES.txt
@@ -1,6 +1,15 @@
Unreleased
==========

Bug Fixes
---------

- Fix the ``pcreate`` script so that when the target directory name ends with a
slash it does not produce a non-working project directory structure.
Previously saying ``pcreate -s starter /foo/bar/`` produced different output
than saying ``pcreate -s starter /foo/bar``. The former did not work
properly.

Documentation
-------------

Expand Down
2 changes: 1 addition & 1 deletion pyramid/scripts/pcreate.py
Expand Up @@ -77,8 +77,8 @@ def run(self):
def render_scaffolds(self):
options = self.options
args = self.args
project_name = os.path.basename(args[0])
output_dir = os.path.abspath(os.path.normpath(args[0]))
project_name = os.path.basename(os.path.split(output_dir)[1])
pkg_name = _bad_chars_re.sub('', project_name.lower())
safe_name = pkg_resources.safe_name(project_name)
egg_name = pkg_resources.to_filename(safe_name)
Expand Down
15 changes: 15 additions & 0 deletions pyramid/tests/test_scripts/test_pcreate.py
Expand Up @@ -110,6 +110,21 @@ def test_known_scaffold_multiple_rendered(self):
scaffold2.vars,
{'project': 'Distro', 'egg': 'Distro', 'package': 'distro'})

def test_known_scaffold_with_path_as_project_target_rendered(self):
import os
cmd = self._makeOne('-s', 'dummy', '/tmp/foo/Distro/')
scaffold = DummyScaffold('dummy')
cmd.scaffolds = [scaffold]
result = cmd.run()
self.assertEqual(result, 0)
self.assertEqual(
scaffold.output_dir,
os.path.normpath(os.path.join(os.getcwd(), '/tmp/foo/Distro'))
)
self.assertEqual(
scaffold.vars,
{'project': 'Distro', 'egg': 'Distro', 'package': 'distro'})

class Test_main(unittest.TestCase):
def _callFUT(self, argv):
from pyramid.scripts.pcreate import main
Expand Down

0 comments on commit 073e524

Please sign in to comment.