pyscaffold.extensions package

Submodules

pyscaffold.extensions.awesome module

class pyscaffold.extensions.awesome.AwesomeFiles(name)[source]

Bases: pyscaffold.api.Extension

Adding some additional awesome files

activate(actions)[source]

Activates the extension by registering its functionality

Parameters

actions (list) – list of action to perform

Returns

updated list of actions

Return type

list

define_awesome_files(struct, opts)[source]

pyscaffold.extensions.cookiecutter module

Extension that integrates cookiecutter templates into PyScaffold.

Warning

Deprecation Notice - In the next major release the Cookiecutter extension will be extracted into an independent package. After PyScaffold v4.0, you will need to explicitly install pyscaffoldext-cookiecutter in your system/virtualenv in order to be able to use it.

class pyscaffold.extensions.cookiecutter.Cookiecutter(name)[source]

Bases: pyscaffold.api.Extension

Additionally apply a Cookiecutter template

activate(actions)[source]

Register before_create hooks to generate project using Cookiecutter

Parameters

actions (list) – list of actions to perform

Returns

updated list of actions

Return type

list

augment_cli(parser)[source]

Add an option to parser that enables the Cookiecutter extension

Parameters

parser (argparse.ArgumentParser) – CLI parser object

mutually_exclusive = True
exception pyscaffold.extensions.cookiecutter.MissingTemplate(message='missing `cookiecutter` option', *args, **kwargs)[source]

Bases: RuntimeError

A cookiecutter template (git url) is required.

DEFAULT_MESSAGE = 'missing `cookiecutter` option'
exception pyscaffold.extensions.cookiecutter.NotInstalled(message='cookiecutter is not installed, run: pip install cookiecutter', *args, **kwargs)[source]

Bases: RuntimeError

This extension depends on the cookiecutter package.

DEFAULT_MESSAGE = 'cookiecutter is not installed, run: pip install cookiecutter'
pyscaffold.extensions.cookiecutter.create_cookiecutter(struct, opts)[source]

Create a cookie cutter template

Parameters
  • struct (dict) – project representation as (possibly) nested dict.

  • opts (dict) – given options, see create_project for an extensive list.

Returns

updated project representation and options

Return type

struct, opts

pyscaffold.extensions.cookiecutter.create_cookiecutter_parser(obj_ref)[source]

Create a Cookiecutter parser.

Parameters

obj_ref (Extension) – object reference to the actual extension

Returns

parser for namespace cli argument

Return type

NamespaceParser

pyscaffold.extensions.cookiecutter.enforce_cookiecutter_options(struct, opts)[source]

Make sure options reflect the cookiecutter usage.

Parameters
  • struct (dict) – project representation as (possibly) nested dict.

  • opts (dict) – given options, see create_project for an extensive list.

Returns

updated project representation and options

Return type

struct, opts

pyscaffold.extensions.django module

Extension that creates a base structure for the project using django-admin.py.

Warning

Deprecation Notice - In the next major release the Django extension will be extracted into an independent package. After PyScaffold v4.0, you will need to explicitly install pyscaffoldext-django in your system/virtualenv in order to be able to use it.

class pyscaffold.extensions.django.Django(name)[source]

Bases: pyscaffold.api.Extension

Generate Django project files

activate(actions)[source]

Register hooks to generate project using django-admin.

Parameters

actions (list) – list of actions to perform

Returns

updated list of actions

Return type

list

mutually_exclusive = True
exception pyscaffold.extensions.django.DjangoAdminNotInstalled(message='django-admin.py is not installed, run: pip install django', *args, **kwargs)[source]

Bases: RuntimeError

This extension depends on the django-admin.py cli script.

DEFAULT_MESSAGE = 'django-admin.py is not installed, run: pip install django'
pyscaffold.extensions.django.create_django_proj(struct, opts)[source]

Creates a standard Django project with django-admin.py

Parameters
  • struct (dict) – project representation as (possibly) nested dict.

  • opts (dict) – given options, see create_project for an extensive list.

Returns

updated project representation and options

Return type

struct, opts

Raises

RuntimeError – raised if django-admin.py is not installed

pyscaffold.extensions.django.enforce_django_options(struct, opts)[source]

Make sure options reflect the Django usage.

Parameters
  • struct (dict) – project representation as (possibly) nested dict.

  • opts (dict) – given options, see create_project for an extensive list.

Returns

updated project representation and options

Return type

struct, opts

pyscaffold.extensions.gitlab_ci module

Extension that generates configuration and script files for GitLab CI.

class pyscaffold.extensions.gitlab_ci.GitLab(name)[source]

Bases: pyscaffold.api.Extension

Generate GitLab CI configuration files

activate(actions)[source]

Activate extension

Parameters

actions (list) – list of actions to perform

Returns

updated list of actions

Return type

list

add_files(struct, opts)[source]

Add .gitlab-ci.yml file to structure

Parameters
  • struct (dict) – project representation as (possibly) nested dict.

  • opts (dict) – given options, see create_project for an extensive list.

Returns

updated project representation and options

Return type

struct, opts

pyscaffold.extensions.namespace module

Extension that adjust project file tree to include a namespace package.

This extension adds a namespace option to create_project and provides correct values for the options root_pkg and namespace_pkg to the following functions in the action list.

class pyscaffold.extensions.namespace.Namespace(name)[source]

Bases: pyscaffold.api.Extension

Add a namespace (container package) to the generated package.

activate(actions)[source]

Register an action responsible for adding namespace to the package.

Parameters

actions (list) – list of actions to perform

Returns

updated list of actions

Return type

list

augment_cli(parser)[source]

Add an option to parser that enables the namespace extension.

Parameters

parser (argparse.ArgumentParser) – CLI parser object

pyscaffold.extensions.namespace.add_namespace(struct, opts)[source]

Prepend the namespace to a given file structure

Parameters
  • struct (dict) – directory structure as dictionary of dictionaries

  • opts (dict) – options of the project

Returns

directory structure as dictionary of dictionaries and input options

Return type

tuple(dict, dict)

pyscaffold.extensions.namespace.create_namespace_parser(obj_ref)[source]

Create a namespace parser.

Parameters

obj_ref (Extension) – object reference to the actual extension

Returns

parser for namespace cli argument

Return type

NamespaceParser

pyscaffold.extensions.namespace.enforce_namespace_options(struct, opts)[source]

Make sure options reflect the namespace usage.

pyscaffold.extensions.namespace.move_old_package(struct, opts)[source]

Move old package that may be eventually created without namespace

Parameters
  • struct (dict) – directory structure as dictionary of dictionaries

  • opts (dict) – options of the project

Returns

directory structure as dictionary of dictionaries and input options

Return type

tuple(dict, dict)

pyscaffold.extensions.no_skeleton module

Extension that omits the creation of file skeleton.py

class pyscaffold.extensions.no_skeleton.NoSkeleton(name)[source]

Bases: pyscaffold.api.Extension

Omit creation of skeleton.py and test_skeleton.py

activate(actions)[source]

Activate extension

Parameters

actions (list) – list of actions to perform

Returns

updated list of actions

Return type

list

remove_files(struct, opts)[source]

Remove all skeleton files from structure

Parameters
  • struct (dict) – project representation as (possibly) nested dict.

  • opts (dict) – given options, see create_project for an extensive list.

Returns

updated project representation and options

Return type

struct, opts

pyscaffold.extensions.pre_commit module

Extension that generates configuration files for Yelp pre-commit.

class pyscaffold.extensions.pre_commit.PreCommit(name)[source]

Bases: pyscaffold.api.Extension

Generate pre-commit configuration file

activate(actions)[source]

Activate extension

Parameters

actions (list) – list of actions to perform

Returns

updated list of actions

Return type

list

static add_files(struct, opts)[source]

Add .pre-commit-config.yaml file to structure

Since the default template uses isort, this function also provides an initial version of .isort.cfg that can be extended by the user (it contains some useful skips, e.g. tox and venv)

Parameters
  • struct (dict) – project representation as (possibly) nested dict.

  • opts (dict) – given options, see create_project for an extensive list.

Returns

updated project representation and options

Return type

struct, opts

static instruct_user(struct, opts)[source]

pyscaffold.extensions.tox module

Extension that generates configuration files for the Tox test automation tool.

class pyscaffold.extensions.tox.Tox(name)[source]

Bases: pyscaffold.api.Extension

Generate Tox configuration file

activate(actions)[source]

Activate extension

Parameters

actions (list) – list of actions to perform

Returns

updated list of actions

Return type

list

add_files(struct, opts)[source]

Add .tox.ini file to structure

Parameters
  • struct (dict) – project representation as (possibly) nested dict.

  • opts (dict) – given options, see create_project for an extensive list.

Returns

updated project representation and options

Return type

struct, opts

pyscaffold.extensions.travis module

Extension that generates configuration and script files for Travis CI.

class pyscaffold.extensions.travis.Travis(name)[source]

Bases: pyscaffold.api.Extension

Generate Travis CI configuration files

activate(actions)[source]

Activate extension

Parameters

actions (list) – list of actions to perform

Returns

updated list of actions

Return type

list

add_files(struct, opts)[source]

Add some Travis files to structure

Parameters
  • struct (dict) – project representation as (possibly) nested dict.

  • opts (dict) – given options, see create_project for an extensive list.

Returns

updated project representation and options

Return type

struct, opts

Module contents

Built-in extensions for PyScaffold.