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

pcreate to cookiecutter #2866

Merged
merged 17 commits into from
Dec 13, 2016
Merged
Show file tree
Hide file tree
Changes from 14 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
2 changes: 2 additions & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ Contributors

- Keith Yang, 2016/07/22

- Hannah Krager, 2016/10/22

- Moriyoshi Koizumi, 2016/11/20

- Mikko Ohtamaa, 2016/12/6
2 changes: 1 addition & 1 deletion pyramid/scaffolds/starter/+package+/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
config = Configurator(settings=settings)
config.include('pyramid_chameleon')
config.include('pyramid_jinja2')
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_route('home', '/')
config.scan()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="${request.locale_name}">
<html lang="\{\{request.locale_name\}\}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
Expand All @@ -14,7 +14,7 @@
<link href="//oss.maxcdn.com/libs/twitter-bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">

<!-- Custom styles for this scaffold -->
<link href="${request.static_url('{{package}}:static/theme.css')}" rel="stylesheet">
<link href="\{\{request.static_url('{{package}}:static/theme.css')\}\}" rel="stylesheet">

<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
Expand All @@ -29,13 +29,12 @@
<div class="container">
<div class="row">
<div class="col-md-2">
<img class="logo img-responsive" src="${request.static_url('{{package}}:static/pyramid.png')}" alt="pyramid web framework">
<img class="logo img-responsive" src="\{\{request.static_url('{{package}}:static/pyramid.png')\}\}" alt="pyramid web framework">
</div>
<div class="col-md-10">
<div class="content">
<h1><span class="font-semi-bold">Pyramid</span> <span class="smaller">Starter scaffold</span></h1>
<p class="lead">Welcome to <span class="font-normal">${project}</span>, an&nbsp;application generated&nbsp;by<br>the <span class="font-normal">Pyramid Web Framework {{pyramid_version}}</span>.</p>
</div>
{% block content %}
<p>No content</p>
{% endblock content %}
</div>
</div>
<div class="row">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% extends "layout.jinja2" %}

{% block content%}
<div class="content">
<h1><span class="font-semi-bold">Pyramid</span> <span class="smaller">Starter scaffold</span></h1>
<p class="lead">Welcome to <span class="font-normal">\{\{project\}\}</span>, an&nbsp;application generated&nbsp;by<br>the <span class="font-normal">Pyramid Web Framework {{pyramid_version}}</span>.</p>
</div>
{% endblock content %}
2 changes: 1 addition & 1 deletion pyramid/scaffolds/starter/+package+/views.py_tmpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pyramid.view import view_config


@view_config(route_name='home', renderer='templates/mytemplate.pt')
@view_config(route_name='home', renderer='templates/mytemplate.jinja2')
def my_view(request):
return {'project': '{{project}}'}
2 changes: 1 addition & 1 deletion pyramid/scaffolds/starter/MANIFEST.in_tmpl
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
include *.txt *.ini *.cfg *.rst
recursive-include {{package}} *.ico *.png *.css *.gif *.jpg *.pt *.txt *.mak *.mako *.js *.html *.xml
recursive-include {{package}} *.ico *.png *.css *.gif *.jpg *.pt *.txt *.mak *.mako *.js *.html *.xml *.jinja2
2 changes: 1 addition & 1 deletion pyramid/scaffolds/starter/setup.py_tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ with open(os.path.join(here, 'CHANGES.txt')) as f:

requires = [
'pyramid',
'pyramid_chameleon',
'pyramid_jinja2',
'pyramid_debugtoolbar',
'waitress',
]
Expand Down
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 @@ -85,6 +91,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 @@ -224,5 +231,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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 4393f8b

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you try the url? That wasn't the only change...

''')

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
3 changes: 1 addition & 2 deletions scaffoldtests.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
#!/bin/bash
tox -e{py27,py33,py34,pypy}-scaffolds

tox -e{py27,py34,py35,pypy}-scaffolds,