cookiecutter.operators package¶
Submodules¶
cookiecutter.operators.aws module¶
AWS Operators.
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
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
Bases:
cookiecutter.operators.BaseOperator
Operator retrieving AWS regions.
- Returns
List of regions
cookiecutter.operators.block module¶
Operator plugin that inherits a base class and is made available through type.
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
cookiecutter.operators.checkbox module¶
Operator plugin that inherits a base class and is made available through type.
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
cookiecutter.operators.command module¶
Operator plugin that inherits a base class and is made available through type.
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
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
cookiecutter.operators.confirm module¶
Operator plugin that inherits a base class and is made available through type.
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
cookiecutter.operators.dicts module¶
Operator plugin that inherits a base class and is made available through type.
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.
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.
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.
cookiecutter.operators.editor module¶
Operator plugin that inherits a base class and is made available through type.
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
cookiecutter.operators.expand module¶
Operator plugin that inherits a base class and is made available through type.
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
cookiecutter.operators.input module¶
Operator plugin that inherits a base class and is made available through type.
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
cookiecutter.operators.jinja module¶
Operator plugin that inherits a base class and is made available through type.
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
cookiecutter.operators.json module¶
Operator plugin that inherits a base class and is made available through type.
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
cookiecutter.operators.list module¶
cookiecutter.operators.listdir module¶
Operator plugin that inherits a base class and is made available through type.
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.
cookiecutter.operators.nukikata module¶
Operator plugin that inherits a base class and is made available through type.
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 thereplay_dir
. if it existsoutput_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
cookiecutter.operators.password module¶
Operator plugin that inherits a base class and is made available through type.
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
cookiecutter.operators.path module¶
cookiecutter.operators.print module¶
Operator plugin that inherits a base class and is made available through type.
Bases:
cookiecutter.operators.BaseOperator
Operator for pretty printing an input and returning the output.
- Parameters
statement – The thing to print
Bases:
cookiecutter.operators.BaseOperator
Operator for printing an input and returning the output.
- Parameters
statement – The thing to print
cookiecutter.operators.rawlist module¶
Operator plugin that inherits a base class and is made available through type.
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
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.
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.
cookiecutter.operators.table module¶
Operator plugin that inherits a base class and is made available through type.
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
cookiecutter.operators.terraform module¶
Operator plugin that inherits a base class and is made available through type.
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
cookiecutter.operators.yaml module¶
Operator plugin that inherits a base class and is made available through type.
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
Module contents¶
Operator plugin base class that all __subclassess__ are brought in scope.