Skip to content

Commit

Permalink
Merge pull request #2780 from stevepiercy/pcreate-to-cookiecutter
Browse files Browse the repository at this point in the history
Add deprecation notice in pcreate
  • Loading branch information
stevepiercy authored Oct 2, 2016
2 parents 2058b2e + 8548e29 commit 6eb58d7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
16 changes: 15 additions & 1 deletion pyramid/scripts/pcreate.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ def main(argv=sys.argv, quiet=False):

class PCreateCommand(object):
verbosity = 1 # required
description = "Render Pyramid scaffolding to an output directory"
description = """\
Render Pyramid scaffolding to an output directory.
Note: As of Pyramid 1.8, this command is deprecated. Use a specific
cookiecutter instead:
https://github.com/pylons/?query=cookiecutter
"""
usage = "usage: %prog [options] -s <scaffold> output_directory"
parser = optparse.OptionParser(usage, description=description)
parser.add_option('-s', '--scaffold',
Expand Down Expand Up @@ -77,6 +83,7 @@ def __init__(self, argv, quiet=False):
self.scaffolds = self.all_scaffolds()

def run(self):
self._warn_pcreate_deprecated()
if self.options.list:
return self.show_scaffolds()
if not self.options.scaffold_name and not self.args:
Expand Down Expand Up @@ -212,5 +219,12 @@ def confirm_bad_name(self, prompt): # pragma: no cover
answer = input_('{0} [y|N]: '.format(prompt))
return answer.strip().lower() == 'y'

def _warn_pcreate_deprecated(self):
self.out('''\
Note: As of Pyramid 1.8, this command is deprecated. Use a specific
cookiecutter instead:
https://github.com/pylons/?query=cookiecutter
''')

if __name__ == '__main__': # pragma: no cover
sys.exit(main() or 0)
10 changes: 5 additions & 5 deletions pyramid/tests/test_scripts/test_pcreate.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ def test_run_show_scaffolds_exist(self):
result = cmd.run()
self.assertEqual(result, 0)
out = self.out_.getvalue()
self.assertTrue(out.startswith('Available scaffolds'))
self.assertTrue(out.count('Available scaffolds'))

def test_run_show_scaffolds_none_exist(self):
cmd = self._makeOne('-l')
cmd.scaffolds = []
result = cmd.run()
self.assertEqual(result, 0)
out = self.out_.getvalue()
self.assertTrue(out.startswith('No scaffolds available'))
self.assertTrue(out.count('No scaffolds available'))

def test_run_no_scaffold_no_args(self):
cmd = self._makeOne(quiet=True)
Expand All @@ -46,22 +46,22 @@ def test_run_no_scaffold_name(self):
result = cmd.run()
self.assertEqual(result, 2)
out = self.out_.getvalue()
self.assertTrue(out.startswith(
self.assertTrue(out.count(
'You must provide at least one scaffold name'))

def test_no_project_name(self):
cmd = self._makeOne('-s', 'dummy')
result = cmd.run()
self.assertEqual(result, 2)
out = self.out_.getvalue()
self.assertTrue(out.startswith('You must provide a project name'))
self.assertTrue(out.count('You must provide a project name'))

def test_unknown_scaffold_name(self):
cmd = self._makeOne('-s', 'dummyXX', 'distro')
result = cmd.run()
self.assertEqual(result, 2)
out = self.out_.getvalue()
self.assertTrue(out.startswith('Unavailable scaffolds'))
self.assertTrue(out.count('Unavailable scaffolds'))

def test_known_scaffold_single_rendered(self):
import os
Expand Down

0 comments on commit 6eb58d7

Please sign in to comment.