summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2013-10-01 21:43:36 -0400
committerChris McDonough <chrism@plope.com>2013-10-01 21:43:36 -0400
commit073e5247f4adf68fe96423d6669b437dc6f337a8 (patch)
treef864ea57c7057fbea9c78798220a6c773581c4f2
parentfd078969a105d421f9e07aad9a7a720e2f5f2900 (diff)
downloadpyramid-073e5247f4adf68fe96423d6669b437dc6f337a8.tar.gz
pyramid-073e5247f4adf68fe96423d6669b437dc6f337a8.tar.bz2
pyramid-073e5247f4adf68fe96423d6669b437dc6f337a8.zip
- 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.
-rw-r--r--CHANGES.txt9
-rw-r--r--pyramid/scripts/pcreate.py2
-rw-r--r--pyramid/tests/test_scripts/test_pcreate.py15
3 files changed, 25 insertions, 1 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 8b2210a99..34e722fd6 100644
--- a/CHANGES.txt
+++ b/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
-------------
diff --git a/pyramid/scripts/pcreate.py b/pyramid/scripts/pcreate.py
index ba4eb0856..5e2240856 100644
--- a/pyramid/scripts/pcreate.py
+++ b/pyramid/scripts/pcreate.py
@@ -77,8 +77,8 @@ class PCreateCommand(object):
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)
diff --git a/pyramid/tests/test_scripts/test_pcreate.py b/pyramid/tests/test_scripts/test_pcreate.py
index 1406d3911..6516ac229 100644
--- a/pyramid/tests/test_scripts/test_pcreate.py
+++ b/pyramid/tests/test_scripts/test_pcreate.py
@@ -110,6 +110,21 @@ class TestPCreateCommand(unittest.TestCase):
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