diff options
| author | Igor Stroh <rennpferd@gmail.com> | 2015-06-11 00:08:33 +0200 |
|---|---|---|
| committer | Igor Stroh <rennpferd@gmail.com> | 2015-06-11 00:08:33 +0200 |
| commit | f09cc1b354f093bd2afd24085a7e747b0867be8b (patch) | |
| tree | c59d296e5233dc41f8b6514250c2bee47e6be6a9 | |
| parent | 7dc81f082adba97effc3ce3726e453ec71e841b7 (diff) | |
| download | pyramid-f09cc1b354f093bd2afd24085a7e747b0867be8b.tar.gz pyramid-f09cc1b354f093bd2afd24085a7e747b0867be8b.tar.bz2 pyramid-f09cc1b354f093bd2afd24085a7e747b0867be8b.zip | |
use input_ from p.compat, renamed option
- Use pyramid.compat.input_ instead of manually checking
for python version and chosing the appropriate
input/raw_input function
- Renamed--force-conflicting-name option to --ignore-conflicting-name
- Display invalid scaffold names in a sorted manner
| -rw-r--r-- | pyramid/scripts/pcreate.py | 14 | ||||
| -rw-r--r-- | pyramid/tests/test_scripts/test_pcreate.py | 2 |
2 files changed, 6 insertions, 10 deletions
diff --git a/pyramid/scripts/pcreate.py b/pyramid/scripts/pcreate.py index 881aacac3..1e8074fc5 100644 --- a/pyramid/scripts/pcreate.py +++ b/pyramid/scripts/pcreate.py @@ -8,11 +8,7 @@ import os.path import pkg_resources import re import sys - -if sys.version_info[0] == 3: - user_input = input # pragma: no cover -else: - user_input = raw_input # NOQA +from pyramid.compat import input_ _bad_chars_re = re.compile('[^a-zA-Z0-9_]') @@ -61,7 +57,7 @@ class PCreateCommand(object): dest='interactive', action='store_true', help='When a file would be overwritten, interrogate') - parser.add_option('--force-conflicting-name', + parser.add_option('--ignore-conflicting-name', dest='force_bad_name', action='store_true', default=False, @@ -181,7 +177,7 @@ class PCreateCommand(object): available = [x.name for x in self.scaffolds] diff = set(self.options.scaffold_name).difference(available) if diff: - self.out('Unavailable scaffolds: %s' % ", ".join(list(diff))) + self.out('Unavailable scaffolds: %s' % ", ".join(sorted(diff))) return False pkg_name = self.project_vars['package'] @@ -204,12 +200,12 @@ class PCreateCommand(object): if self.options.force_bad_name: return True - self.out('Package "{0}" already exists, are you sure you want ' + self.out('A package named "{0}" already exists, are you sure you want ' 'to use it as your project\'s name?'.format(pkg_name)) return self.confirm_bad_name('Really use "{0}"?: '.format(pkg_name)) def confirm_bad_name(self, prompt): # pragma: no cover - answer = user_input('{0} [y|N]: '.format(prompt)) + answer = input_('{0} [y|N]: '.format(prompt)) return answer.strip().lower() == 'y' if __name__ == '__main__': # pragma: no cover diff --git a/pyramid/tests/test_scripts/test_pcreate.py b/pyramid/tests/test_scripts/test_pcreate.py index 8fc9c1267..eaa7c1464 100644 --- a/pyramid/tests/test_scripts/test_pcreate.py +++ b/pyramid/tests/test_scripts/test_pcreate.py @@ -240,7 +240,7 @@ class TestPCreateCommand(unittest.TestCase): 'pyramid_docs_branch': 'master'}) def test_force_override_conflicting_name(self): - cmd = self._makeOne('-s', 'dummy', 'Unittest', '--force-conflicting-name') + cmd = self._makeOne('-s', 'dummy', 'Unittest', '--ignore-conflicting-name') scaffold = DummyScaffold('dummy') cmd.scaffolds = [scaffold] cmd.pyramid_dist = DummyDist("0.10.1dev") |
