repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
pypyr/pypyr-cli | pypyr/steps/pype.py | run_step | def run_step(context):
"""Run another pipeline from this step.
The parent pipeline is the current, executing pipeline. The invoked, or
child pipeline is the pipeline you are calling from this step.
Args:
context: dictionary-like pypyr.context.Context. context is mandatory.
Use... | python | def run_step(context):
"""Run another pipeline from this step.
The parent pipeline is the current, executing pipeline. The invoked, or
child pipeline is the pipeline you are calling from this step.
Args:
context: dictionary-like pypyr.context.Context. context is mandatory.
Use... | [
"def",
"run_step",
"(",
"context",
")",
":",
"logger",
".",
"debug",
"(",
"\"started\"",
")",
"(",
"pipeline_name",
",",
"use_parent_context",
",",
"pipe_arg",
",",
"skip_parse",
",",
"raise_error",
",",
"loader",
",",
")",
"=",
"get_arguments",
"(",
"contex... | Run another pipeline from this step.
The parent pipeline is the current, executing pipeline. The invoked, or
child pipeline is the pipeline you are calling from this step.
Args:
context: dictionary-like pypyr.context.Context. context is mandatory.
Uses the following context keys i... | [
"Run",
"another",
"pipeline",
"from",
"this",
"step",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/steps/pype.py#L10-L93 |
pypyr/pypyr-cli | pypyr/steps/pype.py | get_arguments | def get_arguments(context):
"""Parse arguments for pype from context and assign default values.
Args:
context: pypyr.context.Context. context is mandatory.
Returns:
tuple (pipeline_name, #str
use_parent_context, #bool
pipe_arg, #str
skip_parse, ... | python | def get_arguments(context):
"""Parse arguments for pype from context and assign default values.
Args:
context: pypyr.context.Context. context is mandatory.
Returns:
tuple (pipeline_name, #str
use_parent_context, #bool
pipe_arg, #str
skip_parse, ... | [
"def",
"get_arguments",
"(",
"context",
")",
":",
"context",
".",
"assert_key_has_value",
"(",
"key",
"=",
"'pype'",
",",
"caller",
"=",
"__name__",
")",
"pype",
"=",
"context",
".",
"get_formatted",
"(",
"'pype'",
")",
"try",
":",
"pipeline_name",
"=",
"p... | Parse arguments for pype from context and assign default values.
Args:
context: pypyr.context.Context. context is mandatory.
Returns:
tuple (pipeline_name, #str
use_parent_context, #bool
pipe_arg, #str
skip_parse, #bool
raise_error #b... | [
"Parse",
"arguments",
"for",
"pype",
"from",
"context",
"and",
"assign",
"default",
"values",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/steps/pype.py#L96-L143 |
pypyr/pypyr-cli | pypyr/pypeloaders/fileloader.py | get_pipeline_path | def get_pipeline_path(pipeline_name, working_directory):
"""Look for the pipeline in the various places it could be.
First checks the cwd. Then checks pypyr/pipelines dir.
Args:
pipeline_name: string. Name of pipeline to find
working_directory: string. Path in which to look for pipeline_na... | python | def get_pipeline_path(pipeline_name, working_directory):
"""Look for the pipeline in the various places it could be.
First checks the cwd. Then checks pypyr/pipelines dir.
Args:
pipeline_name: string. Name of pipeline to find
working_directory: string. Path in which to look for pipeline_na... | [
"def",
"get_pipeline_path",
"(",
"pipeline_name",
",",
"working_directory",
")",
":",
"logger",
".",
"debug",
"(",
"\"starting\"",
")",
"# look for name.yaml in the pipelines/ sub-directory",
"logger",
".",
"debug",
"(",
"f\"current directory is {working_directory}\"",
")",
... | Look for the pipeline in the various places it could be.
First checks the cwd. Then checks pypyr/pipelines dir.
Args:
pipeline_name: string. Name of pipeline to find
working_directory: string. Path in which to look for pipeline_name.yaml
Returns:
Absolute path to the pipeline_name... | [
"Look",
"for",
"the",
"pipeline",
"in",
"the",
"various",
"places",
"it",
"could",
"be",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/pypeloaders/fileloader.py#L11-L61 |
pypyr/pypyr-cli | pypyr/pypeloaders/fileloader.py | get_pipeline_definition | def get_pipeline_definition(pipeline_name, working_dir):
"""Open and parse the pipeline definition yaml.
Parses pipeline yaml and returns dictionary representing the pipeline.
pipeline_name.yaml should be in the working_dir/pipelines/ directory.
Args:
pipeline_name: string. Name of pipeline. ... | python | def get_pipeline_definition(pipeline_name, working_dir):
"""Open and parse the pipeline definition yaml.
Parses pipeline yaml and returns dictionary representing the pipeline.
pipeline_name.yaml should be in the working_dir/pipelines/ directory.
Args:
pipeline_name: string. Name of pipeline. ... | [
"def",
"get_pipeline_definition",
"(",
"pipeline_name",
",",
"working_dir",
")",
":",
"logger",
".",
"debug",
"(",
"\"starting\"",
")",
"pipeline_path",
"=",
"get_pipeline_path",
"(",
"pipeline_name",
"=",
"pipeline_name",
",",
"working_directory",
"=",
"working_dir",... | Open and parse the pipeline definition yaml.
Parses pipeline yaml and returns dictionary representing the pipeline.
pipeline_name.yaml should be in the working_dir/pipelines/ directory.
Args:
pipeline_name: string. Name of pipeline. This will be the file-name of
the pipelin... | [
"Open",
"and",
"parse",
"the",
"pipeline",
"definition",
"yaml",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/pypeloaders/fileloader.py#L64-L107 |
pypyr/pypyr-cli | pypyr/dsl.py | SpecialTagDirective.to_yaml | def to_yaml(cls, representer, node):
"""How to serialize this class back to yaml."""
return representer.represent_scalar(cls.yaml_tag, node.value) | python | def to_yaml(cls, representer, node):
"""How to serialize this class back to yaml."""
return representer.represent_scalar(cls.yaml_tag, node.value) | [
"def",
"to_yaml",
"(",
"cls",
",",
"representer",
",",
"node",
")",
":",
"return",
"representer",
".",
"represent_scalar",
"(",
"cls",
".",
"yaml_tag",
",",
"node",
".",
"value",
")"
] | How to serialize this class back to yaml. | [
"How",
"to",
"serialize",
"this",
"class",
"back",
"to",
"yaml",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/dsl.py#L55-L57 |
pypyr/pypyr-cli | pypyr/dsl.py | PyString.get_value | def get_value(self, context):
"""Run python eval on the input string."""
if self.value:
return expressions.eval_string(self.value, context)
else:
# Empty input raises cryptic EOF syntax err, this more human
# friendly
raise ValueError('!py string e... | python | def get_value(self, context):
"""Run python eval on the input string."""
if self.value:
return expressions.eval_string(self.value, context)
else:
# Empty input raises cryptic EOF syntax err, this more human
# friendly
raise ValueError('!py string e... | [
"def",
"get_value",
"(",
"self",
",",
"context",
")",
":",
"if",
"self",
".",
"value",
":",
"return",
"expressions",
".",
"eval_string",
"(",
"self",
".",
"value",
",",
"context",
")",
"else",
":",
"# Empty input raises cryptic EOF syntax err, this more human",
... | Run python eval on the input string. | [
"Run",
"python",
"eval",
"on",
"the",
"input",
"string",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/dsl.py#L107-L115 |
pypyr/pypyr-cli | pypyr/dsl.py | Step.foreach_loop | def foreach_loop(self, context):
"""Run step once for each item in foreach_items.
On each iteration, the invoked step can use context['i'] to get the
current iterator value.
Args:
context: (pypyr.context.Context) The pypyr context. This arg will
mutate.... | python | def foreach_loop(self, context):
"""Run step once for each item in foreach_items.
On each iteration, the invoked step can use context['i'] to get the
current iterator value.
Args:
context: (pypyr.context.Context) The pypyr context. This arg will
mutate.... | [
"def",
"foreach_loop",
"(",
"self",
",",
"context",
")",
":",
"logger",
".",
"debug",
"(",
"\"starting\"",
")",
"# Loop decorators only evaluated once, not for every step repeat",
"# execution.",
"foreach",
"=",
"context",
".",
"get_formatted_iterable",
"(",
"self",
"."... | Run step once for each item in foreach_items.
On each iteration, the invoked step can use context['i'] to get the
current iterator value.
Args:
context: (pypyr.context.Context) The pypyr context. This arg will
mutate. | [
"Run",
"step",
"once",
"for",
"each",
"item",
"in",
"foreach_items",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/dsl.py#L253-L283 |
pypyr/pypyr-cli | pypyr/dsl.py | Step.invoke_step | def invoke_step(self, context):
"""Invoke 'run_step' in the dynamically loaded step module.
Don't invoke this from outside the Step class. Use
pypyr.dsl.Step.run_step instead.
invoke_step just does the bare module step invocation, it does not
evaluate any of the decorator logic ... | python | def invoke_step(self, context):
"""Invoke 'run_step' in the dynamically loaded step module.
Don't invoke this from outside the Step class. Use
pypyr.dsl.Step.run_step instead.
invoke_step just does the bare module step invocation, it does not
evaluate any of the decorator logic ... | [
"def",
"invoke_step",
"(",
"self",
",",
"context",
")",
":",
"logger",
".",
"debug",
"(",
"\"starting\"",
")",
"logger",
".",
"debug",
"(",
"f\"running step {self.module}\"",
")",
"self",
".",
"run_step_function",
"(",
"context",
")",
"logger",
".",
"debug",
... | Invoke 'run_step' in the dynamically loaded step module.
Don't invoke this from outside the Step class. Use
pypyr.dsl.Step.run_step instead.
invoke_step just does the bare module step invocation, it does not
evaluate any of the decorator logic surrounding the step. So unless
you... | [
"Invoke",
"run_step",
"in",
"the",
"dynamically",
"loaded",
"step",
"module",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/dsl.py#L285-L305 |
pypyr/pypyr-cli | pypyr/dsl.py | Step.run_conditional_decorators | def run_conditional_decorators(self, context):
"""Evaluate the step decorators to decide whether to run step or not.
Use pypyr.dsl.Step.run_step if you intend on executing the step the
same way pypyr does.
Args:
context: (pypyr.context.Context) The pypyr context. This arg w... | python | def run_conditional_decorators(self, context):
"""Evaluate the step decorators to decide whether to run step or not.
Use pypyr.dsl.Step.run_step if you intend on executing the step the
same way pypyr does.
Args:
context: (pypyr.context.Context) The pypyr context. This arg w... | [
"def",
"run_conditional_decorators",
"(",
"self",
",",
"context",
")",
":",
"logger",
".",
"debug",
"(",
"\"starting\"",
")",
"# The decorator attributes might contain formatting expressions that",
"# change whether they evaluate True or False, thus apply formatting at",
"# last poss... | Evaluate the step decorators to decide whether to run step or not.
Use pypyr.dsl.Step.run_step if you intend on executing the step the
same way pypyr does.
Args:
context: (pypyr.context.Context) The pypyr context. This arg will
mutate. | [
"Evaluate",
"the",
"step",
"decorators",
"to",
"decide",
"whether",
"to",
"run",
"step",
"or",
"not",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/dsl.py#L307-L349 |
pypyr/pypyr-cli | pypyr/dsl.py | Step.run_foreach_or_conditional | def run_foreach_or_conditional(self, context):
"""Run the foreach sequence or the conditional evaluation.
Args:
context: (pypyr.context.Context) The pypyr context. This arg will
mutate.
"""
logger.debug("starting")
# friendly reminder [] list obj... | python | def run_foreach_or_conditional(self, context):
"""Run the foreach sequence or the conditional evaluation.
Args:
context: (pypyr.context.Context) The pypyr context. This arg will
mutate.
"""
logger.debug("starting")
# friendly reminder [] list obj... | [
"def",
"run_foreach_or_conditional",
"(",
"self",
",",
"context",
")",
":",
"logger",
".",
"debug",
"(",
"\"starting\"",
")",
"# friendly reminder [] list obj (i.e empty) evals False",
"if",
"self",
".",
"foreach_items",
":",
"self",
".",
"foreach_loop",
"(",
"context... | Run the foreach sequence or the conditional evaluation.
Args:
context: (pypyr.context.Context) The pypyr context. This arg will
mutate. | [
"Run",
"the",
"foreach",
"sequence",
"or",
"the",
"conditional",
"evaluation",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/dsl.py#L351-L366 |
pypyr/pypyr-cli | pypyr/dsl.py | Step.run_step | def run_step(self, context):
"""Run a single pipeline step.
Args:
context: (pypyr.context.Context) The pypyr context. This arg will
mutate.
"""
logger.debug("starting")
# the in params should be added to context before step execution.
sel... | python | def run_step(self, context):
"""Run a single pipeline step.
Args:
context: (pypyr.context.Context) The pypyr context. This arg will
mutate.
"""
logger.debug("starting")
# the in params should be added to context before step execution.
sel... | [
"def",
"run_step",
"(",
"self",
",",
"context",
")",
":",
"logger",
".",
"debug",
"(",
"\"starting\"",
")",
"# the in params should be added to context before step execution.",
"self",
".",
"set_step_input_context",
"(",
"context",
")",
"if",
"self",
".",
"while_decor... | Run a single pipeline step.
Args:
context: (pypyr.context.Context) The pypyr context. This arg will
mutate. | [
"Run",
"a",
"single",
"pipeline",
"step",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/dsl.py#L368-L385 |
pypyr/pypyr-cli | pypyr/dsl.py | Step.set_step_input_context | def set_step_input_context(self, context):
"""Append step's 'in' parameters to context, if they exist.
Append the[in] dictionary to the context. This will overwrite
existing values if the same keys are already in there. I.e if
in_parameters has {'eggs': 'boiled'} and key 'eggs' already
... | python | def set_step_input_context(self, context):
"""Append step's 'in' parameters to context, if they exist.
Append the[in] dictionary to the context. This will overwrite
existing values if the same keys are already in there. I.e if
in_parameters has {'eggs': 'boiled'} and key 'eggs' already
... | [
"def",
"set_step_input_context",
"(",
"self",
",",
"context",
")",
":",
"logger",
".",
"debug",
"(",
"\"starting\"",
")",
"if",
"self",
".",
"in_parameters",
"is",
"not",
"None",
":",
"parameter_count",
"=",
"len",
"(",
"self",
".",
"in_parameters",
")",
"... | Append step's 'in' parameters to context, if they exist.
Append the[in] dictionary to the context. This will overwrite
existing values if the same keys are already in there. I.e if
in_parameters has {'eggs': 'boiled'} and key 'eggs' already
exists in context, context['eggs'] hereafter w... | [
"Append",
"step",
"s",
"in",
"parameters",
"to",
"context",
"if",
"they",
"exist",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/dsl.py#L387-L409 |
pypyr/pypyr-cli | pypyr/dsl.py | RetryDecorator.exec_iteration | def exec_iteration(self, counter, context, step_method):
"""Run a single retry iteration.
This method abides by the signature invoked by poll.while_until_true,
which is to say (counter, *args, **kwargs). In a normal execution
chain, this method's args passed by self.retry_loop where con... | python | def exec_iteration(self, counter, context, step_method):
"""Run a single retry iteration.
This method abides by the signature invoked by poll.while_until_true,
which is to say (counter, *args, **kwargs). In a normal execution
chain, this method's args passed by self.retry_loop where con... | [
"def",
"exec_iteration",
"(",
"self",
",",
"counter",
",",
"context",
",",
"step_method",
")",
":",
"logger",
".",
"debug",
"(",
"\"starting\"",
")",
"context",
"[",
"'retryCounter'",
"]",
"=",
"counter",
"logger",
".",
"info",
"(",
"f\"retry: running step wit... | Run a single retry iteration.
This method abides by the signature invoked by poll.while_until_true,
which is to say (counter, *args, **kwargs). In a normal execution
chain, this method's args passed by self.retry_loop where context
and step_method set. while_until_true injects counter a... | [
"Run",
"a",
"single",
"retry",
"iteration",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/dsl.py#L469-L536 |
pypyr/pypyr-cli | pypyr/dsl.py | RetryDecorator.retry_loop | def retry_loop(self, context, step_method):
"""Run step inside a retry loop.
Args:
context: (pypyr.context.Context) The pypyr context. This arg will
mutate - after method execution will contain the new
updated context.
step_method: (meth... | python | def retry_loop(self, context, step_method):
"""Run step inside a retry loop.
Args:
context: (pypyr.context.Context) The pypyr context. This arg will
mutate - after method execution will contain the new
updated context.
step_method: (meth... | [
"def",
"retry_loop",
"(",
"self",
",",
"context",
",",
"step_method",
")",
":",
"logger",
".",
"debug",
"(",
"\"starting\"",
")",
"context",
"[",
"'retryCounter'",
"]",
"=",
"0",
"sleep",
"=",
"context",
".",
"get_formatted_as_type",
"(",
"self",
".",
"sle... | Run step inside a retry loop.
Args:
context: (pypyr.context.Context) The pypyr context. This arg will
mutate - after method execution will contain the new
updated context.
step_method: (method/function) This is the method/function that
... | [
"Run",
"step",
"inside",
"a",
"retry",
"loop",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/dsl.py#L538-L578 |
pypyr/pypyr-cli | pypyr/dsl.py | WhileDecorator.exec_iteration | def exec_iteration(self, counter, context, step_method):
"""Run a single loop iteration.
This method abides by the signature invoked by poll.while_until_true,
which is to say (counter, *args, **kwargs). In a normal execution
chain, this method's args passed by self.while_loop where cont... | python | def exec_iteration(self, counter, context, step_method):
"""Run a single loop iteration.
This method abides by the signature invoked by poll.while_until_true,
which is to say (counter, *args, **kwargs). In a normal execution
chain, this method's args passed by self.while_loop where cont... | [
"def",
"exec_iteration",
"(",
"self",
",",
"counter",
",",
"context",
",",
"step_method",
")",
":",
"logger",
".",
"debug",
"(",
"\"starting\"",
")",
"context",
"[",
"'whileCounter'",
"]",
"=",
"counter",
"logger",
".",
"info",
"(",
"f\"while: running step wit... | Run a single loop iteration.
This method abides by the signature invoked by poll.while_until_true,
which is to say (counter, *args, **kwargs). In a normal execution
chain, this method's args passed by self.while_loop where context
and step_method set. while_until_true injects counter as... | [
"Run",
"a",
"single",
"loop",
"iteration",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/dsl.py#L645-L682 |
pypyr/pypyr-cli | pypyr/dsl.py | WhileDecorator.while_loop | def while_loop(self, context, step_method):
"""Run step inside a while loop.
Args:
context: (pypyr.context.Context) The pypyr context. This arg will
mutate - after method execution will contain the new
updated context.
step_method: (meth... | python | def while_loop(self, context, step_method):
"""Run step inside a while loop.
Args:
context: (pypyr.context.Context) The pypyr context. This arg will
mutate - after method execution will contain the new
updated context.
step_method: (meth... | [
"def",
"while_loop",
"(",
"self",
",",
"context",
",",
"step_method",
")",
":",
"logger",
".",
"debug",
"(",
"\"starting\"",
")",
"context",
"[",
"'whileCounter'",
"]",
"=",
"0",
"if",
"self",
".",
"stop",
"is",
"None",
"and",
"self",
".",
"max",
"is",... | Run step inside a while loop.
Args:
context: (pypyr.context.Context) The pypyr context. This arg will
mutate - after method execution will contain the new
updated context.
step_method: (method/function) This is the method/function that
... | [
"Run",
"step",
"inside",
"a",
"while",
"loop",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/dsl.py#L684-L757 |
pypyr/pypyr-cli | pypyr/steps/fetchyaml.py | run_step | def run_step(context):
"""Load a yaml file into the pypyr context.
Yaml parsed from the file will be merged into the pypyr context. This will
overwrite existing values if the same keys are already in there.
I.e if file yaml has {'eggs' : 'boiled'} and context {'eggs': 'fried'}
already exists, retur... | python | def run_step(context):
"""Load a yaml file into the pypyr context.
Yaml parsed from the file will be merged into the pypyr context. This will
overwrite existing values if the same keys are already in there.
I.e if file yaml has {'eggs' : 'boiled'} and context {'eggs': 'fried'}
already exists, retur... | [
"def",
"run_step",
"(",
"context",
")",
":",
"logger",
".",
"debug",
"(",
"\"started\"",
")",
"deprecated",
"(",
"context",
")",
"context",
".",
"assert_key_has_value",
"(",
"key",
"=",
"'fetchYaml'",
",",
"caller",
"=",
"__name__",
")",
"fetch_yaml_input",
... | Load a yaml file into the pypyr context.
Yaml parsed from the file will be merged into the pypyr context. This will
overwrite existing values if the same keys are already in there.
I.e if file yaml has {'eggs' : 'boiled'} and context {'eggs': 'fried'}
already exists, returned context['eggs'] will be 'b... | [
"Load",
"a",
"yaml",
"file",
"into",
"the",
"pypyr",
"context",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/steps/fetchyaml.py#L10-L81 |
pypyr/pypyr-cli | pypyr/steps/fileformatyaml.py | run_step | def run_step(context):
"""Parse input yaml file and substitute {tokens} from context.
Loads yaml into memory to do parsing, so be aware of big files.
Args:
context: pypyr.context.Context. Mandatory.
- fileFormatYaml
- in. mandatory.
str, path-like, or an iterable ... | python | def run_step(context):
"""Parse input yaml file and substitute {tokens} from context.
Loads yaml into memory to do parsing, so be aware of big files.
Args:
context: pypyr.context.Context. Mandatory.
- fileFormatYaml
- in. mandatory.
str, path-like, or an iterable ... | [
"def",
"run_step",
"(",
"context",
")",
":",
"logger",
".",
"debug",
"(",
"\"started\"",
")",
"deprecated",
"(",
"context",
")",
"ObjectRewriterStep",
"(",
"__name__",
",",
"'fileFormatYaml'",
",",
"context",
")",
".",
"run_step",
"(",
"YamlRepresenter",
"(",
... | Parse input yaml file and substitute {tokens} from context.
Loads yaml into memory to do parsing, so be aware of big files.
Args:
context: pypyr.context.Context. Mandatory.
- fileFormatYaml
- in. mandatory.
str, path-like, or an iterable (list/tuple) of
... | [
"Parse",
"input",
"yaml",
"file",
"and",
"substitute",
"{",
"tokens",
"}",
"from",
"context",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/steps/fileformatyaml.py#L10-L52 |
pypyr/pypyr-cli | pypyr/utils/poll.py | wait_until_true | def wait_until_true(interval, max_attempts):
"""Decorator that executes a function until it returns True.
Executes wrapped function at every number of seconds specified by interval,
until wrapped function either returns True or max_attempts are exhausted,
whichever comes 1st. The wrapped function can h... | python | def wait_until_true(interval, max_attempts):
"""Decorator that executes a function until it returns True.
Executes wrapped function at every number of seconds specified by interval,
until wrapped function either returns True or max_attempts are exhausted,
whichever comes 1st. The wrapped function can h... | [
"def",
"wait_until_true",
"(",
"interval",
",",
"max_attempts",
")",
":",
"def",
"decorator",
"(",
"f",
")",
":",
"logger",
".",
"debug",
"(",
"\"started\"",
")",
"def",
"sleep_looper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"logger",
"."... | Decorator that executes a function until it returns True.
Executes wrapped function at every number of seconds specified by interval,
until wrapped function either returns True or max_attempts are exhausted,
whichever comes 1st. The wrapped function can have any given signature.
Use me if you always w... | [
"Decorator",
"that",
"executes",
"a",
"function",
"until",
"it",
"returns",
"True",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/utils/poll.py#L9-L47 |
pypyr/pypyr-cli | pypyr/utils/poll.py | while_until_true | def while_until_true(interval, max_attempts):
"""Decorator that executes a function until it returns True.
Executes wrapped function at every number of seconds specified by interval,
until wrapped function either returns True or max_attempts are exhausted,
whichever comes 1st.
The difference betwe... | python | def while_until_true(interval, max_attempts):
"""Decorator that executes a function until it returns True.
Executes wrapped function at every number of seconds specified by interval,
until wrapped function either returns True or max_attempts are exhausted,
whichever comes 1st.
The difference betwe... | [
"def",
"while_until_true",
"(",
"interval",
",",
"max_attempts",
")",
":",
"def",
"decorator",
"(",
"f",
")",
":",
"logger",
".",
"debug",
"(",
"\"started\"",
")",
"def",
"sleep_looper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"max_a... | Decorator that executes a function until it returns True.
Executes wrapped function at every number of seconds specified by interval,
until wrapped function either returns True or max_attempts are exhausted,
whichever comes 1st.
The difference between while_until_true and wait_until_true is that the
... | [
"Decorator",
"that",
"executes",
"a",
"function",
"until",
"it",
"returns",
"True",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/utils/poll.py#L50-L118 |
pypyr/pypyr-cli | pypyr/steps/fileformat.py | run_step | def run_step(context):
"""Parse input file and substitutes {tokens} from context.
Args:
context: pypyr.context.Context. Mandatory.
The following context keys expected:
- fileFormat
- in. mandatory.
str, path-like, or an iterable... | python | def run_step(context):
"""Parse input file and substitutes {tokens} from context.
Args:
context: pypyr.context.Context. Mandatory.
The following context keys expected:
- fileFormat
- in. mandatory.
str, path-like, or an iterable... | [
"def",
"run_step",
"(",
"context",
")",
":",
"logger",
".",
"debug",
"(",
"\"started\"",
")",
"deprecated",
"(",
"context",
")",
"StreamRewriterStep",
"(",
"__name__",
",",
"'fileFormat'",
",",
"context",
")",
".",
"run_step",
"(",
")",
"logger",
".",
"deb... | Parse input file and substitutes {tokens} from context.
Args:
context: pypyr.context.Context. Mandatory.
The following context keys expected:
- fileFormat
- in. mandatory.
str, path-like, or an iterable (list/tuple) of
... | [
"Parse",
"input",
"file",
"and",
"substitutes",
"{",
"tokens",
"}",
"from",
"context",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/steps/fileformat.py#L9-L46 |
pypyr/pypyr-cli | pypyr/steps/fileformat.py | deprecated | def deprecated(context):
"""Create new style in params from deprecated."""
if 'fileFormatIn' in context:
context.assert_keys_have_values(__name__,
'fileFormatIn',
'fileFormatOut')
context['fileFormat'] = {'in': cont... | python | def deprecated(context):
"""Create new style in params from deprecated."""
if 'fileFormatIn' in context:
context.assert_keys_have_values(__name__,
'fileFormatIn',
'fileFormatOut')
context['fileFormat'] = {'in': cont... | [
"def",
"deprecated",
"(",
"context",
")",
":",
"if",
"'fileFormatIn'",
"in",
"context",
":",
"context",
".",
"assert_keys_have_values",
"(",
"__name__",
",",
"'fileFormatIn'",
",",
"'fileFormatOut'",
")",
"context",
"[",
"'fileFormat'",
"]",
"=",
"{",
"'in'",
... | Create new style in params from deprecated. | [
"Create",
"new",
"style",
"in",
"params",
"from",
"deprecated",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/steps/fileformat.py#L49-L64 |
pypyr/pypyr-cli | pypyr/steps/nowutc.py | run_step | def run_step(context):
"""pypyr step saves current utc datetime to context.
Args:
context: pypyr.context.Context. Mandatory.
The following context key is optional:
- nowUtcIn. str. Datetime formatting expression. For full list
of possible expressions, ... | python | def run_step(context):
"""pypyr step saves current utc datetime to context.
Args:
context: pypyr.context.Context. Mandatory.
The following context key is optional:
- nowUtcIn. str. Datetime formatting expression. For full list
of possible expressions, ... | [
"def",
"run_step",
"(",
"context",
")",
":",
"logger",
".",
"debug",
"(",
"\"started\"",
")",
"format_expression",
"=",
"context",
".",
"get",
"(",
"'nowUtcIn'",
",",
"None",
")",
"if",
"format_expression",
":",
"formatted_expression",
"=",
"context",
".",
"... | pypyr step saves current utc datetime to context.
Args:
context: pypyr.context.Context. Mandatory.
The following context key is optional:
- nowUtcIn. str. Datetime formatting expression. For full list
of possible expressions, check here:
... | [
"pypyr",
"step",
"saves",
"current",
"utc",
"datetime",
"to",
"context",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/steps/nowutc.py#L9-L44 |
pypyr/pypyr-cli | pypyr/steps/env.py | run_step | def run_step(context):
"""Get, set, unset $ENVs.
Context is a dictionary or dictionary-like. context is mandatory.
Input context is:
env:
get: {dict}
set: {dict}
unset: [list]
At least one of env's sub-keys (get, set or unset) must exist.
This step wil... | python | def run_step(context):
"""Get, set, unset $ENVs.
Context is a dictionary or dictionary-like. context is mandatory.
Input context is:
env:
get: {dict}
set: {dict}
unset: [list]
At least one of env's sub-keys (get, set or unset) must exist.
This step wil... | [
"def",
"run_step",
"(",
"context",
")",
":",
"logger",
".",
"debug",
"(",
"\"started\"",
")",
"assert",
"context",
",",
"f\"context must have value for {__name__}\"",
"deprecated",
"(",
"context",
")",
"context",
".",
"assert_key_has_value",
"(",
"'env'",
",",
"__... | Get, set, unset $ENVs.
Context is a dictionary or dictionary-like. context is mandatory.
Input context is:
env:
get: {dict}
set: {dict}
unset: [list]
At least one of env's sub-keys (get, set or unset) must exist.
This step will run whatever combination of ... | [
"Get",
"set",
"unset",
"$ENVs",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/steps/env.py#L10-L43 |
pypyr/pypyr-cli | pypyr/steps/env.py | env_get | def env_get(context):
"""Get $ENVs into the pypyr context.
Context is a dictionary or dictionary-like. context is mandatory.
context['env']['get'] must exist. It's a dictionary.
Values are the names of the $ENVs to write to the pypyr context.
Keys are the pypyr context item to which to write the $... | python | def env_get(context):
"""Get $ENVs into the pypyr context.
Context is a dictionary or dictionary-like. context is mandatory.
context['env']['get'] must exist. It's a dictionary.
Values are the names of the $ENVs to write to the pypyr context.
Keys are the pypyr context item to which to write the $... | [
"def",
"env_get",
"(",
"context",
")",
":",
"get",
"=",
"context",
"[",
"'env'",
"]",
".",
"get",
"(",
"'get'",
",",
"None",
")",
"exists",
"=",
"False",
"if",
"get",
":",
"logger",
".",
"debug",
"(",
"\"start\"",
")",
"for",
"k",
",",
"v",
"in",... | Get $ENVs into the pypyr context.
Context is a dictionary or dictionary-like. context is mandatory.
context['env']['get'] must exist. It's a dictionary.
Values are the names of the $ENVs to write to the pypyr context.
Keys are the pypyr context item to which to write the $ENV values.
For example,... | [
"Get",
"$ENVs",
"into",
"the",
"pypyr",
"context",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/steps/env.py#L46-L85 |
pypyr/pypyr-cli | pypyr/steps/env.py | env_set | def env_set(context):
"""Set $ENVs to specified string. from the pypyr context.
Args:
context: is dictionary-like. context is mandatory.
context['env']['set'] must exist. It's a dictionary.
Values are strings to write to $ENV.
Keys are the names of the... | python | def env_set(context):
"""Set $ENVs to specified string. from the pypyr context.
Args:
context: is dictionary-like. context is mandatory.
context['env']['set'] must exist. It's a dictionary.
Values are strings to write to $ENV.
Keys are the names of the... | [
"def",
"env_set",
"(",
"context",
")",
":",
"env_set",
"=",
"context",
"[",
"'env'",
"]",
".",
"get",
"(",
"'set'",
",",
"None",
")",
"exists",
"=",
"False",
"if",
"env_set",
":",
"logger",
".",
"debug",
"(",
"\"started\"",
")",
"for",
"k",
",",
"v... | Set $ENVs to specified string. from the pypyr context.
Args:
context: is dictionary-like. context is mandatory.
context['env']['set'] must exist. It's a dictionary.
Values are strings to write to $ENV.
Keys are the names of the $ENV values to which to writ... | [
"Set",
"$ENVs",
"to",
"specified",
"string",
".",
"from",
"the",
"pypyr",
"context",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/steps/env.py#L88-L132 |
pypyr/pypyr-cli | pypyr/steps/env.py | env_unset | def env_unset(context):
"""Unset $ENVs.
Context is a dictionary or dictionary-like. context is mandatory.
context['env']['unset'] must exist. It's a list.
List items are the names of the $ENV values to unset.
For example, say input context is:
key1: value1
key2: value2
key... | python | def env_unset(context):
"""Unset $ENVs.
Context is a dictionary or dictionary-like. context is mandatory.
context['env']['unset'] must exist. It's a list.
List items are the names of the $ENV values to unset.
For example, say input context is:
key1: value1
key2: value2
key... | [
"def",
"env_unset",
"(",
"context",
")",
":",
"unset",
"=",
"context",
"[",
"'env'",
"]",
".",
"get",
"(",
"'unset'",
",",
"None",
")",
"exists",
"=",
"False",
"if",
"unset",
":",
"logger",
".",
"debug",
"(",
"\"started\"",
")",
"for",
"env_var_name",
... | Unset $ENVs.
Context is a dictionary or dictionary-like. context is mandatory.
context['env']['unset'] must exist. It's a list.
List items are the names of the $ENV values to unset.
For example, say input context is:
key1: value1
key2: value2
key3: value3
env:
... | [
"Unset",
"$ENVs",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/steps/env.py#L135-L177 |
pypyr/pypyr-cli | pypyr/steps/env.py | deprecated | def deprecated(context):
"""Handle deprecated context input."""
env = context.get('env', None)
get_info, set_info, unset_info = context.keys_of_type_exist(
('envGet', dict),
('envSet', dict),
('envUnset', list)
)
found_at_least_one = (get_info.key_in_context or set_info.key... | python | def deprecated(context):
"""Handle deprecated context input."""
env = context.get('env', None)
get_info, set_info, unset_info = context.keys_of_type_exist(
('envGet', dict),
('envSet', dict),
('envUnset', list)
)
found_at_least_one = (get_info.key_in_context or set_info.key... | [
"def",
"deprecated",
"(",
"context",
")",
":",
"env",
"=",
"context",
".",
"get",
"(",
"'env'",
",",
"None",
")",
"get_info",
",",
"set_info",
",",
"unset_info",
"=",
"context",
".",
"keys_of_type_exist",
"(",
"(",
"'envGet'",
",",
"dict",
")",
",",
"(... | Handle deprecated context input. | [
"Handle",
"deprecated",
"context",
"input",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/steps/env.py#L180-L211 |
pypyr/pypyr-cli | pypyr/steps/assert.py | run_step | def run_step(context):
"""Assert that something is True or equal to something else.
Args:
context: dictionary-like pypyr.context.Context. context is mandatory.
Uses the following context keys in context:
- assert
- this. mandatory. Any type. If assert['equals'] not s... | python | def run_step(context):
"""Assert that something is True or equal to something else.
Args:
context: dictionary-like pypyr.context.Context. context is mandatory.
Uses the following context keys in context:
- assert
- this. mandatory. Any type. If assert['equals'] not s... | [
"def",
"run_step",
"(",
"context",
")",
":",
"logger",
".",
"debug",
"(",
"\"started\"",
")",
"assert",
"context",
",",
"f\"context must have value for {__name__}\"",
"deprecated",
"(",
"context",
")",
"context",
".",
"assert_key_has_value",
"(",
"'assert'",
",",
... | Assert that something is True or equal to something else.
Args:
context: dictionary-like pypyr.context.Context. context is mandatory.
Uses the following context keys in context:
- assert
- this. mandatory. Any type. If assert['equals'] not specified,
ev... | [
"Assert",
"that",
"something",
"is",
"True",
"or",
"equal",
"to",
"something",
"else",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/steps/assert.py#L9-L71 |
pypyr/pypyr-cli | pypyr/steps/assert.py | deprecated | def deprecated(context):
"""Handle deprecated context input."""
assert_context = context.get('assert', None)
# specifically do "key in dict" to avoid python bool eval thinking
# None/Empty values mean the key isn't there.
if 'assertThis' in context:
assert_this = context['assertThis']
... | python | def deprecated(context):
"""Handle deprecated context input."""
assert_context = context.get('assert', None)
# specifically do "key in dict" to avoid python bool eval thinking
# None/Empty values mean the key isn't there.
if 'assertThis' in context:
assert_this = context['assertThis']
... | [
"def",
"deprecated",
"(",
"context",
")",
":",
"assert_context",
"=",
"context",
".",
"get",
"(",
"'assert'",
",",
"None",
")",
"# specifically do \"key in dict\" to avoid python bool eval thinking",
"# None/Empty values mean the key isn't there.",
"if",
"'assertThis'",
"in",... | Handle deprecated context input. | [
"Handle",
"deprecated",
"context",
"input",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/steps/assert.py#L74-L91 |
pypyr/pypyr-cli | pypyr/steps/tar.py | run_step | def run_step(context):
"""Archive and/or extract tars with or without compression.
Args:
context: dictionary-like. Mandatory.
Expects the following context:
tar:
extract:
- in: /path/my.tar
out: /out/path
archive:
... | python | def run_step(context):
"""Archive and/or extract tars with or without compression.
Args:
context: dictionary-like. Mandatory.
Expects the following context:
tar:
extract:
- in: /path/my.tar
out: /out/path
archive:
... | [
"def",
"run_step",
"(",
"context",
")",
":",
"logger",
".",
"debug",
"(",
"\"started\"",
")",
"assert",
"context",
",",
"f\"context must have value for {__name__}\"",
"deprecated",
"(",
"context",
")",
"found_at_least_one",
"=",
"False",
"context",
".",
"assert_key_... | Archive and/or extract tars with or without compression.
Args:
context: dictionary-like. Mandatory.
Expects the following context:
tar:
extract:
- in: /path/my.tar
out: /out/path
archive:
- in: /dir/to/archive
... | [
"Archive",
"and",
"/",
"or",
"extract",
"tars",
"with",
"or",
"without",
"compression",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/steps/tar.py#L10-L66 |
pypyr/pypyr-cli | pypyr/steps/tar.py | get_file_mode_for_reading | def get_file_mode_for_reading(context):
"""Get file mode for reading from tar['format'].
This should return r:*, r:gz, r:bz2 or r:xz. If user specified something
wacky in tar.Format, that's their business.
In theory r:* will auto-deduce the correct format.
"""
format = context['tar'].get('form... | python | def get_file_mode_for_reading(context):
"""Get file mode for reading from tar['format'].
This should return r:*, r:gz, r:bz2 or r:xz. If user specified something
wacky in tar.Format, that's their business.
In theory r:* will auto-deduce the correct format.
"""
format = context['tar'].get('form... | [
"def",
"get_file_mode_for_reading",
"(",
"context",
")",
":",
"format",
"=",
"context",
"[",
"'tar'",
"]",
".",
"get",
"(",
"'format'",
",",
"None",
")",
"if",
"format",
"or",
"format",
"==",
"''",
":",
"mode",
"=",
"f\"r:{context.get_formatted_string(format)}... | Get file mode for reading from tar['format'].
This should return r:*, r:gz, r:bz2 or r:xz. If user specified something
wacky in tar.Format, that's their business.
In theory r:* will auto-deduce the correct format. | [
"Get",
"file",
"mode",
"for",
"reading",
"from",
"tar",
"[",
"format",
"]",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/steps/tar.py#L69-L84 |
pypyr/pypyr-cli | pypyr/steps/tar.py | get_file_mode_for_writing | def get_file_mode_for_writing(context):
"""Get file mode for writing from tar['format'].
This should return w:, w:gz, w:bz2 or w:xz. If user specified something
wacky in tar.Format, that's their business.
"""
format = context['tar'].get('format', None)
# slightly weird double-check because fals... | python | def get_file_mode_for_writing(context):
"""Get file mode for writing from tar['format'].
This should return w:, w:gz, w:bz2 or w:xz. If user specified something
wacky in tar.Format, that's their business.
"""
format = context['tar'].get('format', None)
# slightly weird double-check because fals... | [
"def",
"get_file_mode_for_writing",
"(",
"context",
")",
":",
"format",
"=",
"context",
"[",
"'tar'",
"]",
".",
"get",
"(",
"'format'",
",",
"None",
")",
"# slightly weird double-check because falsy format could mean either format",
"# doesn't exist in input, OR that it exist... | Get file mode for writing from tar['format'].
This should return w:, w:gz, w:bz2 or w:xz. If user specified something
wacky in tar.Format, that's their business. | [
"Get",
"file",
"mode",
"for",
"writing",
"from",
"tar",
"[",
"format",
"]",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/steps/tar.py#L87-L102 |
pypyr/pypyr-cli | pypyr/steps/tar.py | tar_archive | def tar_archive(context):
"""Archive specified path to a tar archive.
Args:
context: dictionary-like. context is mandatory.
context['tar']['archive'] must exist. It's a dictionary.
keys are the paths to archive.
values are the destination output paths.
Example:
... | python | def tar_archive(context):
"""Archive specified path to a tar archive.
Args:
context: dictionary-like. context is mandatory.
context['tar']['archive'] must exist. It's a dictionary.
keys are the paths to archive.
values are the destination output paths.
Example:
... | [
"def",
"tar_archive",
"(",
"context",
")",
":",
"logger",
".",
"debug",
"(",
"\"start\"",
")",
"mode",
"=",
"get_file_mode_for_writing",
"(",
"context",
")",
"for",
"item",
"in",
"context",
"[",
"'tar'",
"]",
"[",
"'archive'",
"]",
":",
"# value is the desti... | Archive specified path to a tar archive.
Args:
context: dictionary-like. context is mandatory.
context['tar']['archive'] must exist. It's a dictionary.
keys are the paths to archive.
values are the destination output paths.
Example:
tar:
archive:... | [
"Archive",
"specified",
"path",
"to",
"a",
"tar",
"archive",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/steps/tar.py#L105-L140 |
pypyr/pypyr-cli | pypyr/steps/tar.py | tar_extract | def tar_extract(context):
"""Extract all members of tar archive to specified path.
Args:
context: dictionary-like. context is mandatory.
context['tar']['extract'] must exist. It's a dictionary.
keys are the path to the tar to extract.
values are the destination paths... | python | def tar_extract(context):
"""Extract all members of tar archive to specified path.
Args:
context: dictionary-like. context is mandatory.
context['tar']['extract'] must exist. It's a dictionary.
keys are the path to the tar to extract.
values are the destination paths... | [
"def",
"tar_extract",
"(",
"context",
")",
":",
"logger",
".",
"debug",
"(",
"\"start\"",
")",
"mode",
"=",
"get_file_mode_for_reading",
"(",
"context",
")",
"for",
"item",
"in",
"context",
"[",
"'tar'",
"]",
"[",
"'extract'",
"]",
":",
"# in is the path to ... | Extract all members of tar archive to specified path.
Args:
context: dictionary-like. context is mandatory.
context['tar']['extract'] must exist. It's a dictionary.
keys are the path to the tar to extract.
values are the destination paths.
Example:
tar:
... | [
"Extract",
"all",
"members",
"of",
"tar",
"archive",
"to",
"specified",
"path",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/steps/tar.py#L143-L178 |
pypyr/pypyr-cli | pypyr/steps/tar.py | deprecated | def deprecated(context):
"""Handle deprecated context input."""
tar = context.get('tar', None)
# at least 1 of tarExtract or tarArchive must exist in context
tar_extract, tar_archive = context.keys_of_type_exist(
('tarExtract', list),
('tarArchive', list))
found_at_least_one = (tar... | python | def deprecated(context):
"""Handle deprecated context input."""
tar = context.get('tar', None)
# at least 1 of tarExtract or tarArchive must exist in context
tar_extract, tar_archive = context.keys_of_type_exist(
('tarExtract', list),
('tarArchive', list))
found_at_least_one = (tar... | [
"def",
"deprecated",
"(",
"context",
")",
":",
"tar",
"=",
"context",
".",
"get",
"(",
"'tar'",
",",
"None",
")",
"# at least 1 of tarExtract or tarArchive must exist in context",
"tar_extract",
",",
"tar_archive",
"=",
"context",
".",
"keys_of_type_exist",
"(",
"("... | Handle deprecated context input. | [
"Handle",
"deprecated",
"context",
"input",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/steps/tar.py#L181-L211 |
pypyr/pypyr-cli | pypyr/steps/shell.py | run_step | def run_step(context):
"""Run shell command without shell interpolation.
Context is a dictionary or dictionary-like.
Context must contain the following keys:
cmd: <<cmd string>> (command + args to execute.)
OR, as a dict
cmd:
run: str. mandatory. <<cmd string>> command + args to execu... | python | def run_step(context):
"""Run shell command without shell interpolation.
Context is a dictionary or dictionary-like.
Context must contain the following keys:
cmd: <<cmd string>> (command + args to execute.)
OR, as a dict
cmd:
run: str. mandatory. <<cmd string>> command + args to execu... | [
"def",
"run_step",
"(",
"context",
")",
":",
"logger",
".",
"debug",
"(",
"\"started\"",
")",
"CmdStep",
"(",
"name",
"=",
"__name__",
",",
"context",
"=",
"context",
")",
".",
"run_step",
"(",
"is_shell",
"=",
"True",
")",
"logger",
".",
"debug",
"(",... | Run shell command without shell interpolation.
Context is a dictionary or dictionary-like.
Context must contain the following keys:
cmd: <<cmd string>> (command + args to execute.)
OR, as a dict
cmd:
run: str. mandatory. <<cmd string>> command + args to execute.
save: bool. defaul... | [
"Run",
"shell",
"command",
"without",
"shell",
"interpolation",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/steps/shell.py#L14-L57 |
pypyr/pypyr-cli | pypyr/steps/envget.py | run_step | def run_step(context):
"""Get $ENVs, allowing a default if not found.
Set context properties from environment variables, and specify a default
if the environment variable is not found.
This differs from pypyr.steps.env get, which raises an error if attempting
to read an $ENV that doesn't exist.
... | python | def run_step(context):
"""Get $ENVs, allowing a default if not found.
Set context properties from environment variables, and specify a default
if the environment variable is not found.
This differs from pypyr.steps.env get, which raises an error if attempting
to read an $ENV that doesn't exist.
... | [
"def",
"run_step",
"(",
"context",
")",
":",
"logger",
".",
"debug",
"(",
"\"started\"",
")",
"assert",
"context",
",",
"f\"context must have value for {__name__}\"",
"context",
".",
"assert_key_has_value",
"(",
"'envGet'",
",",
"__name__",
")",
"# allow a list OR a s... | Get $ENVs, allowing a default if not found.
Set context properties from environment variables, and specify a default
if the environment variable is not found.
This differs from pypyr.steps.env get, which raises an error if attempting
to read an $ENV that doesn't exist.
Args:
context. mand... | [
"Get",
"$ENVs",
"allowing",
"a",
"default",
"if",
"not",
"found",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/steps/envget.py#L10-L77 |
pypyr/pypyr-cli | pypyr/steps/envget.py | get_args | def get_args(get_item):
"""Parse env, key, default out of input dict.
Args:
get_item: dict. contains keys env/key/default
Returns:
(env, key, has_default, default) tuple, where
env: str. env var name.
key: str. save env value to this context key.
has_def... | python | def get_args(get_item):
"""Parse env, key, default out of input dict.
Args:
get_item: dict. contains keys env/key/default
Returns:
(env, key, has_default, default) tuple, where
env: str. env var name.
key: str. save env value to this context key.
has_def... | [
"def",
"get_args",
"(",
"get_item",
")",
":",
"if",
"not",
"isinstance",
"(",
"get_item",
",",
"dict",
")",
":",
"raise",
"ContextError",
"(",
"'envGet must contain a list of dicts.'",
")",
"env",
"=",
"get_item",
".",
"get",
"(",
"'env'",
",",
"None",
")",
... | Parse env, key, default out of input dict.
Args:
get_item: dict. contains keys env/key/default
Returns:
(env, key, has_default, default) tuple, where
env: str. env var name.
key: str. save env value to this context key.
has_default: bool. True if default spe... | [
"Parse",
"env",
"key",
"default",
"out",
"of",
"input",
"dict",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/steps/envget.py#L80-L120 |
pypyr/pypyr-cli | pypyr/steps/py.py | run_step | def run_step(context):
"""Executes dynamic python code.
Context is a dictionary or dictionary-like.
Context must contain key 'pycode'
Will exec context['pycode'] as dynamically interpreted python statements.
context is mandatory. When you execute the pipeline, it should look
something like thi... | python | def run_step(context):
"""Executes dynamic python code.
Context is a dictionary or dictionary-like.
Context must contain key 'pycode'
Will exec context['pycode'] as dynamically interpreted python statements.
context is mandatory. When you execute the pipeline, it should look
something like thi... | [
"def",
"run_step",
"(",
"context",
")",
":",
"logger",
".",
"debug",
"(",
"\"started\"",
")",
"context",
".",
"assert_key_has_value",
"(",
"key",
"=",
"'pycode'",
",",
"caller",
"=",
"__name__",
")",
"logger",
".",
"debug",
"(",
"f\"Executing python string: {c... | Executes dynamic python code.
Context is a dictionary or dictionary-like.
Context must contain key 'pycode'
Will exec context['pycode'] as dynamically interpreted python statements.
context is mandatory. When you execute the pipeline, it should look
something like this:
pipeline-runner [na... | [
"Executes",
"dynamic",
"python",
"code",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/steps/py.py#L11-L35 |
pypyr/pypyr-cli | pypyr/parser/yamlfile.py | get_parsed_context | def get_parsed_context(context_arg):
"""Parse input context string and returns context as dictionary."""
assert context_arg, ("pipeline must be invoked with context arg set. For "
"this yaml parser you're looking for something "
"like: "
... | python | def get_parsed_context(context_arg):
"""Parse input context string and returns context as dictionary."""
assert context_arg, ("pipeline must be invoked with context arg set. For "
"this yaml parser you're looking for something "
"like: "
... | [
"def",
"get_parsed_context",
"(",
"context_arg",
")",
":",
"assert",
"context_arg",
",",
"(",
"\"pipeline must be invoked with context arg set. For \"",
"\"this yaml parser you're looking for something \"",
"\"like: \"",
"\"pypyr pipelinename './myyamlfile.yaml'\"",
")",
"logger",
".... | Parse input context string and returns context as dictionary. | [
"Parse",
"input",
"context",
"string",
"and",
"returns",
"context",
"as",
"dictionary",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/parser/yamlfile.py#L11-L32 |
pypyr/pypyr-cli | pypyr/cli.py | get_parser | def get_parser():
"""Return ArgumentParser for pypyr cli."""
parser = argparse.ArgumentParser(
allow_abbrev=True,
description='pypyr pipeline runner')
parser.add_argument('pipeline_name',
help='Name of pipeline to run. It should exist in the '
... | python | def get_parser():
"""Return ArgumentParser for pypyr cli."""
parser = argparse.ArgumentParser(
allow_abbrev=True,
description='pypyr pipeline runner')
parser.add_argument('pipeline_name',
help='Name of pipeline to run. It should exist in the '
... | [
"def",
"get_parser",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"allow_abbrev",
"=",
"True",
",",
"description",
"=",
"'pypyr pipeline runner'",
")",
"parser",
".",
"add_argument",
"(",
"'pipeline_name'",
",",
"help",
"=",
"'Name of pi... | Return ArgumentParser for pypyr cli. | [
"Return",
"ArgumentParser",
"for",
"pypyr",
"cli",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/cli.py#L19-L44 |
pypyr/pypyr-cli | pypyr/cli.py | main | def main(args=None):
"""Entry point for pypyr cli.
The setup_py entry_point wraps this in sys.exit already so this effectively
becomes sys.exit(main()).
The __main__ entry point similarly wraps sys.exit().
"""
if args is None:
args = sys.argv[1:]
parsed_args = get_args(args)
t... | python | def main(args=None):
"""Entry point for pypyr cli.
The setup_py entry_point wraps this in sys.exit already so this effectively
becomes sys.exit(main()).
The __main__ entry point similarly wraps sys.exit().
"""
if args is None:
args = sys.argv[1:]
parsed_args = get_args(args)
t... | [
"def",
"main",
"(",
"args",
"=",
"None",
")",
":",
"if",
"args",
"is",
"None",
":",
"args",
"=",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
"parsed_args",
"=",
"get_args",
"(",
"args",
")",
"try",
":",
"return",
"pypyr",
".",
"pipelinerunner",
".",
... | Entry point for pypyr cli.
The setup_py entry_point wraps this in sys.exit already so this effectively
becomes sys.exit(main()).
The __main__ entry point similarly wraps sys.exit(). | [
"Entry",
"point",
"for",
"pypyr",
"cli",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/cli.py#L47-L80 |
pypyr/pypyr-cli | pypyr/steps/dsl/cmd.py | CmdStep.run_step | def run_step(self, is_shell):
"""Run a command.
Runs a program or executable. If is_shell is True, executes the command
through the shell.
Args:
is_shell: bool. defaults False. Set to true to execute cmd through
the default shell.
"""
a... | python | def run_step(self, is_shell):
"""Run a command.
Runs a program or executable. If is_shell is True, executes the command
through the shell.
Args:
is_shell: bool. defaults False. Set to true to execute cmd through
the default shell.
"""
a... | [
"def",
"run_step",
"(",
"self",
",",
"is_shell",
")",
":",
"assert",
"is_shell",
"is",
"not",
"None",
",",
"(",
"\"is_shell param must exist for CmdStep.\"",
")",
"# why? If shell is True, it is recommended to pass args as a string",
"# rather than as a sequence.",
"if",
"is_... | Run a command.
Runs a program or executable. If is_shell is True, executes the command
through the shell.
Args:
is_shell: bool. defaults False. Set to true to execute cmd through
the default shell. | [
"Run",
"a",
"command",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/steps/dsl/cmd.py#L95-L139 |
pypyr/pypyr-cli | pypyr/steps/contextclear.py | run_step | def run_step(context):
"""Remove specified keys from context.
Args:
Context is a dictionary or dictionary-like.
context['contextClear'] must exist. It's a dictionary.
Will iterate context['contextClear'] and remove those keys from
context.
For example, say input context is:... | python | def run_step(context):
"""Remove specified keys from context.
Args:
Context is a dictionary or dictionary-like.
context['contextClear'] must exist. It's a dictionary.
Will iterate context['contextClear'] and remove those keys from
context.
For example, say input context is:... | [
"def",
"run_step",
"(",
"context",
")",
":",
"logger",
".",
"debug",
"(",
"\"started\"",
")",
"context",
".",
"assert_key_has_value",
"(",
"key",
"=",
"'contextClear'",
",",
"caller",
"=",
"__name__",
")",
"for",
"k",
"in",
"context",
"[",
"'contextClear'",
... | Remove specified keys from context.
Args:
Context is a dictionary or dictionary-like.
context['contextClear'] must exist. It's a dictionary.
Will iterate context['contextClear'] and remove those keys from
context.
For example, say input context is:
key1: value1
... | [
"Remove",
"specified",
"keys",
"from",
"context",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/steps/contextclear.py#L13-L46 |
pypyr/pypyr-cli | pypyr/steps/safeshell.py | run_step | def run_step(context):
"""Run command, program or executable.
Context is a dictionary or dictionary-like.
Context must contain the following keys:
cmd: <<cmd string>> (command + args to execute.)
OR, as a dict
cmd:
run: str. mandatory. <<cmd string>> command + args to execute.
... | python | def run_step(context):
"""Run command, program or executable.
Context is a dictionary or dictionary-like.
Context must contain the following keys:
cmd: <<cmd string>> (command + args to execute.)
OR, as a dict
cmd:
run: str. mandatory. <<cmd string>> command + args to execute.
... | [
"def",
"run_step",
"(",
"context",
")",
":",
"logger",
".",
"debug",
"(",
"\"started\"",
")",
"pypyr",
".",
"steps",
".",
"cmd",
".",
"run_step",
"(",
"context",
")",
"logger",
".",
"debug",
"(",
"\"done\"",
")"
] | Run command, program or executable.
Context is a dictionary or dictionary-like.
Context must contain the following keys:
cmd: <<cmd string>> (command + args to execute.)
OR, as a dict
cmd:
run: str. mandatory. <<cmd string>> command + args to execute.
save: bool. defaults False. s... | [
"Run",
"command",
"program",
"or",
"executable",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/steps/safeshell.py#L16-L55 |
pypyr/pypyr-cli | pypyr/steps/default.py | run_step | def run_step(context):
"""Set hierarchy into context with substitutions if it doesn't exist yet.
context is a dictionary or dictionary-like.
context['defaults'] must exist. It's a dictionary.
Will iterate context['defaults'] and add these as new values where
their keys don't already exist. While i... | python | def run_step(context):
"""Set hierarchy into context with substitutions if it doesn't exist yet.
context is a dictionary or dictionary-like.
context['defaults'] must exist. It's a dictionary.
Will iterate context['defaults'] and add these as new values where
their keys don't already exist. While i... | [
"def",
"run_step",
"(",
"context",
")",
":",
"logger",
".",
"debug",
"(",
"\"started\"",
")",
"context",
".",
"assert_key_has_value",
"(",
"key",
"=",
"'defaults'",
",",
"caller",
"=",
"__name__",
")",
"context",
".",
"set_defaults",
"(",
"context",
"[",
"... | Set hierarchy into context with substitutions if it doesn't exist yet.
context is a dictionary or dictionary-like.
context['defaults'] must exist. It's a dictionary.
Will iterate context['defaults'] and add these as new values where
their keys don't already exist. While it's doing so, it will leave
... | [
"Set",
"hierarchy",
"into",
"context",
"with",
"substitutions",
"if",
"it",
"doesn",
"t",
"exist",
"yet",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/steps/default.py#L38-L84 |
pypyr/pypyr-cli | pypyr/stepsrunner.py | get_pipeline_steps | def get_pipeline_steps(pipeline, steps_group):
"""Get the steps attribute of module pipeline.
If there is no steps sequence on the pipeline, return None. Guess you
could theoretically want to run a pipeline with nothing in it.
"""
logger.debug("starting")
assert pipeline
assert steps_group
... | python | def get_pipeline_steps(pipeline, steps_group):
"""Get the steps attribute of module pipeline.
If there is no steps sequence on the pipeline, return None. Guess you
could theoretically want to run a pipeline with nothing in it.
"""
logger.debug("starting")
assert pipeline
assert steps_group
... | [
"def",
"get_pipeline_steps",
"(",
"pipeline",
",",
"steps_group",
")",
":",
"logger",
".",
"debug",
"(",
"\"starting\"",
")",
"assert",
"pipeline",
"assert",
"steps_group",
"logger",
".",
"debug",
"(",
"f\"retrieving {steps_group} steps from pipeline\"",
")",
"if",
... | Get the steps attribute of module pipeline.
If there is no steps sequence on the pipeline, return None. Guess you
could theoretically want to run a pipeline with nothing in it. | [
"Get",
"the",
"steps",
"attribute",
"of",
"module",
"pipeline",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/stepsrunner.py#L13-L47 |
pypyr/pypyr-cli | pypyr/stepsrunner.py | run_failure_step_group | def run_failure_step_group(pipeline, context):
"""Run the on_failure step group if it exists.
This function will swallow all errors, to prevent obfuscating the error
condition that got it here to begin with.
"""
logger.debug("starting")
try:
assert pipeline
# if no on_failure ex... | python | def run_failure_step_group(pipeline, context):
"""Run the on_failure step group if it exists.
This function will swallow all errors, to prevent obfuscating the error
condition that got it here to begin with.
"""
logger.debug("starting")
try:
assert pipeline
# if no on_failure ex... | [
"def",
"run_failure_step_group",
"(",
"pipeline",
",",
"context",
")",
":",
"logger",
".",
"debug",
"(",
"\"starting\"",
")",
"try",
":",
"assert",
"pipeline",
"# if no on_failure exists, it'll do nothing.",
"run_step_group",
"(",
"pipeline_definition",
"=",
"pipeline",... | Run the on_failure step group if it exists.
This function will swallow all errors, to prevent obfuscating the error
condition that got it here to begin with. | [
"Run",
"the",
"on_failure",
"step",
"group",
"if",
"it",
"exists",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/stepsrunner.py#L50-L67 |
pypyr/pypyr-cli | pypyr/stepsrunner.py | run_pipeline_steps | def run_pipeline_steps(steps, context):
"""Run the run_step(context) method of each step in steps.
Args:
steps: list. Sequence of Steps to execute
context: pypyr.context.Context. The pypyr context. Will mutate.
"""
logger.debug("starting")
assert isinstance(
context, dict), ... | python | def run_pipeline_steps(steps, context):
"""Run the run_step(context) method of each step in steps.
Args:
steps: list. Sequence of Steps to execute
context: pypyr.context.Context. The pypyr context. Will mutate.
"""
logger.debug("starting")
assert isinstance(
context, dict), ... | [
"def",
"run_pipeline_steps",
"(",
"steps",
",",
"context",
")",
":",
"logger",
".",
"debug",
"(",
"\"starting\"",
")",
"assert",
"isinstance",
"(",
"context",
",",
"dict",
")",
",",
"\"context must be a dictionary, even if empty {}.\"",
"if",
"steps",
"is",
"None"... | Run the run_step(context) method of each step in steps.
Args:
steps: list. Sequence of Steps to execute
context: pypyr.context.Context. The pypyr context. Will mutate. | [
"Run",
"the",
"run_step",
"(",
"context",
")",
"method",
"of",
"each",
"step",
"in",
"steps",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/stepsrunner.py#L70-L93 |
pypyr/pypyr-cli | pypyr/stepsrunner.py | run_step_group | def run_step_group(pipeline_definition, step_group_name, context):
"""Get the specified step group from the pipeline and run its steps."""
logger.debug(f"starting {step_group_name}")
assert step_group_name
steps = get_pipeline_steps(pipeline=pipeline_definition,
steps_gro... | python | def run_step_group(pipeline_definition, step_group_name, context):
"""Get the specified step group from the pipeline and run its steps."""
logger.debug(f"starting {step_group_name}")
assert step_group_name
steps = get_pipeline_steps(pipeline=pipeline_definition,
steps_gro... | [
"def",
"run_step_group",
"(",
"pipeline_definition",
",",
"step_group_name",
",",
"context",
")",
":",
"logger",
".",
"debug",
"(",
"f\"starting {step_group_name}\"",
")",
"assert",
"step_group_name",
"steps",
"=",
"get_pipeline_steps",
"(",
"pipeline",
"=",
"pipeline... | Get the specified step group from the pipeline and run its steps. | [
"Get",
"the",
"specified",
"step",
"group",
"from",
"the",
"pipeline",
"and",
"run",
"its",
"steps",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/stepsrunner.py#L96-L106 |
pypyr/pypyr-cli | pypyr/utils/filesystem.py | ensure_dir | def ensure_dir(path):
"""Create all parent directories of path if they don't exist.
Args:
path. Path-like object. Create parent dirs to this path.
Return:
None.
"""
os.makedirs(os.path.abspath(os.path.dirname(path)), exist_ok=True) | python | def ensure_dir(path):
"""Create all parent directories of path if they don't exist.
Args:
path. Path-like object. Create parent dirs to this path.
Return:
None.
"""
os.makedirs(os.path.abspath(os.path.dirname(path)), exist_ok=True) | [
"def",
"ensure_dir",
"(",
"path",
")",
":",
"os",
".",
"makedirs",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"path",
")",
")",
",",
"exist_ok",
"=",
"True",
")"
] | Create all parent directories of path if they don't exist.
Args:
path. Path-like object. Create parent dirs to this path.
Return:
None. | [
"Create",
"all",
"parent",
"directories",
"of",
"path",
"if",
"they",
"don",
"t",
"exist",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/utils/filesystem.py#L394-L404 |
pypyr/pypyr-cli | pypyr/utils/filesystem.py | get_glob | def get_glob(path):
"""Process the input path, applying globbing and formatting.
Do note that this will returns files AND directories that match the glob.
No tilde expansion is done, but *, ?, and character ranges expressed with
[] will be correctly matched.
Escape all special characters ('?', '*... | python | def get_glob(path):
"""Process the input path, applying globbing and formatting.
Do note that this will returns files AND directories that match the glob.
No tilde expansion is done, but *, ?, and character ranges expressed with
[] will be correctly matched.
Escape all special characters ('?', '*... | [
"def",
"get_glob",
"(",
"path",
")",
":",
"if",
"isinstance",
"(",
"path",
",",
"str",
")",
":",
"return",
"glob",
".",
"glob",
"(",
"path",
",",
"recursive",
"=",
"True",
")",
"if",
"isinstance",
"(",
"path",
",",
"os",
".",
"PathLike",
")",
":",
... | Process the input path, applying globbing and formatting.
Do note that this will returns files AND directories that match the glob.
No tilde expansion is done, but *, ?, and character ranges expressed with
[] will be correctly matched.
Escape all special characters ('?', '*' and '['). For a literal m... | [
"Process",
"the",
"input",
"path",
"applying",
"globbing",
"and",
"formatting",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/utils/filesystem.py#L407-L441 |
pypyr/pypyr-cli | pypyr/utils/filesystem.py | is_same_file | def is_same_file(path1, path2):
"""Return True if path1 is the same file as path2.
The reason for this dance is that samefile throws if either file doesn't
exist.
Args:
path1: str or path-like.
path2: str or path-like.
Returns:
bool. True if the same file, False if not.
... | python | def is_same_file(path1, path2):
"""Return True if path1 is the same file as path2.
The reason for this dance is that samefile throws if either file doesn't
exist.
Args:
path1: str or path-like.
path2: str or path-like.
Returns:
bool. True if the same file, False if not.
... | [
"def",
"is_same_file",
"(",
"path1",
",",
"path2",
")",
":",
"return",
"(",
"path1",
"and",
"path2",
"and",
"os",
".",
"path",
".",
"isfile",
"(",
"path1",
")",
"and",
"os",
".",
"path",
".",
"isfile",
"(",
"path2",
")",
"and",
"os",
".",
"path",
... | Return True if path1 is the same file as path2.
The reason for this dance is that samefile throws if either file doesn't
exist.
Args:
path1: str or path-like.
path2: str or path-like.
Returns:
bool. True if the same file, False if not. | [
"Return",
"True",
"if",
"path1",
"is",
"the",
"same",
"file",
"as",
"path2",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/utils/filesystem.py#L444-L461 |
pypyr/pypyr-cli | pypyr/utils/filesystem.py | move_file | def move_file(src, dest):
"""Move source file to destination.
Overwrites dest.
Args:
src: str or path-like. source file
dest: str or path-like. destination file
Returns:
None.
Raises:
FileNotFoundError: out path parent doesn't exist.
OSError: if any IO ope... | python | def move_file(src, dest):
"""Move source file to destination.
Overwrites dest.
Args:
src: str or path-like. source file
dest: str or path-like. destination file
Returns:
None.
Raises:
FileNotFoundError: out path parent doesn't exist.
OSError: if any IO ope... | [
"def",
"move_file",
"(",
"src",
",",
"dest",
")",
":",
"try",
":",
"os",
".",
"replace",
"(",
"src",
",",
"dest",
")",
"except",
"Exception",
"as",
"ex_replace",
":",
"logger",
".",
"error",
"(",
"f\"error moving file {src} to \"",
"f\"{dest}. {ex_replace}\"",... | Move source file to destination.
Overwrites dest.
Args:
src: str or path-like. source file
dest: str or path-like. destination file
Returns:
None.
Raises:
FileNotFoundError: out path parent doesn't exist.
OSError: if any IO operations go wrong. | [
"Move",
"source",
"file",
"to",
"destination",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/utils/filesystem.py#L464-L486 |
pypyr/pypyr-cli | pypyr/utils/filesystem.py | move_temp_file | def move_temp_file(src, dest):
"""Move src to dest. Delete src if something goes wrong.
Overwrites dest.
Args:
src: str or path-like. source file
dest: str or path-like. destination file
Returns:
None.
Raises:
FileNotFoundError: out path parent doesn't exist.
... | python | def move_temp_file(src, dest):
"""Move src to dest. Delete src if something goes wrong.
Overwrites dest.
Args:
src: str or path-like. source file
dest: str or path-like. destination file
Returns:
None.
Raises:
FileNotFoundError: out path parent doesn't exist.
... | [
"def",
"move_temp_file",
"(",
"src",
",",
"dest",
")",
":",
"try",
":",
"move_file",
"(",
"src",
",",
"dest",
")",
"except",
"Exception",
":",
"try",
":",
"os",
".",
"remove",
"(",
"src",
")",
"except",
"Exception",
"as",
"ex_clean",
":",
"# at this po... | Move src to dest. Delete src if something goes wrong.
Overwrites dest.
Args:
src: str or path-like. source file
dest: str or path-like. destination file
Returns:
None.
Raises:
FileNotFoundError: out path parent doesn't exist.
OSError: if any IO operations go w... | [
"Move",
"src",
"to",
"dest",
".",
"Delete",
"src",
"if",
"something",
"goes",
"wrong",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/utils/filesystem.py#L489-L520 |
pypyr/pypyr-cli | pypyr/utils/filesystem.py | FileRewriter.files_in_to_out | def files_in_to_out(self, in_path, out_path=None):
"""Write in files to out, calling the line_handler on each line.
Calls file_in_to_out under the hood to format the in_path payload. The
formatting processing is done by the self.formatter instance.
Args:
in_path: str, path-... | python | def files_in_to_out(self, in_path, out_path=None):
"""Write in files to out, calling the line_handler on each line.
Calls file_in_to_out under the hood to format the in_path payload. The
formatting processing is done by the self.formatter instance.
Args:
in_path: str, path-... | [
"def",
"files_in_to_out",
"(",
"self",
",",
"in_path",
",",
"out_path",
"=",
"None",
")",
":",
"in_paths",
"=",
"get_glob",
"(",
"in_path",
")",
"in_count",
"=",
"len",
"(",
"in_paths",
")",
"if",
"in_count",
"==",
"0",
":",
"logger",
".",
"debug",
"("... | Write in files to out, calling the line_handler on each line.
Calls file_in_to_out under the hood to format the in_path payload. The
formatting processing is done by the self.formatter instance.
Args:
in_path: str, path-like, or an iterable (list/tuple) of
stri... | [
"Write",
"in",
"files",
"to",
"out",
"calling",
"the",
"line_handler",
"on",
"each",
"line",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/utils/filesystem.py#L56-L156 |
pypyr/pypyr-cli | pypyr/utils/filesystem.py | ObjectRewriter.in_to_out | def in_to_out(self, in_path, out_path=None):
"""Load file into object, formats, writes object to out.
If in_path and out_path point to the same thing it will in-place edit
and overwrite the in path. Even easier, if you do want to edit a file
in place, don't specify out_path, or set it t... | python | def in_to_out(self, in_path, out_path=None):
"""Load file into object, formats, writes object to out.
If in_path and out_path point to the same thing it will in-place edit
and overwrite the in path. Even easier, if you do want to edit a file
in place, don't specify out_path, or set it t... | [
"def",
"in_to_out",
"(",
"self",
",",
"in_path",
",",
"out_path",
"=",
"None",
")",
":",
"if",
"is_same_file",
"(",
"in_path",
",",
"out_path",
")",
":",
"logger",
".",
"debug",
"(",
"\"in path and out path are the same file. writing to temp \"",
"\"file and then re... | Load file into object, formats, writes object to out.
If in_path and out_path point to the same thing it will in-place edit
and overwrite the in path. Even easier, if you do want to edit a file
in place, don't specify out_path, or set it to None.
Args:
in_path: str or path-... | [
"Load",
"file",
"into",
"object",
"formats",
"writes",
"object",
"to",
"out",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/utils/filesystem.py#L188-L233 |
pypyr/pypyr-cli | pypyr/utils/filesystem.py | StreamRewriter.in_to_out | def in_to_out(self, in_path, out_path=None):
"""Write a single file in to out, running self.formatter on each line.
If in_path and out_path point to the same thing it will in-place edit
and overwrite the in path. Even easier, if you do want to edit a file
in place, don't specify out_pat... | python | def in_to_out(self, in_path, out_path=None):
"""Write a single file in to out, running self.formatter on each line.
If in_path and out_path point to the same thing it will in-place edit
and overwrite the in path. Even easier, if you do want to edit a file
in place, don't specify out_pat... | [
"def",
"in_to_out",
"(",
"self",
",",
"in_path",
",",
"out_path",
"=",
"None",
")",
":",
"is_in_place_edit",
"=",
"False",
"if",
"is_same_file",
"(",
"in_path",
",",
"out_path",
")",
":",
"logger",
".",
"debug",
"(",
"\"in path and out path are the same file. wr... | Write a single file in to out, running self.formatter on each line.
If in_path and out_path point to the same thing it will in-place edit
and overwrite the in path. Even easier, if you do want to edit a file
in place, don't specify out_path, or set it to None.
Args:
in_path... | [
"Write",
"a",
"single",
"file",
"in",
"to",
"out",
"running",
"self",
".",
"formatter",
"on",
"each",
"line",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/utils/filesystem.py#L252-L303 |
pypyr/pypyr-cli | pypyr/utils/filesystem.py | JsonRepresenter.dump | def dump(self, file, payload):
"""Dump json oject to open file output.
Writes json with 2 spaces indentation.
Args:
file: Open file-like object. Must be open for writing.
payload: The Json object to write to file.
Returns:
None.
"""
... | python | def dump(self, file, payload):
"""Dump json oject to open file output.
Writes json with 2 spaces indentation.
Args:
file: Open file-like object. Must be open for writing.
payload: The Json object to write to file.
Returns:
None.
"""
... | [
"def",
"dump",
"(",
"self",
",",
"file",
",",
"payload",
")",
":",
"json",
".",
"dump",
"(",
"payload",
",",
"file",
",",
"indent",
"=",
"2",
",",
"ensure_ascii",
"=",
"False",
")"
] | Dump json oject to open file output.
Writes json with 2 spaces indentation.
Args:
file: Open file-like object. Must be open for writing.
payload: The Json object to write to file.
Returns:
None. | [
"Dump",
"json",
"oject",
"to",
"open",
"file",
"output",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/utils/filesystem.py#L341-L354 |
pypyr/pypyr-cli | pypyr/steps/filereplace.py | run_step | def run_step(context):
"""Parse input file and replace a search string.
This also does string substitutions from context on the fileReplacePairs.
It does this before it search & replaces the in file.
Be careful of order. If fileReplacePairs is not an ordered collection,
replacements could evaluate... | python | def run_step(context):
"""Parse input file and replace a search string.
This also does string substitutions from context on the fileReplacePairs.
It does this before it search & replaces the in file.
Be careful of order. If fileReplacePairs is not an ordered collection,
replacements could evaluate... | [
"def",
"run_step",
"(",
"context",
")",
":",
"logger",
".",
"debug",
"(",
"\"started\"",
")",
"deprecated",
"(",
"context",
")",
"StreamReplacePairsRewriterStep",
"(",
"__name__",
",",
"'fileReplace'",
",",
"context",
")",
".",
"run_step",
"(",
")",
"logger",
... | Parse input file and replace a search string.
This also does string substitutions from context on the fileReplacePairs.
It does this before it search & replaces the in file.
Be careful of order. If fileReplacePairs is not an ordered collection,
replacements could evaluate in any given order. If this i... | [
"Parse",
"input",
"file",
"and",
"replace",
"a",
"search",
"string",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/steps/filereplace.py#L9-L56 |
pypyr/pypyr-cli | pypyr/steps/fileformatjson.py | run_step | def run_step(context):
"""Parse input json file and substitute {tokens} from context.
Loads json into memory to do parsing, so be aware of big files.
Args:
context: pypyr.context.Context. Mandatory.
- fileFormatJson
- in. mandatory.
str, pa... | python | def run_step(context):
"""Parse input json file and substitute {tokens} from context.
Loads json into memory to do parsing, so be aware of big files.
Args:
context: pypyr.context.Context. Mandatory.
- fileFormatJson
- in. mandatory.
str, pa... | [
"def",
"run_step",
"(",
"context",
")",
":",
"logger",
".",
"debug",
"(",
"\"started\"",
")",
"deprecated",
"(",
"context",
")",
"ObjectRewriterStep",
"(",
"__name__",
",",
"'fileFormatJson'",
",",
"context",
")",
".",
"run_step",
"(",
"JsonRepresenter",
"(",
... | Parse input json file and substitute {tokens} from context.
Loads json into memory to do parsing, so be aware of big files.
Args:
context: pypyr.context.Context. Mandatory.
- fileFormatJson
- in. mandatory.
str, path-like, or an iterable (list/... | [
"Parse",
"input",
"json",
"file",
"and",
"substitute",
"{",
"tokens",
"}",
"from",
"context",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/steps/fileformatjson.py#L10-L52 |
pypyr/pypyr-cli | pypyr/log/logger.py | set_logging_config | def set_logging_config(log_level, handlers):
"""Set python logging library config.
Run this ONCE at the start of your process. It formats the python logging
module's output.
Defaults logging level to INFO = 20)
"""
logging.basicConfig(
format='%(asctime)s %(levelname)s:%(name)s:%(funcNa... | python | def set_logging_config(log_level, handlers):
"""Set python logging library config.
Run this ONCE at the start of your process. It formats the python logging
module's output.
Defaults logging level to INFO = 20)
"""
logging.basicConfig(
format='%(asctime)s %(levelname)s:%(name)s:%(funcNa... | [
"def",
"set_logging_config",
"(",
"log_level",
",",
"handlers",
")",
":",
"logging",
".",
"basicConfig",
"(",
"format",
"=",
"'%(asctime)s %(levelname)s:%(name)s:%(funcName)s: %(message)s'",
",",
"datefmt",
"=",
"'%Y-%m-%d %H:%M:%S'",
",",
"level",
"=",
"log_level",
","... | Set python logging library config.
Run this ONCE at the start of your process. It formats the python logging
module's output.
Defaults logging level to INFO = 20) | [
"Set",
"python",
"logging",
"library",
"config",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/log/logger.py#L8-L19 |
pypyr/pypyr-cli | pypyr/log/logger.py | set_root_logger | def set_root_logger(root_log_level, log_path=None):
"""Set the root logger 'pypyr'. Do this before you do anything else.
Run once and only once at initialization.
"""
handlers = []
console_handler = logging.StreamHandler()
handlers.append(console_handler)
if log_path:
file_handler ... | python | def set_root_logger(root_log_level, log_path=None):
"""Set the root logger 'pypyr'. Do this before you do anything else.
Run once and only once at initialization.
"""
handlers = []
console_handler = logging.StreamHandler()
handlers.append(console_handler)
if log_path:
file_handler ... | [
"def",
"set_root_logger",
"(",
"root_log_level",
",",
"log_path",
"=",
"None",
")",
":",
"handlers",
"=",
"[",
"]",
"console_handler",
"=",
"logging",
".",
"StreamHandler",
"(",
")",
"handlers",
".",
"append",
"(",
"console_handler",
")",
"if",
"log_path",
"... | Set the root logger 'pypyr'. Do this before you do anything else.
Run once and only once at initialization. | [
"Set",
"the",
"root",
"logger",
"pypyr",
".",
"Do",
"this",
"before",
"you",
"do",
"anything",
"else",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/log/logger.py#L22-L39 |
pypyr/pypyr-cli | pypyr/parser/json.py | get_parsed_context | def get_parsed_context(context_arg):
"""Parse input context string and returns context as dictionary."""
if not context_arg:
logger.debug("pipeline invoked without context arg set. For "
"this json parser you're looking for something "
"like: "
... | python | def get_parsed_context(context_arg):
"""Parse input context string and returns context as dictionary."""
if not context_arg:
logger.debug("pipeline invoked without context arg set. For "
"this json parser you're looking for something "
"like: "
... | [
"def",
"get_parsed_context",
"(",
"context_arg",
")",
":",
"if",
"not",
"context_arg",
":",
"logger",
".",
"debug",
"(",
"\"pipeline invoked without context arg set. For \"",
"\"this json parser you're looking for something \"",
"\"like: \"",
"\"pypyr pipelinename '{\\\"key1\\\":\\... | Parse input context string and returns context as dictionary. | [
"Parse",
"input",
"context",
"string",
"and",
"returns",
"context",
"as",
"dictionary",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/parser/json.py#L10-L22 |
pypyr/pypyr-cli | pypyr/pipelinerunner.py | get_parsed_context | def get_parsed_context(pipeline, context_in_string):
"""Execute get_parsed_context handler if specified.
Dynamically load the module specified by the context_parser key in pipeline
dict and execute the get_parsed_context function on that module.
Args:
pipeline: dict. Pipeline object.
c... | python | def get_parsed_context(pipeline, context_in_string):
"""Execute get_parsed_context handler if specified.
Dynamically load the module specified by the context_parser key in pipeline
dict and execute the get_parsed_context function on that module.
Args:
pipeline: dict. Pipeline object.
c... | [
"def",
"get_parsed_context",
"(",
"pipeline",
",",
"context_in_string",
")",
":",
"logger",
".",
"debug",
"(",
"\"starting\"",
")",
"if",
"'context_parser'",
"in",
"pipeline",
":",
"parser_module_name",
"=",
"pipeline",
"[",
"'context_parser'",
"]",
"logger",
".",... | Execute get_parsed_context handler if specified.
Dynamically load the module specified by the context_parser key in pipeline
dict and execute the get_parsed_context function on that module.
Args:
pipeline: dict. Pipeline object.
context_in_string: string. Argument string used to initialize... | [
"Execute",
"get_parsed_context",
"handler",
"if",
"specified",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/pipelinerunner.py#L17-L65 |
pypyr/pypyr-cli | pypyr/pipelinerunner.py | main | def main(
pipeline_name,
pipeline_context_input,
working_dir,
log_level,
log_path,
):
"""Entry point for pypyr pipeline runner.
Call this once per pypyr run. Call me if you want to run a pypyr pipeline
from your own code. This function does some one-off 1st time initialization
befor... | python | def main(
pipeline_name,
pipeline_context_input,
working_dir,
log_level,
log_path,
):
"""Entry point for pypyr pipeline runner.
Call this once per pypyr run. Call me if you want to run a pypyr pipeline
from your own code. This function does some one-off 1st time initialization
befor... | [
"def",
"main",
"(",
"pipeline_name",
",",
"pipeline_context_input",
",",
"working_dir",
",",
"log_level",
",",
"log_path",
",",
")",
":",
"pypyr",
".",
"log",
".",
"logger",
".",
"set_root_logger",
"(",
"log_level",
",",
"log_path",
")",
"logger",
".",
"debu... | Entry point for pypyr pipeline runner.
Call this once per pypyr run. Call me if you want to run a pypyr pipeline
from your own code. This function does some one-off 1st time initialization
before running the actual pipeline.
pipeline_name.yaml should be in the working_dir/pipelines/ directory.
Ar... | [
"Entry",
"point",
"for",
"pypyr",
"pipeline",
"runner",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/pipelinerunner.py#L68-L108 |
pypyr/pypyr-cli | pypyr/pipelinerunner.py | prepare_context | def prepare_context(pipeline, context_in_string, context):
"""Prepare context for pipeline run.
Args:
pipeline: dict. Dictionary representing the pipeline.
context_in_string: string. Argument string used to initialize context.
context: pypyr.context.Context. Merge any new context genera... | python | def prepare_context(pipeline, context_in_string, context):
"""Prepare context for pipeline run.
Args:
pipeline: dict. Dictionary representing the pipeline.
context_in_string: string. Argument string used to initialize context.
context: pypyr.context.Context. Merge any new context genera... | [
"def",
"prepare_context",
"(",
"pipeline",
",",
"context_in_string",
",",
"context",
")",
":",
"logger",
".",
"debug",
"(",
"\"starting\"",
")",
"parsed_context",
"=",
"get_parsed_context",
"(",
"pipeline",
"=",
"pipeline",
",",
"context_in_string",
"=",
"context_... | Prepare context for pipeline run.
Args:
pipeline: dict. Dictionary representing the pipeline.
context_in_string: string. Argument string used to initialize context.
context: pypyr.context.Context. Merge any new context generated from
context_in_string into this context inst... | [
"Prepare",
"context",
"for",
"pipeline",
"run",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/pipelinerunner.py#L111-L133 |
pypyr/pypyr-cli | pypyr/pipelinerunner.py | load_and_run_pipeline | def load_and_run_pipeline(pipeline_name,
pipeline_context_input=None,
working_dir=None,
context=None,
parse_input=True,
loader=None):
"""Load and run the specified pypyr pipeline.
T... | python | def load_and_run_pipeline(pipeline_name,
pipeline_context_input=None,
working_dir=None,
context=None,
parse_input=True,
loader=None):
"""Load and run the specified pypyr pipeline.
T... | [
"def",
"load_and_run_pipeline",
"(",
"pipeline_name",
",",
"pipeline_context_input",
"=",
"None",
",",
"working_dir",
"=",
"None",
",",
"context",
"=",
"None",
",",
"parse_input",
"=",
"True",
",",
"loader",
"=",
"None",
")",
":",
"logger",
".",
"debug",
"("... | Load and run the specified pypyr pipeline.
This function runs the actual pipeline by name. If you are running another
pipeline from within a pipeline, call this, not main(). Do call main()
instead for your 1st pipeline if there are pipelines calling pipelines.
By default pypyr uses file loader. This m... | [
"Load",
"and",
"run",
"the",
"specified",
"pypyr",
"pipeline",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/pipelinerunner.py#L136-L215 |
pypyr/pypyr-cli | pypyr/pipelinerunner.py | run_pipeline | def run_pipeline(pipeline,
context,
pipeline_context_input=None,
parse_input=True):
"""Run the specified pypyr pipeline.
This function runs the actual pipeline. If you are running another
pipeline from within a pipeline, call this, not main(). Do call main... | python | def run_pipeline(pipeline,
context,
pipeline_context_input=None,
parse_input=True):
"""Run the specified pypyr pipeline.
This function runs the actual pipeline. If you are running another
pipeline from within a pipeline, call this, not main(). Do call main... | [
"def",
"run_pipeline",
"(",
"pipeline",
",",
"context",
",",
"pipeline_context_input",
"=",
"None",
",",
"parse_input",
"=",
"True",
")",
":",
"logger",
".",
"debug",
"(",
"\"starting\"",
")",
"try",
":",
"if",
"parse_input",
":",
"logger",
".",
"debug",
"... | Run the specified pypyr pipeline.
This function runs the actual pipeline. If you are running another
pipeline from within a pipeline, call this, not main(). Do call main()
instead for your 1st pipeline if there are pipelines calling pipelines.
Pipeline and context should be already loaded.
Args:
... | [
"Run",
"the",
"specified",
"pypyr",
"pipeline",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/pipelinerunner.py#L218-L276 |
pypyr/pypyr-cli | pypyr/steps/filewriteyaml.py | run_step | def run_step(context):
"""Write payload out to yaml file.
Args:
context: pypyr.context.Context. Mandatory.
The following context keys expected:
- fileWriteYaml
- path. mandatory. path-like. Write output file to
here. Will create... | python | def run_step(context):
"""Write payload out to yaml file.
Args:
context: pypyr.context.Context. Mandatory.
The following context keys expected:
- fileWriteYaml
- path. mandatory. path-like. Write output file to
here. Will create... | [
"def",
"run_step",
"(",
"context",
")",
":",
"logger",
".",
"debug",
"(",
"\"started\"",
")",
"context",
".",
"assert_child_key_has_value",
"(",
"'fileWriteYaml'",
",",
"'path'",
",",
"__name__",
")",
"out_path",
"=",
"context",
".",
"get_formatted_string",
"(",... | Write payload out to yaml file.
Args:
context: pypyr.context.Context. Mandatory.
The following context keys expected:
- fileWriteYaml
- path. mandatory. path-like. Write output file to
here. Will create directories in path for you.
... | [
"Write",
"payload",
"out",
"to",
"yaml",
"file",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/steps/filewriteyaml.py#L10-L55 |
pypyr/pypyr-cli | pypyr/steps/debug.py | run_step | def run_step(context):
"""Print debug info to console.
context is a dictionary or dictionary-like.
If you use pypyr.steps.debug as a simple step (i.e you do NOT specify the
debug input context), it will just dump the entire context to stdout.
Configure the debug step with the following optional c... | python | def run_step(context):
"""Print debug info to console.
context is a dictionary or dictionary-like.
If you use pypyr.steps.debug as a simple step (i.e you do NOT specify the
debug input context), it will just dump the entire context to stdout.
Configure the debug step with the following optional c... | [
"def",
"run_step",
"(",
"context",
")",
":",
"logger",
".",
"debug",
"(",
"\"started\"",
")",
"debug",
"=",
"context",
".",
"get",
"(",
"'debug'",
",",
"None",
")",
"if",
"debug",
":",
"keys",
"=",
"debug",
".",
"get",
"(",
"'keys'",
",",
"None",
"... | Print debug info to console.
context is a dictionary or dictionary-like.
If you use pypyr.steps.debug as a simple step (i.e you do NOT specify the
debug input context), it will just dump the entire context to stdout.
Configure the debug step with the following optional context item:
debug:
... | [
"Print",
"debug",
"info",
"to",
"console",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/steps/debug.py#L23-L64 |
pypyr/pypyr-cli | pypyr/steps/echo.py | run_step | def run_step(context):
"""Simple echo. Outputs context['echoMe'].
Args:
context: dictionary-like. context is mandatory.
context must contain key 'echoMe'
context['echoMe'] will echo the value to logger.
This logger could well be stdout.
When you e... | python | def run_step(context):
"""Simple echo. Outputs context['echoMe'].
Args:
context: dictionary-like. context is mandatory.
context must contain key 'echoMe'
context['echoMe'] will echo the value to logger.
This logger could well be stdout.
When you e... | [
"def",
"run_step",
"(",
"context",
")",
":",
"logger",
".",
"debug",
"(",
"\"started\"",
")",
"assert",
"context",
",",
"(",
"\"context must be set for echo. Did you set \"",
"\"'echoMe=text here'?\"",
")",
"context",
".",
"assert_key_exists",
"(",
"'echoMe'",
",",
... | Simple echo. Outputs context['echoMe'].
Args:
context: dictionary-like. context is mandatory.
context must contain key 'echoMe'
context['echoMe'] will echo the value to logger.
This logger could well be stdout.
When you execute the pipeline, it should... | [
"Simple",
"echo",
".",
"Outputs",
"context",
"[",
"echoMe",
"]",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/steps/echo.py#L8-L34 |
pypyr/pypyr-cli | pypyr/errors.py | get_error_name | def get_error_name(error):
"""Return canonical error name as string.
For builtin errors like ValueError or Exception, will return the bare
name, like ValueError or Exception.
For all other exceptions, will return modulename.errorname, such as
arbpackage.mod.myerror
Args:
error: Except... | python | def get_error_name(error):
"""Return canonical error name as string.
For builtin errors like ValueError or Exception, will return the bare
name, like ValueError or Exception.
For all other exceptions, will return modulename.errorname, such as
arbpackage.mod.myerror
Args:
error: Except... | [
"def",
"get_error_name",
"(",
"error",
")",
":",
"error_type",
"=",
"type",
"(",
"error",
")",
"if",
"error_type",
".",
"__module__",
"in",
"[",
"'__main__'",
",",
"'builtins'",
"]",
":",
"return",
"error_type",
".",
"__name__",
"else",
":",
"return",
"f'{... | Return canonical error name as string.
For builtin errors like ValueError or Exception, will return the bare
name, like ValueError or Exception.
For all other exceptions, will return modulename.errorname, such as
arbpackage.mod.myerror
Args:
error: Exception object.
Returns:
... | [
"Return",
"canonical",
"error",
"name",
"as",
"string",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/errors.py#L7-L27 |
pypyr/pypyr-cli | pypyr/moduleloader.py | get_module | def get_module(module_abs_import):
"""Use importlib to get the module dynamically.
Get instance of the module specified by the module_abs_import.
This means that module_abs_import must be resolvable from this package.
Args:
module_abs_import: string. Absolute name of module to import.
Rai... | python | def get_module(module_abs_import):
"""Use importlib to get the module dynamically.
Get instance of the module specified by the module_abs_import.
This means that module_abs_import must be resolvable from this package.
Args:
module_abs_import: string. Absolute name of module to import.
Rai... | [
"def",
"get_module",
"(",
"module_abs_import",
")",
":",
"logger",
".",
"debug",
"(",
"\"starting\"",
")",
"logger",
".",
"debug",
"(",
"f\"loading module {module_abs_import}\"",
")",
"try",
":",
"imported_module",
"=",
"importlib",
".",
"import_module",
"(",
"mod... | Use importlib to get the module dynamically.
Get instance of the module specified by the module_abs_import.
This means that module_abs_import must be resolvable from this package.
Args:
module_abs_import: string. Absolute name of module to import.
Raises:
PyModuleNotFoundError: if mod... | [
"Use",
"importlib",
"to",
"get",
"the",
"module",
"dynamically",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/moduleloader.py#L15-L48 |
pypyr/pypyr-cli | pypyr/moduleloader.py | set_working_directory | def set_working_directory(working_directory):
"""Add working_directory to sys.paths.
This allows dynamic loading of arbitrary python modules in cwd.
Args:
working_directory: string. path to add to sys.paths
"""
logger.debug("starting")
logger.debug(f"adding {working_directory} to sys... | python | def set_working_directory(working_directory):
"""Add working_directory to sys.paths.
This allows dynamic loading of arbitrary python modules in cwd.
Args:
working_directory: string. path to add to sys.paths
"""
logger.debug("starting")
logger.debug(f"adding {working_directory} to sys... | [
"def",
"set_working_directory",
"(",
"working_directory",
")",
":",
"logger",
".",
"debug",
"(",
"\"starting\"",
")",
"logger",
".",
"debug",
"(",
"f\"adding {working_directory} to sys.paths\"",
")",
"sys",
".",
"path",
".",
"append",
"(",
"working_directory",
")",
... | Add working_directory to sys.paths.
This allows dynamic loading of arbitrary python modules in cwd.
Args:
working_directory: string. path to add to sys.paths | [
"Add",
"working_directory",
"to",
"sys",
".",
"paths",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/moduleloader.py#L51-L65 |
pypyr/pypyr-cli | pypyr/context.py | Context.assert_child_key_has_value | def assert_child_key_has_value(self, parent, child, caller):
"""Assert that context contains key that has child which has a value.
Args:
parent: parent key
child: validate this sub-key of parent exists AND isn't None.
caller: string. calling function name - this used... | python | def assert_child_key_has_value(self, parent, child, caller):
"""Assert that context contains key that has child which has a value.
Args:
parent: parent key
child: validate this sub-key of parent exists AND isn't None.
caller: string. calling function name - this used... | [
"def",
"assert_child_key_has_value",
"(",
"self",
",",
"parent",
",",
"child",
",",
"caller",
")",
":",
"assert",
"parent",
",",
"(",
"\"parent parameter must be specified.\"",
")",
"assert",
"child",
",",
"(",
"\"child parameter must be specified.\"",
")",
"self",
... | Assert that context contains key that has child which has a value.
Args:
parent: parent key
child: validate this sub-key of parent exists AND isn't None.
caller: string. calling function name - this used to construct
error messages
Raises:
... | [
"Assert",
"that",
"context",
"contains",
"key",
"that",
"has",
"child",
"which",
"has",
"a",
"value",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/context.py#L48-L83 |
pypyr/pypyr-cli | pypyr/context.py | Context.assert_key_has_value | def assert_key_has_value(self, key, caller):
"""Assert that context contains key which also has a value.
Args:
key: validate this key exists in context AND has a value that isn't
None.
caller: string. calling function name - this used to construct
... | python | def assert_key_has_value(self, key, caller):
"""Assert that context contains key which also has a value.
Args:
key: validate this key exists in context AND has a value that isn't
None.
caller: string. calling function name - this used to construct
... | [
"def",
"assert_key_has_value",
"(",
"self",
",",
"key",
",",
"caller",
")",
":",
"assert",
"key",
",",
"(",
"\"key parameter must be specified.\"",
")",
"self",
".",
"assert_key_exists",
"(",
"key",
",",
"caller",
")",
"if",
"self",
"[",
"key",
"]",
"is",
... | Assert that context contains key which also has a value.
Args:
key: validate this key exists in context AND has a value that isn't
None.
caller: string. calling function name - this used to construct
error messages
Raises:
KeyNot... | [
"Assert",
"that",
"context",
"contains",
"key",
"which",
"also",
"has",
"a",
"value",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/context.py#L102-L122 |
pypyr/pypyr-cli | pypyr/context.py | Context.assert_key_type_value | def assert_key_type_value(self,
context_item,
caller,
extra_error_text=''):
"""Assert that keys exist of right type and has a value.
Args:
context_item: ContextItemInfo tuple
caller: stri... | python | def assert_key_type_value(self,
context_item,
caller,
extra_error_text=''):
"""Assert that keys exist of right type and has a value.
Args:
context_item: ContextItemInfo tuple
caller: stri... | [
"def",
"assert_key_type_value",
"(",
"self",
",",
"context_item",
",",
"caller",
",",
"extra_error_text",
"=",
"''",
")",
":",
"assert",
"context_item",
",",
"(",
"\"context_item parameter must be specified.\"",
")",
"if",
"extra_error_text",
"is",
"None",
"or",
"ex... | Assert that keys exist of right type and has a value.
Args:
context_item: ContextItemInfo tuple
caller: string. calling function name - this used to construct
error messages
extra_error_text: append to end of error message.
Raises:
... | [
"Assert",
"that",
"keys",
"exist",
"of",
"right",
"type",
"and",
"has",
"a",
"value",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/context.py#L124-L165 |
pypyr/pypyr-cli | pypyr/context.py | Context.assert_keys_exist | def assert_keys_exist(self, caller, *keys):
"""Assert that context contains keys.
Args:
keys: validates that these keys exists in context
caller: string. calling function or module name - this used to
construct error messages
Raises:
KeyN... | python | def assert_keys_exist(self, caller, *keys):
"""Assert that context contains keys.
Args:
keys: validates that these keys exists in context
caller: string. calling function or module name - this used to
construct error messages
Raises:
KeyN... | [
"def",
"assert_keys_exist",
"(",
"self",
",",
"caller",
",",
"*",
"keys",
")",
":",
"assert",
"keys",
",",
"(",
"\"*keys parameter must be specified.\"",
")",
"for",
"key",
"in",
"keys",
":",
"self",
".",
"assert_key_exists",
"(",
"key",
",",
"caller",
")"
] | Assert that context contains keys.
Args:
keys: validates that these keys exists in context
caller: string. calling function or module name - this used to
construct error messages
Raises:
KeyNotInContextError: When key doesn't exist in context. | [
"Assert",
"that",
"context",
"contains",
"keys",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/context.py#L167-L181 |
pypyr/pypyr-cli | pypyr/context.py | Context.assert_keys_have_values | def assert_keys_have_values(self, caller, *keys):
"""Check that keys list are all in context and all have values.
Args:
*keys: Will check each of these keys in context
caller: string. Calling function name - just used for informational
messages
Raise... | python | def assert_keys_have_values(self, caller, *keys):
"""Check that keys list are all in context and all have values.
Args:
*keys: Will check each of these keys in context
caller: string. Calling function name - just used for informational
messages
Raise... | [
"def",
"assert_keys_have_values",
"(",
"self",
",",
"caller",
",",
"*",
"keys",
")",
":",
"for",
"key",
"in",
"keys",
":",
"self",
".",
"assert_key_has_value",
"(",
"key",
",",
"caller",
")"
] | Check that keys list are all in context and all have values.
Args:
*keys: Will check each of these keys in context
caller: string. Calling function name - just used for informational
messages
Raises:
KeyNotInContextError: Key doesn't exist
... | [
"Check",
"that",
"keys",
"list",
"are",
"all",
"in",
"context",
"and",
"all",
"have",
"values",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/context.py#L183-L198 |
pypyr/pypyr-cli | pypyr/context.py | Context.assert_keys_type_value | def assert_keys_type_value(self,
caller,
extra_error_text,
*context_items):
"""Assert that keys exist of right type and has a value.
Args:
caller: string. calling function name - this used to const... | python | def assert_keys_type_value(self,
caller,
extra_error_text,
*context_items):
"""Assert that keys exist of right type and has a value.
Args:
caller: string. calling function name - this used to const... | [
"def",
"assert_keys_type_value",
"(",
"self",
",",
"caller",
",",
"extra_error_text",
",",
"*",
"context_items",
")",
":",
"assert",
"context_items",
",",
"(",
"\"context_items parameter must be specified.\"",
")",
"for",
"context_item",
"in",
"context_items",
":",
"s... | Assert that keys exist of right type and has a value.
Args:
caller: string. calling function name - this used to construct
error messages
extra_error_text: append to end of error message. This can happily
be None or ''.
*... | [
"Assert",
"that",
"keys",
"exist",
"of",
"right",
"type",
"and",
"has",
"a",
"value",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/context.py#L200-L223 |
pypyr/pypyr-cli | pypyr/context.py | Context.get_formatted | def get_formatted(self, key):
"""Return formatted value for context[key].
If context[key] is a type string, will just format and return the
string.
If context[key] is a special literal type, like a py string or sic
string, will run the formatting implemented by the custom tag
... | python | def get_formatted(self, key):
"""Return formatted value for context[key].
If context[key] is a type string, will just format and return the
string.
If context[key] is a special literal type, like a py string or sic
string, will run the formatting implemented by the custom tag
... | [
"def",
"get_formatted",
"(",
"self",
",",
"key",
")",
":",
"val",
"=",
"self",
"[",
"key",
"]",
"if",
"isinstance",
"(",
"val",
",",
"str",
")",
":",
"try",
":",
"return",
"self",
".",
"get_processed_string",
"(",
"val",
")",
"except",
"KeyNotInContext... | Return formatted value for context[key].
If context[key] is a type string, will just format and return the
string.
If context[key] is a special literal type, like a py string or sic
string, will run the formatting implemented by the custom tag
representer.
If context[key... | [
"Return",
"formatted",
"value",
"for",
"context",
"[",
"key",
"]",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/context.py#L249-L296 |
pypyr/pypyr-cli | pypyr/context.py | Context.get_formatted_iterable | def get_formatted_iterable(self, obj, memo=None):
"""Recursively loop through obj, formatting as it goes.
Interpolates strings from the context dictionary.
This is not a full on deepcopy, and it's on purpose not a full on
deepcopy. It will handle dict, list, set, tuple for iteration, w... | python | def get_formatted_iterable(self, obj, memo=None):
"""Recursively loop through obj, formatting as it goes.
Interpolates strings from the context dictionary.
This is not a full on deepcopy, and it's on purpose not a full on
deepcopy. It will handle dict, list, set, tuple for iteration, w... | [
"def",
"get_formatted_iterable",
"(",
"self",
",",
"obj",
",",
"memo",
"=",
"None",
")",
":",
"if",
"memo",
"is",
"None",
":",
"memo",
"=",
"{",
"}",
"obj_id",
"=",
"id",
"(",
"obj",
")",
"already_done",
"=",
"memo",
".",
"get",
"(",
"obj_id",
",",... | Recursively loop through obj, formatting as it goes.
Interpolates strings from the context dictionary.
This is not a full on deepcopy, and it's on purpose not a full on
deepcopy. It will handle dict, list, set, tuple for iteration, without
any especial cuteness for other types or types... | [
"Recursively",
"loop",
"through",
"obj",
"formatting",
"as",
"it",
"goes",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/context.py#L298-L361 |
pypyr/pypyr-cli | pypyr/context.py | Context.get_formatted_string | def get_formatted_string(self, input_string):
"""Return formatted value for input_string.
get_formatted gets a context[key] value.
get_formatted_string is for any arbitrary string that is not in the
context.
Only valid if input_string is a type string.
Return a string i... | python | def get_formatted_string(self, input_string):
"""Return formatted value for input_string.
get_formatted gets a context[key] value.
get_formatted_string is for any arbitrary string that is not in the
context.
Only valid if input_string is a type string.
Return a string i... | [
"def",
"get_formatted_string",
"(",
"self",
",",
"input_string",
")",
":",
"if",
"isinstance",
"(",
"input_string",
",",
"str",
")",
":",
"try",
":",
"return",
"self",
".",
"get_processed_string",
"(",
"input_string",
")",
"except",
"KeyNotInContextError",
"as",... | Return formatted value for input_string.
get_formatted gets a context[key] value.
get_formatted_string is for any arbitrary string that is not in the
context.
Only valid if input_string is a type string.
Return a string interpolated from the context dictionary.
If inpu... | [
"Return",
"formatted",
"value",
"for",
"input_string",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/context.py#L363-L403 |
pypyr/pypyr-cli | pypyr/context.py | Context.get_formatted_as_type | def get_formatted_as_type(self, value, default=None, out_type=str):
"""Return formatted value for input value, returns as out_type.
Caveat emptor: if out_type is bool and value a string,
return will be True if str is 'True'. It will be False for all other
cases.
Args:
... | python | def get_formatted_as_type(self, value, default=None, out_type=str):
"""Return formatted value for input value, returns as out_type.
Caveat emptor: if out_type is bool and value a string,
return will be True if str is 'True'. It will be False for all other
cases.
Args:
... | [
"def",
"get_formatted_as_type",
"(",
"self",
",",
"value",
",",
"default",
"=",
"None",
",",
"out_type",
"=",
"str",
")",
":",
"if",
"value",
"is",
"None",
":",
"value",
"=",
"default",
"if",
"isinstance",
"(",
"value",
",",
"SpecialTagDirective",
")",
"... | Return formatted value for input value, returns as out_type.
Caveat emptor: if out_type is bool and value a string,
return will be True if str is 'True'. It will be False for all other
cases.
Args:
value: the value to format
default: if value is None, set to thi... | [
"Return",
"formatted",
"value",
"for",
"input",
"value",
"returns",
"as",
"out_type",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/context.py#L405-L441 |
pypyr/pypyr-cli | pypyr/context.py | Context.get_processed_string | def get_processed_string(self, input_string):
"""Run token substitution on input_string against context.
You probably don't want to call this directly yourself - rather use
get_formatted, get_formatted_iterable, or get_formatted_string because
these contain more friendly error handling ... | python | def get_processed_string(self, input_string):
"""Run token substitution on input_string against context.
You probably don't want to call this directly yourself - rather use
get_formatted, get_formatted_iterable, or get_formatted_string because
these contain more friendly error handling ... | [
"def",
"get_processed_string",
"(",
"self",
",",
"input_string",
")",
":",
"# arguably, this doesn't really belong here, or at least it makes a",
"# nonsense of the function name. given how py and strings",
"# look and feel pretty much like strings from user's perspective, and",
"# given legac... | Run token substitution on input_string against context.
You probably don't want to call this directly yourself - rather use
get_formatted, get_formatted_iterable, or get_formatted_string because
these contain more friendly error handling plumbing and context logic.
If you do want to ca... | [
"Run",
"token",
"substitution",
"on",
"input_string",
"against",
"context",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/context.py#L443-L523 |
pypyr/pypyr-cli | pypyr/context.py | Context.keys_of_type_exist | def keys_of_type_exist(self, *keys):
"""Check if keys exist in context and if types are as expected.
Args:
*keys: *args for keys to check in context.
Each arg is a tuple (str, type)
Returns:
Tuple of namedtuple ContextItemInfo, same order as *keys.
... | python | def keys_of_type_exist(self, *keys):
"""Check if keys exist in context and if types are as expected.
Args:
*keys: *args for keys to check in context.
Each arg is a tuple (str, type)
Returns:
Tuple of namedtuple ContextItemInfo, same order as *keys.
... | [
"def",
"keys_of_type_exist",
"(",
"self",
",",
"*",
"keys",
")",
":",
"# k[0] = key name, k[1] = exists, k2 = expected type",
"keys_exist",
"=",
"[",
"(",
"key",
",",
"key",
"in",
"self",
".",
"keys",
"(",
")",
",",
"expected_type",
")",
"for",
"key",
",",
"... | Check if keys exist in context and if types are as expected.
Args:
*keys: *args for keys to check in context.
Each arg is a tuple (str, type)
Returns:
Tuple of namedtuple ContextItemInfo, same order as *keys.
ContextItemInfo(key,
... | [
"Check",
"if",
"keys",
"exist",
"in",
"context",
"and",
"if",
"types",
"are",
"as",
"expected",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/context.py#L560-L593 |
pypyr/pypyr-cli | pypyr/context.py | Context.merge | def merge(self, add_me):
"""Merge add_me into context and applies interpolation.
Bottom-up merge where add_me merges into context. Applies string
interpolation where the type is a string. Where a key exists in
context already, add_me's value will overwrite what's in context
alre... | python | def merge(self, add_me):
"""Merge add_me into context and applies interpolation.
Bottom-up merge where add_me merges into context. Applies string
interpolation where the type is a string. Where a key exists in
context already, add_me's value will overwrite what's in context
alre... | [
"def",
"merge",
"(",
"self",
",",
"add_me",
")",
":",
"def",
"merge_recurse",
"(",
"current",
",",
"add_me",
")",
":",
"\"\"\"Walk the current context tree in recursive inner function.\n\n On 1st iteration, current = self (i.e root of context)\n On subsequent re... | Merge add_me into context and applies interpolation.
Bottom-up merge where add_me merges into context. Applies string
interpolation where the type is a string. Where a key exists in
context already, add_me's value will overwrite what's in context
already.
Supports nested hierar... | [
"Merge",
"add_me",
"into",
"context",
"and",
"applies",
"interpolation",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/context.py#L595-L675 |
pypyr/pypyr-cli | pypyr/context.py | Context.set_defaults | def set_defaults(self, defaults):
"""Set defaults in context if keys do not exist already.
Adds the input dict (defaults) into the context, only where keys in
defaults do not already exist in context. Supports nested hierarchies.
Example:
Given a context like this:
... | python | def set_defaults(self, defaults):
"""Set defaults in context if keys do not exist already.
Adds the input dict (defaults) into the context, only where keys in
defaults do not already exist in context. Supports nested hierarchies.
Example:
Given a context like this:
... | [
"def",
"set_defaults",
"(",
"self",
",",
"defaults",
")",
":",
"def",
"defaults_recurse",
"(",
"current",
",",
"defaults",
")",
":",
"\"\"\"Walk the current context tree in recursive inner function.\n\n On 1st iteration, current = self (i.e root of context)\n On... | Set defaults in context if keys do not exist already.
Adds the input dict (defaults) into the context, only where keys in
defaults do not already exist in context. Supports nested hierarchies.
Example:
Given a context like this:
key1: value1
key2:
... | [
"Set",
"defaults",
"in",
"context",
"if",
"keys",
"do",
"not",
"exist",
"already",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/context.py#L677-L737 |
pypyr/pypyr-cli | pypyr/steps/dsl/fileinoutrewriter.py | FileInRewriterStep.run_step | def run_step(self, rewriter):
"""Do the file in to out rewrite.
Doesn't do anything more crazy than call files_in_to_out on the
rewriter.
Args:
rewriter: pypyr.filesystem.FileRewriter instance.
"""
assert rewriter, ("FileRewriter instance required to run "
... | python | def run_step(self, rewriter):
"""Do the file in to out rewrite.
Doesn't do anything more crazy than call files_in_to_out on the
rewriter.
Args:
rewriter: pypyr.filesystem.FileRewriter instance.
"""
assert rewriter, ("FileRewriter instance required to run "
... | [
"def",
"run_step",
"(",
"self",
",",
"rewriter",
")",
":",
"assert",
"rewriter",
",",
"(",
"\"FileRewriter instance required to run \"",
"\"FileInRewriterStep.\"",
")",
"rewriter",
".",
"files_in_to_out",
"(",
"in_path",
"=",
"self",
".",
"path_in",
",",
"out_path",... | Do the file in to out rewrite.
Doesn't do anything more crazy than call files_in_to_out on the
rewriter.
Args:
rewriter: pypyr.filesystem.FileRewriter instance. | [
"Do",
"the",
"file",
"in",
"to",
"out",
"rewrite",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/steps/dsl/fileinoutrewriter.py#L57-L68 |
pypyr/pypyr-cli | pypyr/steps/dsl/fileinoutrewriter.py | ObjectRewriterStep.run_step | def run_step(self, representer):
"""Do the object in-out rewrite.
Args:
representer: A pypyr.filesystem.ObjectRepresenter instance.
"""
assert representer, ("ObjectRepresenter instance required to run "
"ObjectRewriterStep.")
rewriter = ... | python | def run_step(self, representer):
"""Do the object in-out rewrite.
Args:
representer: A pypyr.filesystem.ObjectRepresenter instance.
"""
assert representer, ("ObjectRepresenter instance required to run "
"ObjectRewriterStep.")
rewriter = ... | [
"def",
"run_step",
"(",
"self",
",",
"representer",
")",
":",
"assert",
"representer",
",",
"(",
"\"ObjectRepresenter instance required to run \"",
"\"ObjectRewriterStep.\"",
")",
"rewriter",
"=",
"ObjectRewriter",
"(",
"self",
".",
"context",
".",
"get_formatted_iterab... | Do the object in-out rewrite.
Args:
representer: A pypyr.filesystem.ObjectRepresenter instance. | [
"Do",
"the",
"object",
"in",
"-",
"out",
"rewrite",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/steps/dsl/fileinoutrewriter.py#L74-L85 |
pypyr/pypyr-cli | pypyr/steps/dsl/fileinoutrewriter.py | StreamRewriterStep.run_step | def run_step(self):
"""Do the file in-out rewrite."""
rewriter = StreamRewriter(self.context.iter_formatted_strings)
super().run_step(rewriter) | python | def run_step(self):
"""Do the file in-out rewrite."""
rewriter = StreamRewriter(self.context.iter_formatted_strings)
super().run_step(rewriter) | [
"def",
"run_step",
"(",
"self",
")",
":",
"rewriter",
"=",
"StreamRewriter",
"(",
"self",
".",
"context",
".",
"iter_formatted_strings",
")",
"super",
"(",
")",
".",
"run_step",
"(",
"rewriter",
")"
] | Do the file in-out rewrite. | [
"Do",
"the",
"file",
"in",
"-",
"out",
"rewrite",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/steps/dsl/fileinoutrewriter.py#L100-L103 |
pypyr/pypyr-cli | pypyr/steps/dsl/fileinoutrewriter.py | StreamReplacePairsRewriterStep.run_step | def run_step(self):
"""Write in to out, replacing strings per the replace_pairs."""
formatted_replacements = self.context.get_formatted_iterable(
self.replace_pairs)
iter = StreamReplacePairsRewriterStep.iter_replace_strings(
formatted_replacements)
rewriter = St... | python | def run_step(self):
"""Write in to out, replacing strings per the replace_pairs."""
formatted_replacements = self.context.get_formatted_iterable(
self.replace_pairs)
iter = StreamReplacePairsRewriterStep.iter_replace_strings(
formatted_replacements)
rewriter = St... | [
"def",
"run_step",
"(",
"self",
")",
":",
"formatted_replacements",
"=",
"self",
".",
"context",
".",
"get_formatted_iterable",
"(",
"self",
".",
"replace_pairs",
")",
"iter",
"=",
"StreamReplacePairsRewriterStep",
".",
"iter_replace_strings",
"(",
"formatted_replacem... | Write in to out, replacing strings per the replace_pairs. | [
"Write",
"in",
"to",
"out",
"replacing",
"strings",
"per",
"the",
"replace_pairs",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/steps/dsl/fileinoutrewriter.py#L133-L141 |
pypyr/pypyr-cli | pypyr/steps/dsl/fileinoutrewriter.py | StreamReplacePairsRewriterStep.iter_replace_strings | def iter_replace_strings(replacements):
"""Create a function that uses replacement pairs to process a string.
The returned function takes an iterator and yields on each processed
line.
Args:
replacements: Dict containing 'find_string': 'replace_string' pairs
Return... | python | def iter_replace_strings(replacements):
"""Create a function that uses replacement pairs to process a string.
The returned function takes an iterator and yields on each processed
line.
Args:
replacements: Dict containing 'find_string': 'replace_string' pairs
Return... | [
"def",
"iter_replace_strings",
"(",
"replacements",
")",
":",
"def",
"function_iter_replace_strings",
"(",
"iterable_strings",
")",
":",
"\"\"\"Yield a formatted string from iterable_strings using a generator.\n\n Args:\n iterable_strings: Iterable containing string... | Create a function that uses replacement pairs to process a string.
The returned function takes an iterator and yields on each processed
line.
Args:
replacements: Dict containing 'find_string': 'replace_string' pairs
Returns:
function with signature: iterator of... | [
"Create",
"a",
"function",
"that",
"uses",
"replacement",
"pairs",
"to",
"process",
"a",
"string",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/steps/dsl/fileinoutrewriter.py#L144-L173 |
pypyr/pypyr-cli | pypyr/steps/contextsetf.py | run_step | def run_step(context):
"""Set new context keys from formatting expressions with substitutions.
Context is a dictionary or dictionary-like.
context['contextSetf'] must exist. It's a dictionary.
Will iterate context['contextSetf'] and save the values as new keys to the
context.
For example, say ... | python | def run_step(context):
"""Set new context keys from formatting expressions with substitutions.
Context is a dictionary or dictionary-like.
context['contextSetf'] must exist. It's a dictionary.
Will iterate context['contextSetf'] and save the values as new keys to the
context.
For example, say ... | [
"def",
"run_step",
"(",
"context",
")",
":",
"logger",
".",
"debug",
"(",
"\"started\"",
")",
"context",
".",
"assert_key_has_value",
"(",
"key",
"=",
"'contextSetf'",
",",
"caller",
"=",
"__name__",
")",
"for",
"k",
",",
"v",
"in",
"context",
"[",
"'con... | Set new context keys from formatting expressions with substitutions.
Context is a dictionary or dictionary-like.
context['contextSetf'] must exist. It's a dictionary.
Will iterate context['contextSetf'] and save the values as new keys to the
context.
For example, say input context is:
key1... | [
"Set",
"new",
"context",
"keys",
"from",
"formatting",
"expressions",
"with",
"substitutions",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/steps/contextsetf.py#L13-L45 |
pypyr/pypyr-cli | pypyr/utils/types.py | cast_to_type | def cast_to_type(obj, out_type):
"""Cast obj to out_type if it's not out_type already.
If the obj happens to be out_type already, it just returns obj as is.
Args:
obj: input object
out_type: type.
Returns:
obj cast to out_type. Usual python conversion / casting rules apply.
... | python | def cast_to_type(obj, out_type):
"""Cast obj to out_type if it's not out_type already.
If the obj happens to be out_type already, it just returns obj as is.
Args:
obj: input object
out_type: type.
Returns:
obj cast to out_type. Usual python conversion / casting rules apply.
... | [
"def",
"cast_to_type",
"(",
"obj",
",",
"out_type",
")",
":",
"in_type",
"=",
"type",
"(",
"obj",
")",
"if",
"out_type",
"is",
"in_type",
":",
"# no need to cast.",
"return",
"obj",
"else",
":",
"return",
"out_type",
"(",
"obj",
")"
] | Cast obj to out_type if it's not out_type already.
If the obj happens to be out_type already, it just returns obj as is.
Args:
obj: input object
out_type: type.
Returns:
obj cast to out_type. Usual python conversion / casting rules apply. | [
"Cast",
"obj",
"to",
"out_type",
"if",
"it",
"s",
"not",
"out_type",
"already",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/utils/types.py#L20-L38 |
pypyr/pypyr-cli | pypyr/yaml.py | get_pipeline_yaml | def get_pipeline_yaml(file):
"""Return pipeline yaml from open file object.
Use specific custom representers to model the custom pypyr pipeline yaml
format, to load in special literal types like py and sic strings.
If looking to extend the pypyr pipeline syntax with special types, add
these to the... | python | def get_pipeline_yaml(file):
"""Return pipeline yaml from open file object.
Use specific custom representers to model the custom pypyr pipeline yaml
format, to load in special literal types like py and sic strings.
If looking to extend the pypyr pipeline syntax with special types, add
these to the... | [
"def",
"get_pipeline_yaml",
"(",
"file",
")",
":",
"tag_representers",
"=",
"[",
"PyString",
",",
"SicString",
"]",
"yaml_loader",
"=",
"get_yaml_parser_safe",
"(",
")",
"for",
"representer",
"in",
"tag_representers",
":",
"yaml_loader",
".",
"register_class",
"("... | Return pipeline yaml from open file object.
Use specific custom representers to model the custom pypyr pipeline yaml
format, to load in special literal types like py and sic strings.
If looking to extend the pypyr pipeline syntax with special types, add
these to the tag_representers list.
Args:
... | [
"Return",
"pipeline",
"yaml",
"from",
"open",
"file",
"object",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/yaml.py#L7-L31 |
pypyr/pypyr-cli | pypyr/yaml.py | get_yaml_parser_roundtrip | def get_yaml_parser_roundtrip():
"""Create the yaml parser object with this factory method.
The round-trip parser preserves:
- comments
- block style and key ordering are kept, so you can diff the round-tripped
source
- flow style sequences ( ‘a: b, c, d’) (based on request and test by
... | python | def get_yaml_parser_roundtrip():
"""Create the yaml parser object with this factory method.
The round-trip parser preserves:
- comments
- block style and key ordering are kept, so you can diff the round-tripped
source
- flow style sequences ( ‘a: b, c, d’) (based on request and test by
... | [
"def",
"get_yaml_parser_roundtrip",
"(",
")",
":",
"yaml_writer",
"=",
"yamler",
".",
"YAML",
"(",
"typ",
"=",
"'rt'",
",",
"pure",
"=",
"True",
")",
"# if this isn't here the yaml doesn't format nicely indented for humans",
"yaml_writer",
".",
"indent",
"(",
"mapping... | Create the yaml parser object with this factory method.
The round-trip parser preserves:
- comments
- block style and key ordering are kept, so you can diff the round-tripped
source
- flow style sequences ( ‘a: b, c, d’) (based on request and test by
Anthony Sottile)
- anchor names that... | [
"Create",
"the",
"yaml",
"parser",
"object",
"with",
"this",
"factory",
"method",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/yaml.py#L46-L65 |
pypyr/pypyr-cli | pypyr/yaml.py | get_yaml_parser_roundtrip_for_context | def get_yaml_parser_roundtrip_for_context():
"""Create a yaml parser that can serialize the pypyr Context.
Create yaml parser with get_yaml_parser_roundtrip, adding Context.
This allows the yaml parser to serialize the pypyr Context.
"""
yaml_writer = get_yaml_parser_roundtrip()
# Context is a... | python | def get_yaml_parser_roundtrip_for_context():
"""Create a yaml parser that can serialize the pypyr Context.
Create yaml parser with get_yaml_parser_roundtrip, adding Context.
This allows the yaml parser to serialize the pypyr Context.
"""
yaml_writer = get_yaml_parser_roundtrip()
# Context is a... | [
"def",
"get_yaml_parser_roundtrip_for_context",
"(",
")",
":",
"yaml_writer",
"=",
"get_yaml_parser_roundtrip",
"(",
")",
"# Context is a dict data structure, so can just use a dict representer",
"yaml_writer",
".",
"Representer",
".",
"add_representer",
"(",
"Context",
",",
"y... | Create a yaml parser that can serialize the pypyr Context.
Create yaml parser with get_yaml_parser_roundtrip, adding Context.
This allows the yaml parser to serialize the pypyr Context. | [
"Create",
"a",
"yaml",
"parser",
"that",
"can",
"serialize",
"the",
"pypyr",
"Context",
"."
] | train | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/yaml.py#L68-L81 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.