Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deprecation notice in pcreate #2780

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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