cookiecutter.operators package

Submodules

cookiecutter.operators.aws module

AWS Operators.

class cookiecutter.operators.aws.AwsAzsOperator(*args, **kwargs)[source]

Bases: cookiecutter.operators.BaseOperator

Operator for retrieving the availability zones in a given region.

Parameters
  • region – A region to search in

  • regions – A list of regions to search in

Returns

A list of availability zones

type = 'aws_azs'
class cookiecutter.operators.aws.AwsEc2TypesOperator(*args, **kwargs)[source]

Bases: cookiecutter.operators.BaseOperator

Operator retrieving the available instance types in a region.

Parameters
  • region – [Required] The region to determine the instances in

  • instance_families – A list of instance families, ie [‘c5’, ‘m5’]

Returns

A list of instance types

type = 'aws_ec2_types'
class cookiecutter.operators.aws.AwsRegionsOperator(*args, **kwargs)[source]

Bases: cookiecutter.operators.BaseOperator

Operator retrieving AWS regions.

Returns

List of regions

type = 'aws_regions'

cookiecutter.operators.block module

Operator plugin that inherits a base class and is made available through type.

class cookiecutter.operators.block.BlockOperator(*args, **kwargs)[source]

Bases: cookiecutter.operators.BaseOperator

Operator for blocks of operators.

This is a special case where the operators input variables are not rendered until it is later executed.

Parameters

items – Map of inputs

type = 'block'

cookiecutter.operators.checkbox module

Operator plugin that inherits a base class and is made available through type.

class cookiecutter.operators.checkbox.InquirerCheckboxOperator(*args, **kwargs)[source]

Bases: cookiecutter.operators.BaseOperator

Operator for PyInquirer type prompts.

Takes in three forms of choices inputs. 1. list of string 2. list of maps with all keys = name 3. list of maps with the key as the output, the value as displayed question

Parameters
  • message – String message to show when prompting.

  • choices – A list of strings or list of k/v pairs per above description

  • name – A key to insert the output value to. If not provided defaults to inserting into parent key

  • qmark – A marker to select with like 😃

Returns

List of answers

type = 'checkbox'

cookiecutter.operators.command module

Operator plugin that inherits a base class and is made available through type.

class cookiecutter.operators.command.CommandOperator(*args, **kwargs)[source]

Bases: cookiecutter.operators.BaseOperator

command operator for system calls.

Hides streaming output. To view streaming output of command use the shell operator.

Parameters

command – The command to run on the host

Returns

String output of command

type = 'command'
class cookiecutter.operators.command.ShellOperator(*args, **kwargs)[source]

Bases: cookiecutter.operators.BaseOperator

Shell operator for system calls.

Streams the output of the process.

Parameters

command – The command to run on the host

Returns

String output of command

type = 'shell'

cookiecutter.operators.confirm module

Operator plugin that inherits a base class and is made available through type.

class cookiecutter.operators.confirm.InquirerConfirmOperator(*args, **kwargs)[source]

Bases: cookiecutter.operators.BaseOperator

Operator for PyInquirer confirm type prompts.

Parameters
  • message – String message to show when prompting.

  • choices – A list of strings or list of k/v pairs per above description

  • name – A key to insert the output value to. If not provided defaults to

inserting into parent key :return: Boolean

type = 'confirm'

cookiecutter.operators.dicts module

Operator plugin that inherits a base class and is made available through type.

class cookiecutter.operators.dicts.DictMergeOperator(*args, **kwargs)[source]

Bases: cookiecutter.operators.BaseOperator

Operator for recursively merging dict objects with input maps.

Parameters
  • dict – The input dict to update

  • input – A dict or list of dicts to update the input dict

Returns

An updated dict object.

type = 'merge'
class cookiecutter.operators.dicts.DictPopOperator(*args, **kwargs)[source]

Bases: cookiecutter.operators.BaseOperator

Operator for recursively merging dict objects with input maps.

Parameters
  • dict – The input dict to update

  • item – A list or string of items to remove from a dictionary or list

Returns

An updated dict object.

type = 'pop'
class cookiecutter.operators.dicts.DictUpdateOperator(*args, **kwargs)[source]

Bases: cookiecutter.operators.BaseOperator

Operator for updating dict objects with items.

Parameters
  • dict – The input dict to update

  • input – A dict or list of dicts to update the input dict

Returns

An updated dict object.

type = 'update'

cookiecutter.operators.editor module

Operator plugin that inherits a base class and is made available through type.

class cookiecutter.operators.editor.InquirerEditorOperator(*args, **kwargs)[source]

Bases: cookiecutter.operators.BaseOperator

Operator for PyInquirer editor type prompts.

https://github.com/CITGuru/PyInquirer/blob/master/examples/expand.py

Parameters
  • message – String message to show when prompting.

  • choices – A list of strings or list of k/v pairs per above description

  • name – A key to insert the output value to. If not provided defaults to inserting into parent key

type = 'editor'

cookiecutter.operators.expand module

Operator plugin that inherits a base class and is made available through type.

class cookiecutter.operators.expand.InquirerExpandOperator(*args, **kwargs)[source]

Bases: cookiecutter.operators.BaseOperator

Operator for PyInquirer expand type prompt.

https://github.com/CITGuru/PyInquirer/blob/master/examples/expand.py

Parameters
  • message – String message to show when prompting.

  • choices – A list of strings or list of k/v pairs per above description

  • name – A key to insert the output value to. If not provided defaults to inserting into parent key

Returns

List of answers

type = 'expand'

cookiecutter.operators.input module

Operator plugin that inherits a base class and is made available through type.

class cookiecutter.operators.input.InquirerInputOperator(*args, **kwargs)[source]

Bases: cookiecutter.operators.BaseOperator

Operator for PyInquirer ‘input’ type prompts.

Parameters
  • message – String message to show when prompting.

  • choices – A list of strings or list of k/v pairs per above description

  • name – A key to insert the output value to. If not provided defaults to inserting into parent key

Returns

String answer

type = 'input'

cookiecutter.operators.jinja module

Operator plugin that inherits a base class and is made available through type.

class cookiecutter.operators.jinja.JinjaOperator(*args, **kwargs)[source]

Bases: cookiecutter.operators.BaseOperator

Operator for jinja templates.

Parameters
  • template_path – Path to the template to render

  • extra_context – A dict to use to render

  • output_path – Path to the output file

Returns

String path to the output file

type = 'jinja'

cookiecutter.operators.json module

Operator plugin that inherits a base class and is made available through type.

class cookiecutter.operators.json.JsonOperator(*args, **kwargs)[source]

Bases: cookiecutter.operators.BaseOperator

Operator for json.

If no contents is provided, the operator reads from path. Otherwise it writes the contents.

Parameters
  • contents – A dict to write

  • path – The path to write the file

Returns

When writing, returns path. When reading, returns dict

type = 'json'

cookiecutter.operators.list module

cookiecutter.operators.listdir module

Operator plugin that inherits a base class and is made available through type.

class cookiecutter.operators.listdir.ListdirOperator(*args, **kwargs)[source]

Bases: cookiecutter.operators.BaseOperator

Operator for listdir. Lists the contents of a directory.

Parameters
  • path – String or list to directories to list

  • sort – Boolean to sort the output

  • ignore_hidden_files – Boolean to ignore hidden files

Returns

A list of contents of the path if input is string, A map with keys of items if input path is list.

type = 'listdir'

cookiecutter.operators.nukikata module

Operator plugin that inherits a base class and is made available through type.

class cookiecutter.operators.nukikata.NukikataOperator(*args, **kwargs)[source]

Bases: cookiecutter.operators.BaseOperator

Operator for calling external cookiecutters.

Parameters
  • template – A directory containing a project template, or a URL to a git repository.

  • templates – A list of directories containing a project template, or a URL to a git repository.

  • checkout – The branch, tag or commit ID to checkout after clone.

  • no_input – Prompt the user at command line for manual configuration?

  • extra_context – A dictionary of context that overrides default and user configuration.

  • replay – Do not prompt for input, instead read from saved json. If True read from the replay_dir. if it exists

  • output_dir – Where to output the generated project dir into.

  • config_file – User configuration file path.

  • default_config – Use default values rather than a config file.

  • password – The password to use when extracting the repository.

  • directory – Relative path to a cookiecutter template in a repository.

  • accept_hooks – Accept pre and post hooks if set to True.

Returns

Dictionary of output

type = 'nukikata'

cookiecutter.operators.password module

Operator plugin that inherits a base class and is made available through type.

class cookiecutter.operators.password.InquirerPasswordOperator(*args, **kwargs)[source]

Bases: cookiecutter.operators.BaseOperator

Operator for PyInquirer password type prompts.

Parameters
  • message – String message to show when prompting.

  • choices – A list of strings or list of k/v pairs per above description

  • name – A key to insert the output value to. If not provided defaults to inserting into parent key

Returns

type = 'password'

cookiecutter.operators.path module

cookiecutter.operators.print module

Operator plugin that inherits a base class and is made available through type.

class cookiecutter.operators.print.PprintOperator(*args, **kwargs)[source]

Bases: cookiecutter.operators.BaseOperator

Operator for pretty printing an input and returning the output.

Parameters

statement – The thing to print

type = 'pprint'
class cookiecutter.operators.print.PrintOperator(*args, **kwargs)[source]

Bases: cookiecutter.operators.BaseOperator

Operator for printing an input and returning the output.

Parameters

statement – The thing to print

type = 'print'

cookiecutter.operators.rawlist module

Operator plugin that inherits a base class and is made available through type.

class cookiecutter.operators.rawlist.InquirerListOperator(*args, **kwargs)[source]

Bases: cookiecutter.operators.BaseOperator

Operator for PyInquirer ‘rawlist’ type prompts.

Parameters
  • message – String message to show when prompting.

  • choices – A list of strings or list of k/v pairs per above description

  • name – A key to insert the output value to. If not provided defaults to inserting into parent key

Returns

String for the answer

type = 'rawlist'

cookiecutter.operators.return module

cookiecutter.operators.split module

cookiecutter.operators.stat module

Operator plugin that inherits a base class and is made available through type.

class cookiecutter.operators.stat.StatOperator(*args, **kwargs)[source]

Bases: cookiecutter.operators.BaseOperator

Operator for registering a variable based on an input. Useful with rendering.

Parameters
  • remove – Parameter or regex to remove from list or dict

  • update – Use the python update dict method on contents before writing

  • merge_config – Recursively update the contents before writing.

  • input – Any type input

Returns

any: Processed input.

type = 'stat'

cookiecutter.operators.table module

Operator plugin that inherits a base class and is made available through type.

class cookiecutter.operators.table.TableOperator(*args, **kwargs)[source]

Bases: cookiecutter.operators.BaseOperator

Operator for creating tables with rich - github.com/willmcgugan/rich.

Parameters
  • column_names – List of column names

  • contents – List of lists to put into columns / rows

  • contents_split – List of strings to separate into columns based on separator

  • separator – A string to separate the strings in the contents

  • sort – Boolean to sort contents or contents_split

type = 'table'

cookiecutter.operators.terraform module

Operator plugin that inherits a base class and is made available through type.

class cookiecutter.operators.terraform.TerraformVariablesOperator(*args, **kwargs)[source]

Bases: cookiecutter.operators.BaseOperator

Operator that reads an input hcl file and prompts user to fill in.

Typically this is used with a variables.tf file.

Parameters
  • variables_file – A path to a file to read

  • var_list – A list of items to only parse and prompt

  • var_skip_list – A list of items to skip when prompting

Returns

Dictionary that can be dumped into json for a terraform.tfvars.json

type = 'terraform_variables'

cookiecutter.operators.yaml module

Operator plugin that inherits a base class and is made available through type.

class cookiecutter.operators.yaml.YamlOperator(*args, **kwargs)[source]

Bases: cookiecutter.operators.BaseOperator

Operator for yaml.

Parameters
  • path – The file path to put read or write to

  • contents – Supplied dictionary or list to write.

  • in_place – Boolean to read the contents of the path and then write after modifications.

  • remove – Parameter or regex to remove from list or dict

  • update – Use the python update dict method on contents before writing

  • filter – List or string to values to.

  • merge_dict – Dict input that recursively overwrites the contents.

  • append_items – List to append to append_key key.

  • append_key – String or list of hierarchical keys to append item to. Defaults to root element.

  • mode – The mode that the file should write. Defaults to write ‘w’. Seee https://docs.python.org/3/library/functions.html#open

type = 'yaml'

Module contents

Operator plugin base class that all __subclassess__ are brought in scope.