Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Commit

Permalink
refactor options
Browse files Browse the repository at this point in the history
  • Loading branch information
steff456 committed Aug 5, 2019
1 parent ec313f6 commit 2249d9e
Show file tree
Hide file tree
Showing 20 changed files with 48 additions and 43 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,23 @@ $ cookiecutter gh:spyder-ide/spyder-plugin-cookiecutter

You'll be prompted for some values. and after that the repo will be generated

Normally you don't need to change `project_name` and `repo_name`.
Normally you don't need to change `python_package_name` and `git_repo_name`.

Example:

```
author [Spyder Project Contributors]:
email [[email protected]]:
plugin_name [Demo]:
git_repo_name [spyder-demo]:
python_package_name [spyder_demo]:
description [Plugin for Spyder IDE.]:
version [0.1.0]:
author [Spyder Project Contributors]:
email [[email protected]]:
github_username [spyder-ide]:
plugin_name [Demo Plugin]: Reports
repo_name [spyder-reports]:
project_name [spyder_reports]:
description [Plugin for Spyder IDE.]: Spyder Plugin for Markdown reports for Pweave
version [0.1.0]:
create_config_page [n]:
use_ciocheck [y]:
support_python_2 [n]:
spyder3_compatibility [y]:
graphical_plugin [y]:
create_config_page [n]:
support_python_2 [n]:
spyder3_compatibility [n]:
```

## Testing
Expand Down
11 changes: 5 additions & 6 deletions cookiecutter.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
{
"author": "Spyder Project Contributors",
"email": "[email protected]",
"github_username": "spyder-ide",
"plugin_name": "Demo",
"repo_name": "spyder-{{ cookiecutter.plugin_name.lower().replace(' ', '-')}}",
"project_name": "{{ cookiecutter.repo_name.replace('-', '_') }}",
"git_repo_name": "spyder-{{ cookiecutter.plugin_name.lower().replace(' ', '-')}}",
"python_package_name": "{{ cookiecutter.git_repo_name.replace('-', '_') }}",
"description": "Plugin for Spyder IDE.",
"version": "0.1.0",
"author": "Spyder Project Contributors",
"email": "[email protected]",
"github_username": "spyder-ide",
"create_config_page": "n",
"use_ciocheck": "y",
"support_python_2": "n",
"spyder3_compatibility": "n",
"graphical_plugin": "y"
Expand Down
10 changes: 8 additions & 2 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ def remove(filepath):
if not create_widget:
# Remove the widgets folder if the plugin is not graphical
remove(os.path.join(PROJECT_DIRECTORY,
'{{cookiecutter.project_name}}', 'widgets'))
'{{cookiecutter.python_package_name}}', 'widgets'))


valid_name = '{{cookiecutter.python_package_name}}'.startswith('spyder_')

if not valid_name:
raise ValueError('Third party plugins name should start with spyder_')


def init_git():
Expand All @@ -49,7 +55,7 @@ def init_git():
# 2. Create empty assets directory

assets_dir = os.path.join(PROJECT_DIRECTORY,
'{{ cookiecutter.project_name }}',
'{{ cookiecutter.python_package_name }}',
'assets')

os.mkdir(assets_dir)
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[tool:pytest]
norecursedirs = {{\ cookiecutter.repo_name\ }}
norecursedirs = {{\ cookiecutter.git_repo_name\ }}
16 changes: 8 additions & 8 deletions tests/test_cookiecutter_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ def context():
'email': '[email protected]',
'github_username': 'spyder-ide',
'plugin_name': 'Demo',
'repo_name': 'spyder-demo',
'project_name': 'spyder_demo',
'git_repo_name': 'spyder-demo',
'python_package_name': 'spyder_demo',
'description': 'Plugin for Spyder IDE.',
'version': '0.1.0',
}
Expand All @@ -24,8 +24,8 @@ def non_graphical():
'email': '[email protected]',
'github_username': 'spyder-ide',
'plugin_name': 'Demo-nongraphic',
'repo_name': 'spyder-demo-nongraphic',
'project_name': 'spyder_demo_nongraphic',
'git_repo_name': 'spyder-demo-nongraphic',
'python_package_name': 'spyder_demo_nongraphic',
'description': 'Plugin for Spyder IDE.',
'version': '0.1.0',
'graphical_plugin': 'n'
Expand All @@ -36,7 +36,7 @@ def test_default_configuration(cookies, context):
result = cookies.bake(extra_context=context)
assert result.exit_code == 0
assert result.exception is None
assert result.project.basename == context['repo_name']
assert result.project.basename == context['git_repo_name']
assert result.project.isdir()

# Test creation of project files
Expand All @@ -54,7 +54,7 @@ def test_default_configuration(cookies, context):
project_files = ['widgets', 'assets', 'demoplugin.py', '_version.py',
'__init__.py', 'tests']

project_dir = result.project.join(context['project_name'])
project_dir = result.project.join(context['python_package_name'])
found_project_files = [f.basename for f in project_dir.listdir()]

for path in project_files:
Expand All @@ -66,7 +66,7 @@ def test_non_graphical_configuration(cookies, non_graphical):
result = cookies.bake(extra_context=non_graphical)
assert result.exit_code == 0
assert result.exception is None
assert result.project.basename == non_graphical['repo_name']
assert result.project.basename == non_graphical['git_repo_name']
assert result.project.isdir()

# Test creation of project files
Expand All @@ -84,7 +84,7 @@ def test_non_graphical_configuration(cookies, non_graphical):
project_files = ['assets', 'demo-nongraphicplugin.py', '_version.py',
'__init__.py', 'tests']

project_dir = result.project.join(non_graphical['project_name'])
project_dir = result.project.join(non_graphical['python_package_name'])
found_project_files = [f.basename for f in project_dir.listdir()]

for path in project_files:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ Using pip

::

pip install {{ cookiecutter.project_name }}
pip install {{ cookiecutter.python_package_name }}

Using conda

::

conda install {{ cookiecutter.project_name }} -c spyder-ide
conda install {{ cookiecutter.python_package_name }} -c spyder-ide

Usage
-----
Expand Down
8 changes: 8 additions & 0 deletions {{ cookiecutter.git_repo_name }}/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{%- if cookiecutter.support_python_2 == 'y' -%}
[bdist_wheel]
universal=1

{% endif -%}

[tool:pytest]
addopts =-x -v -rw --durations=10 --cov={{ cookiecutter.python_package_name }} --cov-report=term-missing
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Licensed under the terms of the MIT License
# (see LICENSE.txt for details)
# -----------------------------------------------------------------------------
"""Setup script for {{ cookiecutter.project_name }}."""
"""Setup script for {{ cookiecutter.python_package_name }}."""

# Standard library imports
import ast
Expand All @@ -29,9 +29,9 @@ def get_description():


setup(
name='{{ cookiecutter.repo_name }}',
name='{{ cookiecutter.git_repo_name }}',
keywords=['Spyder', 'Plugin'],
url='https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.repo_name }}',
url='https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.git_repo_name }}',
license='MIT',
author='{{ cookiecutter.author }}',
author_email='{{ cookiecutter.email }}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import pytest

# Local imports
from {{ cookiecutter.project_name }}.{{ module_name }} import {{ plugin_name }}
from {{ cookiecutter.python_package_name }}.{{ module_name }} import {{ plugin_name }}


{%- if cookiecutter.graphical_plugin == 'y' %}
Expand Down
8 changes: 0 additions & 8 deletions {{ cookiecutter.repo_name }}/setup.cfg

This file was deleted.

0 comments on commit 2249d9e

Please sign in to comment.