Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljoseph authored Dec 31, 2016
2 parents 86d75a8 + b0d6469 commit 8426895
Show file tree
Hide file tree
Showing 39 changed files with 528 additions and 146 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ matrix:
env: TOX_ENV=py34
- python: 3.5
env: TOX_ENV=py35
- python: nightly
- python: 3.6-dev
env: TOX_ENV=py36
- python: pypy
env: TOX_ENV=pypy
Expand Down
8 changes: 8 additions & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ Contributors
* Brett Cannon (`@brettcannon`_)
* Michael Warkentin (`@mwarkentin`_)
* Bartłomiej Kurzeja (`@B3QL`_)
* Thomas O'Donnell (`@andytom`_)
* Jeremy Carbaugh (`@jcarbaugh`_)
* Nathan Cheung (`@cheungnj`_)
* Abdó Roig-Maranges (`@aroig`_)

.. _`@cedk`: https://github.com/cedk
.. _`@johtso`: https://github.com/johtso
Expand Down Expand Up @@ -190,3 +194,7 @@ Contributors
.. _`@brettcannon`: https://github.com/brettcannon
.. _`@mwarkentin`: https://github.com/mwarkentin
.. _`@B3QL`: https://github.com/B3QL
.. _`@andytom`: https://github.com/andytom
.. _`@jcarbaugh`: https://github.com/jcarbaugh
.. _`@cheungnj`: https://github.com/cheungnj
.. _`@aroig`: https://github.com/aroig
72 changes: 69 additions & 3 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,47 @@
History
-------

1.5.0 (2016-04-20) ???
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1.6.0 (????-??-??) ???????
~~~~~~~~~~~~~~~~~~~~~~~~~~

New Features:

* ???

Bug Fixes:

* ???

Other Changes:

* Added more cookiecutter templates to the mix:

* `widget-cookiecutter`_ by `@willingc`_ (#781)
* `cookiecutter-django-foundation`_ by `@Parbhat`_ (#804)
* `cookiecutter-tornado`_ by `@hkage`_ (#807)
* `cookiecutter-django-ansible`_ by `@Ivaylo-Bachvarov`_ (#816)
* `cookiecutter-pyqt4`_ by `@aeroaks`_ (#847)
* `cookiecutter-golang`_ by `@mjhea0`_ (#872)

.. _`@Parbhat`: https://github.com/Parbhat
.. _`@hkage`: https://github.com/hkage
.. _`@Ivaylo-Bachvarov`: https://github.com/Ivaylo-Bachvarov
.. _`@aeroaks`: https://github.com/aeroaks
.. _`@mjhea0`: https://github.com/mjhea0

.. _`widget-cookiecutter`: https://github.com/jupyter/widget-cookiecutter
.. _`cookiecutter-django-foundation`: https://github.com/Parbhat/cookiecutter-django-foundation
.. _`cookiecutter-tornado`: https://github.com/hkage/cookiecutter-tornado
.. _`cookiecutter-django-ansible`: https://github.com/HackSoftware/cookiecutter-django-ansible
.. _`cookiecutter-pyqt4`: https://github.com/aeroaks/cookiecutter-pyqt4
.. _`cookiecutter-golang`: https://github.com/lacion/cookiecutter-golang


1.5.0 (2016-12-18) Alfajor
~~~~~~~~~~~~~~~~~~~~~~~~~~

The primary goal of this release was to add command-line support for passing
extra context, address minor bugs and make a number of improvements.

New Features:

Expand All @@ -24,7 +63,9 @@ New Features:
``~/.cookiecutters/``) can now be referenced by directory name, thanks to
`@michaeljoseph`_ (#825).
* Add support for dict values in ``cookiecutter.json``, thanks to
`@freakboy3742`_ (#815).
`@freakboy3742`_ and `@hackebrot`_ (#815, #858).
* Add a ``jsonify`` filter to default jinja2 extensions that json.dumps a
Python object into a string, thanks to `@aroig`_ (#791).

Bug Fixes:

Expand All @@ -36,6 +77,12 @@ Bug Fixes:
* Ignore hook files with tilde-suffixes, thanks to `@hackebrot`_ (#768)
* Fix a minor issue with the code that generates a name for a template, thanks
to `@hackebrot`_ (#798)
* Handle empty hook file or other OS errors, thanks to `@christianmlong`_ for
raising this bug and `@jcarbaugh`_ and `@hackebrot`_ for the fix (#632, #729,
#862)
* Resolve an issue with custom extensions not being loaded for
``pre_gen_project`` and ``post_gen_project`` hooks, thanks to `@cheungnj`_
(#860)

Other Changes:

Expand Down Expand Up @@ -103,6 +150,19 @@ Other Changes:
* Fix broken link to *Invoke* docs, thanks to `@B3QL`_ (#820)
* Add documentation to ``render_variable`` function in ``prompt.py``, thanks to
`@pydanny`_ (#678)
* Fix python3.6 travis-ci and tox configuration, thanks to `@luzfcb`_ (#844)
* Add missing encoding declarations to python files, thanks to `@andytom`_
(#852)
* Disable poyo logging for tests, thanks to `@hackebrot`_ (#855)
* Remove pycache directories in make clean-pyc, thanks to `@hackebrot`_ (#849)
* Refactor hook system to only find the requested hook, thanks to
`@michaeljoseph`_ (#834)
* Add tests for custom extensions in ``pre_gen_project`` and
``post_gen_project`` hooks, thanks to `@hackebrot`_ (#856)
* Make the build reproducible by avoiding nondeterministic keyword arguments,
thanks to `@lamby`_ and `@hackebrot`_ (#800, #861)
* Extend CLI help message and point users to the github project to engage with
the community, thanks to `@hackebrot`_ (#859)
* Added more cookiecutter templates to the mix:

* `cookiecutter-funkload-friendly`_ by `@tokibito`_ (#657)
Expand Down Expand Up @@ -181,6 +241,12 @@ Other Changes:
.. _`@laerus`: https://github.com/laerus
.. _`@mkrapp`: https://github.com/mkrapp
.. _`@TAMU-CPT`: https://github.com/TAMU-CPT
.. _`@andytom`: https://github.com/andytom
.. _`@lamby`: https://github.com/lamby
.. _`@christianmlong`: https://github.com/christianmlong
.. _`@jcarbaugh`: https://github.com/jcarbaugh
.. _`@cheungnj`: https://github.com/cheungnj
.. _`@aroig`: https://github.com/aroig

.. _`cookiecutter-pyqt5`: https://github.com/mandeepbhutani/cookiecutter-pyqt5
.. _`cookiecutter-funkload-friendly`: https://github.com/tokibito/cookiecutter-funkload-friendly
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ clean-build:
rm -fr *.egg-info

clean-pyc:
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -type d -name '__pycache__' -exec rm -rf {} +
find . -type f -name '*.py[co]' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +

clean-tox:
Expand Down
27 changes: 22 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ Categories of Cookiecutters
`Scala`_ |
`6502 Assembly`_ |
`Data Science`_ |
`Tornado`_ |
`Reproducible Science`_

If you don't find a cookiecutter that suits your needs here, please consider
Expand Down Expand Up @@ -328,6 +329,7 @@ Python
* `cookiecutter-snakemake-analysis-pipeline`_: One way to easily set up `Snakemake`_-based analysis pipelines.
* `cookiecutter-py3tkinter`_: Template for Python 3 Tkinter application gui.
* `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`_: A prebuilt PyQt4 GUI template with a logging support, structure for tests and separation of ui and worker components.
* `cookiecutter-xontrib`_: A template for building xontribs, a.k.a `xonsh`_ contributions

.. _`cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
Expand Down Expand Up @@ -369,6 +371,7 @@ Python
.. _`Snakemake`: https://bitbucket.org/snakemake/snakemake/wiki/Home
.. _`cookiecutter-py3tkinter`: https://github.com/ivanlyon/cookiecutter-py3tkinter
.. _`cookiecutter-pyqt5`: https://github.com/mandeepbhutani/cookiecutter-pyqt5
.. _`cookiecutter-pyqt4`: https://github.com/aeroaks/cookiecutter-pyqt4
.. _`cookiecutter-xontrib`: https://github.com/laerus/cookiecutter-xontrib
.. _`xonsh`: https://github.com/xonsh/xonsh

Expand All @@ -388,7 +391,7 @@ Python-Django
* `cookiecutter-django-rest-framework`_: A template for creating reusable Django REST Framework packages.
* `cookiecutter-django-aws-eb`_: Get up and running with Django on AWS Elastic Beanstalk.
* `cookiecutter-wagtail`_ : A cookiecutter template for `Wagtail`_ CMS based sites.
* `wagtail-cookiecutter-foundation`_: A complete template for Wagtail CMS projects featuring Zurb Foundation 5, ansible provisioning and deployment , front-end dependency management with bower, modular apps to get your site up and running including photo_gallery, RSS feed etc.
* `wagtail-cookiecutter-foundation`_: A complete template for Wagtail CMS projects featuring `Zurb Foundation`_ 6, ansible provisioning and deployment , front-end dependency management with bower, modular apps to get your site up and running including photo_gallery, RSS feed etc.
* `django-starter`_: A Django template complete with vagrant and provisioning scripts - inspired by 12 factor apps and cookiecutter-django.
* `cookiecutter-django-gulp`_: A Cookiecutter template for integrating frontend development tools in Django projects.
* `wagtail-starter-kit`_: A cookiecutter complete with wagtail, django layout, vagrant, provisioning scripts, front end build system and more!
Expand All @@ -398,6 +401,8 @@ Python-Django
* `cc_project_app_drf`_: For creating REST apis based on the "project app" project architecture
* `cc_project_app_full_with_hooks`_: For creating Django projects using the "project app" project architecture
* `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`_: Fork of `cookiecutter-django`_ based on `Zurb Foundation`_ 6 front-end framework
* `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.

.. _`cookiecutter-django`: https://github.com/pydanny/cookiecutter-django
.. _`cookiecutter-django-rest`: https://github.com/agconti/cookiecutter-django-rest
Expand All @@ -422,14 +427,16 @@ Python-Django
.. _`cc_project_app_drf`: https://bitbucket.org/levit_scs/cc_project_app_drf
.. _`cc_project_app_full_with_hooks`: https://bitbucket.org/levit_scs/cc_project_app_full_with_hooks
.. _`cc-automated-drf-template`: https://github.com/TAMU-CPT/cc-automated-drf-template

.. _`cookiecutter-django-foundation`: https://github.com/Parbhat/cookiecutter-django-foundation
.. _`Zurb Foundation`: http://foundation.zurb.com
.. _`cookiecutter-django-ansible`: https://github.com/HackSoftware/cookiecutter-django-ansible

Python-Pyramid
^^^^^^^^^^^^^^

* `pyramid-cookiecutter-alchemy`_: A cookiecutter (project template) for creating a Pyramid project using SQLite as persistent storage, SQLAlchemy as an ORM, URL dispatch for routing, and Jinja2 for templating.
* `pyramid-cookiecutter-starter`_: A cookiecutter (project template) for creating a Pyramid starter project using Chameleon for templating.
* `pyramid-cookiecutter-zodb`_: A cookiecutter (project template) for creating a Pyramid project using ZODB for persistent storage, traversal for routing, and Chameleon for templating.
* `pyramid-cookiecutter-alchemy`_: A Cookiecutter (project template) for creating a Pyramid project using SQLite for persistent storage, SQLAlchemy for an ORM, URL dispatch for routing, and Jinja2 for templating.
* `pyramid-cookiecutter-starter`_: A Cookiecutter (project template) for creating a Pyramid starter project using URL dispatch for routing and Jinja2 for templating.
* `pyramid-cookiecutter-zodb`_: A Cookiecutter (project template) for creating a Pyramid project using ZODB for persistent storage, traversal for routing, and Chameleon for templating.
* `substanced-cookiecutter`_: A cookiecutter (project template) for creating a Substance D starter project. Substance D is built on top of Pyramid.

.. _`pyramid-cookiecutter-alchemy`: https://github.com/Pylons/pyramid-cookiecutter-alchemy
Expand Down Expand Up @@ -489,8 +496,10 @@ Golang
~~~~~~

* `beat-generator`_: A template to create your own beat to ship data to Elasticsearch.
* `cookiecutter-golang`_: Basic project template for golang

.. _`beat-generator`: https://github.com/elastic/beat-generator
.. _`cookiecutter-golang`: https://github.com/lacion/cookiecutter-golang


JS
Expand Down Expand Up @@ -584,8 +593,10 @@ Scala
Data Science
~~~~~~~~~~~~

* `widget-cookiecutter`_: A cookiecutter template for creating a custom Jupyter widget project.
* `cookiecutter-data-science`_: A logical, reasonably standardized, but flexible project structure for doing and sharing data science work in Python. Full documentation available `here <http://drivendata.github.io/cookiecutter-data-science/>`__.

.. _`widget-cookiecutter`_: https://github.com/jupyter/widget-cookiecutter
.. _`cookiecutter-data-science`: https://github.com/drivendata/cookiecutter-data-science

Reproducible Science
Expand All @@ -602,6 +613,12 @@ Cloud Tools

.. _`cookiecutter-tf-module`: https://github.com/DualSpark/cookiecutter-tf-module

Tornado
~~~~~~~

* `cookiecutter-tornado`_: Cookiecutter template for Tornado based projects

.. _`cookiecutter-tornado`: https://github.com/hkage/cookiecutter-tornado

Similar projects
----------------
Expand Down
1 change: 1 addition & 0 deletions __main__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
"""Allow cookiecutter to be executable from a checkout or zip file."""
import runpy

Expand Down
2 changes: 1 addition & 1 deletion cookiecutter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
Main package for Cookiecutter.
"""

__version__ = '1.4.0'
__version__ = '1.5.0'
1 change: 1 addition & 0 deletions cookiecutter/__main__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
"""Allow cookiecutter to be executable through `python -m cookiecutter`."""
from __future__ import absolute_import

Expand Down
15 changes: 9 additions & 6 deletions cookiecutter/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import click

from cookiecutter import __version__
from cookiecutter.config import USER_CONFIG_PATH
from cookiecutter.log import configure_logger
from cookiecutter.main import cookiecutter
from cookiecutter.exceptions import (
Expand Down Expand Up @@ -80,7 +79,7 @@ def validate_extra_context(ctx, param, value):
help=u'Where to output the generated project dir into'
)
@click.option(
u'--config-file', type=click.Path(), default=USER_CONFIG_PATH,
u'--config-file', type=click.Path(), default=None,
help=u'User configuration file'
)
@click.option(
Expand All @@ -95,7 +94,12 @@ def main(
template, extra_context, no_input, checkout, verbose,
replay, overwrite_if_exists, output_dir, config_file,
default_config, debug_file):
"""Create a project from a Cookiecutter project template (TEMPLATE)."""
"""Create a project from a Cookiecutter project template (TEMPLATE).

Cookiecutter is free and open source software, developed and managed by
volunteers. If you would like to help out or fund the project, please get
in touch at https://github.com/audreyr/cookiecutter.
"""

# If you _need_ to support a local template in a directory
# called 'help', use a qualified path to the directory.
Expand All @@ -109,15 +113,14 @@ def main(
)

try:
user_config = None if default_config else config_file

cookiecutter(
template, checkout, no_input,
extra_context=extra_context,
replay=replay,
overwrite_if_exists=overwrite_if_exists,
output_dir=output_dir,
config_file=user_config
config_file=config_file,
default_config=default_config,
)
except (OutputDirExistsException,
InvalidModeException,
Expand Down
21 changes: 16 additions & 5 deletions cookiecutter/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,24 @@ def get_config(config_path):
return config_dict


def get_user_config(config_file=USER_CONFIG_PATH):
"""Retrieve the config from a file or return the defaults if None is
passed. If an environment variable `COOKIECUTTER_CONFIG` is set up, try
to load its value. Otherwise fall back to a default file or config.
def get_user_config(config_file=None, default_config=False):
"""Return the user config as a dict.

If ``default_config`` is True, ignore ``config_file and return default
values for the config parameters.

If a path to a ``config_file`` is given, that is different from the default
location, load the user config from that.

Otherwise look up the config file path in the ``COOKIECUTTER_CONFIG``
environment variable. If set, load the config from this path. This will
raise an error if the specified path is not valid.

If the environment variable is not set, try the default config file path
before falling back to the default config values.
"""
# Do NOT load a config. Return defaults instead.
if config_file is None:
if default_config:
return copy.copy(DEFAULT_CONFIG)

# Load the given config file
Expand Down
3 changes: 3 additions & 0 deletions cookiecutter/environment.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# -*- coding: utf-8 -*-

"""Jinja2 environment and extensions loading."""

from jinja2 import Environment, StrictUndefined

from .exceptions import UnknownExtension


Expand All @@ -24,6 +26,7 @@ def __init__(self, **kwargs):
context = kwargs.pop('context', {})

default_extensions = [
'cookiecutter.extensions.JsonifyExtension',
'jinja2_time.TimeExtension',
]
extensions = default_extensions + self._read_extensions(context)
Expand Down
19 changes: 19 additions & 0 deletions cookiecutter/extensions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-

"""Jinja2 extensions."""

import json

from jinja2.ext import Extension


class JsonifyExtension(Extension):
"""Jinja2 extension to convert a python object to json"""

def __init__(self, environment):
super(JsonifyExtension, self).__init__(environment)

def jsonify(obj):
return json.dumps(obj, sort_keys=True, indent=4)

environment.filters['jsonify'] = jsonify
8 changes: 7 additions & 1 deletion cookiecutter/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,13 @@ def ensure_dir_is_templated(dirname):


def _run_hook_from_repo_dir(repo_dir, hook_name, project_dir, context):
"""Run hook from repo directory, clean project directory if hook fails."""
"""Run hook from repo directory, clean project directory if hook fails.

:param repo_dir: Project template input directory.
:param hook_name: The hook to execute.
:param project_dir: The directory to execute the script from.
:param context: Cookiecutter project context.
"""
with work_in(repo_dir):
try:
run_hook(hook_name, project_dir, context)
Expand Down
Loading

0 comments on commit 8426895

Please sign in to comment.