repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
Chilipp/docrep
docrep/__init__.py
DocstringProcessor.with_indents
def with_indents(self, s, indent=0, stacklevel=3): """ Substitute a string with the indented :attr:`params` Parameters ---------- s: str The string in which to substitute indent: int The number of spaces that the substitution should be indented ...
python
def with_indents(self, s, indent=0, stacklevel=3): """ Substitute a string with the indented :attr:`params` Parameters ---------- s: str The string in which to substitute indent: int The number of spaces that the substitution should be indented ...
[ "def", "with_indents", "(", "self", ",", "s", ",", "indent", "=", "0", ",", "stacklevel", "=", "3", ")", ":", "# we make a new dictionary with objects that indent the original", "# strings if necessary. Note that the first line is not indented", "d", "=", "{", "key", ":",...
Substitute a string with the indented :attr:`params` Parameters ---------- s: str The string in which to substitute indent: int The number of spaces that the substitution should be indented stacklevel: int The stacklevel for the warning raised...
[ "Substitute", "a", "string", "with", "the", "indented", ":", "attr", ":", "params" ]
train
https://github.com/Chilipp/docrep/blob/637971f76e1a6e1c70e36dcd1b02bbc37ba02487/docrep/__init__.py#L439-L465
Chilipp/docrep
docrep/__init__.py
DocstringProcessor.delete_params
def delete_params(self, base_key, *params): """ Method to delete a parameter from a parameter documentation. This method deletes the given `param` from the `base_key` item in the :attr:`params` dictionary and creates a new item with the original documentation without the descrip...
python
def delete_params(self, base_key, *params): """ Method to delete a parameter from a parameter documentation. This method deletes the given `param` from the `base_key` item in the :attr:`params` dictionary and creates a new item with the original documentation without the descrip...
[ "def", "delete_params", "(", "self", ",", "base_key", ",", "*", "params", ")", ":", "self", ".", "params", "[", "base_key", "+", "'.no_'", "+", "'|'", ".", "join", "(", "params", ")", "]", "=", "self", ".", "delete_params_s", "(", "self", ".", "param...
Method to delete a parameter from a parameter documentation. This method deletes the given `param` from the `base_key` item in the :attr:`params` dictionary and creates a new item with the original documentation without the description of the param. This method works for the ``'Paramete...
[ "Method", "to", "delete", "a", "parameter", "from", "a", "parameter", "documentation", "." ]
train
https://github.com/Chilipp/docrep/blob/637971f76e1a6e1c70e36dcd1b02bbc37ba02487/docrep/__init__.py#L467-L495
Chilipp/docrep
docrep/__init__.py
DocstringProcessor.delete_params_s
def delete_params_s(s, params): """ Delete the given parameters from a string Same as :meth:`delete_params` but does not use the :attr:`params` dictionary Parameters ---------- s: str The string of the parameters section params: list of str ...
python
def delete_params_s(s, params): """ Delete the given parameters from a string Same as :meth:`delete_params` but does not use the :attr:`params` dictionary Parameters ---------- s: str The string of the parameters section params: list of str ...
[ "def", "delete_params_s", "(", "s", ",", "params", ")", ":", "patt", "=", "'(?s)'", "+", "'|'", ".", "join", "(", "'(?<=\\n)'", "+", "s", "+", "'\\s*:.+?\\n(?=\\S+|$)'", "for", "s", "in", "params", ")", "return", "re", ".", "sub", "(", "patt", ",", "...
Delete the given parameters from a string Same as :meth:`delete_params` but does not use the :attr:`params` dictionary Parameters ---------- s: str The string of the parameters section params: list of str The names of the parameters to delete ...
[ "Delete", "the", "given", "parameters", "from", "a", "string" ]
train
https://github.com/Chilipp/docrep/blob/637971f76e1a6e1c70e36dcd1b02bbc37ba02487/docrep/__init__.py#L498-L519
Chilipp/docrep
docrep/__init__.py
DocstringProcessor.delete_kwargs
def delete_kwargs(self, base_key, args=None, kwargs=None): """ Deletes the ``*args`` or ``**kwargs`` part from the parameters section Either `args` or `kwargs` must not be None. The resulting key will be stored in ``base_key + 'no_args'`` if `args` is not None and `...
python
def delete_kwargs(self, base_key, args=None, kwargs=None): """ Deletes the ``*args`` or ``**kwargs`` part from the parameters section Either `args` or `kwargs` must not be None. The resulting key will be stored in ``base_key + 'no_args'`` if `args` is not None and `...
[ "def", "delete_kwargs", "(", "self", ",", "base_key", ",", "args", "=", "None", ",", "kwargs", "=", "None", ")", ":", "if", "not", "args", "and", "not", "kwargs", ":", "warn", "(", "\"Neither args nor kwargs are given. I do nothing for %s\"", "%", "(", "base_k...
Deletes the ``*args`` or ``**kwargs`` part from the parameters section Either `args` or `kwargs` must not be None. The resulting key will be stored in ``base_key + 'no_args'`` if `args` is not None and `kwargs` is None ``base_key + 'no_kwargs'`` if `args` is Non...
[ "Deletes", "the", "*", "args", "or", "**", "kwargs", "part", "from", "the", "parameters", "section" ]
train
https://github.com/Chilipp/docrep/blob/637971f76e1a6e1c70e36dcd1b02bbc37ba02487/docrep/__init__.py#L521-L556
Chilipp/docrep
docrep/__init__.py
DocstringProcessor.delete_kwargs_s
def delete_kwargs_s(cls, s, args=None, kwargs=None): """ Deletes the ``*args`` or ``**kwargs`` part from the parameters section Either `args` or `kwargs` must not be None. Parameters ---------- s: str The string to delete the args and kwargs from arg...
python
def delete_kwargs_s(cls, s, args=None, kwargs=None): """ Deletes the ``*args`` or ``**kwargs`` part from the parameters section Either `args` or `kwargs` must not be None. Parameters ---------- s: str The string to delete the args and kwargs from arg...
[ "def", "delete_kwargs_s", "(", "cls", ",", "s", ",", "args", "=", "None", ",", "kwargs", "=", "None", ")", ":", "if", "not", "args", "and", "not", "kwargs", ":", "return", "s", "types", "=", "[", "]", "if", "args", "is", "not", "None", ":", "type...
Deletes the ``*args`` or ``**kwargs`` part from the parameters section Either `args` or `kwargs` must not be None. Parameters ---------- s: str The string to delete the args and kwargs from args: None or str The string for the args to delete kwar...
[ "Deletes", "the", "*", "args", "or", "**", "kwargs", "part", "from", "the", "parameters", "section" ]
train
https://github.com/Chilipp/docrep/blob/637971f76e1a6e1c70e36dcd1b02bbc37ba02487/docrep/__init__.py#L559-L587
Chilipp/docrep
docrep/__init__.py
DocstringProcessor.delete_types
def delete_types(self, base_key, out_key, *types): """ Method to delete a parameter from a parameter documentation. This method deletes the given `param` from the `base_key` item in the :attr:`params` dictionary and creates a new item with the original documentation without the ...
python
def delete_types(self, base_key, out_key, *types): """ Method to delete a parameter from a parameter documentation. This method deletes the given `param` from the `base_key` item in the :attr:`params` dictionary and creates a new item with the original documentation without the ...
[ "def", "delete_types", "(", "self", ",", "base_key", ",", "out_key", ",", "*", "types", ")", ":", "self", ".", "params", "[", "'%s.%s'", "%", "(", "base_key", ",", "out_key", ")", "]", "=", "self", ".", "delete_types_s", "(", "self", ".", "params", "...
Method to delete a parameter from a parameter documentation. This method deletes the given `param` from the `base_key` item in the :attr:`params` dictionary and creates a new item with the original documentation without the description of the param. This method works for ``'Results'`` l...
[ "Method", "to", "delete", "a", "parameter", "from", "a", "parameter", "documentation", "." ]
train
https://github.com/Chilipp/docrep/blob/637971f76e1a6e1c70e36dcd1b02bbc37ba02487/docrep/__init__.py#L589-L615
Chilipp/docrep
docrep/__init__.py
DocstringProcessor.delete_types_s
def delete_types_s(s, types): """ Delete the given types from a string Same as :meth:`delete_types` but does not use the :attr:`params` dictionary Parameters ---------- s: str The string of the returns like section types: list of str ...
python
def delete_types_s(s, types): """ Delete the given types from a string Same as :meth:`delete_types` but does not use the :attr:`params` dictionary Parameters ---------- s: str The string of the returns like section types: list of str ...
[ "def", "delete_types_s", "(", "s", ",", "types", ")", ":", "patt", "=", "'(?s)'", "+", "'|'", ".", "join", "(", "'(?<=\\n)'", "+", "s", "+", "'\\n.+?\\n(?=\\S+|$)'", "for", "s", "in", "types", ")", "return", "re", ".", "sub", "(", "patt", ",", "''", ...
Delete the given types from a string Same as :meth:`delete_types` but does not use the :attr:`params` dictionary Parameters ---------- s: str The string of the returns like section types: list of str The type identifiers to delete Return...
[ "Delete", "the", "given", "types", "from", "a", "string" ]
train
https://github.com/Chilipp/docrep/blob/637971f76e1a6e1c70e36dcd1b02bbc37ba02487/docrep/__init__.py#L618-L639
Chilipp/docrep
docrep/__init__.py
DocstringProcessor.keep_params
def keep_params(self, base_key, *params): """ Method to keep only specific parameters from a parameter documentation. This method extracts the given `param` from the `base_key` item in the :attr:`params` dictionary and creates a new item with the original documentation with only...
python
def keep_params(self, base_key, *params): """ Method to keep only specific parameters from a parameter documentation. This method extracts the given `param` from the `base_key` item in the :attr:`params` dictionary and creates a new item with the original documentation with only...
[ "def", "keep_params", "(", "self", ",", "base_key", ",", "*", "params", ")", ":", "self", ".", "params", "[", "base_key", "+", "'.'", "+", "'|'", ".", "join", "(", "params", ")", "]", "=", "self", ".", "keep_params_s", "(", "self", ".", "params", "...
Method to keep only specific parameters from a parameter documentation. This method extracts the given `param` from the `base_key` item in the :attr:`params` dictionary and creates a new item with the original documentation with only the description of the param. This method works for `...
[ "Method", "to", "keep", "only", "specific", "parameters", "from", "a", "parameter", "documentation", "." ]
train
https://github.com/Chilipp/docrep/blob/637971f76e1a6e1c70e36dcd1b02bbc37ba02487/docrep/__init__.py#L641-L727
Chilipp/docrep
docrep/__init__.py
DocstringProcessor.keep_params_s
def keep_params_s(s, params): """ Keep the given parameters from a string Same as :meth:`keep_params` but does not use the :attr:`params` dictionary Parameters ---------- s: str The string of the parameters like section params: list of str ...
python
def keep_params_s(s, params): """ Keep the given parameters from a string Same as :meth:`keep_params` but does not use the :attr:`params` dictionary Parameters ---------- s: str The string of the parameters like section params: list of str ...
[ "def", "keep_params_s", "(", "s", ",", "params", ")", ":", "patt", "=", "'(?s)'", "+", "'|'", ".", "join", "(", "'(?<=\\n)'", "+", "s", "+", "'\\s*:.+?\\n(?=\\S+|$)'", "for", "s", "in", "params", ")", "return", "''", ".", "join", "(", "re", ".", "fin...
Keep the given parameters from a string Same as :meth:`keep_params` but does not use the :attr:`params` dictionary Parameters ---------- s: str The string of the parameters like section params: list of str The parameter names to keep Ret...
[ "Keep", "the", "given", "parameters", "from", "a", "string" ]
train
https://github.com/Chilipp/docrep/blob/637971f76e1a6e1c70e36dcd1b02bbc37ba02487/docrep/__init__.py#L730-L751
Chilipp/docrep
docrep/__init__.py
DocstringProcessor.keep_types
def keep_types(self, base_key, out_key, *types): """ Method to keep only specific parameters from a parameter documentation. This method extracts the given `type` from the `base_key` item in the :attr:`params` dictionary and creates a new item with the original documentation wit...
python
def keep_types(self, base_key, out_key, *types): """ Method to keep only specific parameters from a parameter documentation. This method extracts the given `type` from the `base_key` item in the :attr:`params` dictionary and creates a new item with the original documentation wit...
[ "def", "keep_types", "(", "self", ",", "base_key", ",", "out_key", ",", "*", "types", ")", ":", "self", ".", "params", "[", "'%s.%s'", "%", "(", "base_key", ",", "out_key", ")", "]", "=", "self", ".", "keep_types_s", "(", "self", ".", "params", "[", ...
Method to keep only specific parameters from a parameter documentation. This method extracts the given `type` from the `base_key` item in the :attr:`params` dictionary and creates a new item with the original documentation with only the description of the type. This method works for the...
[ "Method", "to", "keep", "only", "specific", "parameters", "from", "a", "parameter", "documentation", "." ]
train
https://github.com/Chilipp/docrep/blob/637971f76e1a6e1c70e36dcd1b02bbc37ba02487/docrep/__init__.py#L753-L833
Chilipp/docrep
docrep/__init__.py
DocstringProcessor.keep_types_s
def keep_types_s(s, types): """ Keep the given types from a string Same as :meth:`keep_types` but does not use the :attr:`params` dictionary Parameters ---------- s: str The string of the returns like section types: list of str Th...
python
def keep_types_s(s, types): """ Keep the given types from a string Same as :meth:`keep_types` but does not use the :attr:`params` dictionary Parameters ---------- s: str The string of the returns like section types: list of str Th...
[ "def", "keep_types_s", "(", "s", ",", "types", ")", ":", "patt", "=", "'|'", ".", "join", "(", "'(?<=\\n)'", "+", "s", "+", "'\\n(?s).+?\\n(?=\\S+|$)'", "for", "s", "in", "types", ")", "return", "''", ".", "join", "(", "re", ".", "findall", "(", "pat...
Keep the given types from a string Same as :meth:`keep_types` but does not use the :attr:`params` dictionary Parameters ---------- s: str The string of the returns like section types: list of str The type identifiers to keep Returns ...
[ "Keep", "the", "given", "types", "from", "a", "string" ]
train
https://github.com/Chilipp/docrep/blob/637971f76e1a6e1c70e36dcd1b02bbc37ba02487/docrep/__init__.py#L836-L856
Chilipp/docrep
docrep/__init__.py
DocstringProcessor.save_docstring
def save_docstring(self, key): """ Descriptor method to save a docstring from a function Like the :meth:`get_sectionsf` method this method serves as a descriptor for functions but saves the entire docstring""" def func(f): self.params[key] = f.__doc__ or '' ...
python
def save_docstring(self, key): """ Descriptor method to save a docstring from a function Like the :meth:`get_sectionsf` method this method serves as a descriptor for functions but saves the entire docstring""" def func(f): self.params[key] = f.__doc__ or '' ...
[ "def", "save_docstring", "(", "self", ",", "key", ")", ":", "def", "func", "(", "f", ")", ":", "self", ".", "params", "[", "key", "]", "=", "f", ".", "__doc__", "or", "''", "return", "f", "return", "func" ]
Descriptor method to save a docstring from a function Like the :meth:`get_sectionsf` method this method serves as a descriptor for functions but saves the entire docstring
[ "Descriptor", "method", "to", "save", "a", "docstring", "from", "a", "function" ]
train
https://github.com/Chilipp/docrep/blob/637971f76e1a6e1c70e36dcd1b02bbc37ba02487/docrep/__init__.py#L858-L867
Chilipp/docrep
docrep/__init__.py
DocstringProcessor.get_summary
def get_summary(self, s, base=None): """ Get the summary of the given docstring This method extracts the summary from the given docstring `s` which is basicly the part until two newlines appear Parameters ---------- s: str The docstring to use ...
python
def get_summary(self, s, base=None): """ Get the summary of the given docstring This method extracts the summary from the given docstring `s` which is basicly the part until two newlines appear Parameters ---------- s: str The docstring to use ...
[ "def", "get_summary", "(", "self", ",", "s", ",", "base", "=", "None", ")", ":", "summary", "=", "summary_patt", ".", "search", "(", "s", ")", ".", "group", "(", ")", "if", "base", "is", "not", "None", ":", "self", ".", "params", "[", "base", "+"...
Get the summary of the given docstring This method extracts the summary from the given docstring `s` which is basicly the part until two newlines appear Parameters ---------- s: str The docstring to use base: str or None A key under which the sum...
[ "Get", "the", "summary", "of", "the", "given", "docstring" ]
train
https://github.com/Chilipp/docrep/blob/637971f76e1a6e1c70e36dcd1b02bbc37ba02487/docrep/__init__.py#L869-L892
Chilipp/docrep
docrep/__init__.py
DocstringProcessor.get_summaryf
def get_summaryf(self, *args, **kwargs): """ Extract the summary from a function docstring Parameters ---------- ``*args`` and ``**kwargs`` See the :meth:`get_summary` method. Note, that the first argument will be the docstring of the specified function ...
python
def get_summaryf(self, *args, **kwargs): """ Extract the summary from a function docstring Parameters ---------- ``*args`` and ``**kwargs`` See the :meth:`get_summary` method. Note, that the first argument will be the docstring of the specified function ...
[ "def", "get_summaryf", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "func", "(", "f", ")", ":", "doc", "=", "f", ".", "__doc__", "self", ".", "get_summary", "(", "doc", "or", "''", ",", "*", "args", ",", "*", "*", ...
Extract the summary from a function docstring Parameters ---------- ``*args`` and ``**kwargs`` See the :meth:`get_summary` method. Note, that the first argument will be the docstring of the specified function Returns ------- function ...
[ "Extract", "the", "summary", "from", "a", "function", "docstring" ]
train
https://github.com/Chilipp/docrep/blob/637971f76e1a6e1c70e36dcd1b02bbc37ba02487/docrep/__init__.py#L894-L913
Chilipp/docrep
docrep/__init__.py
DocstringProcessor.get_extended_summary
def get_extended_summary(self, s, base=None): """Get the extended summary from a docstring This here is the extended summary Parameters ---------- s: str The docstring to use base: str or None A key under which the summary shall be stored in the ...
python
def get_extended_summary(self, s, base=None): """Get the extended summary from a docstring This here is the extended summary Parameters ---------- s: str The docstring to use base: str or None A key under which the summary shall be stored in the ...
[ "def", "get_extended_summary", "(", "self", ",", "s", ",", "base", "=", "None", ")", ":", "# Remove the summary and dedent", "s", "=", "self", ".", "_remove_summary", "(", "s", ")", "ret", "=", "''", "if", "not", "self", ".", "_all_sections_patt", ".", "ma...
Get the extended summary from a docstring This here is the extended summary Parameters ---------- s: str The docstring to use base: str or None A key under which the summary shall be stored in the :attr:`params` attribute. If not None, the su...
[ "Get", "the", "extended", "summary", "from", "a", "docstring" ]
train
https://github.com/Chilipp/docrep/blob/637971f76e1a6e1c70e36dcd1b02bbc37ba02487/docrep/__init__.py#L915-L943
Chilipp/docrep
docrep/__init__.py
DocstringProcessor.get_extended_summaryf
def get_extended_summaryf(self, *args, **kwargs): """Extract the extended summary from a function docstring This function can be used as a decorator to extract the extended summary of a function docstring (similar to :meth:`get_sectionsf`). Parameters ---------- ``*args...
python
def get_extended_summaryf(self, *args, **kwargs): """Extract the extended summary from a function docstring This function can be used as a decorator to extract the extended summary of a function docstring (similar to :meth:`get_sectionsf`). Parameters ---------- ``*args...
[ "def", "get_extended_summaryf", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "func", "(", "f", ")", ":", "doc", "=", "f", ".", "__doc__", "self", ".", "get_extended_summary", "(", "doc", "or", "''", ",", "*", "args", ","...
Extract the extended summary from a function docstring This function can be used as a decorator to extract the extended summary of a function docstring (similar to :meth:`get_sectionsf`). Parameters ---------- ``*args`` and ``**kwargs`` See the :meth:`get_extended_s...
[ "Extract", "the", "extended", "summary", "from", "a", "function", "docstring" ]
train
https://github.com/Chilipp/docrep/blob/637971f76e1a6e1c70e36dcd1b02bbc37ba02487/docrep/__init__.py#L945-L966
Chilipp/docrep
docrep/__init__.py
DocstringProcessor.get_full_description
def get_full_description(self, s, base=None): """Get the full description from a docstring This here and the line above is the full description (i.e. the combination of the :meth:`get_summary` and the :meth:`get_extended_summary`) output Parameters ---------- s:...
python
def get_full_description(self, s, base=None): """Get the full description from a docstring This here and the line above is the full description (i.e. the combination of the :meth:`get_summary` and the :meth:`get_extended_summary`) output Parameters ---------- s:...
[ "def", "get_full_description", "(", "self", ",", "s", ",", "base", "=", "None", ")", ":", "summary", "=", "self", ".", "get_summary", "(", "s", ")", "extended_summary", "=", "self", ".", "get_extended_summary", "(", "s", ")", "ret", "=", "(", "summary", ...
Get the full description from a docstring This here and the line above is the full description (i.e. the combination of the :meth:`get_summary` and the :meth:`get_extended_summary`) output Parameters ---------- s: str The docstring to use base: str o...
[ "Get", "the", "full", "description", "from", "a", "docstring" ]
train
https://github.com/Chilipp/docrep/blob/637971f76e1a6e1c70e36dcd1b02bbc37ba02487/docrep/__init__.py#L968-L994
Chilipp/docrep
docrep/__init__.py
DocstringProcessor.get_full_descriptionf
def get_full_descriptionf(self, *args, **kwargs): """Extract the full description from a function docstring This function can be used as a decorator to extract the full descriptions of a function docstring (similar to :meth:`get_sectionsf`). Parameters ---------- ...
python
def get_full_descriptionf(self, *args, **kwargs): """Extract the full description from a function docstring This function can be used as a decorator to extract the full descriptions of a function docstring (similar to :meth:`get_sectionsf`). Parameters ---------- ...
[ "def", "get_full_descriptionf", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "func", "(", "f", ")", ":", "doc", "=", "f", ".", "__doc__", "self", ".", "get_full_description", "(", "doc", "or", "''", ",", "*", "args", ","...
Extract the full description from a function docstring This function can be used as a decorator to extract the full descriptions of a function docstring (similar to :meth:`get_sectionsf`). Parameters ---------- ``*args`` and ``**kwargs`` See the :meth:`get_f...
[ "Extract", "the", "full", "description", "from", "a", "function", "docstring" ]
train
https://github.com/Chilipp/docrep/blob/637971f76e1a6e1c70e36dcd1b02bbc37ba02487/docrep/__init__.py#L996-L1018
pylover/pymlconf
pymlconf/models.py
Mergable.make_mergable_if_possible
def make_mergable_if_possible(cls, data, context): """ Makes an object mergable if possible. Returns the virgin object if cannot convert it to a mergable instance. :returns: :class:`.Mergable` or type(data) """ if isinstance(data, dict): return MergableDict(...
python
def make_mergable_if_possible(cls, data, context): """ Makes an object mergable if possible. Returns the virgin object if cannot convert it to a mergable instance. :returns: :class:`.Mergable` or type(data) """ if isinstance(data, dict): return MergableDict(...
[ "def", "make_mergable_if_possible", "(", "cls", ",", "data", ",", "context", ")", ":", "if", "isinstance", "(", "data", ",", "dict", ")", ":", "return", "MergableDict", "(", "data", "=", "data", ",", "context", "=", "context", ")", "elif", "isiterable", ...
Makes an object mergable if possible. Returns the virgin object if cannot convert it to a mergable instance. :returns: :class:`.Mergable` or type(data)
[ "Makes", "an", "object", "mergable", "if", "possible", ".", "Returns", "the", "virgin", "object", "if", "cannot", "convert", "it", "to", "a", "mergable", "instance", "." ]
train
https://github.com/pylover/pymlconf/blob/a187dc3924dffc4d9992a369c7964599c6e201c1/pymlconf/models.py#L63-L79
pylover/pymlconf
pymlconf/models.py
Mergable.merge
def merge(self, *args): """ Merges this instance with new instances, in-place. :param \\*args: Configuration values to merge with current instance. :type \\*args: iterable """ for data in args: if isinstance(data, str): to_merge = load_string...
python
def merge(self, *args): """ Merges this instance with new instances, in-place. :param \\*args: Configuration values to merge with current instance. :type \\*args: iterable """ for data in args: if isinstance(data, str): to_merge = load_string...
[ "def", "merge", "(", "self", ",", "*", "args", ")", ":", "for", "data", "in", "args", ":", "if", "isinstance", "(", "data", ",", "str", ")", ":", "to_merge", "=", "load_string", "(", "data", ",", "self", ".", "context", ")", "if", "not", "to_merge"...
Merges this instance with new instances, in-place. :param \\*args: Configuration values to merge with current instance. :type \\*args: iterable
[ "Merges", "this", "instance", "with", "new", "instances", "in", "-", "place", "." ]
train
https://github.com/pylover/pymlconf/blob/a187dc3924dffc4d9992a369c7964599c6e201c1/pymlconf/models.py#L81-L103
pylover/pymlconf
pymlconf/models.py
Root.load_file
def load_file(self, filename): """ load file which contains yaml configuration entries.and merge it by current instance :param files: files to load and merge into existing configuration instance :type files: list """ if not path.exists(file...
python
def load_file(self, filename): """ load file which contains yaml configuration entries.and merge it by current instance :param files: files to load and merge into existing configuration instance :type files: list """ if not path.exists(file...
[ "def", "load_file", "(", "self", ",", "filename", ")", ":", "if", "not", "path", ".", "exists", "(", "filename", ")", ":", "raise", "FileNotFoundError", "(", "filename", ")", "loaded_yaml", "=", "load_yaml", "(", "filename", ",", "self", ".", "context", ...
load file which contains yaml configuration entries.and merge it by current instance :param files: files to load and merge into existing configuration instance :type files: list
[ "load", "file", "which", "contains", "yaml", "configuration", "entries", ".", "and", "merge", "it", "by", "current", "instance" ]
train
https://github.com/pylover/pymlconf/blob/a187dc3924dffc4d9992a369c7964599c6e201c1/pymlconf/models.py#L195-L210
pylover/pymlconf
pymlconf/models.py
DeferredRoot.initialize
def initialize(self, init_value, context=None, force=False): """ Initialize the configuration manager :param force: force initialization even if it's already initialized :return: """ if not force and self._instance is not None: raise ConfigurationAlreadyInit...
python
def initialize(self, init_value, context=None, force=False): """ Initialize the configuration manager :param force: force initialization even if it's already initialized :return: """ if not force and self._instance is not None: raise ConfigurationAlreadyInit...
[ "def", "initialize", "(", "self", ",", "init_value", ",", "context", "=", "None", ",", "force", "=", "False", ")", ":", "if", "not", "force", "and", "self", ".", "_instance", "is", "not", "None", ":", "raise", "ConfigurationAlreadyInitializedError", "(", "...
Initialize the configuration manager :param force: force initialization even if it's already initialized :return:
[ "Initialize", "the", "configuration", "manager" ]
train
https://github.com/pylover/pymlconf/blob/a187dc3924dffc4d9992a369c7964599c6e201c1/pymlconf/models.py#L237-L250
Autodesk/aomi
aomi/template.py
grok_filter_name
def grok_filter_name(element): """Extracts the name, which may be embedded, for a Jinja2 filter node""" e_name = None if element.name == 'default': if isinstance(element.node, jinja2.nodes.Getattr): e_name = element.node.node.name else: e_name = element.node.name ...
python
def grok_filter_name(element): """Extracts the name, which may be embedded, for a Jinja2 filter node""" e_name = None if element.name == 'default': if isinstance(element.node, jinja2.nodes.Getattr): e_name = element.node.node.name else: e_name = element.node.name ...
[ "def", "grok_filter_name", "(", "element", ")", ":", "e_name", "=", "None", "if", "element", ".", "name", "==", "'default'", ":", "if", "isinstance", "(", "element", ".", "node", ",", "jinja2", ".", "nodes", ".", "Getattr", ")", ":", "e_name", "=", "el...
Extracts the name, which may be embedded, for a Jinja2 filter node
[ "Extracts", "the", "name", "which", "may", "be", "embedded", "for", "a", "Jinja2", "filter", "node" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/template.py#L21-L31
Autodesk/aomi
aomi/template.py
grok_for_node
def grok_for_node(element, default_vars): """Properly parses a For loop element""" if isinstance(element.iter, jinja2.nodes.Filter): if element.iter.name == 'default' \ and element.iter.node.name not in default_vars: default_vars.append(element.iter.node.name) default_var...
python
def grok_for_node(element, default_vars): """Properly parses a For loop element""" if isinstance(element.iter, jinja2.nodes.Filter): if element.iter.name == 'default' \ and element.iter.node.name not in default_vars: default_vars.append(element.iter.node.name) default_var...
[ "def", "grok_for_node", "(", "element", ",", "default_vars", ")", ":", "if", "isinstance", "(", "element", ".", "iter", ",", "jinja2", ".", "nodes", ".", "Filter", ")", ":", "if", "element", ".", "iter", ".", "name", "==", "'default'", "and", "element", ...
Properly parses a For loop element
[ "Properly", "parses", "a", "For", "loop", "element" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/template.py#L34-L43
Autodesk/aomi
aomi/template.py
grok_if_node
def grok_if_node(element, default_vars): """Properly parses a If element""" if isinstance(element.test, jinja2.nodes.Filter) and \ element.test.name == 'default': default_vars.append(element.test.node.name) return default_vars + grok_vars(element)
python
def grok_if_node(element, default_vars): """Properly parses a If element""" if isinstance(element.test, jinja2.nodes.Filter) and \ element.test.name == 'default': default_vars.append(element.test.node.name) return default_vars + grok_vars(element)
[ "def", "grok_if_node", "(", "element", ",", "default_vars", ")", ":", "if", "isinstance", "(", "element", ".", "test", ",", "jinja2", ".", "nodes", ".", "Filter", ")", "and", "element", ".", "test", ".", "name", "==", "'default'", ":", "default_vars", "....
Properly parses a If element
[ "Properly", "parses", "a", "If", "element" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/template.py#L46-L52
Autodesk/aomi
aomi/template.py
grok_vars
def grok_vars(elements): """Returns a list of vars for which the value is being appropriately set This currently includes the default filter, for-based iterators, and the explicit use of set""" default_vars = [] iterbody = None if hasattr(elements, 'body'): iterbody = elements.body e...
python
def grok_vars(elements): """Returns a list of vars for which the value is being appropriately set This currently includes the default filter, for-based iterators, and the explicit use of set""" default_vars = [] iterbody = None if hasattr(elements, 'body'): iterbody = elements.body e...
[ "def", "grok_vars", "(", "elements", ")", ":", "default_vars", "=", "[", "]", "iterbody", "=", "None", "if", "hasattr", "(", "elements", ",", "'body'", ")", ":", "iterbody", "=", "elements", ".", "body", "elif", "hasattr", "(", "elements", ",", "'nodes'"...
Returns a list of vars for which the value is being appropriately set This currently includes the default filter, for-based iterators, and the explicit use of set
[ "Returns", "a", "list", "of", "vars", "for", "which", "the", "value", "is", "being", "appropriately", "set", "This", "currently", "includes", "the", "default", "filter", "for", "-", "based", "iterators", "and", "the", "explicit", "use", "of", "set" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/template.py#L55-L83
Autodesk/aomi
aomi/template.py
jinja_env
def jinja_env(template_path): """Sets up our Jinja environment, loading the few filters we have""" fs_loader = FileSystemLoader(os.path.dirname(template_path)) env = Environment(loader=fs_loader, autoescape=True, trim_blocks=True, lstrip_bloc...
python
def jinja_env(template_path): """Sets up our Jinja environment, loading the few filters we have""" fs_loader = FileSystemLoader(os.path.dirname(template_path)) env = Environment(loader=fs_loader, autoescape=True, trim_blocks=True, lstrip_bloc...
[ "def", "jinja_env", "(", "template_path", ")", ":", "fs_loader", "=", "FileSystemLoader", "(", "os", ".", "path", ".", "dirname", "(", "template_path", ")", ")", "env", "=", "Environment", "(", "loader", "=", "fs_loader", ",", "autoescape", "=", "True", ",...
Sets up our Jinja environment, loading the few filters we have
[ "Sets", "up", "our", "Jinja", "environment", "loading", "the", "few", "filters", "we", "have" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/template.py#L86-L95
Autodesk/aomi
aomi/template.py
missing_vars
def missing_vars(template_vars, parsed_content, obj): """If we find missing variables when rendering a template we want to give the user a friendly error""" missing = [] default_vars = grok_vars(parsed_content) for var in template_vars: if var not in default_vars and var not in obj: ...
python
def missing_vars(template_vars, parsed_content, obj): """If we find missing variables when rendering a template we want to give the user a friendly error""" missing = [] default_vars = grok_vars(parsed_content) for var in template_vars: if var not in default_vars and var not in obj: ...
[ "def", "missing_vars", "(", "template_vars", ",", "parsed_content", ",", "obj", ")", ":", "missing", "=", "[", "]", "default_vars", "=", "grok_vars", "(", "parsed_content", ")", "for", "var", "in", "template_vars", ":", "if", "var", "not", "in", "default_var...
If we find missing variables when rendering a template we want to give the user a friendly error
[ "If", "we", "find", "missing", "variables", "when", "rendering", "a", "template", "we", "want", "to", "give", "the", "user", "a", "friendly", "error" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/template.py#L104-L116
Autodesk/aomi
aomi/template.py
render
def render(filename, obj): """Render a template, maybe mixing in extra variables""" template_path = abspath(filename) env = jinja_env(template_path) template_base = os.path.basename(template_path) try: parsed_content = env.parse(env .loader ...
python
def render(filename, obj): """Render a template, maybe mixing in extra variables""" template_path = abspath(filename) env = jinja_env(template_path) template_base = os.path.basename(template_path) try: parsed_content = env.parse(env .loader ...
[ "def", "render", "(", "filename", ",", "obj", ")", ":", "template_path", "=", "abspath", "(", "filename", ")", "env", "=", "jinja_env", "(", "template_path", ")", "template_base", "=", "os", ".", "path", ".", "basename", "(", "template_path", ")", "try", ...
Render a template, maybe mixing in extra variables
[ "Render", "a", "template", "maybe", "mixing", "in", "extra", "variables" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/template.py#L119-L161
Autodesk/aomi
aomi/template.py
load_vars
def load_vars(opt): """Loads variable from cli and var files, passing in cli options as a seed (although they can be overwritten!). Note, turn this into an object so it's a nicer "cache".""" if not hasattr(opt, '_vars_cache'): cli_opts = cli_hash(opt.extra_vars) setattr(opt, '_vars_cache...
python
def load_vars(opt): """Loads variable from cli and var files, passing in cli options as a seed (although they can be overwritten!). Note, turn this into an object so it's a nicer "cache".""" if not hasattr(opt, '_vars_cache'): cli_opts = cli_hash(opt.extra_vars) setattr(opt, '_vars_cache...
[ "def", "load_vars", "(", "opt", ")", ":", "if", "not", "hasattr", "(", "opt", ",", "'_vars_cache'", ")", ":", "cli_opts", "=", "cli_hash", "(", "opt", ".", "extra_vars", ")", "setattr", "(", "opt", ",", "'_vars_cache'", ",", "merge_dicts", "(", "load_var...
Loads variable from cli and var files, passing in cli options as a seed (although they can be overwritten!). Note, turn this into an object so it's a nicer "cache".
[ "Loads", "variable", "from", "cli", "and", "var", "files", "passing", "in", "cli", "options", "as", "a", "seed", "(", "although", "they", "can", "be", "overwritten!", ")", ".", "Note", "turn", "this", "into", "an", "object", "so", "it", "s", "a", "nice...
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/template.py#L164-L173
Autodesk/aomi
aomi/template.py
load_var_files
def load_var_files(opt, p_obj=None): """Load variable files, merge, return contents""" obj = {} if p_obj: obj = p_obj for var_file in opt.extra_vars_file: LOG.debug("loading vars from %s", var_file) obj = merge_dicts(obj.copy(), load_var_file(var_file, obj)) return obj
python
def load_var_files(opt, p_obj=None): """Load variable files, merge, return contents""" obj = {} if p_obj: obj = p_obj for var_file in opt.extra_vars_file: LOG.debug("loading vars from %s", var_file) obj = merge_dicts(obj.copy(), load_var_file(var_file, obj)) return obj
[ "def", "load_var_files", "(", "opt", ",", "p_obj", "=", "None", ")", ":", "obj", "=", "{", "}", "if", "p_obj", ":", "obj", "=", "p_obj", "for", "var_file", "in", "opt", ".", "extra_vars_file", ":", "LOG", ".", "debug", "(", "\"loading vars from %s\"", ...
Load variable files, merge, return contents
[ "Load", "variable", "files", "merge", "return", "contents" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/template.py#L176-L186
Autodesk/aomi
aomi/template.py
load_var_file
def load_var_file(filename, obj): """Loads a varible file, processing it as a template""" rendered = render(filename, obj) ext = os.path.splitext(filename)[1][1:] v_obj = dict() if ext == 'json': v_obj = json.loads(rendered) elif ext == 'yaml' or ext == 'yml': v_obj = yaml.safe_l...
python
def load_var_file(filename, obj): """Loads a varible file, processing it as a template""" rendered = render(filename, obj) ext = os.path.splitext(filename)[1][1:] v_obj = dict() if ext == 'json': v_obj = json.loads(rendered) elif ext == 'yaml' or ext == 'yml': v_obj = yaml.safe_l...
[ "def", "load_var_file", "(", "filename", ",", "obj", ")", ":", "rendered", "=", "render", "(", "filename", ",", "obj", ")", "ext", "=", "os", ".", "path", ".", "splitext", "(", "filename", ")", "[", "1", "]", "[", "1", ":", "]", "v_obj", "=", "di...
Loads a varible file, processing it as a template
[ "Loads", "a", "varible", "file", "processing", "it", "as", "a", "template" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/template.py#L189-L203
Autodesk/aomi
aomi/template.py
load_template_help
def load_template_help(builtin): """Loads the help for a given template""" help_file = "templates/%s-help.yml" % builtin help_file = resource_filename(__name__, help_file) help_obj = {} if os.path.exists(help_file): help_data = yaml.safe_load(open(help_file)) if 'name' in help_data:...
python
def load_template_help(builtin): """Loads the help for a given template""" help_file = "templates/%s-help.yml" % builtin help_file = resource_filename(__name__, help_file) help_obj = {} if os.path.exists(help_file): help_data = yaml.safe_load(open(help_file)) if 'name' in help_data:...
[ "def", "load_template_help", "(", "builtin", ")", ":", "help_file", "=", "\"templates/%s-help.yml\"", "%", "builtin", "help_file", "=", "resource_filename", "(", "__name__", ",", "help_file", ")", "help_obj", "=", "{", "}", "if", "os", ".", "path", ".", "exist...
Loads the help for a given template
[ "Loads", "the", "help", "for", "a", "given", "template" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/template.py#L206-L223
Autodesk/aomi
aomi/template.py
builtin_list
def builtin_list(): """Show a listing of all our builtin templates""" for template in resource_listdir(__name__, "templates"): builtin, ext = os.path.splitext(os.path.basename(abspath(template))) if ext == '.yml': continue help_obj = load_template_help(builtin) if 'n...
python
def builtin_list(): """Show a listing of all our builtin templates""" for template in resource_listdir(__name__, "templates"): builtin, ext = os.path.splitext(os.path.basename(abspath(template))) if ext == '.yml': continue help_obj = load_template_help(builtin) if 'n...
[ "def", "builtin_list", "(", ")", ":", "for", "template", "in", "resource_listdir", "(", "__name__", ",", "\"templates\"", ")", ":", "builtin", ",", "ext", "=", "os", ".", "path", ".", "splitext", "(", "os", ".", "path", ".", "basename", "(", "abspath", ...
Show a listing of all our builtin templates
[ "Show", "a", "listing", "of", "all", "our", "builtin", "templates" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/template.py#L226-L237
Autodesk/aomi
aomi/template.py
builtin_info
def builtin_info(builtin): """Show information on a particular builtin template""" help_obj = load_template_help(builtin) if help_obj.get('name') and help_obj.get('help'): print("The %s template" % (help_obj['name'])) print(help_obj['help']) else: print("No help for %s" % builtin...
python
def builtin_info(builtin): """Show information on a particular builtin template""" help_obj = load_template_help(builtin) if help_obj.get('name') and help_obj.get('help'): print("The %s template" % (help_obj['name'])) print(help_obj['help']) else: print("No help for %s" % builtin...
[ "def", "builtin_info", "(", "builtin", ")", ":", "help_obj", "=", "load_template_help", "(", "builtin", ")", "if", "help_obj", ".", "get", "(", "'name'", ")", "and", "help_obj", ".", "get", "(", "'help'", ")", ":", "print", "(", "\"The %s template\"", "%",...
Show information on a particular builtin template
[ "Show", "information", "on", "a", "particular", "builtin", "template" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/template.py#L240-L251
Autodesk/aomi
aomi/template.py
render_secretfile
def render_secretfile(opt): """Renders and returns the Secretfile construct""" LOG.debug("Using Secretfile %s", opt.secretfile) secretfile_path = abspath(opt.secretfile) obj = load_vars(opt) return render(secretfile_path, obj)
python
def render_secretfile(opt): """Renders and returns the Secretfile construct""" LOG.debug("Using Secretfile %s", opt.secretfile) secretfile_path = abspath(opt.secretfile) obj = load_vars(opt) return render(secretfile_path, obj)
[ "def", "render_secretfile", "(", "opt", ")", ":", "LOG", ".", "debug", "(", "\"Using Secretfile %s\"", ",", "opt", ".", "secretfile", ")", "secretfile_path", "=", "abspath", "(", "opt", ".", "secretfile", ")", "obj", "=", "load_vars", "(", "opt", ")", "ret...
Renders and returns the Secretfile construct
[ "Renders", "and", "returns", "the", "Secretfile", "construct" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/template.py#L259-L264
Autodesk/aomi
aomi/util.py
update_user_password
def update_user_password(client, userpass): """Will update the password for a userpass user""" vault_path = '' user = '' user_path_bits = userpass.split('/') if len(user_path_bits) == 1: user = user_path_bits[0] vault_path = "auth/userpass/users/%s/password" % user LOG.debug(...
python
def update_user_password(client, userpass): """Will update the password for a userpass user""" vault_path = '' user = '' user_path_bits = userpass.split('/') if len(user_path_bits) == 1: user = user_path_bits[0] vault_path = "auth/userpass/users/%s/password" % user LOG.debug(...
[ "def", "update_user_password", "(", "client", ",", "userpass", ")", ":", "vault_path", "=", "''", "user", "=", "''", "user_path_bits", "=", "userpass", ".", "split", "(", "'/'", ")", "if", "len", "(", "user_path_bits", ")", "==", "1", ":", "user", "=", ...
Will update the password for a userpass user
[ "Will", "update", "the", "password", "for", "a", "userpass", "user" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/util.py#L12-L35
Autodesk/aomi
aomi/util.py
update_generic_password
def update_generic_password(client, path): """Will update a single key in a generic secret backend as thought it were a password""" vault_path, key = path_pieces(path) mount = mount_for_path(vault_path, client) if not mount: client.revoke_self_token() raise aomi.exceptions.VaultConst...
python
def update_generic_password(client, path): """Will update a single key in a generic secret backend as thought it were a password""" vault_path, key = path_pieces(path) mount = mount_for_path(vault_path, client) if not mount: client.revoke_self_token() raise aomi.exceptions.VaultConst...
[ "def", "update_generic_password", "(", "client", ",", "path", ")", ":", "vault_path", ",", "key", "=", "path_pieces", "(", "path", ")", "mount", "=", "mount_for_path", "(", "vault_path", ",", "client", ")", "if", "not", "mount", ":", "client", ".", "revoke...
Will update a single key in a generic secret backend as thought it were a password
[ "Will", "update", "a", "single", "key", "in", "a", "generic", "secret", "backend", "as", "thought", "it", "were", "a", "password" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/util.py#L38-L66
Autodesk/aomi
aomi/util.py
password
def password(client, path): """Will attempt to contextually update a password in Vault""" if path.startswith('user:'): update_user_password(client, path[5:]) else: update_generic_password(client, path)
python
def password(client, path): """Will attempt to contextually update a password in Vault""" if path.startswith('user:'): update_user_password(client, path[5:]) else: update_generic_password(client, path)
[ "def", "password", "(", "client", ",", "path", ")", ":", "if", "path", ".", "startswith", "(", "'user:'", ")", ":", "update_user_password", "(", "client", ",", "path", "[", "5", ":", "]", ")", "else", ":", "update_generic_password", "(", "client", ",", ...
Will attempt to contextually update a password in Vault
[ "Will", "attempt", "to", "contextually", "update", "a", "password", "in", "Vault" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/util.py#L69-L74
Autodesk/aomi
aomi/util.py
vault_file
def vault_file(env, default): """The path to a misc Vault file This function will check for the env override on a file path, compute a fully qualified OS appropriate path to the desired file and return it if it exists. Otherwise returns None """ home = os.environ['HOME'] if 'HOME' in os.envi...
python
def vault_file(env, default): """The path to a misc Vault file This function will check for the env override on a file path, compute a fully qualified OS appropriate path to the desired file and return it if it exists. Otherwise returns None """ home = os.environ['HOME'] if 'HOME' in os.envi...
[ "def", "vault_file", "(", "env", ",", "default", ")", ":", "home", "=", "os", ".", "environ", "[", "'HOME'", "]", "if", "'HOME'", "in", "os", ".", "environ", "else", "os", ".", "environ", "[", "'USERPROFILE'", "]", "filename", "=", "os", ".", "enviro...
The path to a misc Vault file This function will check for the env override on a file path, compute a fully qualified OS appropriate path to the desired file and return it if it exists. Otherwise returns None
[ "The", "path", "to", "a", "misc", "Vault", "file", "This", "function", "will", "check", "for", "the", "env", "override", "on", "a", "file", "path", "compute", "a", "fully", "qualified", "OS", "appropriate", "path", "to", "the", "desired", "file", "and", ...
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/util.py#L77-L91
Autodesk/aomi
aomi/util.py
vault_time_to_s
def vault_time_to_s(time_string): """Will convert a time string, as recognized by other Vault tooling, into an integer representation of seconds""" if not time_string or len(time_string) < 2: raise aomi.exceptions \ .AomiData("Invalid timestring %s" % time_string) last_char = ...
python
def vault_time_to_s(time_string): """Will convert a time string, as recognized by other Vault tooling, into an integer representation of seconds""" if not time_string or len(time_string) < 2: raise aomi.exceptions \ .AomiData("Invalid timestring %s" % time_string) last_char = ...
[ "def", "vault_time_to_s", "(", "time_string", ")", ":", "if", "not", "time_string", "or", "len", "(", "time_string", ")", "<", "2", ":", "raise", "aomi", ".", "exceptions", ".", "AomiData", "(", "\"Invalid timestring %s\"", "%", "time_string", ")", "last_char"...
Will convert a time string, as recognized by other Vault tooling, into an integer representation of seconds
[ "Will", "convert", "a", "time", "string", "as", "recognized", "by", "other", "Vault", "tooling", "into", "an", "integer", "representation", "of", "seconds" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/util.py#L109-L130
mpeterv/hererocks
hererocks.py
run
def run(*args, **kwargs): """Execute a command. Command can be passed as several arguments, each being a string or a list of strings; lists are flattened. If opts.verbose is True, output of the command is shown. If the command exits with non-zero, print an error message and exit. If keyward arg...
python
def run(*args, **kwargs): """Execute a command. Command can be passed as several arguments, each being a string or a list of strings; lists are flattened. If opts.verbose is True, output of the command is shown. If the command exits with non-zero, print an error message and exit. If keyward arg...
[ "def", "run", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "capture", "=", "kwargs", ".", "get", "(", "\"get_output\"", ",", "False", ")", "args", "=", "[", "arg", "for", "arglist", "in", "args", "for", "arg", "in", "(", "arglist", "if", ...
Execute a command. Command can be passed as several arguments, each being a string or a list of strings; lists are flattened. If opts.verbose is True, output of the command is shown. If the command exits with non-zero, print an error message and exit. If keyward argument get_output is True, output ...
[ "Execute", "a", "command", "." ]
train
https://github.com/mpeterv/hererocks/blob/c0349eee68c3c9b63e0bd6704ab36217a226d3fc/hererocks.py#L236-L274
sernst/cauldron
cauldron/runner/python_file.py
set_executing
def set_executing(on: bool): """ Toggle whether or not the current thread is executing a step file. This will only apply when the current thread is a CauldronThread. This function has no effect when run on a Main thread. :param on: Whether or not the thread should be annotated as executing ...
python
def set_executing(on: bool): """ Toggle whether or not the current thread is executing a step file. This will only apply when the current thread is a CauldronThread. This function has no effect when run on a Main thread. :param on: Whether or not the thread should be annotated as executing ...
[ "def", "set_executing", "(", "on", ":", "bool", ")", ":", "my_thread", "=", "threading", ".", "current_thread", "(", ")", "if", "isinstance", "(", "my_thread", ",", "threads", ".", "CauldronThread", ")", ":", "my_thread", ".", "is_executing", "=", "on" ]
Toggle whether or not the current thread is executing a step file. This will only apply when the current thread is a CauldronThread. This function has no effect when run on a Main thread. :param on: Whether or not the thread should be annotated as executing a step file.
[ "Toggle", "whether", "or", "not", "the", "current", "thread", "is", "executing", "a", "step", "file", ".", "This", "will", "only", "apply", "when", "the", "current", "thread", "is", "a", "CauldronThread", ".", "This", "function", "has", "no", "effect", "wh...
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/runner/python_file.py#L29-L42
sernst/cauldron
cauldron/runner/python_file.py
get_file_contents
def get_file_contents(source_path: str) -> str: """ Loads the contents of the source into a string for execution using multiple loading methods to handle cross-platform encoding edge cases. If none of the load methods work, a string is returned that contains an error function response that will be d...
python
def get_file_contents(source_path: str) -> str: """ Loads the contents of the source into a string for execution using multiple loading methods to handle cross-platform encoding edge cases. If none of the load methods work, a string is returned that contains an error function response that will be d...
[ "def", "get_file_contents", "(", "source_path", ":", "str", ")", "->", "str", ":", "open_funcs", "=", "[", "functools", ".", "partial", "(", "codecs", ".", "open", ",", "source_path", ",", "encoding", "=", "'utf-8'", ")", ",", "functools", ".", "partial", ...
Loads the contents of the source into a string for execution using multiple loading methods to handle cross-platform encoding edge cases. If none of the load methods work, a string is returned that contains an error function response that will be displayed when the step is run alert the user to the erro...
[ "Loads", "the", "contents", "of", "the", "source", "into", "a", "string", "for", "execution", "using", "multiple", "loading", "methods", "to", "handle", "cross", "-", "platform", "encoding", "edge", "cases", ".", "If", "none", "of", "the", "load", "methods",...
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/runner/python_file.py#L45-L72
sernst/cauldron
cauldron/runner/python_file.py
load_step_file
def load_step_file(source_path: str) -> str: """ Loads the source for a step file at the given path location and then renders it in a template to add additional footer data. The footer is used to force the display to flush the print buffer and breathe the step to open things up for resolution. This...
python
def load_step_file(source_path: str) -> str: """ Loads the source for a step file at the given path location and then renders it in a template to add additional footer data. The footer is used to force the display to flush the print buffer and breathe the step to open things up for resolution. This...
[ "def", "load_step_file", "(", "source_path", ":", "str", ")", "->", "str", ":", "return", "templating", ".", "render_template", "(", "template_name", "=", "'embedded-step.py.txt'", ",", "source_contents", "=", "get_file_contents", "(", "source_path", ")", ")" ]
Loads the source for a step file at the given path location and then renders it in a template to add additional footer data. The footer is used to force the display to flush the print buffer and breathe the step to open things up for resolution. This shouldn't be necessary, but it seems there's an asyn...
[ "Loads", "the", "source", "for", "a", "step", "file", "at", "the", "given", "path", "location", "and", "then", "renders", "it", "in", "a", "template", "to", "add", "additional", "footer", "data", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/runner/python_file.py#L75-L90
sernst/cauldron
cauldron/runner/python_file.py
create_module
def create_module( project: 'projects.Project', step: 'projects.ProjectStep' ): """ Creates an artificial module that will encompass the code execution for the specified step. The target module is populated with the standard dunder attributes like __file__ to simulate the normal way that...
python
def create_module( project: 'projects.Project', step: 'projects.ProjectStep' ): """ Creates an artificial module that will encompass the code execution for the specified step. The target module is populated with the standard dunder attributes like __file__ to simulate the normal way that...
[ "def", "create_module", "(", "project", ":", "'projects.Project'", ",", "step", ":", "'projects.ProjectStep'", ")", ":", "module_name", "=", "step", ".", "definition", ".", "name", ".", "rsplit", "(", "'.'", ",", "1", ")", "[", "0", "]", "target_module", "...
Creates an artificial module that will encompass the code execution for the specified step. The target module is populated with the standard dunder attributes like __file__ to simulate the normal way that Python populates values when loading a module. :param project: The currently open project....
[ "Creates", "an", "artificial", "module", "that", "will", "encompass", "the", "code", "execution", "for", "the", "specified", "step", ".", "The", "target", "module", "is", "populated", "with", "the", "standard", "dunder", "attributes", "like", "__file__", "to", ...
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/runner/python_file.py#L93-L125
sernst/cauldron
cauldron/runner/python_file.py
run
def run( project: 'projects.Project', step: 'projects.ProjectStep', ) -> dict: """ Carries out the execution of the step python source file by loading it into an artificially created module and then executing that module and returning the result. :param project: The currentl...
python
def run( project: 'projects.Project', step: 'projects.ProjectStep', ) -> dict: """ Carries out the execution of the step python source file by loading it into an artificially created module and then executing that module and returning the result. :param project: The currentl...
[ "def", "run", "(", "project", ":", "'projects.Project'", ",", "step", ":", "'projects.ProjectStep'", ",", ")", "->", "dict", ":", "target_module", "=", "create_module", "(", "project", ",", "step", ")", "source_code", "=", "load_step_file", "(", "step", ".", ...
Carries out the execution of the step python source file by loading it into an artificially created module and then executing that module and returning the result. :param project: The currently open project. :param step: The project step for which the run execution will take place. ...
[ "Carries", "out", "the", "execution", "of", "the", "step", "python", "source", "file", "by", "loading", "it", "into", "an", "artificially", "created", "module", "and", "then", "executing", "that", "module", "and", "returning", "the", "result", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/runner/python_file.py#L128-L192
sernst/cauldron
cauldron/runner/python_file.py
render_syntax_error
def render_syntax_error( project: 'projects.Project', error: SyntaxError ) -> dict: """ Renders a SyntaxError, which has a shallow, custom stack trace derived from the data included in the error, instead of the standard stack trace pulled from the exception frames. :param project: ...
python
def render_syntax_error( project: 'projects.Project', error: SyntaxError ) -> dict: """ Renders a SyntaxError, which has a shallow, custom stack trace derived from the data included in the error, instead of the standard stack trace pulled from the exception frames. :param project: ...
[ "def", "render_syntax_error", "(", "project", ":", "'projects.Project'", ",", "error", ":", "SyntaxError", ")", "->", "dict", ":", "return", "render_error", "(", "project", "=", "project", ",", "error", "=", "error", ",", "stack", "=", "[", "dict", "(", "f...
Renders a SyntaxError, which has a shallow, custom stack trace derived from the data included in the error, instead of the standard stack trace pulled from the exception frames. :param project: Currently open project. :param error: The SyntaxError to be rendered to html and text for dis...
[ "Renders", "a", "SyntaxError", "which", "has", "a", "shallow", "custom", "stack", "trace", "derived", "from", "the", "data", "included", "in", "the", "error", "instead", "of", "the", "standard", "stack", "trace", "pulled", "from", "the", "exception", "frames",...
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/runner/python_file.py#L195-L222
sernst/cauldron
cauldron/runner/python_file.py
render_error
def render_error( project: 'projects.Project', error: Exception, stack: typing.List[dict] = None ) -> dict: """ Renders an Exception to an error response that includes rendered text and html error messages for display. :param project: Currently open project. :param e...
python
def render_error( project: 'projects.Project', error: Exception, stack: typing.List[dict] = None ) -> dict: """ Renders an Exception to an error response that includes rendered text and html error messages for display. :param project: Currently open project. :param e...
[ "def", "render_error", "(", "project", ":", "'projects.Project'", ",", "error", ":", "Exception", ",", "stack", ":", "typing", ".", "List", "[", "dict", "]", "=", "None", ")", "->", "dict", ":", "data", "=", "dict", "(", "type", "=", "error", ".", "_...
Renders an Exception to an error response that includes rendered text and html error messages for display. :param project: Currently open project. :param error: The SyntaxError to be rendered to html and text for display. :param stack: Optionally specify a parsed stack. If this ...
[ "Renders", "an", "Exception", "to", "an", "error", "response", "that", "includes", "rendered", "text", "and", "html", "error", "messages", "for", "display", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/runner/python_file.py#L225-L261
sernst/cauldron
cauldron/cli/server/routes/execution.py
execute
def execute(asynchronous: bool = False): """ :param asynchronous: Whether or not to allow asynchronous command execution that returns before the command is complete with a run_uid that can be used to track the continued execution of the command until completion. """ r = Response(...
python
def execute(asynchronous: bool = False): """ :param asynchronous: Whether or not to allow asynchronous command execution that returns before the command is complete with a run_uid that can be used to track the continued execution of the command until completion. """ r = Response(...
[ "def", "execute", "(", "asynchronous", ":", "bool", "=", "False", ")", ":", "r", "=", "Response", "(", ")", "r", ".", "update", "(", "server", "=", "server_runner", ".", "get_server_data", "(", ")", ")", "cmd", ",", "args", "=", "parse_command_args", "...
:param asynchronous: Whether or not to allow asynchronous command execution that returns before the command is complete with a run_uid that can be used to track the continued execution of the command until completion.
[ ":", "param", "asynchronous", ":", "Whether", "or", "not", "to", "allow", "asynchronous", "command", "execution", "that", "returns", "before", "the", "command", "is", "complete", "with", "a", "run_uid", "that", "can", "be", "used", "to", "track", "the", "con...
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/server/routes/execution.py#L101-L164
sernst/cauldron
cauldron/cli/server/routes/execution.py
abort
def abort(): """...""" uid_list = list(server_runner.active_execution_responses.keys()) while len(uid_list) > 0: uid = uid_list.pop() response = server_runner.active_execution_responses.get(uid) if not response: continue try: del server_runner.activ...
python
def abort(): """...""" uid_list = list(server_runner.active_execution_responses.keys()) while len(uid_list) > 0: uid = uid_list.pop() response = server_runner.active_execution_responses.get(uid) if not response: continue try: del server_runner.activ...
[ "def", "abort", "(", ")", ":", "uid_list", "=", "list", "(", "server_runner", ".", "active_execution_responses", ".", "keys", "(", ")", ")", "while", "len", "(", "uid_list", ")", ">", "0", ":", "uid", "=", "uid_list", ".", "pop", "(", ")", "response", ...
...
[ "..." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/server/routes/execution.py#L169-L223
sernst/cauldron
cauldron/cli/commands/configure/actions.py
remove_key
def remove_key(key: str, persists: bool = True): """ Removes the specified key from the cauldron configs if the key exists :param key: The key in the cauldron configs object to remove :param persists: """ environ.configs.remove(key, include_persists=persists) environ.configs.save()...
python
def remove_key(key: str, persists: bool = True): """ Removes the specified key from the cauldron configs if the key exists :param key: The key in the cauldron configs object to remove :param persists: """ environ.configs.remove(key, include_persists=persists) environ.configs.save()...
[ "def", "remove_key", "(", "key", ":", "str", ",", "persists", ":", "bool", "=", "True", ")", ":", "environ", ".", "configs", ".", "remove", "(", "key", ",", "include_persists", "=", "persists", ")", "environ", ".", "configs", ".", "save", "(", ")", "...
Removes the specified key from the cauldron configs if the key exists :param key: The key in the cauldron configs object to remove :param persists:
[ "Removes", "the", "specified", "key", "from", "the", "cauldron", "configs", "if", "the", "key", "exists" ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/commands/configure/actions.py#L6-L20
sernst/cauldron
cauldron/cli/commands/configure/actions.py
set_key
def set_key(key: str, value: typing.List[str], persists: bool = True): """ Removes the specified key from the cauldron configs if the key exists :param key: The key in the cauldron configs object to remove :param value: :param persists: """ if key.endswith('_path') or key.endswith(...
python
def set_key(key: str, value: typing.List[str], persists: bool = True): """ Removes the specified key from the cauldron configs if the key exists :param key: The key in the cauldron configs object to remove :param value: :param persists: """ if key.endswith('_path') or key.endswith(...
[ "def", "set_key", "(", "key", ":", "str", ",", "value", ":", "typing", ".", "List", "[", "str", "]", ",", "persists", ":", "bool", "=", "True", ")", ":", "if", "key", ".", "endswith", "(", "'_path'", ")", "or", "key", ".", "endswith", "(", "'_pat...
Removes the specified key from the cauldron configs if the key exists :param key: The key in the cauldron configs object to remove :param value: :param persists:
[ "Removes", "the", "specified", "key", "from", "the", "cauldron", "configs", "if", "the", "key", "exists" ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/commands/configure/actions.py#L23-L42
sernst/cauldron
cauldron/environ/configuration.py
Configuration.save
def save(self) -> 'Configuration': """ Saves the configuration settings object to the current user's home directory :return: """ data = self.load().persistent if data is None: return self directory = os.path.dirname(self._source_path) ...
python
def save(self) -> 'Configuration': """ Saves the configuration settings object to the current user's home directory :return: """ data = self.load().persistent if data is None: return self directory = os.path.dirname(self._source_path) ...
[ "def", "save", "(", "self", ")", "->", "'Configuration'", ":", "data", "=", "self", ".", "load", "(", ")", ".", "persistent", "if", "data", "is", "None", ":", "return", "self", "directory", "=", "os", ".", "path", ".", "dirname", "(", "self", ".", ...
Saves the configuration settings object to the current user's home directory :return:
[ "Saves", "the", "configuration", "settings", "object", "to", "the", "current", "user", "s", "home", "directory" ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/environ/configuration.py#L143-L163
WimpyAnalytics/django-andablog
demo/democomments/models.py
DemoComment._get_userinfo
def _get_userinfo(self): """ Get a dictionary that pulls together information about the poster safely for both authenticated and non-authenticated comments. This dict will have ``name``, ``email``, and ``url`` fields. """ if not hasattr(self, "_userinfo"): us...
python
def _get_userinfo(self): """ Get a dictionary that pulls together information about the poster safely for both authenticated and non-authenticated comments. This dict will have ``name``, ``email``, and ``url`` fields. """ if not hasattr(self, "_userinfo"): us...
[ "def", "_get_userinfo", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "\"_userinfo\"", ")", ":", "userinfo", "=", "{", "\"name\"", ":", "self", ".", "user_name", ",", "\"email\"", ":", "self", ".", "user_email", ",", "\"url\"", ":", ...
Get a dictionary that pulls together information about the poster safely for both authenticated and non-authenticated comments. This dict will have ``name``, ``email``, and ``url`` fields.
[ "Get", "a", "dictionary", "that", "pulls", "together", "information", "about", "the", "poster", "safely", "for", "both", "authenticated", "and", "non", "-", "authenticated", "comments", "." ]
train
https://github.com/WimpyAnalytics/django-andablog/blob/9175144140d220e4ce8212d0da6abc8c9ba9816a/demo/democomments/models.py#L65-L91
WimpyAnalytics/django-andablog
demo/democomments/models.py
DemoComment.get_as_text
def get_as_text(self): """ Return this comment as plain text. Useful for emails. """ d = { 'user': self.user or self.name, 'date': self.submit_date, 'comment': self.comment, 'domain': self.site.domain, 'url': self.get_absolute_...
python
def get_as_text(self): """ Return this comment as plain text. Useful for emails. """ d = { 'user': self.user or self.name, 'date': self.submit_date, 'comment': self.comment, 'domain': self.site.domain, 'url': self.get_absolute_...
[ "def", "get_as_text", "(", "self", ")", ":", "d", "=", "{", "'user'", ":", "self", ".", "user", "or", "self", ".", "name", ",", "'date'", ":", "self", ".", "submit_date", ",", "'comment'", ":", "self", ".", "comment", ",", "'domain'", ":", "self", ...
Return this comment as plain text. Useful for emails.
[ "Return", "this", "comment", "as", "plain", "text", ".", "Useful", "for", "emails", "." ]
train
https://github.com/WimpyAnalytics/django-andablog/blob/9175144140d220e4ce8212d0da6abc8c9ba9816a/demo/democomments/models.py#L128-L139
sernst/cauldron
cauldron/session/writing/file_io.py
entry_from_dict
def entry_from_dict( data: dict ) -> typing.Union[FILE_WRITE_ENTRY, FILE_COPY_ENTRY]: """ Converts the given data dictionary into either a file write or file copy entry depending on the keys in the dictionary. The dictionary should contain either ('path', 'contents') keys for file write entries ...
python
def entry_from_dict( data: dict ) -> typing.Union[FILE_WRITE_ENTRY, FILE_COPY_ENTRY]: """ Converts the given data dictionary into either a file write or file copy entry depending on the keys in the dictionary. The dictionary should contain either ('path', 'contents') keys for file write entries ...
[ "def", "entry_from_dict", "(", "data", ":", "dict", ")", "->", "typing", ".", "Union", "[", "FILE_WRITE_ENTRY", ",", "FILE_COPY_ENTRY", "]", ":", "if", "'contents'", "in", "data", ":", "return", "FILE_WRITE_ENTRY", "(", "*", "*", "data", ")", "return", "FI...
Converts the given data dictionary into either a file write or file copy entry depending on the keys in the dictionary. The dictionary should contain either ('path', 'contents') keys for file write entries or ('source', 'destination') keys for file copy entries.
[ "Converts", "the", "given", "data", "dictionary", "into", "either", "a", "file", "write", "or", "file", "copy", "entry", "depending", "on", "the", "keys", "in", "the", "dictionary", ".", "The", "dictionary", "should", "contain", "either", "(", "path", "conte...
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/writing/file_io.py#L14-L25
sernst/cauldron
cauldron/session/writing/file_io.py
deploy
def deploy(files_list: typing.List[tuple]): """ Iterates through the specified files_list and copies or writes each entry depending on whether its a file copy entry or a file write entry. :param files_list: A list of file write entries and file copy entries """ def deploy_entry(entry): ...
python
def deploy(files_list: typing.List[tuple]): """ Iterates through the specified files_list and copies or writes each entry depending on whether its a file copy entry or a file write entry. :param files_list: A list of file write entries and file copy entries """ def deploy_entry(entry): ...
[ "def", "deploy", "(", "files_list", ":", "typing", ".", "List", "[", "tuple", "]", ")", ":", "def", "deploy_entry", "(", "entry", ")", ":", "if", "not", "entry", ":", "return", "if", "hasattr", "(", "entry", ",", "'source'", ")", "and", "hasattr", "(...
Iterates through the specified files_list and copies or writes each entry depending on whether its a file copy entry or a file write entry. :param files_list: A list of file write entries and file copy entries
[ "Iterates", "through", "the", "specified", "files_list", "and", "copies", "or", "writes", "each", "entry", "depending", "on", "whether", "its", "a", "file", "copy", "entry", "or", "a", "file", "write", "entry", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/writing/file_io.py#L28-L48
sernst/cauldron
cauldron/session/writing/file_io.py
make_output_directory
def make_output_directory(output_path: str) -> str: """ Creates the parent directory or directories for the specified output path if they do not already exist to prevent incomplete directory path errors during copying/writing operations. :param output_path: The path of the destination file ...
python
def make_output_directory(output_path: str) -> str: """ Creates the parent directory or directories for the specified output path if they do not already exist to prevent incomplete directory path errors during copying/writing operations. :param output_path: The path of the destination file ...
[ "def", "make_output_directory", "(", "output_path", ":", "str", ")", "->", "str", ":", "output_directory", "=", "os", ".", "path", ".", "dirname", "(", "environ", ".", "paths", ".", "clean", "(", "output_path", ")", ")", "if", "not", "os", ".", "path", ...
Creates the parent directory or directories for the specified output path if they do not already exist to prevent incomplete directory path errors during copying/writing operations. :param output_path: The path of the destination file or directory that will be written. :return: The abso...
[ "Creates", "the", "parent", "directory", "or", "directories", "for", "the", "specified", "output", "path", "if", "they", "do", "not", "already", "exist", "to", "prevent", "incomplete", "directory", "path", "errors", "during", "copying", "/", "writing", "operatio...
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/writing/file_io.py#L51-L69
sernst/cauldron
cauldron/session/writing/file_io.py
copy
def copy(copy_entry: FILE_COPY_ENTRY): """ Copies the specified file from its source location to its destination location. """ source_path = environ.paths.clean(copy_entry.source) output_path = environ.paths.clean(copy_entry.destination) copier = shutil.copy2 if os.path.isfile(source_path) e...
python
def copy(copy_entry: FILE_COPY_ENTRY): """ Copies the specified file from its source location to its destination location. """ source_path = environ.paths.clean(copy_entry.source) output_path = environ.paths.clean(copy_entry.destination) copier = shutil.copy2 if os.path.isfile(source_path) e...
[ "def", "copy", "(", "copy_entry", ":", "FILE_COPY_ENTRY", ")", ":", "source_path", "=", "environ", ".", "paths", ".", "clean", "(", "copy_entry", ".", "source", ")", "output_path", "=", "environ", ".", "paths", ".", "clean", "(", "copy_entry", ".", "destin...
Copies the specified file from its source location to its destination location.
[ "Copies", "the", "specified", "file", "from", "its", "source", "location", "to", "its", "destination", "location", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/writing/file_io.py#L72-L92
sernst/cauldron
cauldron/session/writing/file_io.py
write
def write(write_entry: FILE_WRITE_ENTRY): """ Writes the contents of the specified file entry to its destination path. """ output_path = environ.paths.clean(write_entry.path) make_output_directory(output_path) writer.write_file(output_path, write_entry.contents)
python
def write(write_entry: FILE_WRITE_ENTRY): """ Writes the contents of the specified file entry to its destination path. """ output_path = environ.paths.clean(write_entry.path) make_output_directory(output_path) writer.write_file(output_path, write_entry.contents)
[ "def", "write", "(", "write_entry", ":", "FILE_WRITE_ENTRY", ")", ":", "output_path", "=", "environ", ".", "paths", ".", "clean", "(", "write_entry", ".", "path", ")", "make_output_directory", "(", "output_path", ")", "writer", ".", "write_file", "(", "output_...
Writes the contents of the specified file entry to its destination path.
[ "Writes", "the", "contents", "of", "the", "specified", "file", "entry", "to", "its", "destination", "path", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/writing/file_io.py#L95-L101
sernst/cauldron
cauldron/runner/redirection.py
enable
def enable(step: 'projects.ProjectStep'): """ Create a print equivalent function that also writes the output to the project page. The write_through is enabled so that the TextIOWrapper immediately writes all of its input data directly to the underlying BytesIO buffer. This is needed so that we can s...
python
def enable(step: 'projects.ProjectStep'): """ Create a print equivalent function that also writes the output to the project page. The write_through is enabled so that the TextIOWrapper immediately writes all of its input data directly to the underlying BytesIO buffer. This is needed so that we can s...
[ "def", "enable", "(", "step", ":", "'projects.ProjectStep'", ")", ":", "# Prevent anything unusual from causing buffer issues", "restore_default_configuration", "(", ")", "stdout_interceptor", "=", "RedirectBuffer", "(", "sys", ".", "stdout", ")", "sys", ".", "stdout", ...
Create a print equivalent function that also writes the output to the project page. The write_through is enabled so that the TextIOWrapper immediately writes all of its input data directly to the underlying BytesIO buffer. This is needed so that we can safely access the buffer data in a multi-threaded e...
[ "Create", "a", "print", "equivalent", "function", "that", "also", "writes", "the", "output", "to", "the", "project", "page", ".", "The", "write_through", "is", "enabled", "so", "that", "the", "TextIOWrapper", "immediately", "writes", "all", "of", "its", "input...
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/runner/redirection.py#L6-L30
sernst/cauldron
cauldron/runner/redirection.py
restore_default_configuration
def restore_default_configuration(): """ Restores the sys.stdout and the sys.stderr buffer streams to their default values without regard to what step has currently overridden their values. This is useful during cleanup outside of the running execution block """ def restore(target, default_valu...
python
def restore_default_configuration(): """ Restores the sys.stdout and the sys.stderr buffer streams to their default values without regard to what step has currently overridden their values. This is useful during cleanup outside of the running execution block """ def restore(target, default_valu...
[ "def", "restore_default_configuration", "(", ")", ":", "def", "restore", "(", "target", ",", "default_value", ")", ":", "if", "target", "==", "default_value", ":", "return", "default_value", "if", "not", "isinstance", "(", "target", ",", "RedirectBuffer", ")", ...
Restores the sys.stdout and the sys.stderr buffer streams to their default values without regard to what step has currently overridden their values. This is useful during cleanup outside of the running execution block
[ "Restores", "the", "sys", ".", "stdout", "and", "the", "sys", ".", "stderr", "buffer", "streams", "to", "their", "default", "values", "without", "regard", "to", "what", "step", "has", "currently", "overridden", "their", "values", ".", "This", "is", "useful",...
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/runner/redirection.py#L33-L56
sernst/cauldron
cauldron/session/writing/html.py
create
def create( project: 'projects.Project', destination_directory, destination_filename: str = None ) -> file_io.FILE_WRITE_ENTRY: """ Creates a FILE_WRITE_ENTRY for the rendered HTML file for the given project that will be saved in the destination directory with the given filename....
python
def create( project: 'projects.Project', destination_directory, destination_filename: str = None ) -> file_io.FILE_WRITE_ENTRY: """ Creates a FILE_WRITE_ENTRY for the rendered HTML file for the given project that will be saved in the destination directory with the given filename....
[ "def", "create", "(", "project", ":", "'projects.Project'", ",", "destination_directory", ",", "destination_filename", ":", "str", "=", "None", ")", "->", "file_io", ".", "FILE_WRITE_ENTRY", ":", "template_path", "=", "environ", ".", "paths", ".", "resources", "...
Creates a FILE_WRITE_ENTRY for the rendered HTML file for the given project that will be saved in the destination directory with the given filename. :param project: The project for which the rendered HTML file will be created :param destination_directory: The absolute path to the folder...
[ "Creates", "a", "FILE_WRITE_ENTRY", "for", "the", "rendered", "HTML", "file", "for", "the", "given", "project", "that", "will", "be", "saved", "in", "the", "destination", "directory", "with", "the", "given", "filename", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/writing/html.py#L9-L54
sernst/cauldron
launcher.py
run_container
def run_container(): """Runs an interactive container""" os.chdir(my_directory) cmd = [ 'docker', 'run', '-it', '--rm', '-v', '{}:/cauldron'.format(my_directory), '-p', '5010:5010', 'cauldron_app', '/bin/bash' ] return os.system(' '.join(cmd))
python
def run_container(): """Runs an interactive container""" os.chdir(my_directory) cmd = [ 'docker', 'run', '-it', '--rm', '-v', '{}:/cauldron'.format(my_directory), '-p', '5010:5010', 'cauldron_app', '/bin/bash' ] return os.system(' '.join(cmd))
[ "def", "run_container", "(", ")", ":", "os", ".", "chdir", "(", "my_directory", ")", "cmd", "=", "[", "'docker'", ",", "'run'", ",", "'-it'", ",", "'--rm'", ",", "'-v'", ",", "'{}:/cauldron'", ".", "format", "(", "my_directory", ")", ",", "'-p'", ",", ...
Runs an interactive container
[ "Runs", "an", "interactive", "container" ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/launcher.py#L24-L38
sernst/cauldron
launcher.py
run
def run(): """Execute the Cauldron container command""" command = sys.argv[1].strip().lower() print('[COMMAND]:', command) if command == 'test': return run_test() elif command == 'build': return run_build() elif command == 'up': return run_container() elif command =...
python
def run(): """Execute the Cauldron container command""" command = sys.argv[1].strip().lower() print('[COMMAND]:', command) if command == 'test': return run_test() elif command == 'build': return run_build() elif command == 'up': return run_container() elif command =...
[ "def", "run", "(", ")", ":", "command", "=", "sys", ".", "argv", "[", "1", "]", ".", "strip", "(", ")", ".", "lower", "(", ")", "print", "(", "'[COMMAND]:'", ",", "command", ")", "if", "command", "==", "'test'", ":", "return", "run_test", "(", ")...
Execute the Cauldron container command
[ "Execute", "the", "Cauldron", "container", "command" ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/launcher.py#L56-L70
sernst/cauldron
cauldron/cli/server/authorization.py
gatekeeper
def gatekeeper(func): """ This function is used to handle authorization code authentication of protected endpoints. This form of authentication is not recommended because it's not very secure, but can be used in places where SSH tunneling or similar strong connection security is not possible. ...
python
def gatekeeper(func): """ This function is used to handle authorization code authentication of protected endpoints. This form of authentication is not recommended because it's not very secure, but can be used in places where SSH tunneling or similar strong connection security is not possible. ...
[ "def", "gatekeeper", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "check_identity", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "code", "=", "server_runner", ".", "authorization", "[", "'code'", "]", "comparison", "=", "reques...
This function is used to handle authorization code authentication of protected endpoints. This form of authentication is not recommended because it's not very secure, but can be used in places where SSH tunneling or similar strong connection security is not possible. The function looks for a spe...
[ "This", "function", "is", "used", "to", "handle", "authorization", "code", "authentication", "of", "protected", "endpoints", ".", "This", "form", "of", "authentication", "is", "not", "recommended", "because", "it", "s", "not", "very", "secure", "but", "can", "...
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/server/authorization.py#L14-L38
sernst/cauldron
cauldron/session/display/__init__.py
inspect
def inspect(source: dict): """ Inspects the data and structure of the source dictionary object and adds the results to the display for viewing. :param source: A dictionary object to be inspected. :return: """ r = _get_report() r.append_body(render.inspect(source))
python
def inspect(source: dict): """ Inspects the data and structure of the source dictionary object and adds the results to the display for viewing. :param source: A dictionary object to be inspected. :return: """ r = _get_report() r.append_body(render.inspect(source))
[ "def", "inspect", "(", "source", ":", "dict", ")", ":", "r", "=", "_get_report", "(", ")", "r", ".", "append_body", "(", "render", ".", "inspect", "(", "source", ")", ")" ]
Inspects the data and structure of the source dictionary object and adds the results to the display for viewing. :param source: A dictionary object to be inspected. :return:
[ "Inspects", "the", "data", "and", "structure", "of", "the", "source", "dictionary", "object", "and", "adds", "the", "results", "to", "the", "display", "for", "viewing", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/display/__init__.py#L20-L30
sernst/cauldron
cauldron/session/display/__init__.py
header
def header(header_text: str, level: int = 1, expand_full: bool = False): """ Adds a text header to the display with the specified level. :param header_text: The text to display in the header. :param level: The level of the header, which corresponds to the html header levels, suc...
python
def header(header_text: str, level: int = 1, expand_full: bool = False): """ Adds a text header to the display with the specified level. :param header_text: The text to display in the header. :param level: The level of the header, which corresponds to the html header levels, suc...
[ "def", "header", "(", "header_text", ":", "str", ",", "level", ":", "int", "=", "1", ",", "expand_full", ":", "bool", "=", "False", ")", ":", "r", "=", "_get_report", "(", ")", "r", ".", "append_body", "(", "render", ".", "header", "(", "header_text"...
Adds a text header to the display with the specified level. :param header_text: The text to display in the header. :param level: The level of the header, which corresponds to the html header levels, such as <h1>, <h2>, ... :param expand_full: Whether or not the header will e...
[ "Adds", "a", "text", "header", "to", "the", "display", "with", "the", "specified", "level", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/display/__init__.py#L33-L52
sernst/cauldron
cauldron/session/display/__init__.py
text
def text(value: str, preformatted: bool = False): """ Adds text to the display. If the text is not preformatted, it will be displayed in paragraph format. Preformatted text will be displayed inside a pre tag with a monospace font. :param value: The text to display. :param preformatted: ...
python
def text(value: str, preformatted: bool = False): """ Adds text to the display. If the text is not preformatted, it will be displayed in paragraph format. Preformatted text will be displayed inside a pre tag with a monospace font. :param value: The text to display. :param preformatted: ...
[ "def", "text", "(", "value", ":", "str", ",", "preformatted", ":", "bool", "=", "False", ")", ":", "if", "preformatted", ":", "result", "=", "render_texts", ".", "preformatted_text", "(", "value", ")", "else", ":", "result", "=", "render_texts", ".", "te...
Adds text to the display. If the text is not preformatted, it will be displayed in paragraph format. Preformatted text will be displayed inside a pre tag with a monospace font. :param value: The text to display. :param preformatted: Whether or not to preserve the whitespace display of t...
[ "Adds", "text", "to", "the", "display", ".", "If", "the", "text", "is", "not", "preformatted", "it", "will", "be", "displayed", "in", "paragraph", "format", ".", "Preformatted", "text", "will", "be", "displayed", "inside", "a", "pre", "tag", "with", "a", ...
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/display/__init__.py#L55-L74
sernst/cauldron
cauldron/session/display/__init__.py
markdown
def markdown( source: str = None, source_path: str = None, preserve_lines: bool = False, font_size: float = None, **kwargs ): """ Renders the specified source string or source file using markdown and adds the resulting HTML to the notebook display. :param source...
python
def markdown( source: str = None, source_path: str = None, preserve_lines: bool = False, font_size: float = None, **kwargs ): """ Renders the specified source string or source file using markdown and adds the resulting HTML to the notebook display. :param source...
[ "def", "markdown", "(", "source", ":", "str", "=", "None", ",", "source_path", ":", "str", "=", "None", ",", "preserve_lines", ":", "bool", "=", "False", ",", "font_size", ":", "float", "=", "None", ",", "*", "*", "kwargs", ")", ":", "r", "=", "_ge...
Renders the specified source string or source file using markdown and adds the resulting HTML to the notebook display. :param source: A markdown formatted string. :param source_path: A file containing markdown text. :param preserve_lines: If True, all line breaks will be treate...
[ "Renders", "the", "specified", "source", "string", "or", "source", "file", "using", "markdown", "and", "adds", "the", "resulting", "HTML", "to", "the", "notebook", "display", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/display/__init__.py#L77-L119
sernst/cauldron
cauldron/session/display/__init__.py
json
def json(**kwargs): """ Adds the specified data to the the output display window with the specified key. This allows the user to make available arbitrary JSON-compatible data to the display for runtime use. :param kwargs: Each keyword argument is added to the CD.data object with the ...
python
def json(**kwargs): """ Adds the specified data to the the output display window with the specified key. This allows the user to make available arbitrary JSON-compatible data to the display for runtime use. :param kwargs: Each keyword argument is added to the CD.data object with the ...
[ "def", "json", "(", "*", "*", "kwargs", ")", ":", "r", "=", "_get_report", "(", ")", "r", ".", "append_body", "(", "render", ".", "json", "(", "*", "*", "kwargs", ")", ")", "r", ".", "stdout_interceptor", ".", "write_source", "(", "'{}\\n'", ".", "...
Adds the specified data to the the output display window with the specified key. This allows the user to make available arbitrary JSON-compatible data to the display for runtime use. :param kwargs: Each keyword argument is added to the CD.data object with the specified key and value.
[ "Adds", "the", "specified", "data", "to", "the", "the", "output", "display", "window", "with", "the", "specified", "key", ".", "This", "allows", "the", "user", "to", "make", "available", "arbitrary", "JSON", "-", "compatible", "data", "to", "the", "display",...
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/display/__init__.py#L122-L136
sernst/cauldron
cauldron/session/display/__init__.py
plotly
def plotly( data: typing.Union[dict, list] = None, layout: dict = None, scale: float = 0.5, figure: dict = None, static: bool = False ): """ Creates a Plotly plot in the display with the specified data and layout. :param data: The Plotly trace data to be ...
python
def plotly( data: typing.Union[dict, list] = None, layout: dict = None, scale: float = 0.5, figure: dict = None, static: bool = False ): """ Creates a Plotly plot in the display with the specified data and layout. :param data: The Plotly trace data to be ...
[ "def", "plotly", "(", "data", ":", "typing", ".", "Union", "[", "dict", ",", "list", "]", "=", "None", ",", "layout", ":", "dict", "=", "None", ",", "scale", ":", "float", "=", "0.5", ",", "figure", ":", "dict", "=", "None", ",", "static", ":", ...
Creates a Plotly plot in the display with the specified data and layout. :param data: The Plotly trace data to be plotted. :param layout: The layout data used for the plot. :param scale: The display scale with units of fractional screen height. A value of 0.5 constrains ...
[ "Creates", "a", "Plotly", "plot", "in", "the", "display", "with", "the", "specified", "data", "and", "layout", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/display/__init__.py#L139-L182
sernst/cauldron
cauldron/session/display/__init__.py
table
def table( data_frame, scale: float = 0.7, include_index: bool = False, max_rows: int = 500 ): """ Adds the specified data frame to the display in a nicely formatted scrolling table. :param data_frame: The pandas data frame to be rendered to a table. :param s...
python
def table( data_frame, scale: float = 0.7, include_index: bool = False, max_rows: int = 500 ): """ Adds the specified data frame to the display in a nicely formatted scrolling table. :param data_frame: The pandas data frame to be rendered to a table. :param s...
[ "def", "table", "(", "data_frame", ",", "scale", ":", "float", "=", "0.7", ",", "include_index", ":", "bool", "=", "False", ",", "max_rows", ":", "int", "=", "500", ")", ":", "r", "=", "_get_report", "(", ")", "r", ".", "append_body", "(", "render", ...
Adds the specified data frame to the display in a nicely formatted scrolling table. :param data_frame: The pandas data frame to be rendered to a table. :param scale: The display scale with units of fractional screen height. A value of 0.5 constrains the output to a maximum height eq...
[ "Adds", "the", "specified", "data", "frame", "to", "the", "display", "in", "a", "nicely", "formatted", "scrolling", "table", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/display/__init__.py#L185-L219
sernst/cauldron
cauldron/session/display/__init__.py
svg
def svg(svg_dom: str, filename: str = None): """ Adds the specified SVG string to the display. If a filename is included, the SVG data will also be saved to that filename within the project results folder. :param svg_dom: The SVG string data to add to the display. :param filename: ...
python
def svg(svg_dom: str, filename: str = None): """ Adds the specified SVG string to the display. If a filename is included, the SVG data will also be saved to that filename within the project results folder. :param svg_dom: The SVG string data to add to the display. :param filename: ...
[ "def", "svg", "(", "svg_dom", ":", "str", ",", "filename", ":", "str", "=", "None", ")", ":", "r", "=", "_get_report", "(", ")", "r", ".", "append_body", "(", "render", ".", "svg", "(", "svg_dom", ")", ")", "r", ".", "stdout_interceptor", ".", "wri...
Adds the specified SVG string to the display. If a filename is included, the SVG data will also be saved to that filename within the project results folder. :param svg_dom: The SVG string data to add to the display. :param filename: An optional filename where the SVG data should be save...
[ "Adds", "the", "specified", "SVG", "string", "to", "the", "display", ".", "If", "a", "filename", "is", "included", "the", "SVG", "data", "will", "also", "be", "saved", "to", "that", "filename", "within", "the", "project", "results", "folder", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/display/__init__.py#L222-L244
sernst/cauldron
cauldron/session/display/__init__.py
jinja
def jinja(path: str, **kwargs): """ Renders the specified Jinja2 template to HTML and adds the output to the display. :param path: The fully-qualified path to the template to be rendered. :param kwargs: Any keyword arguments that will be use as variable replacements within t...
python
def jinja(path: str, **kwargs): """ Renders the specified Jinja2 template to HTML and adds the output to the display. :param path: The fully-qualified path to the template to be rendered. :param kwargs: Any keyword arguments that will be use as variable replacements within t...
[ "def", "jinja", "(", "path", ":", "str", ",", "*", "*", "kwargs", ")", ":", "r", "=", "_get_report", "(", ")", "r", ".", "append_body", "(", "render", ".", "jinja", "(", "path", ",", "*", "*", "kwargs", ")", ")", "r", ".", "stdout_interceptor", "...
Renders the specified Jinja2 template to HTML and adds the output to the display. :param path: The fully-qualified path to the template to be rendered. :param kwargs: Any keyword arguments that will be use as variable replacements within the template.
[ "Renders", "the", "specified", "Jinja2", "template", "to", "HTML", "and", "adds", "the", "output", "to", "the", "display", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/display/__init__.py#L247-L260
sernst/cauldron
cauldron/session/display/__init__.py
whitespace
def whitespace(lines: float = 1.0): """ Adds the specified number of lines of whitespace. :param lines: The number of lines of whitespace to show. """ r = _get_report() r.append_body(render.whitespace(lines)) r.stdout_interceptor.write_source('\n')
python
def whitespace(lines: float = 1.0): """ Adds the specified number of lines of whitespace. :param lines: The number of lines of whitespace to show. """ r = _get_report() r.append_body(render.whitespace(lines)) r.stdout_interceptor.write_source('\n')
[ "def", "whitespace", "(", "lines", ":", "float", "=", "1.0", ")", ":", "r", "=", "_get_report", "(", ")", "r", ".", "append_body", "(", "render", ".", "whitespace", "(", "lines", ")", ")", "r", ".", "stdout_interceptor", ".", "write_source", "(", "'\\n...
Adds the specified number of lines of whitespace. :param lines: The number of lines of whitespace to show.
[ "Adds", "the", "specified", "number", "of", "lines", "of", "whitespace", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/display/__init__.py#L263-L272
sernst/cauldron
cauldron/session/display/__init__.py
image
def image( filename: str, width: int = None, height: int = None, justify: str = 'left' ): """ Adds an image to the display. The image must be located within the assets directory of the Cauldron notebook's folder. :param filename: Name of the file within the asset...
python
def image( filename: str, width: int = None, height: int = None, justify: str = 'left' ): """ Adds an image to the display. The image must be located within the assets directory of the Cauldron notebook's folder. :param filename: Name of the file within the asset...
[ "def", "image", "(", "filename", ":", "str", ",", "width", ":", "int", "=", "None", ",", "height", ":", "int", "=", "None", ",", "justify", ":", "str", "=", "'left'", ")", ":", "r", "=", "_get_report", "(", ")", "path", "=", "'/'", ".", "join", ...
Adds an image to the display. The image must be located within the assets directory of the Cauldron notebook's folder. :param filename: Name of the file within the assets directory, :param width: Optional width in pixels for the image. :param height: Optional height in pixels fo...
[ "Adds", "an", "image", "to", "the", "display", ".", "The", "image", "must", "be", "located", "within", "the", "assets", "directory", "of", "the", "Cauldron", "notebook", "s", "folder", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/display/__init__.py#L275-L298
sernst/cauldron
cauldron/session/display/__init__.py
html
def html(dom: str): """ A string containing a valid HTML snippet. :param dom: The HTML string to add to the display. """ r = _get_report() r.append_body(render.html(dom)) r.stdout_interceptor.write_source('[ADDED] HTML\n')
python
def html(dom: str): """ A string containing a valid HTML snippet. :param dom: The HTML string to add to the display. """ r = _get_report() r.append_body(render.html(dom)) r.stdout_interceptor.write_source('[ADDED] HTML\n')
[ "def", "html", "(", "dom", ":", "str", ")", ":", "r", "=", "_get_report", "(", ")", "r", ".", "append_body", "(", "render", ".", "html", "(", "dom", ")", ")", "r", ".", "stdout_interceptor", ".", "write_source", "(", "'[ADDED] HTML\\n'", ")" ]
A string containing a valid HTML snippet. :param dom: The HTML string to add to the display.
[ "A", "string", "containing", "a", "valid", "HTML", "snippet", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/display/__init__.py#L301-L310
sernst/cauldron
cauldron/session/display/__init__.py
workspace
def workspace(show_values: bool = True, show_types: bool = True): """ Adds a list of the shared variables currently stored in the project workspace. :param show_values: When true the values for each variable will be shown in addition to their name. :param show_types: When tr...
python
def workspace(show_values: bool = True, show_types: bool = True): """ Adds a list of the shared variables currently stored in the project workspace. :param show_values: When true the values for each variable will be shown in addition to their name. :param show_types: When tr...
[ "def", "workspace", "(", "show_values", ":", "bool", "=", "True", ",", "show_types", ":", "bool", "=", "True", ")", ":", "r", "=", "_get_report", "(", ")", "data", "=", "{", "}", "for", "key", ",", "value", "in", "r", ".", "project", ".", "shared",...
Adds a list of the shared variables currently stored in the project workspace. :param show_values: When true the values for each variable will be shown in addition to their name. :param show_types: When true the data types for each shared variable will be shown in addition t...
[ "Adds", "a", "list", "of", "the", "shared", "variables", "currently", "stored", "in", "the", "project", "workspace", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/display/__init__.py#L313-L333
sernst/cauldron
cauldron/session/display/__init__.py
pyplot
def pyplot( figure=None, scale: float = 0.8, clear: bool = True, aspect_ratio: typing.Union[list, tuple] = None ): """ Creates a matplotlib plot in the display for the specified figure. The size of the plot is determined automatically to best fit the notebook. :param fig...
python
def pyplot( figure=None, scale: float = 0.8, clear: bool = True, aspect_ratio: typing.Union[list, tuple] = None ): """ Creates a matplotlib plot in the display for the specified figure. The size of the plot is determined automatically to best fit the notebook. :param fig...
[ "def", "pyplot", "(", "figure", "=", "None", ",", "scale", ":", "float", "=", "0.8", ",", "clear", ":", "bool", "=", "True", ",", "aspect_ratio", ":", "typing", ".", "Union", "[", "list", ",", "tuple", "]", "=", "None", ")", ":", "r", "=", "_get_...
Creates a matplotlib plot in the display for the specified figure. The size of the plot is determined automatically to best fit the notebook. :param figure: The matplotlib figure to plot. If omitted, the currently active figure will be used. :param scale: The display scale with unit...
[ "Creates", "a", "matplotlib", "plot", "in", "the", "display", "for", "the", "specified", "figure", ".", "The", "size", "of", "the", "plot", "is", "determined", "automatically", "to", "best", "fit", "the", "notebook", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/display/__init__.py#L336-L374
sernst/cauldron
cauldron/session/display/__init__.py
bokeh
def bokeh(model, scale: float = 0.7, responsive: bool = True): """ Adds a Bokeh plot object to the notebook display. :param model: The plot object to be added to the notebook display. :param scale: How tall the plot should be in the notebook as a fraction of screen height. A num...
python
def bokeh(model, scale: float = 0.7, responsive: bool = True): """ Adds a Bokeh plot object to the notebook display. :param model: The plot object to be added to the notebook display. :param scale: How tall the plot should be in the notebook as a fraction of screen height. A num...
[ "def", "bokeh", "(", "model", ",", "scale", ":", "float", "=", "0.7", ",", "responsive", ":", "bool", "=", "True", ")", ":", "r", "=", "_get_report", "(", ")", "if", "'bokeh'", "not", "in", "r", ".", "library_includes", ":", "r", ".", "library_includ...
Adds a Bokeh plot object to the notebook display. :param model: The plot object to be added to the notebook display. :param scale: How tall the plot should be in the notebook as a fraction of screen height. A number between 0.1 and 1.0. The default value is 0.7. :param responsive: ...
[ "Adds", "a", "Bokeh", "plot", "object", "to", "the", "notebook", "display", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/display/__init__.py#L377-L400
sernst/cauldron
cauldron/session/display/__init__.py
listing
def listing( source: list, ordered: bool = False, expand_full: bool = False ): """ An unordered or ordered list of the specified *source* iterable where each element is converted to a string representation for display. :param source: The iterable to display as a list. ...
python
def listing( source: list, ordered: bool = False, expand_full: bool = False ): """ An unordered or ordered list of the specified *source* iterable where each element is converted to a string representation for display. :param source: The iterable to display as a list. ...
[ "def", "listing", "(", "source", ":", "list", ",", "ordered", ":", "bool", "=", "False", ",", "expand_full", ":", "bool", "=", "False", ")", ":", "r", "=", "_get_report", "(", ")", "r", ".", "append_body", "(", "render", ".", "listing", "(", "source"...
An unordered or ordered list of the specified *source* iterable where each element is converted to a string representation for display. :param source: The iterable to display as a list. :param ordered: Whether or not the list should be ordered. If False, which is the default, an uno...
[ "An", "unordered", "or", "ordered", "list", "of", "the", "specified", "*", "source", "*", "iterable", "where", "each", "element", "is", "converted", "to", "a", "string", "representation", "for", "display", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/display/__init__.py#L403-L429
sernst/cauldron
cauldron/session/display/__init__.py
list_grid
def list_grid( source: list, expand_full: bool = False, column_count: int = 2, row_spacing: float = 1.0 ): """ An multi-column list of the specified *source* iterable where each element is converted to a string representation for display. :param source: The itera...
python
def list_grid( source: list, expand_full: bool = False, column_count: int = 2, row_spacing: float = 1.0 ): """ An multi-column list of the specified *source* iterable where each element is converted to a string representation for display. :param source: The itera...
[ "def", "list_grid", "(", "source", ":", "list", ",", "expand_full", ":", "bool", "=", "False", ",", "column_count", ":", "int", "=", "2", ",", "row_spacing", ":", "float", "=", "1.0", ")", ":", "r", "=", "_get_report", "(", ")", "r", ".", "append_bod...
An multi-column list of the specified *source* iterable where each element is converted to a string representation for display. :param source: The iterable to display as a list. :param expand_full: Whether or not the list should expand to fill the screen horizontally. When defaulted...
[ "An", "multi", "-", "column", "list", "of", "the", "specified", "*", "source", "*", "iterable", "where", "each", "element", "is", "converted", "to", "a", "string", "representation", "for", "display", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/display/__init__.py#L432-L465
sernst/cauldron
cauldron/session/display/__init__.py
latex
def latex(source: str): """ Add a mathematical equation in latex math-mode syntax to the display. Instead of the traditional backslash escape character, the @ character is used instead to prevent backslash conflicts with Python strings. For example, \\delta would be @delta. :param source: ...
python
def latex(source: str): """ Add a mathematical equation in latex math-mode syntax to the display. Instead of the traditional backslash escape character, the @ character is used instead to prevent backslash conflicts with Python strings. For example, \\delta would be @delta. :param source: ...
[ "def", "latex", "(", "source", ":", "str", ")", ":", "r", "=", "_get_report", "(", ")", "if", "'katex'", "not", "in", "r", ".", "library_includes", ":", "r", ".", "library_includes", ".", "append", "(", "'katex'", ")", "r", ".", "append_body", "(", "...
Add a mathematical equation in latex math-mode syntax to the display. Instead of the traditional backslash escape character, the @ character is used instead to prevent backslash conflicts with Python strings. For example, \\delta would be @delta. :param source: The string representing the latex...
[ "Add", "a", "mathematical", "equation", "in", "latex", "math", "-", "mode", "syntax", "to", "the", "display", ".", "Instead", "of", "the", "traditional", "backslash", "escape", "character", "the", "@", "character", "is", "used", "instead", "to", "prevent", "...
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/display/__init__.py#L468-L483
sernst/cauldron
cauldron/session/display/__init__.py
head
def head(source, count: int = 5): """ Displays a specified number of elements in a source object of many different possible types. :param source: DataFrames will show *count* rows of that DataFrame. A list, tuple or other iterable, will show the first *count* rows. Dictionaries will ...
python
def head(source, count: int = 5): """ Displays a specified number of elements in a source object of many different possible types. :param source: DataFrames will show *count* rows of that DataFrame. A list, tuple or other iterable, will show the first *count* rows. Dictionaries will ...
[ "def", "head", "(", "source", ",", "count", ":", "int", "=", "5", ")", ":", "r", "=", "_get_report", "(", ")", "r", ".", "append_body", "(", "render_texts", ".", "head", "(", "source", ",", "count", "=", "count", ")", ")", "r", ".", "stdout_interce...
Displays a specified number of elements in a source object of many different possible types. :param source: DataFrames will show *count* rows of that DataFrame. A list, tuple or other iterable, will show the first *count* rows. Dictionaries will show *count* keys from the dictionary, wh...
[ "Displays", "a", "specified", "number", "of", "elements", "in", "a", "source", "object", "of", "many", "different", "possible", "types", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/display/__init__.py#L486-L502
sernst/cauldron
cauldron/session/display/__init__.py
status
def status( message: str = None, progress: float = None, section_message: str = None, section_progress: float = None, ): """ Updates the status display, which is only visible while a step is running. This is useful for providing feedback and information during long-running ...
python
def status( message: str = None, progress: float = None, section_message: str = None, section_progress: float = None, ): """ Updates the status display, which is only visible while a step is running. This is useful for providing feedback and information during long-running ...
[ "def", "status", "(", "message", ":", "str", "=", "None", ",", "progress", ":", "float", "=", "None", ",", "section_message", ":", "str", "=", "None", ",", "section_progress", ":", "float", "=", "None", ",", ")", ":", "environ", ".", "abort_thread", "(...
Updates the status display, which is only visible while a step is running. This is useful for providing feedback and information during long-running steps. A section progress is also available for cases where long running tasks consist of multiple tasks and you want to display sub-progress messages ...
[ "Updates", "the", "status", "display", "which", "is", "only", "visible", "while", "a", "step", "is", "running", ".", "This", "is", "useful", "for", "providing", "feedback", "and", "information", "during", "long", "-", "running", "steps", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/display/__init__.py#L524-L570
sernst/cauldron
cauldron/session/display/__init__.py
code_block
def code_block( code: str = None, path: str = None, language_id: str = None, title: str = None, caption: str = None ): """ Adds a block of syntax highlighted code to the display from either the supplied code argument, or from the code file specified by the path ar...
python
def code_block( code: str = None, path: str = None, language_id: str = None, title: str = None, caption: str = None ): """ Adds a block of syntax highlighted code to the display from either the supplied code argument, or from the code file specified by the path ar...
[ "def", "code_block", "(", "code", ":", "str", "=", "None", ",", "path", ":", "str", "=", "None", ",", "language_id", ":", "str", "=", "None", ",", "title", ":", "str", "=", "None", ",", "caption", ":", "str", "=", "None", ")", ":", "environ", "."...
Adds a block of syntax highlighted code to the display from either the supplied code argument, or from the code file specified by the path argument. :param code: A string containing the code to be added to the display :param path: A path to a file containing code to be added to the disp...
[ "Adds", "a", "block", "of", "syntax", "highlighted", "code", "to", "the", "display", "from", "either", "the", "supplied", "code", "argument", "or", "from", "the", "code", "file", "specified", "by", "the", "path", "argument", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/display/__init__.py#L573-L609
sernst/cauldron
cauldron/session/display/__init__.py
elapsed
def elapsed(): """ Displays the elapsed time since the step started running. """ environ.abort_thread() step = _cd.project.get_internal_project().current_step r = _get_report() r.append_body(render.elapsed_time(step.elapsed_time)) result = '[ELAPSED]: {}\n'.format(timedelta(seconds=step...
python
def elapsed(): """ Displays the elapsed time since the step started running. """ environ.abort_thread() step = _cd.project.get_internal_project().current_step r = _get_report() r.append_body(render.elapsed_time(step.elapsed_time)) result = '[ELAPSED]: {}\n'.format(timedelta(seconds=step...
[ "def", "elapsed", "(", ")", ":", "environ", ".", "abort_thread", "(", ")", "step", "=", "_cd", ".", "project", ".", "get_internal_project", "(", ")", ".", "current_step", "r", "=", "_get_report", "(", ")", "r", ".", "append_body", "(", "render", ".", "...
Displays the elapsed time since the step started running.
[ "Displays", "the", "elapsed", "time", "since", "the", "step", "started", "running", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/display/__init__.py#L612-L622
sernst/cauldron
cauldron/session/reloading.py
get_module
def get_module(name: str) -> typing.Union[types.ModuleType, None]: """ Retrieves the loaded module for the given module name or returns None if no such module has been loaded. :param name: The name of the module to be retrieved :return: Either the loaded module with the specified na...
python
def get_module(name: str) -> typing.Union[types.ModuleType, None]: """ Retrieves the loaded module for the given module name or returns None if no such module has been loaded. :param name: The name of the module to be retrieved :return: Either the loaded module with the specified na...
[ "def", "get_module", "(", "name", ":", "str", ")", "->", "typing", ".", "Union", "[", "types", ".", "ModuleType", ",", "None", "]", ":", "return", "sys", ".", "modules", ".", "get", "(", "name", ")" ]
Retrieves the loaded module for the given module name or returns None if no such module has been loaded. :param name: The name of the module to be retrieved :return: Either the loaded module with the specified name, or None if no such module has been imported.
[ "Retrieves", "the", "loaded", "module", "for", "the", "given", "module", "name", "or", "returns", "None", "if", "no", "such", "module", "has", "been", "loaded", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/reloading.py#L10-L21
sernst/cauldron
cauldron/session/reloading.py
get_module_name
def get_module_name(module: types.ModuleType) -> str: """ Returns the name of the specified module by looking up its name in multiple ways to prevent incompatibility issues. :param module: A module object for which to retrieve the name. """ try: return module.__spec__.name e...
python
def get_module_name(module: types.ModuleType) -> str: """ Returns the name of the specified module by looking up its name in multiple ways to prevent incompatibility issues. :param module: A module object for which to retrieve the name. """ try: return module.__spec__.name e...
[ "def", "get_module_name", "(", "module", ":", "types", ".", "ModuleType", ")", "->", "str", ":", "try", ":", "return", "module", ".", "__spec__", ".", "name", "except", "AttributeError", ":", "return", "module", ".", "__name__" ]
Returns the name of the specified module by looking up its name in multiple ways to prevent incompatibility issues. :param module: A module object for which to retrieve the name.
[ "Returns", "the", "name", "of", "the", "specified", "module", "by", "looking", "up", "its", "name", "in", "multiple", "ways", "to", "prevent", "incompatibility", "issues", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/reloading.py#L24-L35
sernst/cauldron
cauldron/session/reloading.py
do_reload
def do_reload(module: types.ModuleType, newer_than: int) -> bool: """ Executes the reload of the specified module if the source file that it was loaded from was updated more recently than the specified time :param module: A module object to be reloaded :param newer_than: The time in...
python
def do_reload(module: types.ModuleType, newer_than: int) -> bool: """ Executes the reload of the specified module if the source file that it was loaded from was updated more recently than the specified time :param module: A module object to be reloaded :param newer_than: The time in...
[ "def", "do_reload", "(", "module", ":", "types", ".", "ModuleType", ",", "newer_than", ":", "int", ")", "->", "bool", ":", "path", "=", "getattr", "(", "module", ",", "'__file__'", ")", "directory", "=", "getattr", "(", "module", ",", "'__path__'", ",", ...
Executes the reload of the specified module if the source file that it was loaded from was updated more recently than the specified time :param module: A module object to be reloaded :param newer_than: The time in seconds since epoch that should be used to determine if the module ne...
[ "Executes", "the", "reload", "of", "the", "specified", "module", "if", "the", "source", "file", "that", "it", "was", "loaded", "from", "was", "updated", "more", "recently", "than", "the", "specified", "time" ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/reloading.py#L38-L67
sernst/cauldron
cauldron/session/reloading.py
reload_children
def reload_children(parent_module: types.ModuleType, newer_than: int) -> bool: """ Reloads all imported children of the specified parent module object :param parent_module: A module object whose children should be refreshed if their currently loaded versions are out of date. :param newe...
python
def reload_children(parent_module: types.ModuleType, newer_than: int) -> bool: """ Reloads all imported children of the specified parent module object :param parent_module: A module object whose children should be refreshed if their currently loaded versions are out of date. :param newe...
[ "def", "reload_children", "(", "parent_module", ":", "types", ".", "ModuleType", ",", "newer_than", ":", "int", ")", "->", "bool", ":", "if", "not", "hasattr", "(", "parent_module", ",", "'__path__'", ")", ":", "return", "False", "parent_name", "=", "get_mod...
Reloads all imported children of the specified parent module object :param parent_module: A module object whose children should be refreshed if their currently loaded versions are out of date. :param newer_than: An integer time in seconds for comparison. Any children modules that ...
[ "Reloads", "all", "imported", "children", "of", "the", "specified", "parent", "module", "object" ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/reloading.py#L70-L93
sernst/cauldron
cauldron/session/reloading.py
reload_module
def reload_module( module: typing.Union[str, types.ModuleType], recursive: bool, force: bool ) -> bool: """ Reloads the specified module, which can either be a module object or a string name of a module. Will not reload a module that has not been imported :param module: ...
python
def reload_module( module: typing.Union[str, types.ModuleType], recursive: bool, force: bool ) -> bool: """ Reloads the specified module, which can either be a module object or a string name of a module. Will not reload a module that has not been imported :param module: ...
[ "def", "reload_module", "(", "module", ":", "typing", ".", "Union", "[", "str", ",", "types", ".", "ModuleType", "]", ",", "recursive", ":", "bool", ",", "force", ":", "bool", ")", "->", "bool", ":", "if", "isinstance", "(", "module", ",", "str", ")"...
Reloads the specified module, which can either be a module object or a string name of a module. Will not reload a module that has not been imported :param module: A module object or string module name that should be refreshed if its currently loaded version is out of date or the action is f...
[ "Reloads", "the", "specified", "module", "which", "can", "either", "be", "a", "module", "object", "or", "a", "string", "name", "of", "a", "module", ".", "Will", "not", "reload", "a", "module", "that", "has", "not", "been", "imported" ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/reloading.py#L96-L143
sernst/cauldron
cauldron/session/reloading.py
refresh
def refresh( *modules: typing.Union[str, types.ModuleType], recursive: bool = False, force: bool = False ) -> bool: """ Checks the specified module or modules for changes and reloads them if they have been changed since the module was first imported or last refreshed. :param...
python
def refresh( *modules: typing.Union[str, types.ModuleType], recursive: bool = False, force: bool = False ) -> bool: """ Checks the specified module or modules for changes and reloads them if they have been changed since the module was first imported or last refreshed. :param...
[ "def", "refresh", "(", "*", "modules", ":", "typing", ".", "Union", "[", "str", ",", "types", ".", "ModuleType", "]", ",", "recursive", ":", "bool", "=", "False", ",", "force", ":", "bool", "=", "False", ")", "->", "bool", ":", "out", "=", "[", "...
Checks the specified module or modules for changes and reloads them if they have been changed since the module was first imported or last refreshed. :param modules: One or more module objects that should be refreshed if they the currently loaded versions are out of date. The package name fo...
[ "Checks", "the", "specified", "module", "or", "modules", "for", "changes", "and", "reloads", "them", "if", "they", "have", "been", "changed", "since", "the", "module", "was", "first", "imported", "or", "last", "refreshed", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/reloading.py#L146-L175
sernst/cauldron
cauldron/docgen/params.py
get_args_index
def get_args_index(target) -> int: """ Returns the index of the "*args" parameter if such a parameter exists in the function arguments or -1 otherwise. :param target: The target function for which the args index should be determined :return: The arguments index if it exists or -1 if...
python
def get_args_index(target) -> int: """ Returns the index of the "*args" parameter if such a parameter exists in the function arguments or -1 otherwise. :param target: The target function for which the args index should be determined :return: The arguments index if it exists or -1 if...
[ "def", "get_args_index", "(", "target", ")", "->", "int", ":", "code", "=", "target", ".", "__code__", "if", "not", "bool", "(", "code", ".", "co_flags", "&", "inspect", ".", "CO_VARARGS", ")", ":", "return", "-", "1", "return", "code", ".", "co_argcou...
Returns the index of the "*args" parameter if such a parameter exists in the function arguments or -1 otherwise. :param target: The target function for which the args index should be determined :return: The arguments index if it exists or -1 if not
[ "Returns", "the", "index", "of", "the", "*", "args", "parameter", "if", "such", "a", "parameter", "exists", "in", "the", "function", "arguments", "or", "-", "1", "otherwise", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/docgen/params.py#L6-L22
sernst/cauldron
cauldron/docgen/params.py
get_kwargs_index
def get_kwargs_index(target) -> int: """ Returns the index of the "**kwargs" parameter if such a parameter exists in the function arguments or -1 otherwise. :param target: The target function for which the kwargs index should be determined :return: The keyword arguments index if it ...
python
def get_kwargs_index(target) -> int: """ Returns the index of the "**kwargs" parameter if such a parameter exists in the function arguments or -1 otherwise. :param target: The target function for which the kwargs index should be determined :return: The keyword arguments index if it ...
[ "def", "get_kwargs_index", "(", "target", ")", "->", "int", ":", "code", "=", "target", ".", "__code__", "if", "not", "bool", "(", "code", ".", "co_flags", "&", "inspect", ".", "CO_VARKEYWORDS", ")", ":", "return", "-", "1", "return", "(", "code", ".",...
Returns the index of the "**kwargs" parameter if such a parameter exists in the function arguments or -1 otherwise. :param target: The target function for which the kwargs index should be determined :return: The keyword arguments index if it exists or -1 if not
[ "Returns", "the", "index", "of", "the", "**", "kwargs", "parameter", "if", "such", "a", "parameter", "exists", "in", "the", "function", "arguments", "or", "-", "1", "otherwise", "." ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/docgen/params.py#L25-L45
sernst/cauldron
cauldron/docgen/params.py
get_arg_names
def get_arg_names(target) -> typing.List[str]: """ Gets the list of named arguments for the target function :param target: Function for which the argument names will be retrieved """ code = getattr(target, '__code__') if code is None: return [] arg_count = code.co_argcoun...
python
def get_arg_names(target) -> typing.List[str]: """ Gets the list of named arguments for the target function :param target: Function for which the argument names will be retrieved """ code = getattr(target, '__code__') if code is None: return [] arg_count = code.co_argcoun...
[ "def", "get_arg_names", "(", "target", ")", "->", "typing", ".", "List", "[", "str", "]", ":", "code", "=", "getattr", "(", "target", ",", "'__code__'", ")", "if", "code", "is", "None", ":", "return", "[", "]", "arg_count", "=", "code", ".", "co_argc...
Gets the list of named arguments for the target function :param target: Function for which the argument names will be retrieved
[ "Gets", "the", "list", "of", "named", "arguments", "for", "the", "target", "function" ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/docgen/params.py#L48-L76
sernst/cauldron
cauldron/docgen/params.py
create_argument
def create_argument(target, name, description: str = '') -> dict: """ Creates a dictionary representation of the parameter :param target: The function object in which the parameter resides :param name: The name of the parameter :param description: The documentation descripti...
python
def create_argument(target, name, description: str = '') -> dict: """ Creates a dictionary representation of the parameter :param target: The function object in which the parameter resides :param name: The name of the parameter :param description: The documentation descripti...
[ "def", "create_argument", "(", "target", ",", "name", ",", "description", ":", "str", "=", "''", ")", "->", "dict", ":", "arg_names", "=", "get_arg_names", "(", "target", ")", "annotations", "=", "getattr", "(", "target", ",", "'__annotations__'", ",", "{"...
Creates a dictionary representation of the parameter :param target: The function object in which the parameter resides :param name: The name of the parameter :param description: The documentation description for the parameter
[ "Creates", "a", "dictionary", "representation", "of", "the", "parameter" ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/docgen/params.py#L79-L101
sernst/cauldron
cauldron/docgen/params.py
explode_line
def explode_line(argument_line: str) -> typing.Tuple[str, str]: """ Returns a tuple containing the parameter name and the description parsed from the given argument line """ parts = tuple(argument_line.split(' ', 1)[-1].split(':', 1)) return parts if len(parts) > 1 else (parts[0], '')
python
def explode_line(argument_line: str) -> typing.Tuple[str, str]: """ Returns a tuple containing the parameter name and the description parsed from the given argument line """ parts = tuple(argument_line.split(' ', 1)[-1].split(':', 1)) return parts if len(parts) > 1 else (parts[0], '')
[ "def", "explode_line", "(", "argument_line", ":", "str", ")", "->", "typing", ".", "Tuple", "[", "str", ",", "str", "]", ":", "parts", "=", "tuple", "(", "argument_line", ".", "split", "(", "' '", ",", "1", ")", "[", "-", "1", "]", ".", "split", ...
Returns a tuple containing the parameter name and the description parsed from the given argument line
[ "Returns", "a", "tuple", "containing", "the", "parameter", "name", "and", "the", "description", "parsed", "from", "the", "given", "argument", "line" ]
train
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/docgen/params.py#L104-L111