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
Improve the ckanext template #1956
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d0e4ea4
Improve the ckanext template
seanh fc9561c
Typo in README template
seanh 8b34820
Remove "deadoralive" from template README
seanh 8108a2c
Change example names
seanh be54ba8
Fix packaging of data files
seanh f5f0565
Add some more package metadata
seanh 19dd325
Fix missing comma in setup.py_tmpl
seanh 3b478e5
Add pypip.in README badges to extension template
seanh File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,72 @@ | ||
"""A Paste template for creating new CKAN extensions. | ||
|
||
Usage:: | ||
|
||
paster --plugin=ckan create -t ckanext | ||
|
||
See: | ||
|
||
* http://docs.pylonsproject.org/projects/pylons-webframework/en/latest/advanced_pylons/creating_paste_templates.html | ||
* http://pythonpaste.org/script/developer.html#templates | ||
|
||
""" | ||
Paste template for new ckanext.plugins projects | ||
""" | ||
import sys | ||
|
||
import jinja2 | ||
from paste.script.templates import Template, var | ||
from paste.util.template import paste_script_template_renderer | ||
from paste.script.create_distro import Command | ||
import sys | ||
|
||
# Horrible hack to change the behaviour of Paste itself | ||
# Since this module is only imported when commands are | ||
# run, this will not affect any other paster commands. | ||
import re | ||
Command._bad_chars_re = re.compile('[^a-zA-Z0-9_-]') | ||
|
||
|
||
def jinja2_template_renderer(content_as_string, vars_as_dict, filename=None): | ||
return jinja2.Environment().from_string(content_as_string).render( | ||
vars_as_dict) | ||
|
||
|
||
class CkanextTemplate(Template): | ||
"""A Paste template for a skeleton CKAN extension package. | ||
|
||
""" | ||
Template to build a skeleton ckanext.plugins package | ||
""" | ||
|
||
_template_dir = 'template/' | ||
summary = 'CKAN extension project template' | ||
template_renderer = staticmethod(paste_script_template_renderer) | ||
use_cheetah = True | ||
template_renderer = staticmethod(jinja2_template_renderer) | ||
|
||
vars = [ | ||
var('version', 'Version (like 0.1)'), | ||
var('description', 'One-line description of the package'), | ||
var('author', 'Author name'), | ||
var('author_email', 'Author email'), | ||
var('url', 'URL of homepage'), | ||
var('license_name', 'License name'), | ||
var('description', 'a one-line description of the extension, ' | ||
'for example: "A simple blog extension for CKAN"'), | ||
var('author', 'for example: "Guybrush Threepwood"'), | ||
var('author_email', 'for example: "guybrush@meleeisland.com"'), | ||
var('keywords', 'a space-separated list of keywords, for example: ' | ||
'"CKAN blog"'), | ||
var('github_user_name', 'your GitHub user or organization name, for ' | ||
'example: "guybrush" or "ckan"'), | ||
] | ||
|
||
def check_vars(self, vars, cmd): | ||
vars = Template.check_vars(self, vars, cmd) | ||
|
||
if not vars['project'].startswith('ckanext-'): | ||
print "\nError: Expected the project name to start with 'ckanext-'" | ||
print "\nError: Project name must start with 'ckanext-'" | ||
sys.exit(1) | ||
vars['project'] = vars['project'][len('ckanext-'):] | ||
|
||
# The project name without the ckanext-. | ||
vars['project_shortname'] = vars['project'][len('ckanext-'):] | ||
|
||
# Make sure keywords contains "CKAN" (upper-case) once only. | ||
keywords = vars['keywords'].strip().split() | ||
keywords = [keyword for keyword in keywords | ||
if keyword not in ('ckan', 'CKAN')] | ||
keywords.insert(0, 'CKAN') | ||
vars['keywords'] = ' '.join(keywords) | ||
|
||
# For an extension named ckanext-example we want a plugin class | ||
# named ExamplePlugin. | ||
vars['plugin_class_name'] = vars['project_shortname'].title() + 'Plugin' | ||
|
||
return vars |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[report] | ||
omit = | ||
*/site-packages/* | ||
*/python?.?/* | ||
ckan/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
.ropeproject | ||
node_modules | ||
bower_components | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
env/ | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
sdist/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.coverage | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
|
||
# Sphinx documentation | ||
docs/_build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
language: python | ||
python: | ||
- "2.6" | ||
- "2.7" | ||
env: PGVERSION=9.1 | ||
install: | ||
- bash bin/travis-build.bash | ||
- pip install coveralls | ||
script: sh bin/travis-run.sh | ||
after_success: | ||
- coveralls | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Brilliant.