repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
potash/drain
drain/step.py
load
def load(steps, reload=False): """ safely load steps in place, excluding those that fail Args: steps: the steps to load """ # work on collections by default for fewer isinstance() calls per call to load() if reload: _STEP_CACHE.clear() if callable(steps): steps = ste...
python
def load(steps, reload=False): """ safely load steps in place, excluding those that fail Args: steps: the steps to load """ # work on collections by default for fewer isinstance() calls per call to load() if reload: _STEP_CACHE.clear() if callable(steps): steps = ste...
[ "def", "load", "(", "steps", ",", "reload", "=", "False", ")", ":", "# work on collections by default for fewer isinstance() calls per call to load()", "if", "reload", ":", "_STEP_CACHE", ".", "clear", "(", ")", "if", "callable", "(", "steps", ")", ":", "steps", "...
safely load steps in place, excluding those that fail Args: steps: the steps to load
[ "safely", "load", "steps", "in", "place", "excluding", "those", "that", "fail", "Args", ":", "steps", ":", "the", "steps", "to", "load" ]
ddd62081cb9317beb5d21f86c8b4bb196ca3d222
https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/step.py#L26-L56
train
Load a list of items from a list of steps into a list of items.
potash/drain
drain/step.py
_simplify_arguments
def _simplify_arguments(arguments): """ If positional or keyword arguments are empty return only one or the other. """ if len(arguments.args) == 0: return arguments.kwargs elif len(arguments.kwargs) == 0: return arguments.args else: return arguments
python
def _simplify_arguments(arguments): """ If positional or keyword arguments are empty return only one or the other. """ if len(arguments.args) == 0: return arguments.kwargs elif len(arguments.kwargs) == 0: return arguments.args else: return arguments
[ "def", "_simplify_arguments", "(", "arguments", ")", ":", "if", "len", "(", "arguments", ".", "args", ")", "==", "0", ":", "return", "arguments", ".", "kwargs", "elif", "len", "(", "arguments", ".", "kwargs", ")", "==", "0", ":", "return", "arguments", ...
If positional or keyword arguments are empty return only one or the other.
[ "If", "positional", "or", "keyword", "arguments", "are", "empty", "return", "only", "one", "or", "the", "other", "." ]
ddd62081cb9317beb5d21f86c8b4bb196ca3d222
https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/step.py#L310-L319
train
Simplify the arguments.
potash/drain
drain/step.py
merge_results
def merge_results(inputs, arguments=None): """ Merges results to form arguments to run(). There are two cases for each result: - dictionary: dictionaries get merged and passed as keyword arguments - list: lists get concatenated to positional arguments - Arguments: kwargs gets ...
python
def merge_results(inputs, arguments=None): """ Merges results to form arguments to run(). There are two cases for each result: - dictionary: dictionaries get merged and passed as keyword arguments - list: lists get concatenated to positional arguments - Arguments: kwargs gets ...
[ "def", "merge_results", "(", "inputs", ",", "arguments", "=", "None", ")", ":", "if", "arguments", "is", "None", ":", "arguments", "=", "Arguments", "(", ")", "args", "=", "arguments", ".", "args", "kwargs", "=", "arguments", ".", "kwargs", "for", "i", ...
Merges results to form arguments to run(). There are two cases for each result: - dictionary: dictionaries get merged and passed as keyword arguments - list: lists get concatenated to positional arguments - Arguments: kwargs gets merged and args gets appended - else: concatenated and...
[ "Merges", "results", "to", "form", "arguments", "to", "run", "()", ".", "There", "are", "two", "cases", "for", "each", "result", ":", "-", "dictionary", ":", "dictionaries", "get", "merged", "and", "passed", "as", "keyword", "arguments", "-", "list", ":", ...
ddd62081cb9317beb5d21f86c8b4bb196ca3d222
https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/step.py#L322-L354
train
Merges the results of a list of inputs into a single Arguments object.
potash/drain
drain/step.py
_expand_inputs
def _expand_inputs(step, steps=None): """ Returns the set of this step and all steps passed to the constructor (recursively). """ if steps is None: steps = set() for arg in step._kwargs.values(): if isinstance(arg, Step): _expand_inputs(arg, steps=steps) elif uti...
python
def _expand_inputs(step, steps=None): """ Returns the set of this step and all steps passed to the constructor (recursively). """ if steps is None: steps = set() for arg in step._kwargs.values(): if isinstance(arg, Step): _expand_inputs(arg, steps=steps) elif uti...
[ "def", "_expand_inputs", "(", "step", ",", "steps", "=", "None", ")", ":", "if", "steps", "is", "None", ":", "steps", "=", "set", "(", ")", "for", "arg", "in", "step", ".", "_kwargs", ".", "values", "(", ")", ":", "if", "isinstance", "(", "arg", ...
Returns the set of this step and all steps passed to the constructor (recursively).
[ "Returns", "the", "set", "of", "this", "step", "and", "all", "steps", "passed", "to", "the", "constructor", "(", "recursively", ")", "." ]
ddd62081cb9317beb5d21f86c8b4bb196ca3d222
https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/step.py#L478-L493
train
Recursively expands the input steps of this step and all steps passed to the constructor.
potash/drain
drain/step.py
_collect_kwargs
def _collect_kwargs(step, drop_duplicate_names=True): """ Collect the kwargs of this step and inputs passed to the constructor (recursively) Returns: dictionary of name: kwargs pairs where name is the name of a step and kwargs is its kwargs minus inputs. If the step doesn't have a name __cla...
python
def _collect_kwargs(step, drop_duplicate_names=True): """ Collect the kwargs of this step and inputs passed to the constructor (recursively) Returns: dictionary of name: kwargs pairs where name is the name of a step and kwargs is its kwargs minus inputs. If the step doesn't have a name __cla...
[ "def", "_collect_kwargs", "(", "step", ",", "drop_duplicate_names", "=", "True", ")", ":", "dicts", "=", "{", "}", "duplicates", "=", "set", "(", ")", "for", "s", "in", "_expand_inputs", "(", "step", ")", ":", "name", "=", "s", ".", "name", "if", "s"...
Collect the kwargs of this step and inputs passed to the constructor (recursively) Returns: dictionary of name: kwargs pairs where name is the name of a step and kwargs is its kwargs minus inputs. If the step doesn't have a name __class__.__name__ is used.
[ "Collect", "the", "kwargs", "of", "this", "step", "and", "inputs", "passed", "to", "the", "constructor", "(", "recursively", ")", "Returns", ":", "dictionary", "of", "name", ":", "kwargs", "pairs", "where", "name", "is", "the", "name", "of", "a", "step", ...
ddd62081cb9317beb5d21f86c8b4bb196ca3d222
https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/step.py#L496-L520
train
Collect the kwargs of this step and inputs passed to the constructor.
potash/drain
drain/step.py
_output_dirnames
def _output_dirnames(workflow=None, leaf=False): """ Args: workflow: optional collection of steps leaf: only include leaves of the workflow Returns: If workflow is specified, returns output directories for all target steps in the workflow. If no workflow specified, returns all extan...
python
def _output_dirnames(workflow=None, leaf=False): """ Args: workflow: optional collection of steps leaf: only include leaves of the workflow Returns: If workflow is specified, returns output directories for all target steps in the workflow. If no workflow specified, returns all extan...
[ "def", "_output_dirnames", "(", "workflow", "=", "None", ",", "leaf", "=", "False", ")", ":", "if", "workflow", "is", "None", ":", "dirs", "=", "set", "(", ")", "for", "cls", "in", "os", ".", "listdir", "(", "drain", ".", "PATH", ")", ":", "for", ...
Args: workflow: optional collection of steps leaf: only include leaves of the workflow Returns: If workflow is specified, returns output directories for all target steps in the workflow. If no workflow specified, returns all extant output directories in drain.PATH.
[ "Args", ":", "workflow", ":", "optional", "collection", "of", "steps", "leaf", ":", "only", "include", "leaves", "of", "the", "workflow" ]
ddd62081cb9317beb5d21f86c8b4bb196ca3d222
https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/step.py#L523-L545
train
Returns a set of output directories for all target steps in the workflow.
potash/drain
drain/step.py
Step.execute
def execute(self, inputs=None, output=None, load_targets=False): """ Run this step, recursively running or loading inputs. Used in bin/run_step.py which is run by drake. Args: inputs: collection of steps that should be loaded output: step that should be dumped aft...
python
def execute(self, inputs=None, output=None, load_targets=False): """ Run this step, recursively running or loading inputs. Used in bin/run_step.py which is run by drake. Args: inputs: collection of steps that should be loaded output: step that should be dumped aft...
[ "def", "execute", "(", "self", ",", "inputs", "=", "None", ",", "output", "=", "None", ",", "load_targets", "=", "False", ")", ":", "if", "self", "==", "output", ":", "if", "os", ".", "path", ".", "exists", "(", "self", ".", "_dump_dirname", ")", "...
Run this step, recursively running or loading inputs. Used in bin/run_step.py which is run by drake. Args: inputs: collection of steps that should be loaded output: step that should be dumped after it is run load_targets (boolean): load all steps which are targets. ...
[ "Run", "this", "step", "recursively", "running", "or", "loading", "inputs", ".", "Used", "in", "bin", "/", "run_step", ".", "py", "which", "is", "run", "by", "drake", ".", "Args", ":", "inputs", ":", "collection", "of", "steps", "that", "should", "be", ...
ddd62081cb9317beb5d21f86c8b4bb196ca3d222
https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/step.py#L86-L124
train
Execute this step recursively loading inputs and dumping the results.
potash/drain
drain/step.py
Step.get_input
def get_input(self, value, _search=None): """ Searches the tree for a step Args: value: The value to search for. If value is a string then the search looks for a step of that name. If the value is a type, it looks for a step of that type. Retur...
python
def get_input(self, value, _search=None): """ Searches the tree for a step Args: value: The value to search for. If value is a string then the search looks for a step of that name. If the value is a type, it looks for a step of that type. Retur...
[ "def", "get_input", "(", "self", ",", "value", ",", "_search", "=", "None", ")", ":", "if", "_search", "is", "None", ":", "if", "isinstance", "(", "value", ",", "string_types", ")", ":", "_search", "=", "lambda", "s", ":", "s", ".", "name", "# noqa: ...
Searches the tree for a step Args: value: The value to search for. If value is a string then the search looks for a step of that name. If the value is a type, it looks for a step of that type. Returns: The first step found via a depth-first search.
[ "Searches", "the", "tree", "for", "a", "step", "Args", ":", "value", ":", "The", "value", "to", "search", "for", ".", "If", "value", "is", "a", "string", "then", "the", "search", "looks", "for", "a", "step", "of", "that", "name", ".", "If", "the", ...
ddd62081cb9317beb5d21f86c8b4bb196ca3d222
https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/step.py#L136-L157
train
Searches the tree for a step with the given value.
potash/drain
drain/step.py
Step.get_inputs
def get_inputs(self, _visited=None): """ Returns: the set of all input steps """ if _visited is None: _visited = set() _visited.add(self) for i in self.inputs: if i not in _visited: i.get_inputs(_visited) return _visited
python
def get_inputs(self, _visited=None): """ Returns: the set of all input steps """ if _visited is None: _visited = set() _visited.add(self) for i in self.inputs: if i not in _visited: i.get_inputs(_visited) return _visited
[ "def", "get_inputs", "(", "self", ",", "_visited", "=", "None", ")", ":", "if", "_visited", "is", "None", ":", "_visited", "=", "set", "(", ")", "_visited", ".", "add", "(", "self", ")", "for", "i", "in", "self", ".", "inputs", ":", "if", "i", "n...
Returns: the set of all input steps
[ "Returns", ":", "the", "set", "of", "all", "input", "steps" ]
ddd62081cb9317beb5d21f86c8b4bb196ca3d222
https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/step.py#L159-L172
train
Returns the set of all input steps that are in the same order as this one.
potash/drain
drain/step.py
Step.get_arguments
def get_arguments(self, **include): """ return a shallow copy of self._kwargs passing {key}=False will pop the {key} from the dict e.g. get_arguments(inputs=False) returns all keywords except inputs """ d = dict(self._kwargs) for k in include: if not ...
python
def get_arguments(self, **include): """ return a shallow copy of self._kwargs passing {key}=False will pop the {key} from the dict e.g. get_arguments(inputs=False) returns all keywords except inputs """ d = dict(self._kwargs) for k in include: if not ...
[ "def", "get_arguments", "(", "self", ",", "*", "*", "include", ")", ":", "d", "=", "dict", "(", "self", ".", "_kwargs", ")", "for", "k", "in", "include", ":", "if", "not", "include", "[", "k", "]", "and", "k", "in", "d", ":", "d", ".", "pop", ...
return a shallow copy of self._kwargs passing {key}=False will pop the {key} from the dict e.g. get_arguments(inputs=False) returns all keywords except inputs
[ "return", "a", "shallow", "copy", "of", "self", ".", "_kwargs", "passing", "{", "key", "}", "=", "False", "will", "pop", "the", "{", "key", "}", "from", "the", "dict", "e", ".", "g", ".", "get_arguments", "(", "inputs", "=", "False", ")", "returns", ...
ddd62081cb9317beb5d21f86c8b4bb196ca3d222
https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/step.py#L176-L187
train
Returns a shallow copy of self. _kwargs except inputs
potash/drain
drain/step.py
Step.load
def load(self): """ Load this step's result from its dump directory """ hdf_filename = os.path.join(self._dump_dirname, 'result.h5') if os.path.isfile(hdf_filename): store = pd.HDFStore(hdf_filename, mode='r') keys = store.keys() if keys == ['/...
python
def load(self): """ Load this step's result from its dump directory """ hdf_filename = os.path.join(self._dump_dirname, 'result.h5') if os.path.isfile(hdf_filename): store = pd.HDFStore(hdf_filename, mode='r') keys = store.keys() if keys == ['/...
[ "def", "load", "(", "self", ")", ":", "hdf_filename", "=", "os", ".", "path", ".", "join", "(", "self", ".", "_dump_dirname", ",", "'result.h5'", ")", "if", "os", ".", "path", ".", "isfile", "(", "hdf_filename", ")", ":", "store", "=", "pd", ".", "...
Load this step's result from its dump directory
[ "Load", "this", "step", "s", "result", "from", "its", "dump", "directory" ]
ddd62081cb9317beb5d21f86c8b4bb196ca3d222
https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/step.py#L211-L230
train
Load this step s result from its dump directory
potash/drain
drain/step.py
Step.setup_dump
def setup_dump(self): """ Set up dump, creating directories and writing step.yaml file containing yaml dump of this step. {drain.PATH}/{self._digest}/ step.yaml dump/ """ dumpdir = self._dump_dirname if not os.path.isdir(dumpdir): ...
python
def setup_dump(self): """ Set up dump, creating directories and writing step.yaml file containing yaml dump of this step. {drain.PATH}/{self._digest}/ step.yaml dump/ """ dumpdir = self._dump_dirname if not os.path.isdir(dumpdir): ...
[ "def", "setup_dump", "(", "self", ")", ":", "dumpdir", "=", "self", ".", "_dump_dirname", "if", "not", "os", ".", "path", ".", "isdir", "(", "dumpdir", ")", ":", "os", ".", "makedirs", "(", "dumpdir", ")", "dump", "=", "False", "yaml_filename", "=", ...
Set up dump, creating directories and writing step.yaml file containing yaml dump of this step. {drain.PATH}/{self._digest}/ step.yaml dump/
[ "Set", "up", "dump", "creating", "directories", "and", "writing", "step", ".", "yaml", "file", "containing", "yaml", "dump", "of", "this", "step", "." ]
ddd62081cb9317beb5d21f86c8b4bb196ca3d222
https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/step.py#L232-L258
train
Setup dump of this step.
ehansis/ozelot
examples/leonardo/leonardo/common/input.py
ArtistsInputData.load
def load(self): """Load the data file, do some basic type conversions """ df = pd.read_csv(self.input_file, encoding='utf8') df['wiki_id'] = df['artist'].str.split('/').str[-1] # some years of birth are given as timestamps with prefix 't', convert to s...
python
def load(self): """Load the data file, do some basic type conversions """ df = pd.read_csv(self.input_file, encoding='utf8') df['wiki_id'] = df['artist'].str.split('/').str[-1] # some years of birth are given as timestamps with prefix 't', convert to s...
[ "def", "load", "(", "self", ")", ":", "df", "=", "pd", ".", "read_csv", "(", "self", ".", "input_file", ",", "encoding", "=", "'utf8'", ")", "df", "[", "'wiki_id'", "]", "=", "df", "[", "'artist'", "]", ".", "str", ".", "split", "(", "'/'", ")", ...
Load the data file, do some basic type conversions
[ "Load", "the", "data", "file", "do", "some", "basic", "type", "conversions" ]
948675e02eb6fca940450f5cb814f53e97159e5b
https://github.com/ehansis/ozelot/blob/948675e02eb6fca940450f5cb814f53e97159e5b/examples/leonardo/leonardo/common/input.py#L17-L33
train
Load the data file and do some basic type conversions
ehansis/ozelot
examples/leonardo/leonardo/common/input.py
PaintingsInputData.load
def load(self): """Load the data file, do some basic type conversions """ df = pd.read_csv(self.input_file, encoding='utf8') df['wiki_id'] = df['painting'].str.split('/').str[-1] df['creator_wiki_id'] = df['creator'].str.split('/').str[-1] df['d...
python
def load(self): """Load the data file, do some basic type conversions """ df = pd.read_csv(self.input_file, encoding='utf8') df['wiki_id'] = df['painting'].str.split('/').str[-1] df['creator_wiki_id'] = df['creator'].str.split('/').str[-1] df['d...
[ "def", "load", "(", "self", ")", ":", "df", "=", "pd", ".", "read_csv", "(", "self", ".", "input_file", ",", "encoding", "=", "'utf8'", ")", "df", "[", "'wiki_id'", "]", "=", "df", "[", "'painting'", "]", ".", "str", ".", "split", "(", "'/'", ")"...
Load the data file, do some basic type conversions
[ "Load", "the", "data", "file", "do", "some", "basic", "type", "conversions" ]
948675e02eb6fca940450f5cb814f53e97159e5b
https://github.com/ehansis/ozelot/blob/948675e02eb6fca940450f5cb814f53e97159e5b/examples/leonardo/leonardo/common/input.py#L41-L53
train
Load the data file and do some basic type conversions
lsst-sqre/documenteer
documenteer/stackdocs/packagecli.py
main
def main(ctx, root_dir, verbose): """package-docs is a CLI for building single-package previews of documentation in the LSST Stack. Use package-docs during development to quickly preview your documentation and docstrings. .. warning:: Using package-docs to compile standalone documentation ...
python
def main(ctx, root_dir, verbose): """package-docs is a CLI for building single-package previews of documentation in the LSST Stack. Use package-docs during development to quickly preview your documentation and docstrings. .. warning:: Using package-docs to compile standalone documentation ...
[ "def", "main", "(", "ctx", ",", "root_dir", ",", "verbose", ")", ":", "root_dir", "=", "discover_package_doc_dir", "(", "root_dir", ")", "# Subcommands should use the click.pass_obj decorator to get this", "# ctx.obj object as the first argument.", "ctx", ".", "obj", "=", ...
package-docs is a CLI for building single-package previews of documentation in the LSST Stack. Use package-docs during development to quickly preview your documentation and docstrings. .. warning:: Using package-docs to compile standalone documentation for a single package will generate...
[ "package", "-", "docs", "is", "a", "CLI", "for", "building", "single", "-", "package", "previews", "of", "documentation", "in", "the", "LSST", "Stack", "." ]
75f02901a80042b28d074df1cc1dca32eb8e38c8
https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/stackdocs/packagecli.py#L41-L78
train
This is the main function for the command line interface.
lsst-sqre/documenteer
documenteer/stackdocs/packagecli.py
build
def build(ctx): """Build documentation as HTML. The build HTML site is located in the ``doc/_build/html`` directory of the package. """ return_code = run_sphinx(ctx.obj['root_dir']) if return_code > 0: sys.exit(return_code)
python
def build(ctx): """Build documentation as HTML. The build HTML site is located in the ``doc/_build/html`` directory of the package. """ return_code = run_sphinx(ctx.obj['root_dir']) if return_code > 0: sys.exit(return_code)
[ "def", "build", "(", "ctx", ")", ":", "return_code", "=", "run_sphinx", "(", "ctx", ".", "obj", "[", "'root_dir'", "]", ")", "if", "return_code", ">", "0", ":", "sys", ".", "exit", "(", "return_code", ")" ]
Build documentation as HTML. The build HTML site is located in the ``doc/_build/html`` directory of the package.
[ "Build", "documentation", "as", "HTML", "." ]
75f02901a80042b28d074df1cc1dca32eb8e38c8
https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/stackdocs/packagecli.py#L97-L105
train
Build documentation as HTML.
potash/drain
drain/aggregate.py
days
def days(date1, date2): """ returns a lambda that determines the number of days between the two dates the dates can be strings (column names) or actual dates e.g. Aggregate(days('date', today), ['min','max'], 'days_since') TODO: should there be a Days(AggregateBase) for this? handle naming """ ...
python
def days(date1, date2): """ returns a lambda that determines the number of days between the two dates the dates can be strings (column names) or actual dates e.g. Aggregate(days('date', today), ['min','max'], 'days_since') TODO: should there be a Days(AggregateBase) for this? handle naming """ ...
[ "def", "days", "(", "date1", ",", "date2", ")", ":", "return", "lambda", "df", ",", "date1", "=", "date1", ",", "date2", "=", "date2", ":", "_days", "(", "df", ",", "date1", ",", "date2", ")" ]
returns a lambda that determines the number of days between the two dates the dates can be strings (column names) or actual dates e.g. Aggregate(days('date', today), ['min','max'], 'days_since') TODO: should there be a Days(AggregateBase) for this? handle naming
[ "returns", "a", "lambda", "that", "determines", "the", "number", "of", "days", "between", "the", "two", "dates", "the", "dates", "can", "be", "strings", "(", "column", "names", ")", "or", "actual", "dates", "e", ".", "g", ".", "Aggregate", "(", "days", ...
ddd62081cb9317beb5d21f86c8b4bb196ca3d222
https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/aggregate.py#L475-L482
train
Returns a lambda that determines the number of days between two dates.
potash/drain
drain/aggregate.py
ColumnFunction.apply_and_name
def apply_and_name(self, aggregator): """Fetches the row-aggregated input columns for this ColumnFunction. Args: aggregator (Aggregator) Returns: pd.DataFrame: The dataframe has columns with names self.names that were created by this ColumnFunction, ...
python
def apply_and_name(self, aggregator): """Fetches the row-aggregated input columns for this ColumnFunction. Args: aggregator (Aggregator) Returns: pd.DataFrame: The dataframe has columns with names self.names that were created by this ColumnFunction, ...
[ "def", "apply_and_name", "(", "self", ",", "aggregator", ")", ":", "reduced_df", "=", "self", ".", "_apply", "(", "aggregator", ")", "if", "len", "(", "self", ".", "names", ")", "!=", "len", "(", "reduced_df", ".", "columns", ")", ":", "raise", "IndexE...
Fetches the row-aggregated input columns for this ColumnFunction. Args: aggregator (Aggregator) Returns: pd.DataFrame: The dataframe has columns with names self.names that were created by this ColumnFunction, and is indexed by the index that was ...
[ "Fetches", "the", "row", "-", "aggregated", "input", "columns", "for", "this", "ColumnFunction", "." ]
ddd62081cb9317beb5d21f86c8b4bb196ca3d222
https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/aggregate.py#L106-L122
train
Fetches the row - aggregated input columns for this ColumnFunction and returns a reduced dataframe with the names of the columns that were created by this ColumnFunction.
potash/drain
drain/aggregate.py
Aggregator.get_reduced
def get_reduced(self, column_reductions): """This function gets called by ColumnFunction._apply(). After a ColumnFunction has been passed to Aggregator's constructor, the ColumnFunction can use this function to request the populated, aggregated columns that correspond to its ColumnReductions. ...
python
def get_reduced(self, column_reductions): """This function gets called by ColumnFunction._apply(). After a ColumnFunction has been passed to Aggregator's constructor, the ColumnFunction can use this function to request the populated, aggregated columns that correspond to its ColumnReductions. ...
[ "def", "get_reduced", "(", "self", ",", "column_reductions", ")", ":", "for", "cr", "in", "column_reductions", ":", "if", "cr", "not", "in", "self", ".", "column_reductions", ":", "raise", "ValueError", "(", "\"Column reduction %r is not known to this Aggregator!\"", ...
This function gets called by ColumnFunction._apply(). After a ColumnFunction has been passed to Aggregator's constructor, the ColumnFunction can use this function to request the populated, aggregated columns that correspond to its ColumnReductions. Args: column_reduction (list[Colum...
[ "This", "function", "gets", "called", "by", "ColumnFunction", ".", "_apply", "()", ".", "After", "a", "ColumnFunction", "has", "been", "passed", "to", "Aggregator", "s", "constructor", "the", "ColumnFunction", "can", "use", "this", "function", "to", "request", ...
ddd62081cb9317beb5d21f86c8b4bb196ca3d222
https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/aggregate.py#L244-L258
train
This function gets called by ColumnFunction. _apply.
potash/drain
drain/aggregate.py
Aggregator.aggregate
def aggregate(self, index): """Performs a groupby of the unique Columns by index, as constructed from self.df. Args: index (str, or pd.Index): Index or column name of self.df. Returns: pd.DataFrame: A dataframe, aggregated by index, that contains the result ...
python
def aggregate(self, index): """Performs a groupby of the unique Columns by index, as constructed from self.df. Args: index (str, or pd.Index): Index or column name of self.df. Returns: pd.DataFrame: A dataframe, aggregated by index, that contains the result ...
[ "def", "aggregate", "(", "self", ",", "index", ")", ":", "# deal with index as a string vs index as a index/MultiIndex", "if", "isinstance", "(", "index", ",", "string_types", ")", ":", "col_df_grouped", "=", "self", ".", "col_df", ".", "groupby", "(", "self", "."...
Performs a groupby of the unique Columns by index, as constructed from self.df. Args: index (str, or pd.Index): Index or column name of self.df. Returns: pd.DataFrame: A dataframe, aggregated by index, that contains the result of the various ColumnFunctions, and...
[ "Performs", "a", "groupby", "of", "the", "unique", "Columns", "by", "index", "as", "constructed", "from", "self", ".", "df", "." ]
ddd62081cb9317beb5d21f86c8b4bb196ca3d222
https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/aggregate.py#L260-L291
train
Performs a groupby of the unique Columns by index and returns a dataframe that contains the result of the column functions and named accordingly.
potash/drain
drain/aggregate.py
Fraction._apply
def _apply(self, aggregator): """Returns a dataframe with the requested ColumnReductions. """ reduced_dfs = [] if self.include_fraction: n_df = self.numerator.apply_and_name(aggregator) d_df = self.denominator.apply_and_name(aggregator) reduced_dfs.ex...
python
def _apply(self, aggregator): """Returns a dataframe with the requested ColumnReductions. """ reduced_dfs = [] if self.include_fraction: n_df = self.numerator.apply_and_name(aggregator) d_df = self.denominator.apply_and_name(aggregator) reduced_dfs.ex...
[ "def", "_apply", "(", "self", ",", "aggregator", ")", ":", "reduced_dfs", "=", "[", "]", "if", "self", ".", "include_fraction", ":", "n_df", "=", "self", ".", "numerator", ".", "apply_and_name", "(", "aggregator", ")", "d_df", "=", "self", ".", "denomina...
Returns a dataframe with the requested ColumnReductions.
[ "Returns", "a", "dataframe", "with", "the", "requested", "ColumnReductions", "." ]
ddd62081cb9317beb5d21f86c8b4bb196ca3d222
https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/aggregate.py#L350-L367
train
Returns a dataframe with the requested ColumnReductions.
fkarb/xltable
xltable/table.py
Table.clone
def clone(self, **kwargs): """Create a clone of the Table, optionally with some properties changed""" init_kwargs = { "name": self.__name, "dataframe": self.__df, "include_columns": self.__include_columns, "include_index": self.__include_index, ...
python
def clone(self, **kwargs): """Create a clone of the Table, optionally with some properties changed""" init_kwargs = { "name": self.__name, "dataframe": self.__df, "include_columns": self.__include_columns, "include_index": self.__include_index, ...
[ "def", "clone", "(", "self", ",", "*", "*", "kwargs", ")", ":", "init_kwargs", "=", "{", "\"name\"", ":", "self", ".", "__name", ",", "\"dataframe\"", ":", "self", ".", "__df", ",", "\"include_columns\"", ":", "self", ".", "__include_columns", ",", "\"in...
Create a clone of the Table, optionally with some properties changed
[ "Create", "a", "clone", "of", "the", "Table", "optionally", "with", "some", "properties", "changed" ]
7a592642d27ad5ee90d2aa8c26338abaa9d84bea
https://github.com/fkarb/xltable/blob/7a592642d27ad5ee90d2aa8c26338abaa9d84bea/xltable/table.py#L105-L120
train
Create a clone of the Table optionally with some properties changed
fkarb/xltable
xltable/table.py
Table.cell_styles
def cell_styles(self): """dict of {(row name, col name): style}""" styles = {} for colname, col in self.dataframe.items(): for rowname, value in col.items(): if isinstance(value, Value) and value.style is not None: style = value.style ...
python
def cell_styles(self): """dict of {(row name, col name): style}""" styles = {} for colname, col in self.dataframe.items(): for rowname, value in col.items(): if isinstance(value, Value) and value.style is not None: style = value.style ...
[ "def", "cell_styles", "(", "self", ")", ":", "styles", "=", "{", "}", "for", "colname", ",", "col", "in", "self", ".", "dataframe", ".", "items", "(", ")", ":", "for", "rowname", ",", "value", "in", "col", ".", "items", "(", ")", ":", "if", "isin...
dict of {(row name, col name): style}
[ "dict", "of", "{", "(", "row", "name", "col", "name", ")", ":", "style", "}" ]
7a592642d27ad5ee90d2aa8c26338abaa9d84bea
https://github.com/fkarb/xltable/blob/7a592642d27ad5ee90d2aa8c26338abaa9d84bea/xltable/table.py#L147-L157
train
dict of cell styles
fkarb/xltable
xltable/table.py
Table.get_data
def get_data(self, workbook, row, col, formula_values={}): """ :return: 2d numpy array for this table with any formulas resolved to the final excel formula. :param xltable.Workbook workbook: Workbook the table has been added to. :param int row: Row where the table will s...
python
def get_data(self, workbook, row, col, formula_values={}): """ :return: 2d numpy array for this table with any formulas resolved to the final excel formula. :param xltable.Workbook workbook: Workbook the table has been added to. :param int row: Row where the table will s...
[ "def", "get_data", "(", "self", ",", "workbook", ",", "row", ",", "col", ",", "formula_values", "=", "{", "}", ")", ":", "if", "workbook", ":", "prev_table", "=", "workbook", ".", "active_table", "workbook", ".", "active_table", "=", "self", "try", ":", ...
:return: 2d numpy array for this table with any formulas resolved to the final excel formula. :param xltable.Workbook workbook: Workbook the table has been added to. :param int row: Row where the table will start in the sheet (used for resolving formulas). :param int col: Column...
[ ":", "return", ":", "2d", "numpy", "array", "for", "this", "table", "with", "any", "formulas", "resolved", "to", "the", "final", "excel", "formula", ".", ":", "param", "xltable", ".", "Workbook", "workbook", ":", "Workbook", "the", "table", "has", "been", ...
7a592642d27ad5ee90d2aa8c26338abaa9d84bea
https://github.com/fkarb/xltable/blob/7a592642d27ad5ee90d2aa8c26338abaa9d84bea/xltable/table.py#L204-L220
train
Get the data for this table with any formulas resolved to the final excel formula.
mojaie/chorus
chorus/v2000reader.py
inspect
def inspect(lines): """Inspect SDFile list of string Returns: tuple: (data label list, number of records) """ labels = set() count = 0 exp = re.compile(r">.*?<([\w ]+)>") # Space should be accepted valid = False for line in lines: if line.startswith("M END\n"): ...
python
def inspect(lines): """Inspect SDFile list of string Returns: tuple: (data label list, number of records) """ labels = set() count = 0 exp = re.compile(r">.*?<([\w ]+)>") # Space should be accepted valid = False for line in lines: if line.startswith("M END\n"): ...
[ "def", "inspect", "(", "lines", ")", ":", "labels", "=", "set", "(", ")", "count", "=", "0", "exp", "=", "re", ".", "compile", "(", "r\">.*?<([\\w ]+)>\"", ")", "# Space should be accepted", "valid", "=", "False", "for", "line", "in", "lines", ":", "if",...
Inspect SDFile list of string Returns: tuple: (data label list, number of records)
[ "Inspect", "SDFile", "list", "of", "string" ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/v2000reader.py#L17-L39
train
Inspect SDFile list of string Returns tuple of data label list and number of records
mojaie/chorus
chorus/v2000reader.py
inspect_file
def inspect_file(path): """Inspect SDFile structure Returns: tuple: (data label list, number of records) """ with open(path, 'rb') as f: labels, count = inspect(tx.decode(line) for line in f) return labels, count
python
def inspect_file(path): """Inspect SDFile structure Returns: tuple: (data label list, number of records) """ with open(path, 'rb') as f: labels, count = inspect(tx.decode(line) for line in f) return labels, count
[ "def", "inspect_file", "(", "path", ")", ":", "with", "open", "(", "path", ",", "'rb'", ")", "as", "f", ":", "labels", ",", "count", "=", "inspect", "(", "tx", ".", "decode", "(", "line", ")", "for", "line", "in", "f", ")", "return", "labels", ",...
Inspect SDFile structure Returns: tuple: (data label list, number of records)
[ "Inspect", "SDFile", "structure" ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/v2000reader.py#L49-L57
train
Inspect SDFile structure
mojaie/chorus
chorus/v2000reader.py
optional_data
def optional_data(lines): """Parse SDFile data part into dict""" data = {} exp = re.compile(r">.*?<([\w ]+)>") # Space should be accepted for i, line in enumerate(lines): result = exp.match(line) if result: data[result.group(1)] = lines[i + 1] return data
python
def optional_data(lines): """Parse SDFile data part into dict""" data = {} exp = re.compile(r">.*?<([\w ]+)>") # Space should be accepted for i, line in enumerate(lines): result = exp.match(line) if result: data[result.group(1)] = lines[i + 1] return data
[ "def", "optional_data", "(", "lines", ")", ":", "data", "=", "{", "}", "exp", "=", "re", ".", "compile", "(", "r\">.*?<([\\w ]+)>\"", ")", "# Space should be accepted", "for", "i", ",", "line", "in", "enumerate", "(", "lines", ")", ":", "result", "=", "e...
Parse SDFile data part into dict
[ "Parse", "SDFile", "data", "part", "into", "dict" ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/v2000reader.py#L60-L68
train
Parse SDFile data part into dict
mojaie/chorus
chorus/v2000reader.py
atoms
def atoms(lines): """Parse atom block into atom objects Returns: dict: networkx nodes """ # Convert sdf style charge to actual charge conv_charge_table = {0: 0, 1: 3, 2: 2, 3: 1, 4: 0, 5: -1, 6: -2, 7: -3} results = {} for i, line in enumerate(lines): symbol = line[31:34].rs...
python
def atoms(lines): """Parse atom block into atom objects Returns: dict: networkx nodes """ # Convert sdf style charge to actual charge conv_charge_table = {0: 0, 1: 3, 2: 2, 3: 1, 4: 0, 5: -1, 6: -2, 7: -3} results = {} for i, line in enumerate(lines): symbol = line[31:34].rs...
[ "def", "atoms", "(", "lines", ")", ":", "# Convert sdf style charge to actual charge", "conv_charge_table", "=", "{", "0", ":", "0", ",", "1", ":", "3", ",", "2", ":", "2", ",", "3", ":", "1", ",", "4", ":", "0", ",", "5", ":", "-", "1", ",", "6"...
Parse atom block into atom objects Returns: dict: networkx nodes
[ "Parse", "atom", "block", "into", "atom", "objects" ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/v2000reader.py#L71-L100
train
Parse atom block into atom objects
mojaie/chorus
chorus/v2000reader.py
bonds
def bonds(lines, atoms): """Parse bond block into bond objects Returns: dict: networkx adjacency dict """ # Convert sdf style stereobond (see chem.model.bond.Bond) conv_stereo_table = {0: 0, 1: 1, 3: 3, 4: 3, 6: 2} results = {a: {} for a in atoms} for line in lines: bond = B...
python
def bonds(lines, atoms): """Parse bond block into bond objects Returns: dict: networkx adjacency dict """ # Convert sdf style stereobond (see chem.model.bond.Bond) conv_stereo_table = {0: 0, 1: 1, 3: 3, 4: 3, 6: 2} results = {a: {} for a in atoms} for line in lines: bond = B...
[ "def", "bonds", "(", "lines", ",", "atoms", ")", ":", "# Convert sdf style stereobond (see chem.model.bond.Bond)", "conv_stereo_table", "=", "{", "0", ":", "0", ",", "1", ":", "1", ",", "3", ":", "3", ",", "4", ":", "3", ",", "6", ":", "2", "}", "resul...
Parse bond block into bond objects Returns: dict: networkx adjacency dict
[ "Parse", "bond", "block", "into", "bond", "objects" ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/v2000reader.py#L103-L124
train
Parse bond block into bond objects
mojaie/chorus
chorus/v2000reader.py
properties
def properties(lines): """Parse properties block Returns: dict: {property_type: (atom_index, value)} """ results = {} for i, line in enumerate(lines): type_ = line[3:6] if type_ not in ["CHG", "RAD", "ISO"]: continue # Other properties are not supported yet ...
python
def properties(lines): """Parse properties block Returns: dict: {property_type: (atom_index, value)} """ results = {} for i, line in enumerate(lines): type_ = line[3:6] if type_ not in ["CHG", "RAD", "ISO"]: continue # Other properties are not supported yet ...
[ "def", "properties", "(", "lines", ")", ":", "results", "=", "{", "}", "for", "i", ",", "line", "in", "enumerate", "(", "lines", ")", ":", "type_", "=", "line", "[", "3", ":", "6", "]", "if", "type_", "not", "in", "[", "\"CHG\"", ",", "\"RAD\"", ...
Parse properties block Returns: dict: {property_type: (atom_index, value)}
[ "Parse", "properties", "block" ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/v2000reader.py#L127-L144
train
Parse properties block
mojaie/chorus
chorus/v2000reader.py
add_properties
def add_properties(props, mol): """apply properties to the molecule object Returns: None (alter molecule object directly) """ if not props: return # The properties supersedes all charge and radical values in the atom block for _, atom in mol.atoms_iter(): atom.charge = 0...
python
def add_properties(props, mol): """apply properties to the molecule object Returns: None (alter molecule object directly) """ if not props: return # The properties supersedes all charge and radical values in the atom block for _, atom in mol.atoms_iter(): atom.charge = 0...
[ "def", "add_properties", "(", "props", ",", "mol", ")", ":", "if", "not", "props", ":", "return", "# The properties supersedes all charge and radical values in the atom block", "for", "_", ",", "atom", "in", "mol", ".", "atoms_iter", "(", ")", ":", "atom", ".", ...
apply properties to the molecule object Returns: None (alter molecule object directly)
[ "apply", "properties", "to", "the", "molecule", "object" ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/v2000reader.py#L147-L165
train
apply properties to the molecule object Returns None if the properties are not set
mojaie/chorus
chorus/v2000reader.py
molecule
def molecule(lines): """Parse molfile part into molecule object Args: lines (list): lines of molfile part Raises: ValueError: Symbol not defined in periodictable.yaml (Polymer expression not supported yet) """ count_line = lines[3] num_atoms = int(count_line...
python
def molecule(lines): """Parse molfile part into molecule object Args: lines (list): lines of molfile part Raises: ValueError: Symbol not defined in periodictable.yaml (Polymer expression not supported yet) """ count_line = lines[3] num_atoms = int(count_line...
[ "def", "molecule", "(", "lines", ")", ":", "count_line", "=", "lines", "[", "3", "]", "num_atoms", "=", "int", "(", "count_line", "[", "0", ":", "3", "]", ")", "num_bonds", "=", "int", "(", "count_line", "[", "3", ":", "6", "]", ")", "# chiral_flag...
Parse molfile part into molecule object Args: lines (list): lines of molfile part Raises: ValueError: Symbol not defined in periodictable.yaml (Polymer expression not supported yet)
[ "Parse", "molfile", "part", "into", "molecule", "object" ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/v2000reader.py#L168-L189
train
Parse a molecule part into a new object
mojaie/chorus
chorus/v2000reader.py
mol_supplier
def mol_supplier(lines, no_halt, assign_descriptors): """Yields molecules generated from CTAB text Args: lines (iterable): CTAB text lines no_halt (boolean): True: shows warning messages for invalid format and go on. False: throws an exception for it and stop parsing. ...
python
def mol_supplier(lines, no_halt, assign_descriptors): """Yields molecules generated from CTAB text Args: lines (iterable): CTAB text lines no_halt (boolean): True: shows warning messages for invalid format and go on. False: throws an exception for it and stop parsing. ...
[ "def", "mol_supplier", "(", "lines", ",", "no_halt", ",", "assign_descriptors", ")", ":", "def", "sdf_block", "(", "lns", ")", ":", "mol", "=", "[", "]", "opt", "=", "[", "]", "is_mol", "=", "True", "for", "line", "in", "lns", ":", "if", "line", "....
Yields molecules generated from CTAB text Args: lines (iterable): CTAB text lines no_halt (boolean): True: shows warning messages for invalid format and go on. False: throws an exception for it and stop parsing. assign_descriptors (boolean): if True, defa...
[ "Yields", "molecules", "generated", "from", "CTAB", "text" ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/v2000reader.py#L192-L253
train
Yields molecules generated from CTAB text lines.
mojaie/chorus
chorus/v2000reader.py
mols_from_text
def mols_from_text(text, no_halt=True, assign_descriptors=True): """Returns molecules generated from sdfile text Throws: StopIteration: if the text does not have molecule ValueError: if Unsupported symbol is found """ if isinstance(text, bytes): t = tx.decode(text) else: ...
python
def mols_from_text(text, no_halt=True, assign_descriptors=True): """Returns molecules generated from sdfile text Throws: StopIteration: if the text does not have molecule ValueError: if Unsupported symbol is found """ if isinstance(text, bytes): t = tx.decode(text) else: ...
[ "def", "mols_from_text", "(", "text", ",", "no_halt", "=", "True", ",", "assign_descriptors", "=", "True", ")", ":", "if", "isinstance", "(", "text", ",", "bytes", ")", ":", "t", "=", "tx", ".", "decode", "(", "text", ")", "else", ":", "t", "=", "t...
Returns molecules generated from sdfile text Throws: StopIteration: if the text does not have molecule ValueError: if Unsupported symbol is found
[ "Returns", "molecules", "generated", "from", "sdfile", "text" ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/v2000reader.py#L256-L271
train
Returns a generator of molecules generated from the given text.
mojaie/chorus
chorus/v2000reader.py
mol_from_text
def mol_from_text(text, assign_descriptors=True): """Parse CTAB text and return first one as a Compound object. Throws: StopIteration: if the text does not have molecule ValueError: if Unsupported symbol is found """ cg = mols_from_text(text, False, assign_descriptors) return next(c...
python
def mol_from_text(text, assign_descriptors=True): """Parse CTAB text and return first one as a Compound object. Throws: StopIteration: if the text does not have molecule ValueError: if Unsupported symbol is found """ cg = mols_from_text(text, False, assign_descriptors) return next(c...
[ "def", "mol_from_text", "(", "text", ",", "assign_descriptors", "=", "True", ")", ":", "cg", "=", "mols_from_text", "(", "text", ",", "False", ",", "assign_descriptors", ")", "return", "next", "(", "cg", ")" ]
Parse CTAB text and return first one as a Compound object. Throws: StopIteration: if the text does not have molecule ValueError: if Unsupported symbol is found
[ "Parse", "CTAB", "text", "and", "return", "first", "one", "as", "a", "Compound", "object", "." ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/v2000reader.py#L274-L282
train
Parse CTAB text and return first one as a Compound object.
mojaie/chorus
chorus/v2000reader.py
mols_from_file
def mols_from_file(path, no_halt=True, assign_descriptors=True): """Compound supplier from CTAB text file (.mol, .sdf)""" with open(path, 'rb') as f: fd = (tx.decode(line) for line in f) for c in mol_supplier(fd, no_halt, assign_descriptors): yield c
python
def mols_from_file(path, no_halt=True, assign_descriptors=True): """Compound supplier from CTAB text file (.mol, .sdf)""" with open(path, 'rb') as f: fd = (tx.decode(line) for line in f) for c in mol_supplier(fd, no_halt, assign_descriptors): yield c
[ "def", "mols_from_file", "(", "path", ",", "no_halt", "=", "True", ",", "assign_descriptors", "=", "True", ")", ":", "with", "open", "(", "path", ",", "'rb'", ")", "as", "f", ":", "fd", "=", "(", "tx", ".", "decode", "(", "line", ")", "for", "line"...
Compound supplier from CTAB text file (.mol, .sdf)
[ "Compound", "supplier", "from", "CTAB", "text", "file", "(", ".", "mol", ".", "sdf", ")" ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/v2000reader.py#L285-L290
train
Yields all Molecules from CTAB text file.
mojaie/chorus
chorus/v2000reader.py
mol_from_file
def mol_from_file(path, assign_descriptors=True): """Parse CTAB file and return first one as a Compound object.""" cs = mols_from_file(path, False, assign_descriptors) return next(cs)
python
def mol_from_file(path, assign_descriptors=True): """Parse CTAB file and return first one as a Compound object.""" cs = mols_from_file(path, False, assign_descriptors) return next(cs)
[ "def", "mol_from_file", "(", "path", ",", "assign_descriptors", "=", "True", ")", ":", "cs", "=", "mols_from_file", "(", "path", ",", "False", ",", "assign_descriptors", ")", "return", "next", "(", "cs", ")" ]
Parse CTAB file and return first one as a Compound object.
[ "Parse", "CTAB", "file", "and", "return", "first", "one", "as", "a", "Compound", "object", "." ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/v2000reader.py#L293-L296
train
Parse CTAB file and return first one as a Compound object.
brutus/wdiffhtml
wdiffhtml/settings.py
load_from_resource
def load_from_resource(name): """ Returns the contents of a file resource. If the resource exists in the users data directory, it is used instead of the default resource. """ filepath = Path(USER_DIR) / name if filepath.exists(): with filepath.open() as fh: return fh.read() else: return ...
python
def load_from_resource(name): """ Returns the contents of a file resource. If the resource exists in the users data directory, it is used instead of the default resource. """ filepath = Path(USER_DIR) / name if filepath.exists(): with filepath.open() as fh: return fh.read() else: return ...
[ "def", "load_from_resource", "(", "name", ")", ":", "filepath", "=", "Path", "(", "USER_DIR", ")", "/", "name", "if", "filepath", ".", "exists", "(", ")", ":", "with", "filepath", ".", "open", "(", ")", "as", "fh", ":", "return", "fh", ".", "read", ...
Returns the contents of a file resource. If the resource exists in the users data directory, it is used instead of the default resource.
[ "Returns", "the", "contents", "of", "a", "file", "resource", "." ]
e97b524a7945f7a626e33ec141343120c524d9fa
https://github.com/brutus/wdiffhtml/blob/e97b524a7945f7a626e33ec141343120c524d9fa/wdiffhtml/settings.py#L40-L53
train
Load a resource from the users data directory.
micolous/python-slackrealtime
src/slackrealtime/__init__.py
connect
def connect(token, protocol=RtmProtocol, factory=WebSocketClientFactory, factory_kwargs=None, api_url=None, debug=False): """ Creates a new connection to the Slack Real-Time API. Returns (connection) which represents this connection to the API server. """ if factory_kwargs is None: factory_kwargs = dict() me...
python
def connect(token, protocol=RtmProtocol, factory=WebSocketClientFactory, factory_kwargs=None, api_url=None, debug=False): """ Creates a new connection to the Slack Real-Time API. Returns (connection) which represents this connection to the API server. """ if factory_kwargs is None: factory_kwargs = dict() me...
[ "def", "connect", "(", "token", ",", "protocol", "=", "RtmProtocol", ",", "factory", "=", "WebSocketClientFactory", ",", "factory_kwargs", "=", "None", ",", "api_url", "=", "None", ",", "debug", "=", "False", ")", ":", "if", "factory_kwargs", "is", "None", ...
Creates a new connection to the Slack Real-Time API. Returns (connection) which represents this connection to the API server.
[ "Creates", "a", "new", "connection", "to", "the", "Slack", "Real", "-", "Time", "API", "." ]
e9c94416f979a6582110ebba09c147de2bfe20a1
https://github.com/micolous/python-slackrealtime/blob/e9c94416f979a6582110ebba09c147de2bfe20a1/src/slackrealtime/__init__.py#L26-L43
train
Creates a new connection to the Slack Real - Time API.
xlfe/reticul8
python/reticul8/block_compressor.py
block_compressor.next_block
def next_block(self): """ This could probably be improved; at the moment it starts by trying to overshoot the desired compressed block size, then it reduces the input bytes one by one until it has met the required block size """ assert self.pos <= self.input_len ...
python
def next_block(self): """ This could probably be improved; at the moment it starts by trying to overshoot the desired compressed block size, then it reduces the input bytes one by one until it has met the required block size """ assert self.pos <= self.input_len ...
[ "def", "next_block", "(", "self", ")", ":", "assert", "self", ".", "pos", "<=", "self", ".", "input_len", "if", "self", ".", "pos", "==", "self", ".", "input_len", ":", "return", "None", "# Overshoot", "i", "=", "self", ".", "START_OVERSHOOT", "while", ...
This could probably be improved; at the moment it starts by trying to overshoot the desired compressed block size, then it reduces the input bytes one by one until it has met the required block size
[ "This", "could", "probably", "be", "improved", ";", "at", "the", "moment", "it", "starts", "by", "trying", "to", "overshoot", "the", "desired", "compressed", "block", "size", "then", "it", "reduces", "the", "input", "bytes", "one", "by", "one", "until", "i...
0f9503f7a0731ae09adfe4c9af9b57327a7f9d84
https://github.com/xlfe/reticul8/blob/0f9503f7a0731ae09adfe4c9af9b57327a7f9d84/python/reticul8/block_compressor.py#L57-L101
train
This function takes the next compressed block of size and returns the CRC32 size and the size of the compressed block.
mesbahamin/chronophore
chronophore/chronophore.py
get_args
def get_args(): """Parse command line arguments.""" parser = argparse.ArgumentParser( prog=__title__, description=__description__, ) parser.add_argument( '--testdb', action='store_true', help='create and use a database with test users' ) parser.add_argument( ...
python
def get_args(): """Parse command line arguments.""" parser = argparse.ArgumentParser( prog=__title__, description=__description__, ) parser.add_argument( '--testdb', action='store_true', help='create and use a database with test users' ) parser.add_argument( ...
[ "def", "get_args", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "prog", "=", "__title__", ",", "description", "=", "__description__", ",", ")", "parser", ".", "add_argument", "(", "'--testdb'", ",", "action", "=", "'store_true'", ","...
Parse command line arguments.
[ "Parse", "command", "line", "arguments", "." ]
ee140c61b4dfada966f078de8304bac737cec6f7
https://github.com/mesbahamin/chronophore/blob/ee140c61b4dfada966f078de8304bac737cec6f7/chronophore/chronophore.py#L15-L45
train
Parse command line arguments.
mesbahamin/chronophore
chronophore/chronophore.py
set_up_logging
def set_up_logging(log_file, console_log_level): """Configure logging settings and return a logger object.""" logger = logging.getLogger() logger.setLevel(logging.DEBUG) fh = logging.FileHandler(str(log_file)) fh.setLevel(logging.DEBUG) ch = logging.StreamHandler() ch.setLevel(console_log_le...
python
def set_up_logging(log_file, console_log_level): """Configure logging settings and return a logger object.""" logger = logging.getLogger() logger.setLevel(logging.DEBUG) fh = logging.FileHandler(str(log_file)) fh.setLevel(logging.DEBUG) ch = logging.StreamHandler() ch.setLevel(console_log_le...
[ "def", "set_up_logging", "(", "log_file", ",", "console_log_level", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", ")", "logger", ".", "setLevel", "(", "logging", ".", "DEBUG", ")", "fh", "=", "logging", ".", "FileHandler", "(", "str", "(", "...
Configure logging settings and return a logger object.
[ "Configure", "logging", "settings", "and", "return", "a", "logger", "object", "." ]
ee140c61b4dfada966f078de8304bac737cec6f7
https://github.com/mesbahamin/chronophore/blob/ee140c61b4dfada966f078de8304bac737cec6f7/chronophore/chronophore.py#L48-L64
train
Configure logging settings and return a logger object.
mesbahamin/chronophore
chronophore/chronophore.py
main
def main(): """Run Chronophore based on the command line arguments.""" args = get_args() # Make Chronophore's directories and files in $HOME DATA_DIR = pathlib.Path(appdirs.user_data_dir(__title__)) LOG_FILE = pathlib.Path(appdirs.user_log_dir(__title__), 'debug.log') os.makedirs(str(DATA_DIR),...
python
def main(): """Run Chronophore based on the command line arguments.""" args = get_args() # Make Chronophore's directories and files in $HOME DATA_DIR = pathlib.Path(appdirs.user_data_dir(__title__)) LOG_FILE = pathlib.Path(appdirs.user_log_dir(__title__), 'debug.log') os.makedirs(str(DATA_DIR),...
[ "def", "main", "(", ")", ":", "args", "=", "get_args", "(", ")", "# Make Chronophore's directories and files in $HOME", "DATA_DIR", "=", "pathlib", ".", "Path", "(", "appdirs", ".", "user_data_dir", "(", "__title__", ")", ")", "LOG_FILE", "=", "pathlib", ".", ...
Run Chronophore based on the command line arguments.
[ "Run", "Chronophore", "based", "on", "the", "command", "line", "arguments", "." ]
ee140c61b4dfada966f078de8304bac737cec6f7
https://github.com/mesbahamin/chronophore/blob/ee140c61b4dfada966f078de8304bac737cec6f7/chronophore/chronophore.py#L67-L134
train
Run Chronophore based on the command line arguments.
zsimic/runez
src/runez/logsetup.py
_replace_and_pad
def _replace_and_pad(fmt, marker, replacement): """ Args: fmt (str | unicode): Format to tweak marker (str | unicode): Marker to replace replacement (str | unicode): What to replace marker with Returns: (str): Resulting format, with marker replaced """ if marker not ...
python
def _replace_and_pad(fmt, marker, replacement): """ Args: fmt (str | unicode): Format to tweak marker (str | unicode): Marker to replace replacement (str | unicode): What to replace marker with Returns: (str): Resulting format, with marker replaced """ if marker not ...
[ "def", "_replace_and_pad", "(", "fmt", ",", "marker", ",", "replacement", ")", ":", "if", "marker", "not", "in", "fmt", ":", "return", "fmt", "if", "replacement", ":", "return", "fmt", ".", "replace", "(", "marker", ",", "replacement", ")", "# Remove menti...
Args: fmt (str | unicode): Format to tweak marker (str | unicode): Marker to replace replacement (str | unicode): What to replace marker with Returns: (str): Resulting format, with marker replaced
[ "Args", ":", "fmt", "(", "str", "|", "unicode", ")", ":", "Format", "to", "tweak", "marker", "(", "str", "|", "unicode", ")", ":", "Marker", "to", "replace", "replacement", "(", "str", "|", "unicode", ")", ":", "What", "to", "replace", "marker", "wit...
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/logsetup.py#L494-L510
train
Replace marker in a string with replacement.
zsimic/runez
src/runez/logsetup.py
_get_formatter
def _get_formatter(fmt): """ Args: fmt (str | unicode): Format specification Returns: (logging.Formatter): Associated logging formatter """ fmt = _replace_and_pad(fmt, "%(timezone)s", LogManager.spec.timezone) return logging.Formatter(fmt)
python
def _get_formatter(fmt): """ Args: fmt (str | unicode): Format specification Returns: (logging.Formatter): Associated logging formatter """ fmt = _replace_and_pad(fmt, "%(timezone)s", LogManager.spec.timezone) return logging.Formatter(fmt)
[ "def", "_get_formatter", "(", "fmt", ")", ":", "fmt", "=", "_replace_and_pad", "(", "fmt", ",", "\"%(timezone)s\"", ",", "LogManager", ".", "spec", ".", "timezone", ")", "return", "logging", ".", "Formatter", "(", "fmt", ")" ]
Args: fmt (str | unicode): Format specification Returns: (logging.Formatter): Associated logging formatter
[ "Args", ":", "fmt", "(", "str", "|", "unicode", ")", ":", "Format", "specification" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/logsetup.py#L513-L522
train
Returns a new formatter object for the given format specification.
zsimic/runez
src/runez/logsetup.py
_get_file_handler
def _get_file_handler(location, rotate, rotate_count): """ Args: location (str | unicode | None): Log file path rotate (str | unicode | None): How to rotate, examples: time:midnight - Rotate at midnight time:15s - Rotate every 15 seconds time:2h - Rotate every...
python
def _get_file_handler(location, rotate, rotate_count): """ Args: location (str | unicode | None): Log file path rotate (str | unicode | None): How to rotate, examples: time:midnight - Rotate at midnight time:15s - Rotate every 15 seconds time:2h - Rotate every...
[ "def", "_get_file_handler", "(", "location", ",", "rotate", ",", "rotate_count", ")", ":", "if", "not", "rotate", ":", "return", "logging", ".", "FileHandler", "(", "location", ")", "kind", ",", "_", ",", "mode", "=", "rotate", ".", "partition", "(", "\"...
Args: location (str | unicode | None): Log file path rotate (str | unicode | None): How to rotate, examples: time:midnight - Rotate at midnight time:15s - Rotate every 15 seconds time:2h - Rotate every 2 hours time:7d - Rotate every 7 days size...
[ "Args", ":", "location", "(", "str", "|", "unicode", "|", "None", ")", ":", "Log", "file", "path", "rotate", "(", "str", "|", "unicode", "|", "None", ")", ":", "How", "to", "rotate", "examples", ":", "time", ":", "midnight", "-", "Rotate", "at", "m...
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/logsetup.py#L525-L570
train
Returns a handler for the log file.
zsimic/runez
src/runez/logsetup.py
LoggingSnapshot._seed
def _seed(self): """Seed initial fields""" for name in self.__slots__: setattr(self, name, getattr(logging, name))
python
def _seed(self): """Seed initial fields""" for name in self.__slots__: setattr(self, name, getattr(logging, name))
[ "def", "_seed", "(", "self", ")", ":", "for", "name", "in", "self", ".", "__slots__", ":", "setattr", "(", "self", ",", "name", ",", "getattr", "(", "logging", ",", "name", ")", ")" ]
Seed initial fields
[ "Seed", "initial", "fields" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/logsetup.py#L40-L43
train
Seed initial fields
zsimic/runez
src/runez/logsetup.py
LogSpec.usable_location
def usable_location(self): """ Returns: str | None: First available usable location """ if self.file_location is not None: # Custom location typically provided via --config CLI flag return self._auto_complete_filename(self.file_location) if sel...
python
def usable_location(self): """ Returns: str | None: First available usable location """ if self.file_location is not None: # Custom location typically provided via --config CLI flag return self._auto_complete_filename(self.file_location) if sel...
[ "def", "usable_location", "(", "self", ")", ":", "if", "self", ".", "file_location", "is", "not", "None", ":", "# Custom location typically provided via --config CLI flag", "return", "self", ".", "_auto_complete_filename", "(", "self", ".", "file_location", ")", "if",...
Returns: str | None: First available usable location
[ "Returns", ":", "str", "|", "None", ":", "First", "available", "usable", "location" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/logsetup.py#L79-L91
train
Returns the first available usable location for the current user.
zsimic/runez
src/runez/logsetup.py
LogSpec.should_log_to_file
def should_log_to_file(self): """ Returns: bool: As per the spec, should we be logging to a file? """ if not self.file_format: return False if self.file_location is not None: return bool(self.file_location) return bool(self.locations)
python
def should_log_to_file(self): """ Returns: bool: As per the spec, should we be logging to a file? """ if not self.file_format: return False if self.file_location is not None: return bool(self.file_location) return bool(self.locations)
[ "def", "should_log_to_file", "(", "self", ")", ":", "if", "not", "self", ".", "file_format", ":", "return", "False", "if", "self", ".", "file_location", "is", "not", "None", ":", "return", "bool", "(", "self", ".", "file_location", ")", "return", "bool", ...
Returns: bool: As per the spec, should we be logging to a file?
[ "Returns", ":", "bool", ":", "As", "per", "the", "spec", "should", "we", "be", "logging", "to", "a", "file?" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/logsetup.py#L94-L103
train
Returns True if we should log to a file.
zsimic/runez
src/runez/logsetup.py
LogSpec._auto_complete_filename
def _auto_complete_filename(self, location): """ Args: location (str | unicode | None): Location to auto-complete with {basename}, if it points to a folder Returns: str | None: {location}/{basename} """ path = formatted(location, self) if path: ...
python
def _auto_complete_filename(self, location): """ Args: location (str | unicode | None): Location to auto-complete with {basename}, if it points to a folder Returns: str | None: {location}/{basename} """ path = formatted(location, self) if path: ...
[ "def", "_auto_complete_filename", "(", "self", ",", "location", ")", ":", "path", "=", "formatted", "(", "location", ",", "self", ")", "if", "path", ":", "if", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "filename", "=", "formatted", "(", ...
Args: location (str | unicode | None): Location to auto-complete with {basename}, if it points to a folder Returns: str | None: {location}/{basename}
[ "Args", ":", "location", "(", "str", "|", "unicode", "|", "None", ")", ":", "Location", "to", "auto", "-", "complete", "with", "{", "basename", "}", "if", "it", "points", "to", "a", "folder" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/logsetup.py#L105-L121
train
Returns the auto - complete filename for a specific resource.
zsimic/runez
src/runez/logsetup.py
_ContextFilter.filter
def filter(self, record): """Determines if the record should be logged and injects context info into the record. Always returns True""" fmt = LogManager.spec.context_format if fmt: data = self.context.to_dict() if data: record.context = fmt % ",".join("%s=...
python
def filter(self, record): """Determines if the record should be logged and injects context info into the record. Always returns True""" fmt = LogManager.spec.context_format if fmt: data = self.context.to_dict() if data: record.context = fmt % ",".join("%s=...
[ "def", "filter", "(", "self", ",", "record", ")", ":", "fmt", "=", "LogManager", ".", "spec", ".", "context_format", "if", "fmt", ":", "data", "=", "self", ".", "context", ".", "to_dict", "(", ")", "if", "data", ":", "record", ".", "context", "=", ...
Determines if the record should be logged and injects context info into the record. Always returns True
[ "Determines", "if", "the", "record", "should", "be", "logged", "and", "injects", "context", "info", "into", "the", "record", ".", "Always", "returns", "True" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/logsetup.py#L142-L151
train
Determines if the record should be logged and injects context info into the record. Always returns True
zsimic/runez
src/runez/logsetup.py
LogManager.setup
def setup( cls, debug=UNSET, dryrun=UNSET, level=UNSET, appname=UNSET, basename=UNSET, clean_handlers=UNSET, context_format=UNSET, dev=UNSET, greetings=UNSET, timezone=UNSET, t...
python
def setup( cls, debug=UNSET, dryrun=UNSET, level=UNSET, appname=UNSET, basename=UNSET, clean_handlers=UNSET, context_format=UNSET, dev=UNSET, greetings=UNSET, timezone=UNSET, t...
[ "def", "setup", "(", "cls", ",", "debug", "=", "UNSET", ",", "dryrun", "=", "UNSET", ",", "level", "=", "UNSET", ",", "appname", "=", "UNSET", ",", "basename", "=", "UNSET", ",", "clean_handlers", "=", "UNSET", ",", "context_format", "=", "UNSET", ",",...
Args: debug (bool): Enable debug level logging (overrides other specified levels) dryrun (bool): Enable dryrun level (int | None): Shortcut to set both `console_level` and `file_level` at once appname (str | unicode | None): Program's base name, not used directly, just as...
[ "Args", ":", "debug", "(", "bool", ")", ":", "Enable", "debug", "level", "logging", "(", "overrides", "other", "specified", "levels", ")", "dryrun", "(", "bool", ")", ":", "Enable", "dryrun", "level", "(", "int", "|", "None", ")", ":", "Shortcut", "to"...
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/logsetup.py#L204-L322
train
This function sets up the base class of the base class for the log file.
zsimic/runez
src/runez/logsetup.py
LogManager.reset
def reset(cls): """Reset logging as it was before setup(), no need to call this outside of testing, or some very special cases""" cls._disable_faulthandler() if cls.handlers is not None: for handler in cls.handlers: logging.root.removeHandler(handler) cls....
python
def reset(cls): """Reset logging as it was before setup(), no need to call this outside of testing, or some very special cases""" cls._disable_faulthandler() if cls.handlers is not None: for handler in cls.handlers: logging.root.removeHandler(handler) cls....
[ "def", "reset", "(", "cls", ")", ":", "cls", ".", "_disable_faulthandler", "(", ")", "if", "cls", ".", "handlers", "is", "not", "None", ":", "for", "handler", "in", "cls", ".", "handlers", ":", "logging", ".", "root", ".", "removeHandler", "(", "handle...
Reset logging as it was before setup(), no need to call this outside of testing, or some very special cases
[ "Reset", "logging", "as", "it", "was", "before", "setup", "()", "no", "need", "to", "call", "this", "outside", "of", "testing", "or", "some", "very", "special", "cases" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/logsetup.py#L325-L339
train
Reset logging as it was before setup
zsimic/runez
src/runez/logsetup.py
LogManager.silence
def silence(cls, *modules, **kwargs): """ Args: *modules: Modules, or names of modules to silence (by setting their log level to WARNING or above) **kwargs: Pass as kwargs due to python 2.7, would be level=logging.WARNING otherwise """ level = kwargs.pop("level", ...
python
def silence(cls, *modules, **kwargs): """ Args: *modules: Modules, or names of modules to silence (by setting their log level to WARNING or above) **kwargs: Pass as kwargs due to python 2.7, would be level=logging.WARNING otherwise """ level = kwargs.pop("level", ...
[ "def", "silence", "(", "cls", ",", "*", "modules", ",", "*", "*", "kwargs", ")", ":", "level", "=", "kwargs", ".", "pop", "(", "\"level\"", ",", "logging", ".", "WARNING", ")", "for", "mod", "in", "modules", ":", "name", "=", "mod", ".", "__name__"...
Args: *modules: Modules, or names of modules to silence (by setting their log level to WARNING or above) **kwargs: Pass as kwargs due to python 2.7, would be level=logging.WARNING otherwise
[ "Args", ":", "*", "modules", ":", "Modules", "or", "names", "of", "modules", "to", "silence", "(", "by", "setting", "their", "log", "level", "to", "WARNING", "or", "above", ")", "**", "kwargs", ":", "Pass", "as", "kwargs", "due", "to", "python", "2", ...
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/logsetup.py#L355-L364
train
A method to silence the log messages for the specified modules.
zsimic/runez
src/runez/logsetup.py
LogManager.is_using_format
def is_using_format(cls, markers, used_formats=None): """ Args: markers (str | unicode): Space separated list of markers to look for used_formats (str | unicode): Formats to consider (default: cls.used_formats) Returns: (bool): True if any one of the 'markers...
python
def is_using_format(cls, markers, used_formats=None): """ Args: markers (str | unicode): Space separated list of markers to look for used_formats (str | unicode): Formats to consider (default: cls.used_formats) Returns: (bool): True if any one of the 'markers...
[ "def", "is_using_format", "(", "cls", ",", "markers", ",", "used_formats", "=", "None", ")", ":", "if", "used_formats", "is", "None", ":", "used_formats", "=", "cls", ".", "used_formats", "if", "not", "markers", "or", "not", "used_formats", ":", "return", ...
Args: markers (str | unicode): Space separated list of markers to look for used_formats (str | unicode): Formats to consider (default: cls.used_formats) Returns: (bool): True if any one of the 'markers' is seen in 'used_formats'
[ "Args", ":", "markers", "(", "str", "|", "unicode", ")", ":", "Space", "separated", "list", "of", "markers", "to", "look", "for", "used_formats", "(", "str", "|", "unicode", ")", ":", "Formats", "to", "consider", "(", "default", ":", "cls", ".", "used_...
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/logsetup.py#L367-L380
train
Returns True if any of the markers in used_formats is seen in the cache otherwise False.
zsimic/runez
src/runez/logsetup.py
LogManager.enable_faulthandler
def enable_faulthandler(cls, signum=signal.SIGUSR1): """ Enable dumping thread stack traces when specified signals are received, similar to java's handling of SIGQUIT Note: this must be called from the surviving process in case of daemonization. Note that SIGQUIT does not work in all en...
python
def enable_faulthandler(cls, signum=signal.SIGUSR1): """ Enable dumping thread stack traces when specified signals are received, similar to java's handling of SIGQUIT Note: this must be called from the surviving process in case of daemonization. Note that SIGQUIT does not work in all en...
[ "def", "enable_faulthandler", "(", "cls", ",", "signum", "=", "signal", ".", "SIGUSR1", ")", ":", "with", "cls", ".", "_lock", ":", "if", "not", "signum", ":", "cls", ".", "_disable_faulthandler", "(", ")", "return", "if", "not", "cls", ".", "file_handle...
Enable dumping thread stack traces when specified signals are received, similar to java's handling of SIGQUIT Note: this must be called from the surviving process in case of daemonization. Note that SIGQUIT does not work in all environments with a python process. :param int|None signum: Signal...
[ "Enable", "dumping", "thread", "stack", "traces", "when", "specified", "signals", "are", "received", "similar", "to", "java", "s", "handling", "of", "SIGQUIT" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/logsetup.py#L383-L401
train
Enable dumping thread stack traces when specified signals are received.
zsimic/runez
src/runez/logsetup.py
LogManager.override_spec
def override_spec(cls, **kwargs): """OVerride 'spec' and '_default_spec' with given values""" cls._default_spec.set(**kwargs) cls.spec.set(**kwargs)
python
def override_spec(cls, **kwargs): """OVerride 'spec' and '_default_spec' with given values""" cls._default_spec.set(**kwargs) cls.spec.set(**kwargs)
[ "def", "override_spec", "(", "cls", ",", "*", "*", "kwargs", ")", ":", "cls", ".", "_default_spec", ".", "set", "(", "*", "*", "kwargs", ")", "cls", ".", "spec", ".", "set", "(", "*", "*", "kwargs", ")" ]
OVerride 'spec' and '_default_spec' with given values
[ "OVerride", "spec", "and", "_default_spec", "with", "given", "values" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/logsetup.py#L404-L407
train
Override the spec and _default_spec with given values
zsimic/runez
src/runez/logsetup.py
LogManager._auto_fill_defaults
def _auto_fill_defaults(cls): """Late auto-filled missing defaults (caller's value kept if provided)""" if not cls.spec.appname: cls.spec.appname = get_basename(get_program_path()) if not cls.spec.dev: cls.spec.dev = get_dev_folder()
python
def _auto_fill_defaults(cls): """Late auto-filled missing defaults (caller's value kept if provided)""" if not cls.spec.appname: cls.spec.appname = get_basename(get_program_path()) if not cls.spec.dev: cls.spec.dev = get_dev_folder()
[ "def", "_auto_fill_defaults", "(", "cls", ")", ":", "if", "not", "cls", ".", "spec", ".", "appname", ":", "cls", ".", "spec", ".", "appname", "=", "get_basename", "(", "get_program_path", "(", ")", ")", "if", "not", "cls", ".", "spec", ".", "dev", ":...
Late auto-filled missing defaults (caller's value kept if provided)
[ "Late", "auto", "-", "filled", "missing", "defaults", "(", "caller", "s", "value", "kept", "if", "provided", ")" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/logsetup.py#L410-L415
train
Late auto - filled missing defaults ( caller s value kept if provided
zsimic/runez
src/runez/logsetup.py
LogManager._add_handler
def _add_handler(cls, handler, fmt, level): """ Args: handler (logging.Handler): Handler to decorate fmt (str | unicode): Format to use """ handler.setFormatter(_get_formatter(fmt)) if level: handler.setLevel(level) logging.root.addHand...
python
def _add_handler(cls, handler, fmt, level): """ Args: handler (logging.Handler): Handler to decorate fmt (str | unicode): Format to use """ handler.setFormatter(_get_formatter(fmt)) if level: handler.setLevel(level) logging.root.addHand...
[ "def", "_add_handler", "(", "cls", ",", "handler", ",", "fmt", ",", "level", ")", ":", "handler", ".", "setFormatter", "(", "_get_formatter", "(", "fmt", ")", ")", "if", "level", ":", "handler", ".", "setLevel", "(", "level", ")", "logging", ".", "root...
Args: handler (logging.Handler): Handler to decorate fmt (str | unicode): Format to use
[ "Args", ":", "handler", "(", "logging", ".", "Handler", ")", ":", "Handler", "to", "decorate", "fmt", "(", "str", "|", "unicode", ")", ":", "Format", "to", "use" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/logsetup.py#L418-L429
train
Add a handler to the log.
zsimic/runez
src/runez/logsetup.py
LogManager._fix_logging_shortcuts
def _fix_logging_shortcuts(cls): """ Fix standard logging shortcuts to correctly report logging module. This is only useful if you: - actually use %(name) and care about it being correct - you would still like to use the logging.info() etc shortcuts So basically you'd l...
python
def _fix_logging_shortcuts(cls): """ Fix standard logging shortcuts to correctly report logging module. This is only useful if you: - actually use %(name) and care about it being correct - you would still like to use the logging.info() etc shortcuts So basically you'd l...
[ "def", "_fix_logging_shortcuts", "(", "cls", ")", ":", "if", "cls", ".", "is_using_format", "(", "\"%(pathname)s %(filename)s %(funcName)s %(module)s\"", ")", ":", "logging", ".", "_srcfile", "=", "cls", ".", "_logging_snapshot", ".", "_srcfile", "else", ":", "loggi...
Fix standard logging shortcuts to correctly report logging module. This is only useful if you: - actually use %(name) and care about it being correct - you would still like to use the logging.info() etc shortcuts So basically you'd like to write this: import logging ...
[ "Fix", "standard", "logging", "shortcuts", "to", "correctly", "report", "logging", "module", "." ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/logsetup.py#L439-L491
train
Fix standard logging shortcuts to correctly report logging module.
dfm/casjobs
casjobs.py
CasJobs._send_request
def _send_request(self, job_type, params={}): """ Construct and submit a structured/authenticated request. ## Arguments * `job_type` (str): The job type identifier to use. ## Keyword Arguments * `params` (dict): Any additional entries to include in the POST ...
python
def _send_request(self, job_type, params={}): """ Construct and submit a structured/authenticated request. ## Arguments * `job_type` (str): The job type identifier to use. ## Keyword Arguments * `params` (dict): Any additional entries to include in the POST ...
[ "def", "_send_request", "(", "self", ",", "job_type", ",", "params", "=", "{", "}", ")", ":", "params", "[", "\"wsid\"", "]", "=", "params", ".", "get", "(", "\"wsid\"", ",", "self", ".", "userid", ")", "params", "[", "\"pw\"", "]", "=", "params", ...
Construct and submit a structured/authenticated request. ## Arguments * `job_type` (str): The job type identifier to use. ## Keyword Arguments * `params` (dict): Any additional entries to include in the POST request. ## Returns * `r` (requests.Response): T...
[ "Construct", "and", "submit", "a", "structured", "/", "authenticated", "request", "." ]
1cc3f5511cc254d776082909221787e3c037ac16
https://github.com/dfm/casjobs/blob/1cc3f5511cc254d776082909221787e3c037ac16/casjobs.py#L58-L91
train
Construct and submit a structured request to the server.
dfm/casjobs
casjobs.py
CasJobs._parse_single
def _parse_single(self, text, tagname): """ A hack to get the content of the XML responses from the CAS server. ## Arguments * `text` (str): The XML string to parse. * `tagname` (str): The tag that contains the info that we want. ## Returns * `content` (str): ...
python
def _parse_single(self, text, tagname): """ A hack to get the content of the XML responses from the CAS server. ## Arguments * `text` (str): The XML string to parse. * `tagname` (str): The tag that contains the info that we want. ## Returns * `content` (str): ...
[ "def", "_parse_single", "(", "self", ",", "text", ",", "tagname", ")", ":", "return", "minidom", ".", "parseString", "(", "text", ")", ".", "getElementsByTagName", "(", "tagname", ")", "[", "0", "]", ".", "firstChild", ".", "data" ]
A hack to get the content of the XML responses from the CAS server. ## Arguments * `text` (str): The XML string to parse. * `tagname` (str): The tag that contains the info that we want. ## Returns * `content` (str): The contents of the tag.
[ "A", "hack", "to", "get", "the", "content", "of", "the", "XML", "responses", "from", "the", "CAS", "server", "." ]
1cc3f5511cc254d776082909221787e3c037ac16
https://github.com/dfm/casjobs/blob/1cc3f5511cc254d776082909221787e3c037ac16/casjobs.py#L93-L108
train
A hack to get the content of the XML response from the CAS server.
dfm/casjobs
casjobs.py
CasJobs.quick
def quick(self, q, context=None, task_name="quickie", system=False): """ Run a quick job. ## Arguments * `q` (str): The SQL query. ## Keyword Arguments * `context` (str): Casjobs context used for this query. * `task_name` (str): The task name. * `syste...
python
def quick(self, q, context=None, task_name="quickie", system=False): """ Run a quick job. ## Arguments * `q` (str): The SQL query. ## Keyword Arguments * `context` (str): Casjobs context used for this query. * `task_name` (str): The task name. * `syste...
[ "def", "quick", "(", "self", ",", "q", ",", "context", "=", "None", ",", "task_name", "=", "\"quickie\"", ",", "system", "=", "False", ")", ":", "if", "not", "context", ":", "context", "=", "self", ".", "context", "params", "=", "{", "\"qry\"", ":", ...
Run a quick job. ## Arguments * `q` (str): The SQL query. ## Keyword Arguments * `context` (str): Casjobs context used for this query. * `task_name` (str): The task name. * `system` (bool) : Whether or not to run this job as a system job (not visible in the ...
[ "Run", "a", "quick", "job", "." ]
1cc3f5511cc254d776082909221787e3c037ac16
https://github.com/dfm/casjobs/blob/1cc3f5511cc254d776082909221787e3c037ac16/casjobs.py#L110-L135
train
Run a quick job.
dfm/casjobs
casjobs.py
CasJobs.submit
def submit(self, q, context=None, task_name="casjobs", estimate=30): """ Submit a job to CasJobs. ## Arguments * `q` (str): The SQL query. ## Keyword Arguments * `context` (str): Casjobs context used for this query. * `task_name` (str): The task name. ...
python
def submit(self, q, context=None, task_name="casjobs", estimate=30): """ Submit a job to CasJobs. ## Arguments * `q` (str): The SQL query. ## Keyword Arguments * `context` (str): Casjobs context used for this query. * `task_name` (str): The task name. ...
[ "def", "submit", "(", "self", ",", "q", ",", "context", "=", "None", ",", "task_name", "=", "\"casjobs\"", ",", "estimate", "=", "30", ")", ":", "if", "not", "context", ":", "context", "=", "self", ".", "context", "params", "=", "{", "\"qry\"", ":", ...
Submit a job to CasJobs. ## Arguments * `q` (str): The SQL query. ## Keyword Arguments * `context` (str): Casjobs context used for this query. * `task_name` (str): The task name. * `estimate` (int): Estimate of the time this job will take (in minutes). ## Ret...
[ "Submit", "a", "job", "to", "CasJobs", "." ]
1cc3f5511cc254d776082909221787e3c037ac16
https://github.com/dfm/casjobs/blob/1cc3f5511cc254d776082909221787e3c037ac16/casjobs.py#L137-L162
train
Submit a job to CasJobs.
dfm/casjobs
casjobs.py
CasJobs.status
def status(self, job_id): """ Check the status of a job. ## Arguments * `job_id` (int): The job to check. ## Returns * `code` (int): The status. * `status` (str): The human-readable name of the current status. """ params = {"jobid": job_id} ...
python
def status(self, job_id): """ Check the status of a job. ## Arguments * `job_id` (int): The job to check. ## Returns * `code` (int): The status. * `status` (str): The human-readable name of the current status. """ params = {"jobid": job_id} ...
[ "def", "status", "(", "self", ",", "job_id", ")", ":", "params", "=", "{", "\"jobid\"", ":", "job_id", "}", "r", "=", "self", ".", "_send_request", "(", "\"GetJobStatus\"", ",", "params", "=", "params", ")", "status", "=", "int", "(", "self", ".", "_...
Check the status of a job. ## Arguments * `job_id` (int): The job to check. ## Returns * `code` (int): The status. * `status` (str): The human-readable name of the current status.
[ "Check", "the", "status", "of", "a", "job", "." ]
1cc3f5511cc254d776082909221787e3c037ac16
https://github.com/dfm/casjobs/blob/1cc3f5511cc254d776082909221787e3c037ac16/casjobs.py#L164-L181
train
Check the status of a job.
dfm/casjobs
casjobs.py
CasJobs.monitor
def monitor(self, job_id, timeout=5): """ Monitor the status of a job. ## Arguments * `job_id` (int): The job to check. * `timeout` (float): The time to wait between checks (in sec). ## Returns * `code` (int): The status. * `status` (str): The human-re...
python
def monitor(self, job_id, timeout=5): """ Monitor the status of a job. ## Arguments * `job_id` (int): The job to check. * `timeout` (float): The time to wait between checks (in sec). ## Returns * `code` (int): The status. * `status` (str): The human-re...
[ "def", "monitor", "(", "self", ",", "job_id", ",", "timeout", "=", "5", ")", ":", "while", "True", ":", "status", "=", "self", ".", "status", "(", "job_id", ")", "logging", ".", "info", "(", "\"Monitoring job: %d - Status: %d, %s\"", "%", "(", "job_id", ...
Monitor the status of a job. ## Arguments * `job_id` (int): The job to check. * `timeout` (float): The time to wait between checks (in sec). ## Returns * `code` (int): The status. * `status` (str): The human-readable name of the current status.
[ "Monitor", "the", "status", "of", "a", "job", "." ]
1cc3f5511cc254d776082909221787e3c037ac16
https://github.com/dfm/casjobs/blob/1cc3f5511cc254d776082909221787e3c037ac16/casjobs.py#L195-L216
train
Monitor the status of a job.
dfm/casjobs
casjobs.py
CasJobs.job_info
def job_info(self, **kwargs): """ Get the information about the jobs returned by a particular search. See the [GetJobs][] documentation for more info. [GetJobs]: http://casjobs.sdss.org/casjobs/services/jobs.asmx?op=GetJobs """ search = ";".join(["%s : %s"%(k, str(kwarg...
python
def job_info(self, **kwargs): """ Get the information about the jobs returned by a particular search. See the [GetJobs][] documentation for more info. [GetJobs]: http://casjobs.sdss.org/casjobs/services/jobs.asmx?op=GetJobs """ search = ";".join(["%s : %s"%(k, str(kwarg...
[ "def", "job_info", "(", "self", ",", "*", "*", "kwargs", ")", ":", "search", "=", "\";\"", ".", "join", "(", "[", "\"%s : %s\"", "%", "(", "k", ",", "str", "(", "kwargs", "[", "k", "]", ")", ")", "for", "k", "in", "kwargs", "]", ")", "params", ...
Get the information about the jobs returned by a particular search. See the [GetJobs][] documentation for more info. [GetJobs]: http://casjobs.sdss.org/casjobs/services/jobs.asmx?op=GetJobs
[ "Get", "the", "information", "about", "the", "jobs", "returned", "by", "a", "particular", "search", ".", "See", "the", "[", "GetJobs", "]", "[]", "documentation", "for", "more", "info", "." ]
1cc3f5511cc254d776082909221787e3c037ac16
https://github.com/dfm/casjobs/blob/1cc3f5511cc254d776082909221787e3c037ac16/casjobs.py#L218-L236
train
Get the information about the jobs returned by a particular search.
dfm/casjobs
casjobs.py
CasJobs.request_output
def request_output(self, table, outtype): """ Request the output for a given table. ## Arguments * `table` (str): The name of the table to export. * `outtype` (str): The type of output. Must be one of: CSV - Comma Seperated Values DataSet - XML DataS...
python
def request_output(self, table, outtype): """ Request the output for a given table. ## Arguments * `table` (str): The name of the table to export. * `outtype` (str): The type of output. Must be one of: CSV - Comma Seperated Values DataSet - XML DataS...
[ "def", "request_output", "(", "self", ",", "table", ",", "outtype", ")", ":", "job_types", "=", "[", "\"CSV\"", ",", "\"DataSet\"", ",", "\"FITS\"", ",", "\"VOTable\"", "]", "assert", "outtype", "in", "job_types", "params", "=", "{", "\"tableName\"", ":", ...
Request the output for a given table. ## Arguments * `table` (str): The name of the table to export. * `outtype` (str): The type of output. Must be one of: CSV - Comma Seperated Values DataSet - XML DataSet FITS - Flexible Image Transfer System (FITS ...
[ "Request", "the", "output", "for", "a", "given", "table", "." ]
1cc3f5511cc254d776082909221787e3c037ac16
https://github.com/dfm/casjobs/blob/1cc3f5511cc254d776082909221787e3c037ac16/casjobs.py#L238-L257
train
Request the output for a given table.
dfm/casjobs
casjobs.py
CasJobs.get_output
def get_output(self, job_id, outfn): """ Download an output file given the id of the output request job. ## Arguments * `job_id` (int): The id of the _output_ job. * `outfn` (str): The file where the output should be stored. May also be a file-like object with a 'wr...
python
def get_output(self, job_id, outfn): """ Download an output file given the id of the output request job. ## Arguments * `job_id` (int): The id of the _output_ job. * `outfn` (str): The file where the output should be stored. May also be a file-like object with a 'wr...
[ "def", "get_output", "(", "self", ",", "job_id", ",", "outfn", ")", ":", "job_info", "=", "self", ".", "job_info", "(", "jobid", "=", "job_id", ")", "[", "0", "]", "# Make sure that the job is finished.", "status", "=", "int", "(", "job_info", "[", "\"Stat...
Download an output file given the id of the output request job. ## Arguments * `job_id` (int): The id of the _output_ job. * `outfn` (str): The file where the output should be stored. May also be a file-like object with a 'write' method.
[ "Download", "an", "output", "file", "given", "the", "id", "of", "the", "output", "request", "job", "." ]
1cc3f5511cc254d776082909221787e3c037ac16
https://github.com/dfm/casjobs/blob/1cc3f5511cc254d776082909221787e3c037ac16/casjobs.py#L259-L294
train
Download an output file given the id of the output request job.
dfm/casjobs
casjobs.py
CasJobs.request_and_get_output
def request_and_get_output(self, table, outtype, outfn): """ Shorthand for requesting an output file and then downloading it when ready. ## Arguments * `table` (str): The name of the table to export. * `outtype` (str): The type of output. Must be one of: CSV...
python
def request_and_get_output(self, table, outtype, outfn): """ Shorthand for requesting an output file and then downloading it when ready. ## Arguments * `table` (str): The name of the table to export. * `outtype` (str): The type of output. Must be one of: CSV...
[ "def", "request_and_get_output", "(", "self", ",", "table", ",", "outtype", ",", "outfn", ")", ":", "job_id", "=", "self", ".", "request_output", "(", "table", ",", "outtype", ")", "status", "=", "self", ".", "monitor", "(", "job_id", ")", "if", "status"...
Shorthand for requesting an output file and then downloading it when ready. ## Arguments * `table` (str): The name of the table to export. * `outtype` (str): The type of output. Must be one of: CSV - Comma Seperated Values DataSet - XML DataSet F...
[ "Shorthand", "for", "requesting", "an", "output", "file", "and", "then", "downloading", "it", "when", "ready", "." ]
1cc3f5511cc254d776082909221787e3c037ac16
https://github.com/dfm/casjobs/blob/1cc3f5511cc254d776082909221787e3c037ac16/casjobs.py#L296-L317
train
Request an output file and then download it when it is ready.
dfm/casjobs
casjobs.py
CasJobs.drop_table
def drop_table(self, table): """ Drop a table from the MyDB context. ## Arguments * `table` (str): The name of the table to drop. """ job_id = self.submit("DROP TABLE %s"%table, context="MYDB") status = self.monitor(job_id) if status[0] != 5: ...
python
def drop_table(self, table): """ Drop a table from the MyDB context. ## Arguments * `table` (str): The name of the table to drop. """ job_id = self.submit("DROP TABLE %s"%table, context="MYDB") status = self.monitor(job_id) if status[0] != 5: ...
[ "def", "drop_table", "(", "self", ",", "table", ")", ":", "job_id", "=", "self", ".", "submit", "(", "\"DROP TABLE %s\"", "%", "table", ",", "context", "=", "\"MYDB\"", ")", "status", "=", "self", ".", "monitor", "(", "job_id", ")", "if", "status", "["...
Drop a table from the MyDB context. ## Arguments * `table` (str): The name of the table to drop.
[ "Drop", "a", "table", "from", "the", "MyDB", "context", "." ]
1cc3f5511cc254d776082909221787e3c037ac16
https://github.com/dfm/casjobs/blob/1cc3f5511cc254d776082909221787e3c037ac16/casjobs.py#L319-L331
train
Drop a table from the MyDB context.
dfm/casjobs
casjobs.py
CasJobs.count
def count(self, q): """ Shorthand for counting the results of a specific query. ## Arguments * `q` (str): The query to count. This will be executed as: `"SELECT COUNT(*) %s" % q`. ## Returns * `count` (int): The resulting count. """ q = "SEL...
python
def count(self, q): """ Shorthand for counting the results of a specific query. ## Arguments * `q` (str): The query to count. This will be executed as: `"SELECT COUNT(*) %s" % q`. ## Returns * `count` (int): The resulting count. """ q = "SEL...
[ "def", "count", "(", "self", ",", "q", ")", ":", "q", "=", "\"SELECT COUNT(*) %s\"", "%", "q", "return", "int", "(", "self", ".", "quick", "(", "q", ")", ".", "split", "(", "\"\\n\"", ")", "[", "1", "]", ")" ]
Shorthand for counting the results of a specific query. ## Arguments * `q` (str): The query to count. This will be executed as: `"SELECT COUNT(*) %s" % q`. ## Returns * `count` (int): The resulting count.
[ "Shorthand", "for", "counting", "the", "results", "of", "a", "specific", "query", "." ]
1cc3f5511cc254d776082909221787e3c037ac16
https://github.com/dfm/casjobs/blob/1cc3f5511cc254d776082909221787e3c037ac16/casjobs.py#L333-L348
train
Returns the number of results that match the query.
dfm/casjobs
casjobs.py
CasJobs.list_tables
def list_tables(self): """ Lists the tables in mydb. ## Returns * `tables` (list): A list of strings with all the table names from mydb. """ q = 'SELECT Distinct TABLE_NAME FROM information_schema.TABLES' res = self.quick(q, context='MYDB', task_name='listtables...
python
def list_tables(self): """ Lists the tables in mydb. ## Returns * `tables` (list): A list of strings with all the table names from mydb. """ q = 'SELECT Distinct TABLE_NAME FROM information_schema.TABLES' res = self.quick(q, context='MYDB', task_name='listtables...
[ "def", "list_tables", "(", "self", ")", ":", "q", "=", "'SELECT Distinct TABLE_NAME FROM information_schema.TABLES'", "res", "=", "self", ".", "quick", "(", "q", ",", "context", "=", "'MYDB'", ",", "task_name", "=", "'listtables'", ",", "system", "=", "True", ...
Lists the tables in mydb. ## Returns * `tables` (list): A list of strings with all the table names from mydb.
[ "Lists", "the", "tables", "in", "mydb", "." ]
1cc3f5511cc254d776082909221787e3c037ac16
https://github.com/dfm/casjobs/blob/1cc3f5511cc254d776082909221787e3c037ac16/casjobs.py#L350-L362
train
Lists the tables in mydb.
ncraike/fang
examples/multiple_dependencies.py
multiply_and_add
def multiply_and_add(n): '''Multiply the given number n by some configured multiplier, and then add a configured offset.''' multiplier, offset = di.resolver.unpack(multiply_and_add) return (multiplier * n) + offset
python
def multiply_and_add(n): '''Multiply the given number n by some configured multiplier, and then add a configured offset.''' multiplier, offset = di.resolver.unpack(multiply_and_add) return (multiplier * n) + offset
[ "def", "multiply_and_add", "(", "n", ")", ":", "multiplier", ",", "offset", "=", "di", ".", "resolver", ".", "unpack", "(", "multiply_and_add", ")", "return", "(", "multiplier", "*", "n", ")", "+", "offset" ]
Multiply the given number n by some configured multiplier, and then add a configured offset.
[ "Multiply", "the", "given", "number", "n", "by", "some", "configured", "multiplier", "and", "then", "add", "a", "configured", "offset", "." ]
2d9e1216c866e450059017f83ab775f7716eda7a
https://github.com/ncraike/fang/blob/2d9e1216c866e450059017f83ab775f7716eda7a/examples/multiple_dependencies.py#L13-L17
train
Multiply the given number n by some configured multiplier and and then add a configured offset.
intfloat/uts
uts/texttiling.py
TextTiling.segment
def segment(self, document): """ document: list[str] return list[int], i-th element denotes whether exists a boundary right before paragraph i(0 indexed) """ # ensure document is not empty and every element is an instance of str assert(len(document) > 0 and le...
python
def segment(self, document): """ document: list[str] return list[int], i-th element denotes whether exists a boundary right before paragraph i(0 indexed) """ # ensure document is not empty and every element is an instance of str assert(len(document) > 0 and le...
[ "def", "segment", "(", "self", ",", "document", ")", ":", "# ensure document is not empty and every element is an instance of str", "assert", "(", "len", "(", "document", ")", ">", "0", "and", "len", "(", "[", "d", "for", "d", "in", "document", "if", "not", "i...
document: list[str] return list[int], i-th element denotes whether exists a boundary right before paragraph i(0 indexed)
[ "document", ":", "list", "[", "str", "]", "return", "list", "[", "int", "]", "i", "-", "th", "element", "denotes", "whether", "exists", "a", "boundary", "right", "before", "paragraph", "i", "(", "0", "indexed", ")" ]
5748a64264283829dc7910c2c53e9c9583e5825e
https://github.com/intfloat/uts/blob/5748a64264283829dc7910c2c53e9c9583e5825e/uts/texttiling.py#L25-L88
train
segment a document into a list of unique identifiers
mastro35/flows
flows/Actions/InputTailAction.py
TailAction.try_opening_file
def try_opening_file(self): '''Try to open the input file''' # read all the file to tail til the end... if os.path.isfile(self.path): self.my_log_file = tyler.Tyler(self.path) try: for line in self.my_log_file: pass except S...
python
def try_opening_file(self): '''Try to open the input file''' # read all the file to tail til the end... if os.path.isfile(self.path): self.my_log_file = tyler.Tyler(self.path) try: for line in self.my_log_file: pass except S...
[ "def", "try_opening_file", "(", "self", ")", ":", "# read all the file to tail til the end...", "if", "os", ".", "path", ".", "isfile", "(", "self", ".", "path", ")", ":", "self", ".", "my_log_file", "=", "tyler", ".", "Tyler", "(", "self", ".", "path", ")...
Try to open the input file
[ "Try", "to", "open", "the", "input", "file" ]
05e488385673a69597b5b39c7728795aa4d5eb18
https://github.com/mastro35/flows/blob/05e488385673a69597b5b39c7728795aa4d5eb18/flows/Actions/InputTailAction.py#L47-L58
train
Try to open the input file
mastro35/flows
flows/Actions/InputTailAction.py
TailAction.flush_buffer
def flush_buffer(self): ''' Flush the buffer of the tail ''' if len(self.buffer) > 0: return_value = ''.join(self.buffer) self.buffer.clear() self.send_message(return_value) self.last_flush_date = datetime.datetime.now()
python
def flush_buffer(self): ''' Flush the buffer of the tail ''' if len(self.buffer) > 0: return_value = ''.join(self.buffer) self.buffer.clear() self.send_message(return_value) self.last_flush_date = datetime.datetime.now()
[ "def", "flush_buffer", "(", "self", ")", ":", "if", "len", "(", "self", ".", "buffer", ")", ">", "0", ":", "return_value", "=", "''", ".", "join", "(", "self", ".", "buffer", ")", "self", ".", "buffer", ".", "clear", "(", ")", "self", ".", "send_...
Flush the buffer of the tail
[ "Flush", "the", "buffer", "of", "the", "tail" ]
05e488385673a69597b5b39c7728795aa4d5eb18
https://github.com/mastro35/flows/blob/05e488385673a69597b5b39c7728795aa4d5eb18/flows/Actions/InputTailAction.py#L64-L70
train
Flush the buffer of the tail
acatton/python-spm
spm/__init__.py
pipe
def pipe(cmd, *arguments, **kwargs): """ Pipe many commands:: >>> noop = pipe(['gzip'], ['gzip'], ['zcat'], ['zcat']) >>> _ = noop.stdin.write('foo'.encode()) # Ignore output in Python 3 >>> noop.stdin.close() >>> print(noop.stdout.read().decode()) foo Returns a Su...
python
def pipe(cmd, *arguments, **kwargs): """ Pipe many commands:: >>> noop = pipe(['gzip'], ['gzip'], ['zcat'], ['zcat']) >>> _ = noop.stdin.write('foo'.encode()) # Ignore output in Python 3 >>> noop.stdin.close() >>> print(noop.stdout.read().decode()) foo Returns a Su...
[ "def", "pipe", "(", "cmd", ",", "*", "arguments", ",", "*", "*", "kwargs", ")", ":", "acc", "=", "run", "(", "*", "cmd", ",", "*", "*", "kwargs", ")", "for", "cmd", "in", "arguments", ":", "if", "isinstance", "(", "cmd", ",", "Subprocess", ")", ...
Pipe many commands:: >>> noop = pipe(['gzip'], ['gzip'], ['zcat'], ['zcat']) >>> _ = noop.stdin.write('foo'.encode()) # Ignore output in Python 3 >>> noop.stdin.close() >>> print(noop.stdout.read().decode()) foo Returns a Subprocess.
[ "Pipe", "many", "commands", "::" ]
0d4e7177aef17c90f7676ae2e099bb4137a0226f
https://github.com/acatton/python-spm/blob/0d4e7177aef17c90f7676ae2e099bb4137a0226f/spm/__init__.py#L274-L292
train
A wrapper around subprocess. run that pipes the command line arguments and returns a Subprocess.
zsimic/runez
src/runez/base.py
decode
def decode(value, strip=False): """Python 2/3 friendly decoding of output. Args: value (str | unicode | bytes | None): The value to decode. strip (bool): If True, `strip()` the returned string. (Default value = False) Returns: str: Decoded value, if applicable. """ if value...
python
def decode(value, strip=False): """Python 2/3 friendly decoding of output. Args: value (str | unicode | bytes | None): The value to decode. strip (bool): If True, `strip()` the returned string. (Default value = False) Returns: str: Decoded value, if applicable. """ if value...
[ "def", "decode", "(", "value", ",", "strip", "=", "False", ")", ":", "if", "value", "is", "None", ":", "return", "None", "if", "isinstance", "(", "value", ",", "bytes", ")", "and", "not", "isinstance", "(", "value", ",", "unicode", ")", ":", "value",...
Python 2/3 friendly decoding of output. Args: value (str | unicode | bytes | None): The value to decode. strip (bool): If True, `strip()` the returned string. (Default value = False) Returns: str: Decoded value, if applicable.
[ "Python", "2", "/", "3", "friendly", "decoding", "of", "output", "." ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/base.py#L39-L55
train
Python 2. 3 friendly decoding of output.
zsimic/runez
src/runez/base.py
Slotted._seed
def _seed(self): """Seed initial fields""" for name in self.__slots__: value = getattr(self, name, UNSET) if value is UNSET: setattr(self, name, self.__class__._default)
python
def _seed(self): """Seed initial fields""" for name in self.__slots__: value = getattr(self, name, UNSET) if value is UNSET: setattr(self, name, self.__class__._default)
[ "def", "_seed", "(", "self", ")", ":", "for", "name", "in", "self", ".", "__slots__", ":", "value", "=", "getattr", "(", "self", ",", "name", ",", "UNSET", ")", "if", "value", "is", "UNSET", ":", "setattr", "(", "self", ",", "name", ",", "self", ...
Seed initial fields
[ "Seed", "initial", "fields" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/base.py#L72-L77
train
Seed initial fields
zsimic/runez
src/runez/base.py
Slotted._set
def _set(self, name, value): """ Args: name (str | unicode): Name of slot to set. value: Associated value """ if value is not UNSET: if isinstance(value, Slotted): current = getattr(self, name, UNSET) if current is None ...
python
def _set(self, name, value): """ Args: name (str | unicode): Name of slot to set. value: Associated value """ if value is not UNSET: if isinstance(value, Slotted): current = getattr(self, name, UNSET) if current is None ...
[ "def", "_set", "(", "self", ",", "name", ",", "value", ")", ":", "if", "value", "is", "not", "UNSET", ":", "if", "isinstance", "(", "value", ",", "Slotted", ")", ":", "current", "=", "getattr", "(", "self", ",", "name", ",", "UNSET", ")", "if", "...
Args: name (str | unicode): Name of slot to set. value: Associated value
[ "Args", ":", "name", "(", "str", "|", "unicode", ")", ":", "Name", "of", "slot", "to", "set", ".", "value", ":", "Associated", "value" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/base.py#L86-L103
train
Sets the value of the named attribute in the object.
zsimic/runez
src/runez/base.py
Slotted.set
def set(self, *args, **kwargs): """Conveniently set one or more fields at a time. Args: *args: Optionally set from other objects, available fields from the passed object are used in order **kwargs: Set from given key/value pairs (only names defined in __slots__ are used) ...
python
def set(self, *args, **kwargs): """Conveniently set one or more fields at a time. Args: *args: Optionally set from other objects, available fields from the passed object are used in order **kwargs: Set from given key/value pairs (only names defined in __slots__ are used) ...
[ "def", "set", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "args", ":", "for", "arg", "in", "args", ":", "if", "arg", "is", "not", "None", ":", "for", "name", "in", "self", ".", "__slots__", ":", "self", ".", "_set", ...
Conveniently set one or more fields at a time. Args: *args: Optionally set from other objects, available fields from the passed object are used in order **kwargs: Set from given key/value pairs (only names defined in __slots__ are used)
[ "Conveniently", "set", "one", "or", "more", "fields", "at", "a", "time", "." ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/base.py#L105-L118
train
Conveniently set one or more fields at a time.
zsimic/runez
src/runez/base.py
Slotted.pop
def pop(self, settings): """ Args: settings (dict): Dict to pop applicable fields from """ if settings: for name in self.__slots__: self._set(name, settings.pop(name, UNSET))
python
def pop(self, settings): """ Args: settings (dict): Dict to pop applicable fields from """ if settings: for name in self.__slots__: self._set(name, settings.pop(name, UNSET))
[ "def", "pop", "(", "self", ",", "settings", ")", ":", "if", "settings", ":", "for", "name", "in", "self", ".", "__slots__", ":", "self", ".", "_set", "(", "name", ",", "settings", ".", "pop", "(", "name", ",", "UNSET", ")", ")" ]
Args: settings (dict): Dict to pop applicable fields from
[ "Args", ":", "settings", "(", "dict", ")", ":", "Dict", "to", "pop", "applicable", "fields", "from" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/base.py#L120-L127
train
Removes all applicable fields from a set of items from the set.
zsimic/runez
src/runez/base.py
ThreadGlobalContext.enable
def enable(self): """Enable contextual logging""" with self._lock: if self.filter is None: self.filter = self._filter_type(self)
python
def enable(self): """Enable contextual logging""" with self._lock: if self.filter is None: self.filter = self._filter_type(self)
[ "def", "enable", "(", "self", ")", ":", "with", "self", ".", "_lock", ":", "if", "self", ".", "filter", "is", "None", ":", "self", ".", "filter", "=", "self", ".", "_filter_type", "(", "self", ")" ]
Enable contextual logging
[ "Enable", "contextual", "logging" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/base.py#L161-L165
train
Enable contextual logging for this instance.
zsimic/runez
src/runez/base.py
ThreadGlobalContext.set_threadlocal
def set_threadlocal(self, **values): """Set current thread's logging context to specified `values`""" with self._lock: self._ensure_threadlocal() self._tpayload.context = values
python
def set_threadlocal(self, **values): """Set current thread's logging context to specified `values`""" with self._lock: self._ensure_threadlocal() self._tpayload.context = values
[ "def", "set_threadlocal", "(", "self", ",", "*", "*", "values", ")", ":", "with", "self", ".", "_lock", ":", "self", ".", "_ensure_threadlocal", "(", ")", "self", ".", "_tpayload", ".", "context", "=", "values" ]
Set current thread's logging context to specified `values`
[ "Set", "current", "thread", "s", "logging", "context", "to", "specified", "values" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/base.py#L175-L179
train
Set current thread s logging context to specified values
zsimic/runez
src/runez/base.py
ThreadGlobalContext.add_threadlocal
def add_threadlocal(self, **values): """Add `values` to current thread's logging context""" with self._lock: self._ensure_threadlocal() self._tpayload.context.update(**values)
python
def add_threadlocal(self, **values): """Add `values` to current thread's logging context""" with self._lock: self._ensure_threadlocal() self._tpayload.context.update(**values)
[ "def", "add_threadlocal", "(", "self", ",", "*", "*", "values", ")", ":", "with", "self", ".", "_lock", ":", "self", ".", "_ensure_threadlocal", "(", ")", "self", ".", "_tpayload", ".", "context", ".", "update", "(", "*", "*", "values", ")" ]
Add `values` to current thread's logging context
[ "Add", "values", "to", "current", "thread", "s", "logging", "context" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/base.py#L181-L185
train
Add values to current thread s logging context
zsimic/runez
src/runez/base.py
ThreadGlobalContext.remove_threadlocal
def remove_threadlocal(self, name): """ Args: name (str | unicode): Remove entry with `name` from current thread's context """ with self._lock: if self._tpayload is not None: if name in self._tpayload.context: del self._tpayload...
python
def remove_threadlocal(self, name): """ Args: name (str | unicode): Remove entry with `name` from current thread's context """ with self._lock: if self._tpayload is not None: if name in self._tpayload.context: del self._tpayload...
[ "def", "remove_threadlocal", "(", "self", ",", "name", ")", ":", "with", "self", ".", "_lock", ":", "if", "self", ".", "_tpayload", "is", "not", "None", ":", "if", "name", "in", "self", ".", "_tpayload", ".", "context", ":", "del", "self", ".", "_tpa...
Args: name (str | unicode): Remove entry with `name` from current thread's context
[ "Args", ":", "name", "(", "str", "|", "unicode", ")", ":", "Remove", "entry", "with", "name", "from", "current", "thread", "s", "context" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/base.py#L187-L197
train
Removes a thread local entry with the given name from current thread s context.
zsimic/runez
src/runez/base.py
ThreadGlobalContext.add_global
def add_global(self, **values): """Add `values` to global logging context""" with self._lock: self._ensure_global() self._gpayload.update(**values)
python
def add_global(self, **values): """Add `values` to global logging context""" with self._lock: self._ensure_global() self._gpayload.update(**values)
[ "def", "add_global", "(", "self", ",", "*", "*", "values", ")", ":", "with", "self", ".", "_lock", ":", "self", ".", "_ensure_global", "(", ")", "self", ".", "_gpayload", ".", "update", "(", "*", "*", "values", ")" ]
Add `values` to global logging context
[ "Add", "values", "to", "global", "logging", "context" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/base.py#L209-L213
train
Add values to global logging context
zsimic/runez
src/runez/base.py
ThreadGlobalContext.remove_global
def remove_global(self, name): """ Args: name (str | unicode): Remove entry with `name` from global context """ with self._lock: if self._gpayload is not None: if name in self._gpayload: del self._gpayload[name] ...
python
def remove_global(self, name): """ Args: name (str | unicode): Remove entry with `name` from global context """ with self._lock: if self._gpayload is not None: if name in self._gpayload: del self._gpayload[name] ...
[ "def", "remove_global", "(", "self", ",", "name", ")", ":", "with", "self", ".", "_lock", ":", "if", "self", ".", "_gpayload", "is", "not", "None", ":", "if", "name", "in", "self", ".", "_gpayload", ":", "del", "self", ".", "_gpayload", "[", "name", ...
Args: name (str | unicode): Remove entry with `name` from global context
[ "Args", ":", "name", "(", "str", "|", "unicode", ")", ":", "Remove", "entry", "with", "name", "from", "global", "context" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/base.py#L215-L225
train
Removes a global entry with the given name from the global context.
zsimic/runez
src/runez/base.py
ThreadGlobalContext.to_dict
def to_dict(self): """ Returns: dict: Combined global and thread-specific logging context """ with self._lock: result = {} if self._gpayload: result.update(self._gpayload) if self._tpayload: result.update(get...
python
def to_dict(self): """ Returns: dict: Combined global and thread-specific logging context """ with self._lock: result = {} if self._gpayload: result.update(self._gpayload) if self._tpayload: result.update(get...
[ "def", "to_dict", "(", "self", ")", ":", "with", "self", ".", "_lock", ":", "result", "=", "{", "}", "if", "self", ".", "_gpayload", ":", "result", ".", "update", "(", "self", ".", "_gpayload", ")", "if", "self", ".", "_tpayload", ":", "result", "....
Returns: dict: Combined global and thread-specific logging context
[ "Returns", ":", "dict", ":", "Combined", "global", "and", "thread", "-", "specific", "logging", "context" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/base.py#L233-L244
train
Returns a dict representation of the current object.
zsimic/runez
src/runez/base.py
ThreadGlobalContext._ensure_global
def _ensure_global(self, values=None): """ Args: values (dict): Ensure internal global tracking dict is created, seed it with `values` when provided (Default value = None) """ if self._gpayload is None: self._gpayload = values or {} self.enable()
python
def _ensure_global(self, values=None): """ Args: values (dict): Ensure internal global tracking dict is created, seed it with `values` when provided (Default value = None) """ if self._gpayload is None: self._gpayload = values or {} self.enable()
[ "def", "_ensure_global", "(", "self", ",", "values", "=", "None", ")", ":", "if", "self", ".", "_gpayload", "is", "None", ":", "self", ".", "_gpayload", "=", "values", "or", "{", "}", "self", ".", "enable", "(", ")" ]
Args: values (dict): Ensure internal global tracking dict is created, seed it with `values` when provided (Default value = None)
[ "Args", ":", "values", "(", "dict", ")", ":", "Ensure", "internal", "global", "tracking", "dict", "is", "created", "seed", "it", "with", "values", "when", "provided", "(", "Default", "value", "=", "None", ")" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/base.py#L252-L259
train
Ensure internal global tracking dict is created
intfloat/uts
uts/c99.py
C99.segment
def segment(self, document): """ document: list[str] return list[int], i-th element denotes whether exists a boundary right before paragraph i(0 indexed) """ assert(len(document) > 0 and len([d for d in document if not isinstance(d, str)]) == 0) if len(documen...
python
def segment(self, document): """ document: list[str] return list[int], i-th element denotes whether exists a boundary right before paragraph i(0 indexed) """ assert(len(document) > 0 and len([d for d in document if not isinstance(d, str)]) == 0) if len(documen...
[ "def", "segment", "(", "self", ",", "document", ")", ":", "assert", "(", "len", "(", "document", ")", ">", "0", "and", "len", "(", "[", "d", "for", "d", "in", "document", "if", "not", "isinstance", "(", "d", ",", "str", ")", "]", ")", "==", "0"...
document: list[str] return list[int], i-th element denotes whether exists a boundary right before paragraph i(0 indexed)
[ "document", ":", "list", "[", "str", "]", "return", "list", "[", "int", "]", "i", "-", "th", "element", "denotes", "whether", "exists", "a", "boundary", "right", "before", "paragraph", "i", "(", "0", "indexed", ")" ]
5748a64264283829dc7910c2c53e9c9583e5825e
https://github.com/intfloat/uts/blob/5748a64264283829dc7910c2c53e9c9583e5825e/uts/c99.py#L26-L131
train
This function computes the similarity matrix and sum matrix of the words in the document.
redhat-cip/python-dciclient
dciclient/v1/shell_commands/feeder.py
create
def create(context, name, team_id, data, active): """create(context, name, team_id, data, active) Create a Feeder. >>> dcictl feeder-create [OPTIONS] :param string name: Name of the feeder [required] :param string team_id: ID of the team to associate this feeder with [required] :param...
python
def create(context, name, team_id, data, active): """create(context, name, team_id, data, active) Create a Feeder. >>> dcictl feeder-create [OPTIONS] :param string name: Name of the feeder [required] :param string team_id: ID of the team to associate this feeder with [required] :param...
[ "def", "create", "(", "context", ",", "name", ",", "team_id", ",", "data", ",", "active", ")", ":", "state", "=", "utils", ".", "active_string", "(", "active", ")", "team_id", "=", "team_id", "result", "=", "feeder", ".", "create", "(", "context", ",",...
create(context, name, team_id, data, active) Create a Feeder. >>> dcictl feeder-create [OPTIONS] :param string name: Name of the feeder [required] :param string team_id: ID of the team to associate this feeder with [required] :param string data: JSON data to pass during feeder creation ...
[ "create", "(", "context", "name", "team_id", "data", "active", ")" ]
a4aa5899062802bbe4c30a075d8447f8d222d214
https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/shell_commands/feeder.py#L55-L74
train
Create a new feeder
redhat-cip/python-dciclient
dciclient/v1/shell_commands/feeder.py
update
def update(context, id, etag, name, team_id, data, active): """update(context, id, etag, name, team_id, data, active) Update a Feeder. >>> dcictl feeder-update [OPTIONS] :param string id: ID of the feeder [required] :param string etag: Entity tag of the feeder resource [required] :param strin...
python
def update(context, id, etag, name, team_id, data, active): """update(context, id, etag, name, team_id, data, active) Update a Feeder. >>> dcictl feeder-update [OPTIONS] :param string id: ID of the feeder [required] :param string etag: Entity tag of the feeder resource [required] :param strin...
[ "def", "update", "(", "context", ",", "id", ",", "etag", ",", "name", ",", "team_id", ",", "data", ",", "active", ")", ":", "result", "=", "feeder", ".", "update", "(", "context", ",", "id", "=", "id", ",", "etag", "=", "etag", ",", "name", "=", ...
update(context, id, etag, name, team_id, data, active) Update a Feeder. >>> dcictl feeder-update [OPTIONS] :param string id: ID of the feeder [required] :param string etag: Entity tag of the feeder resource [required] :param string name: Name of the feeder :param string team_id: ID of the tea...
[ "update", "(", "context", "id", "etag", "name", "team_id", "data", "active", ")" ]
a4aa5899062802bbe4c30a075d8447f8d222d214
https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/shell_commands/feeder.py#L85-L103
train
Update a specific object in a specific feeder
redhat-cip/python-dciclient
dciclient/v1/shell_commands/feeder.py
delete
def delete(context, id, etag): """delete(context, id, etag) Delete a Feeder. >>> dcictl feeder-delete [OPTIONS] :param string id: ID of the feeder to delete [required] :param string etag: Entity tag of the feeder resource [required] """ result = feeder.delete(context, id=id, etag=etag) ...
python
def delete(context, id, etag): """delete(context, id, etag) Delete a Feeder. >>> dcictl feeder-delete [OPTIONS] :param string id: ID of the feeder to delete [required] :param string etag: Entity tag of the feeder resource [required] """ result = feeder.delete(context, id=id, etag=etag) ...
[ "def", "delete", "(", "context", ",", "id", ",", "etag", ")", ":", "result", "=", "feeder", ".", "delete", "(", "context", ",", "id", "=", "id", ",", "etag", "=", "etag", ")", "if", "result", ".", "status_code", "==", "204", ":", "utils", ".", "p...
delete(context, id, etag) Delete a Feeder. >>> dcictl feeder-delete [OPTIONS] :param string id: ID of the feeder to delete [required] :param string etag: Entity tag of the feeder resource [required]
[ "delete", "(", "context", "id", "etag", ")" ]
a4aa5899062802bbe4c30a075d8447f8d222d214
https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/shell_commands/feeder.py#L110-L125
train
Delete a specific resource of a specific resource
redhat-cip/python-dciclient
dciclient/v1/shell_commands/feeder.py
show
def show(context, id): """show(context, id) Show a Feeder. >>> dcictl feeder-show [OPTIONS] :param string id: ID of the feeder to show [required] """ result = feeder.get(context, id=id) utils.format_output(result, context.format)
python
def show(context, id): """show(context, id) Show a Feeder. >>> dcictl feeder-show [OPTIONS] :param string id: ID of the feeder to show [required] """ result = feeder.get(context, id=id) utils.format_output(result, context.format)
[ "def", "show", "(", "context", ",", "id", ")", ":", "result", "=", "feeder", ".", "get", "(", "context", ",", "id", "=", "id", ")", "utils", ".", "format_output", "(", "result", ",", "context", ".", "format", ")" ]
show(context, id) Show a Feeder. >>> dcictl feeder-show [OPTIONS] :param string id: ID of the feeder to show [required]
[ "show", "(", "context", "id", ")" ]
a4aa5899062802bbe4c30a075d8447f8d222d214
https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/shell_commands/feeder.py#L131-L141
train
Show a specific n - item feeder
redhat-cip/python-dciclient
dciclient/v1/shell_commands/feeder.py
reset_api_secret
def reset_api_secret(context, id, etag): """reset_api_secret(context, id, etag) Reset a Feeder api_secret. >>> dcictl feeder-reset-api-secret [OPTIONS] :param string id: ID of the feeder [required] :param string etag: Entity tag of the feeder resource [required] """ result = feeder.reset_...
python
def reset_api_secret(context, id, etag): """reset_api_secret(context, id, etag) Reset a Feeder api_secret. >>> dcictl feeder-reset-api-secret [OPTIONS] :param string id: ID of the feeder [required] :param string etag: Entity tag of the feeder resource [required] """ result = feeder.reset_...
[ "def", "reset_api_secret", "(", "context", ",", "id", ",", "etag", ")", ":", "result", "=", "feeder", ".", "reset_api_secret", "(", "context", ",", "id", "=", "id", ",", "etag", "=", "etag", ")", "utils", ".", "format_output", "(", "result", ",", "cont...
reset_api_secret(context, id, etag) Reset a Feeder api_secret. >>> dcictl feeder-reset-api-secret [OPTIONS] :param string id: ID of the feeder [required] :param string etag: Entity tag of the feeder resource [required]
[ "reset_api_secret", "(", "context", "id", "etag", ")" ]
a4aa5899062802bbe4c30a075d8447f8d222d214
https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/shell_commands/feeder.py#L148-L160
train
Reset API Secret of a specific resource
mojaie/chorus
chorus/draw/helper.py
display_terminal_carbon
def display_terminal_carbon(mol): """Set visible=True to the terminal carbon atoms. """ for i, a in mol.atoms_iter(): if mol.neighbor_count(i) == 1: a.visible = True
python
def display_terminal_carbon(mol): """Set visible=True to the terminal carbon atoms. """ for i, a in mol.atoms_iter(): if mol.neighbor_count(i) == 1: a.visible = True
[ "def", "display_terminal_carbon", "(", "mol", ")", ":", "for", "i", ",", "a", "in", "mol", ".", "atoms_iter", "(", ")", ":", "if", "mol", ".", "neighbor_count", "(", "i", ")", "==", "1", ":", "a", ".", "visible", "=", "True" ]
Set visible=True to the terminal carbon atoms.
[ "Set", "visible", "=", "True", "to", "the", "terminal", "carbon", "atoms", "." ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/draw/helper.py#L16-L21
train
Set visible = True to the terminal carbon atoms.
mojaie/chorus
chorus/draw/helper.py
equalize_terminal_double_bond
def equalize_terminal_double_bond(mol): """Show equalized double bond if it is connected to terminal atom. """ for i, a in mol.atoms_iter(): if mol.neighbor_count(i) == 1: nb = list(mol.neighbors(i).values())[0] if nb.order == 2: nb.type = 2
python
def equalize_terminal_double_bond(mol): """Show equalized double bond if it is connected to terminal atom. """ for i, a in mol.atoms_iter(): if mol.neighbor_count(i) == 1: nb = list(mol.neighbors(i).values())[0] if nb.order == 2: nb.type = 2
[ "def", "equalize_terminal_double_bond", "(", "mol", ")", ":", "for", "i", ",", "a", "in", "mol", ".", "atoms_iter", "(", ")", ":", "if", "mol", ".", "neighbor_count", "(", "i", ")", "==", "1", ":", "nb", "=", "list", "(", "mol", ".", "neighbors", "...
Show equalized double bond if it is connected to terminal atom.
[ "Show", "equalized", "double", "bond", "if", "it", "is", "connected", "to", "terminal", "atom", "." ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/draw/helper.py#L24-L31
train
Show equalized double bond if it is connected to terminal atom.
mojaie/chorus
chorus/draw/helper.py
spine_to_terminal_wedge
def spine_to_terminal_wedge(mol): """Arrange stereo wedge direction from spine to terminal atom """ for i, a in mol.atoms_iter(): if mol.neighbor_count(i) == 1: ni, nb = list(mol.neighbors(i).items())[0] if nb.order == 1 and nb.type in (1, 2) \ and ni > i ...
python
def spine_to_terminal_wedge(mol): """Arrange stereo wedge direction from spine to terminal atom """ for i, a in mol.atoms_iter(): if mol.neighbor_count(i) == 1: ni, nb = list(mol.neighbors(i).items())[0] if nb.order == 1 and nb.type in (1, 2) \ and ni > i ...
[ "def", "spine_to_terminal_wedge", "(", "mol", ")", ":", "for", "i", ",", "a", "in", "mol", ".", "atoms_iter", "(", ")", ":", "if", "mol", ".", "neighbor_count", "(", "i", ")", "==", "1", ":", "ni", ",", "nb", "=", "list", "(", "mol", ".", "neighb...
Arrange stereo wedge direction from spine to terminal atom
[ "Arrange", "stereo", "wedge", "direction", "from", "spine", "to", "terminal", "atom" ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/draw/helper.py#L34-L43
train
Arrange stereo wedge direction from spine to terminal atom