Skip to content
Browse files

- Fix the ``pcreate`` script so that when the target directory name e…

…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...
1 parent fd07896 commit 073e5247f4adf68fe96423d6669b437dc6f337a8 @mcdonc mcdonc committed
Showing with 25 additions and 1 deletion.
  1. +9 −0 CHANGES.txt
  2. +1 −1 pyramid/scripts/pcreate.py
  3. +15 −0 pyramid/tests/test_scripts/test_pcreate.py
View
9 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
-------------
View
2 pyramid/scripts/pcreate.py
@@ -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)
View
15 pyramid/tests/test_scripts/test_pcreate.py
@@ -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

0 comments on commit 073e524

Please sign in to comment.
Something went wrong with that request. Please try again.