Protect from bad (non-importable) repo names, like those with dashes

This commit is contained in:
Catherine Devlin 2016-03-06 05:05:24 -05:00
parent 8a3d36fe40
commit 3573272952
2 changed files with 5 additions and 1 deletions

View File

@ -1,6 +1,6 @@
{
"project_name": "project_name",
"repo_name": "{{ cookiecutter.project_name|replace(' ', '_') }}",
"repo_name": "{{ cookiecutter.project_name|replace(' ', '_')|replace('-', '_') }}",
"author_name": "Your Name",
"email": "Your email",
"description": "A short description of the project.",

4
hooks/pre_gen_project.py Normal file
View File

@ -0,0 +1,4 @@
repo_name = '{{ cookiecutter.repo_name }}'
if hasattr(repo_name, 'isidentifier'):
assert repo_name.isidentifier(), 'Repo name should be valid Python identifier!'