Skip to content

Commit

Permalink
Correction for string literal prefix test
Browse files Browse the repository at this point in the history
  • Loading branch information
f-osorio committed Sep 30, 2019
1 parent 963bc78 commit 9e23b10
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 28 deletions.
52 changes: 26 additions & 26 deletions ckan/cli/generate.py
Expand Up @@ -15,49 +15,49 @@ def generate():
@generate.command(name=u'extension', short_help=u"Create empty extension.")
@click.option(u'-n', u'--name', help=u"Name of the extension (must begin "
u"with 'ckanext-')",
default="extension")
default=u"extension")
@click.option(u'-o', u'--output-dir', help=u"Location to put the generated "
u"template.",
default='.')
default=u'.')
def extension(name, output_dir):
cur_loc = os.path.dirname(os.path.abspath(__file__))
os.chdir(cur_loc)
os.chdir('../../contrib/cookiecutter/ckan_extension/')
os.chdir(u'../../contrib/cookiecutter/ckan_extension/')
template_loc = os.getcwd()

# Prompt user for information
click.echo("\n")
author = click.prompt("Author's name", default="")
email = click.prompt("Author's email", default="")
github = click.prompt("Your Github user or organization name", default="")
description = click.prompt("Brief description of the project",
default="")
keywords = click.prompt("List of keywords (seperated by spaces)",
default="CKAN")
click.echo(u"\n")
author = click.prompt(u"Author's name", default=u"")
email = click.prompt(u"Author's email", default=u"")
github = click.prompt(u"Your Github user or organization name", default=u"")
description = click.prompt(u"Brief description of the project",
default=u"")
keywords = click.prompt(u"List of keywords (seperated by spaces)",
default=u"CKAN")

# Ensure one instance of 'CKAN' in keywords
keywords = keywords.strip().split()
keywords = [keyword for keyword in keywords
if keyword not in ('ckan', 'CKAN')]
keywords.insert(0, 'CKAN')
if keyword not in (u'ckan', u'CKAN')]
keywords.insert(0, u'CKAN')
keywords = u' '.join(keywords)

# Set short name and plugin class name
project_shortname = name[8:].lower().replace('-', '_')
plugin_class_name = project_shortname.title().replace('_', '') + 'Plugin'
project_shortname = name[8:].lower().replace(u'-', u'_')
plugin_class_name = project_shortname.title().replace(u'_', u'') + u'Plugin'

context = {"project": name,
"description": description,
"author": author,
"author_email": email,
"keywords": keywords,
"github_user_name": github,
"project_shortname": project_shortname,
"plugin_class_name": plugin_class_name,
"_source": "cli"}
context = {u"project": name,
u"description": description,
u"author": author,
u"author_email": email,
u"keywords": keywords,
u"github_user_name": github,
u"project_shortname": project_shortname,
u"plugin_class_name": plugin_class_name,
u"_source": "cli"}

if output_dir == '.':
os.chdir('../../../..')
if output_dir == u'.':
os.chdir(u'../../../..')
output_dir = os.getcwd()

cookiecutter(template_loc, no_input=True, extra_context=context,
Expand Down
3 changes: 1 addition & 2 deletions ckan/tests/legacy/test_coding_standards.py
Expand Up @@ -487,8 +487,7 @@ class TestPep8(object):
'contrib/cookiecutter/ckan_extension/'
'{{cookiecutter.project}}/ckanext/{{cookiecutter.project_shortname}}'
'/tests/test_plugin.py',
'contrib/cookiecutter/ckan_extension/{{cookiecutter.project}}'
'/ckanext/{{cookiecutter.project_shortname}}/plugin.py'
'contrib/cookiecutter/ckan_extension/{{cookiecutter.project}}/ckanext/{{cookiecutter.project_shortname}}/plugin.py'
]
fails = {}
passes = []
Expand Down

0 comments on commit 9e23b10

Please sign in to comment.