8000 pep257 cleanup of cookiecutter.exceptions by minchinweb · Pull Request #1237 · cookiecutter/cookiecutter · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

pep257 cleanup of cookiecutter.exceptions #1237

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

Merged
merged 10 commits into from
Dec 22, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
36 changes: 18 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![pypi](https://img.shields.io/pypi/v/cookiecutter.svg)](https://pypi.python.org/pypi/cookiecutter)
[![python](https://img.shields.io/pypi/pyversions/cookiecutter.svg)](https://pypi.python.org/pypi/cookiecutter)
[![Build Status](https://travis-ci.org/cookiecutter/cookiecutter.svg?branch=master)](https://travis-ci.org/cookiecutter/cookiecutter)
[![Appveyor](https://ci.appveyor.com/api/projects/status/github/cookiecutter/cookiecutter?branch=master)](https://ci.appveyor.com/project/cookiecutter/cookiecutter/branch/master)
[![Appveyor](https://ci.appveyor.com/api/projects/status/github/cookiecutter/cookiecutter?branch=master&svg=true)](https://ci.appveyor.com/project/cookiecutter/cookiecutter/branch/master)
[![codecov](https://codecov.io/gh/cookiecutter/cookiecutter/branch/master/graphs/badge.svg?branch=master)](https://codecov.io/github/cookiecutter/cookiecutter?branch=master)
[![gitter](https://badges.gitter.im/JoinChat.svg)](https://gitter.im/audreyr/cookiecutter?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![docs](https://readthedocs.org/projects/cookiecutter/badge/?version=latest)](https://readthedocs.org/projects/cookiecutter/?badge=latest)
Expand Down Expand Up @@ -160,7 +160,7 @@ Stuck? Try one of the following:
* See the [Troubleshooting](https://cookiecutter.readthedocs.io/en/latest/troubleshooting.html) page.
* Ask for help on [Stack Overflow](https://stackoverflow.com/).
* You are strongly encouraged to [file an issue](https://github.com/cookiecutter/cookiecutter/issues?q=is%3Aopen) about the problem, even if it's just "I can't get it to work on this cookiecutter" with a link to your cookiecutter. Don't worry about naming/pinpointing the issue properly.
* Ask for help on [Gitter](https://gitter.im/audreyr/cookiecutter) if you must (but please try one of the other options first, so that others can benefit from the discussion)
* Ask for help on [Gitter](https://gitter.im/audreyr/cookiecutter) if you must (but please try one of the other options first, so that others can benefit from the discussion).

Development on Cookiecutter is community-driven:

Expand Down Expand Up @@ -207,11 +207,11 @@ Please avoid creating PRs for listing additional templates. We outsourced their
### Python

* [cookiecutter-pypackage](https://github.com/audreyr/cookiecutter-pypackage): [@audreyr](https://github.com/audreyr)'s ultimate Python package project template.
* [cookiecutter-pipproject](https://github.com/wdm0006/cookiecutter-pipproject): Minimal package for pip-installable projects
* [cookiecutter-pipproject](https://github.com/wdm0006/cookiecutter-pipproject): Minimal package for pip-installable projects.
* [cookiecutter-pypackage-minimal](https://github.com/kragniz/cookiecutter-pypackage-minimal): A minimal Python package template.
* [cookiecutter-lux-python](https://github.com/alexkey/cookiecutter-lux-python): A boilerplate Python project that aims to create Python package with a convenient Makefile-facility and additional helpers.
* [cookiecutter-flask](https://github.com/cookiecutter-flask/cookiecutter-flask) : A Flask template with Bootstrap 3, starter templates, and working user registration.
* [cookiecutter-flask-2](https://github.com/wdm0006/cookiecutter-flask): A heavier weight fork of cookiecutter-flask, with more boilerplate including forgotten password and Heroku integration
* [cookiecutter-flask-2](https://github.com/wdm0006/cookiecutter-flask): A heavier weight fork of cookiecutter-flask, with more boilerplate including forgotten password and Heroku integration.
* [cookiecutter-flask-foundation](https://github.com/JackStouffer/cookiecutter-Flask-Foundation) : Flask Template with caching, forms, sqlalchemy and unit-testing.
* [cookiecutter-flask-minimal](https://github.com/candidtim/cookiecutter-flask-minimal) : Minimal but production-ready Flask project template with no other dependencies except for Flask itself.
* [cookiecutter-flask-skeleton](https://github.com/realpython/cookiecutter-flask-skeleton) : Flask starter project.
Expand Down Expand Up @@ -241,8 +241,8 @@ Please avoid creating PRs for listing additional templates. We outsourced their
* [cookiecutter-py3tkinter](https://github.com/ivanlyon/cookiecutter-py3tkinter): Template for Python 3 Tkinter application gui.
* [cookiecutter-pyqt5](https://github.com/mandeep/cookiecutter-pyqt5): A prebuilt PyQt5 GUI template with a fully featured Pytest test suite and Travis CI integration all in an optimal Python package.
* [cookiecutter-pyqt4](https://github.com/aeroaks/cookiecutter-pyqt4): A prebuilt PyQt4 GUI template with a logging support, structure for tests and separation of ui and worker components.
* [cookiecutter-xontrib](https://github.com/laerus/cookiecutter-xontrib): A template for building xontribs, a.k.a [xonsh](https://github.com/xonsh/xonsh) contributions
* [cookiecutter-conda-python](https://github.com/conda/cookiecutter-conda-python): A template for building Conda Python packages
* [cookiecutter-xontrib](https://github.com/laerus/cookiecutter-xontrib): A template for building xontribs, a.k.a [xonsh](https://github.com/xonsh/xonsh) contributions.
* [cookiecutter-conda-python](https://github.com/conda/cookiecutter-conda-python): A template for building Conda Python packages.
* [cookiecutter-pypackage-rust-cross-platform-publish](https://github.com/mckaymatt/cookiecutter-pypackage-rust-cross-platform-publish): A template for a Python wheel containing a Rust binary module that supports releasing on Windows, OSX and Linux.
* [cookiecutter-telegram-bot](https://github.com/Ars2014/cookiecutter-telegram-bot): A template project for Telegram bots with webhooks on CherryPy.
* [python-project-template](https://github.com/Kwpolska/python-project-template): A template for Python projects with sophisticated release automation.
Expand All @@ -258,7 +258,7 @@ Please avoid creating PRs for listing additional templates. We outsourced their
* [cookiecutter-djangopackage](https://github.com/pydanny/cookiecutter-djangopackage): A template designed to create reusable third-party PyPI friendly Django apps. Documentation is written in tutorial format.
* [cookiecutter-django-cms](https://github.com/palazzem/cookiecutter-django-cms): A template for Django CMS with simple Bootstrap 3 template. It has a quick start and deploy documentation.
* [cookiecutter-django-crud](https://github.com/wildfish/cookiecutter-django-crud): A template to create a Django app with boilerplate CRUD around a model including a factory and tests.
* [cookiecutter-django-lborgav](https://github.com/lborgav/cookiecutter-django): Another cookiecutter template for Django project with Bootstrap 3 and FontAwesome 4
* [cookiecutter-django-lborgav](https://github.com/lborgav/cookiecutter-django): Another cookiecutter template for Django project with Bootstrap 3 and FontAwesome 4.
* [cookiecutter-django-paas](https://github.com/pbacterio/cookiecutter-django-paas): Django template ready to use in PAAS platforms like Heroku, OpenShift, etc..
* [cookiecutter-django-rest-framework](https://github.com/jpadilla/cookiecutter-django-rest-framework): A template for creating reusable Django REST Framework packages.
* [cookiecutter-django-aws-eb](https://github.com/dolphinkiss/cookiecutter-django-aws-eb): Get up and running with Django on AWS Elastic Beanstalk.
Expand All @@ -269,9 +269,9 @@ Please avoid creating PRs for listing additional templates. We outsourced their
* [wagtail-starter-kit](https://github.com/tkjone/starterkit-wagtail): A cookiecutter complete with wagtail, django layout, vagrant, provisioning scripts, front end build system and more!
* [cookiecutter-django-herokuapp](https://github.com/dulacp/cookiecutter-django-herokuapp): A Django 1.7+ template optimized for Python 3 on Heroku.
* [cookiecutter-simple-django-cn](https://github.com/shenyushun/cookiecutter-simple-django-cn): A simple Django templates for chinese.
* [cc_django_ember_app](https://bitbucket.org/levit_scs/cc_django_ember_app/src/master/): For creating applications with Django and EmberJS
* [cc_project_app_drf](https://bitbucket.org/levit_scs/cc_project_app_drf/src/master/): For creating REST apis based on the "project app" project architecture
* [cc_project_app_full_with_hooks](https://bitbucket.org/levit_scs/cc_project_app_full_with_hooks/src/master/): For creating Django projects using the "project app" project architecture
* [cc_django_ember_app](https://bitbucket.org/levit_scs/cc_django_ember_app/src/master/): For creating applications with Django and EmberJS.
* [cc_project_app_drf](https://bitbucket.org/levit_scs/cc_project_app_drf/src/master/): For creating REST apis based on the "project app" project architecture.
* [cc_project_app_full_with_hooks](https://bitbucket.org/levit_scs/cc_project_app_full_with_hooks/src/master/): For creating Django projects using the "project app" project architecture.
* [cc-automated-drf-template](https://github.com/TAMU-CPT/cc-automated-drf-template): A template + script that automatically creates your Django REST project with serializers, views, urls, and admin files based on your models file as input.
* [cookiecutter-django-foundation](https://github.com/Parbhat/cookiecutter-django-foundation): Fork of [cookiecutter-django](https://github.com/pydanny/cookiecutter-django) based on [Zurb Foundation](https://foundation.zurb.com/) 6 front-end framework.
* [cookiecutter-django-ansible](https://github.com/HackSoftware/cookiecutter-django-ansible): Cookiecutter Django Ansible is a framework for jumpstarting an ansible project for provisioning a server that is ready for your *cookiecutter-django* application.
Expand Down Expand Up @@ -300,7 +300,7 @@ Meta-templates for generating Cookiecutter project templates.

### Git

* [cookiecutter-git](https://github.com/NathanUrwin/cookiecutter-git): Git repo project template :clipboard:
* [cookiecutter-git](https://github.com/NathanUrwin/cookiecutter-git): Git repo project template :clipboard.

### C

Expand All @@ -310,7 +310,7 @@ Meta-templates for generating Cookiecutter project templates.
### C++

* [BoilerplatePP](https://github.com/Paspartout/BoilerplatePP): A simple cmake template with unit testing for projects written in C++.
* [cookiecutter-dpf-effect](https://github.com/SpotlightKid/cookiecutter-dpf-effect): An audio plugin project template for the DISTRHO Plugin Framework (DPF)
* [cookiecutter-dpf-effect](https://github.com/SpotlightKid/cookiecutter-dpf-effect): An audio plugin project template for the DISTRHO Plugin Framework (DPF).
* [cookiecutter-dpf-audiotk](https://github.com/SpotlightKid/cookiecutter-dpf-audiotk): An audio plugin project template for the DISTRHO Plugin Framework (DPF) and the Audio Toolkit (ATK) DSP library
* [cookiecutter-kata-gtest](https://github.com/13coders/cookiecutter-kata-gtest): A template for C++ test-driven development katas using the Google Test framework.
* [cookiecutter-kata-cpputest](https://github.com/13coders/cookiecutter-kata-cpputest): A template for C++ test-driven-development katas using the CppUTest framework.
Expand All @@ -333,9 +333,9 @@ Meta-templates for generating Cookiecutter project templates.

### Java

* [cookiecutter-java](https://github.com/m-x-k/cookiecutter-java): Cookiecutter for basic java application setup with gradle
* [cookiecutter-spring-boot](https://github.com/m-x-k/cookiecutter-spring-boot): Cookiecutter for standard java spring boot gradle application
* [cookiecutter-android](https://github.com/alexfu/cookiecutter-android): Cookiecutter for Gradle-based Android projects
* [cookiecutter-java](https://github.com/m-x-k/cookiecutter-java): Cookiecutter for basic java application setup with gradle.
* [cookiecutter-spring-boot](https://github.com/m-x-k/cookiecutter-spring-boot): Cookiecutter for standard java spring boot gradle application.
* [cookiecutter-android](https://github.com/alexfu/cookiecutter-android): Cookiecutter for Gradle-based Android projects.

### JS

Expand Down Expand Up @@ -400,7 +400,7 @@ Meta-templates for generating Cookiecutter project templates.

### Data Driven Journalism

* [cookiecutter-data-driven-journalism](https://github.com/jastark/cookiecutter-data-driven-journalism): A cookiecutter template to facilitate transparency in data journalism with consistent organisation of data journalism projects and some pre-populated files (including .gitignore, README, AUTHORS)
* [cookiecutter-data-driven-journalism](https://github.com/jastark/cookiecutter-data-driven-journalism): A cookiecutter template to facilitate transparency in data journalism with consistent organisation of data journalism projects and some pre-populated files (including .gitignore, README, AUTHORS).

### Continuous Delivery

Expand All @@ -413,7 +413,7 @@ Meta-templates for generating Cookiecutter project templates.

### Tornado

* [cookiecutter-tornado](https://github.com/hkage/cookiecutter-tornado): Cookiecutter template for Tornado based projects
* [cookiecutter-tornado](https://github.com/hkage/cookiecutter-tornado): Cookiecutter template for Tornado based projects.

### Other

Expand All @@ -434,7 +434,7 @@ Meta-templates for generating Cookiecutter project templates.
* [mr.bob](https://github.com/domenkozar/mr.bob) is a filesystem template renderer, meant to deprecate tools such as
paster and templer.

* [grunt-init](https://github.com/gruntjs/grunt-init) used to be built into Grunt and is now a standalone scaffolding tool
* [grunt-init](https://github.com/gruntjs/grunt-init) is used to be built into Grunt and is now a standalone scaffolding tool
to automate project creation.

* [scaffolt](https://github.com/paulmillr/scaffolt) consumes JSON generators with Handlebars support.
Expand Down
2 changes: 1 addition & 1 deletion cookiecutter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

"""Main package for Cookiecutter."""

__version__ = '1.6.0'
__version__ = '1.7.0'
63 changes: 50 additions & 13 deletions cookiecutter/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,103 +1,128 @@
# -*- coding: utf-8 -*-

"""
cookiecutter.exceptions
-----------------------

All exceptions used in the Cookiecutter code base are defined here.
"""
"""All exceptions used in the Cookiecutter code base are defined here."""


class CookiecutterException(Exception):
"""
Base exception class. All Cookiecutter-specific exceptions should subclass
this class.
Base exception class.

All Cookiecutter-specific exceptions should subclass this class.
"""


class NonTemplatedInputDirException(CookiecutterException):
"""
Raised when a project's input dir is not templated.
Exception for when a project's input dir is not templated.

The name of the input directory should always contain a string that is
rendered to something else, so that input_dir != output_dir.
"""


class UnknownTemplateDirException(CookiecutterException):
"""
Exception for ambiguous project template directory.

Raised when Cookiecutter cannot determine which directory is the project
template, e.g. more than one dir appears to be a template dir.
"""
# unused locally


class MissingProjectDir(CookiecutterException):
"""
Exception for missing generated project directory.

Raised during cleanup when remove_repo() can't find a generated project
directory inside of a repo.
"""
# unused locally


class ConfigDoesNotExistException(CookiecutterException):
"""
Exception for missing config file.

Raised when get_config() is passed a path to a config file, but no file
is found at that path.
"""


class InvalidConfiguration(CookiecutterException):
"""
Exception for invalid configuration file.

Raised if the global configuration file is not valid YAML or is
badly constructed.
"""


class UnknownRepoType(CookiecutterException):
"""
Exception for unknown repo types.

Raised if a repo's type cannot be determined.
"""


class VCSNotInstalled(CookiecutterException):
"""
Exception when version control is unavailable.

Raised if the version control system (git or hg) is not installed.
"""


class ContextDecodingException(CookiecutterException):
"""
Exception for failed JSON decoding.

Raised when a project's JSON context file can not be decoded.
"""


class OutputDirExistsException(CookiecutterException):
"""
Exception for existing output directory.

Raised when the output directory of the project exists already.
"""


class InvalidModeException(CookiecutterException):
"""
Exception for incompatible modes.

Raised when cookiecutter is called with both `no_input==True` and
`replay==True` at the same time.
"""


class FailedHookException(CookiecutterException):
"""
Raised when a hook script fails
Exception for hook failures.

Raised when a hook script fails.
"""


class UndefinedVariableInTemplate(CookiecutterException):
"""Raised when a template uses a variable which is not defined in the
"""
Exception for out-of-scope variables.

Raised when a template uses a variable which is not defined in the
context.
"""

def __init__(self, message, error, F438 context):
"""Exception for out-of-scope variables."""
self.message = message
self.error = error
self.context = context

def __str__(self):
"""Text representation of UndefinedVariableInTemplate."""
return (
"{self.message}. "
"Error message: {self.error.message}. "
Expand All @@ -106,21 +131,33 @@ def __str__(self):


class UnknownExtension(CookiecutterException):
"""Raised when an environment is unable to import a required extension."""
"""
Exception for un-importable extention.

Raised when an environment is unable to import a required extension.
"""


class RepositoryNotFound(CookiecutterException):
"""
Exception for missing repo.

Raised when the specified cookiecutter repository doesn't exist.
"""


class RepositoryCloneFailed(CookiecutterException):
"""Raised when a cookiecutter template can't be cloned."""
"""
Exception for un-cloneable repo.

Raised when a cookiecutter template can't be cloned.
"""


class InvalidZipRepository(CookiecutterException):
"""
Exception for bad zip repo.

Raised when the specified cookiecutter repository isn't a valid
Zip archive.
"""
2 changes: 2 additions & 0 deletions docs/advanced/choice_variables.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ can be used like this::
{%- elif cookiecutter.license == "BSD-3" -%}
# More possible license content here

{% endif %}

Cookiecutter is using `Jinja2's if conditional expression <http://jinja.pocoo.org/docs/dev/templates/#if>`_ to determine the correct license.

The created choice variable is still a regular Cookiecutter variable and can be used like this::
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.6.0
current_version = 1.7.0
commit = True
tag = True
tag_name = {new_version}
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from setuptools import setup

version = "1.6.0"
version = "1.7.0"

if sys.argv[-1] == 'publish':
os.system('python setup.py sdist upload')
Expand Down
13 changes: 8 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,27 @@ envlist =
py37
py38
pypy
minversion = 3.13.2
minversion = 3.14.2
requires =
# https://github.com/tox-dev/tox/issues/765
virtualenv >= 16.7.4
pip >= 19.2.3
virtualenv >= 16.7.9
pip >= 19.3.1

[testenv]
passenv =
LC_ALL
LANG
HOME
commands = pytest --cov=cookiecutter {posargs:tests}
commands =
pip install -e .
pytest --cov=cookiecutter {posargs:tests}
deps = -rtest_requirements.txt
skip_install = true

[testenv:lint]
commands =
python -m pre_commit run {posargs:--all}
deps = pre-commit>=1.17.0
deps = pre-commit>=1.20.0
skip_install = true
usedevelop = false

Expand Down
0