repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
nickjj/ansigenome
ansigenome/export.py
Export.dump
def dump(self): """ Dump the output to json. """ report_as_json_string = utils.dict_to_json(self.report) if self.out_file: utils.string_to_file(self.out_file, report_as_json_string) else: print report_as_json_string
python
def dump(self): """ Dump the output to json. """ report_as_json_string = utils.dict_to_json(self.report) if self.out_file: utils.string_to_file(self.out_file, report_as_json_string) else: print report_as_json_string
[ "def", "dump", "(", "self", ")", ":", "report_as_json_string", "=", "utils", ".", "dict_to_json", "(", "self", ".", "report", ")", "if", "self", ".", "out_file", ":", "utils", ".", "string_to_file", "(", "self", ".", "out_file", ",", "report_as_json_string",...
Dump the output to json.
[ "Dump", "the", "output", "to", "json", "." ]
70cd98d7a23d36c56f4e713ea820cfb4c485c81c
https://github.com/nickjj/ansigenome/blob/70cd98d7a23d36c56f4e713ea820cfb4c485c81c/ansigenome/export.py#L258-L266
train
SethMMorton/natsort
natsort/compat/fake_fastnumbers.py
fast_float
def fast_float( x, key=lambda x: x, nan=None, _uni=unicodedata.numeric, _nan_inf=NAN_INF, _first_char=POTENTIAL_FIRST_CHAR, ): """ Convert a string to a float quickly, return input as-is if not possible. We don't need to accept all input that the real fast_int accepts because na...
python
def fast_float( x, key=lambda x: x, nan=None, _uni=unicodedata.numeric, _nan_inf=NAN_INF, _first_char=POTENTIAL_FIRST_CHAR, ): """ Convert a string to a float quickly, return input as-is if not possible. We don't need to accept all input that the real fast_int accepts because na...
[ "def", "fast_float", "(", "x", ",", "key", "=", "lambda", "x", ":", "x", ",", "nan", "=", "None", ",", "_uni", "=", "unicodedata", ".", "numeric", ",", "_nan_inf", "=", "NAN_INF", ",", "_first_char", "=", "POTENTIAL_FIRST_CHAR", ",", ")", ":", "if", ...
Convert a string to a float quickly, return input as-is if not possible. We don't need to accept all input that the real fast_int accepts because natsort is controlling what is passed to this function. Parameters ---------- x : str String to attempt to convert to a float. key : callabl...
[ "Convert", "a", "string", "to", "a", "float", "quickly", "return", "input", "as", "-", "is", "if", "not", "possible", "." ]
ea0d37ef790b42c424a096e079edd9ea0d5717e3
https://github.com/SethMMorton/natsort/blob/ea0d37ef790b42c424a096e079edd9ea0d5717e3/natsort/compat/fake_fastnumbers.py#L44-L85
train
SethMMorton/natsort
natsort/compat/fake_fastnumbers.py
fast_int
def fast_int( x, key=lambda x: x, _uni=unicodedata.digit, _first_char=POTENTIAL_FIRST_CHAR, ): """ Convert a string to a int quickly, return input as-is if not possible. We don't need to accept all input that the real fast_int accepts because natsort is controlling what is passed to thi...
python
def fast_int( x, key=lambda x: x, _uni=unicodedata.digit, _first_char=POTENTIAL_FIRST_CHAR, ): """ Convert a string to a int quickly, return input as-is if not possible. We don't need to accept all input that the real fast_int accepts because natsort is controlling what is passed to thi...
[ "def", "fast_int", "(", "x", ",", "key", "=", "lambda", "x", ":", "x", ",", "_uni", "=", "unicodedata", ".", "digit", ",", "_first_char", "=", "POTENTIAL_FIRST_CHAR", ",", ")", ":", "if", "x", "[", "0", "]", "in", "_first_char", ":", "try", ":", "r...
Convert a string to a int quickly, return input as-is if not possible. We don't need to accept all input that the real fast_int accepts because natsort is controlling what is passed to this function. Parameters ---------- x : str String to attempt to convert to an int. key : callable ...
[ "Convert", "a", "string", "to", "a", "int", "quickly", "return", "input", "as", "-", "is", "if", "not", "possible", "." ]
ea0d37ef790b42c424a096e079edd9ea0d5717e3
https://github.com/SethMMorton/natsort/blob/ea0d37ef790b42c424a096e079edd9ea0d5717e3/natsort/compat/fake_fastnumbers.py#L89-L125
train
SethMMorton/natsort
natsort/__main__.py
check_filters
def check_filters(filters): """ Execute range_check for every element of an iterable. Parameters ---------- filters : iterable The collection of filters to check. Each element must be a two-element tuple of floats or ints. Returns ------- The input as-is, or None if it ...
python
def check_filters(filters): """ Execute range_check for every element of an iterable. Parameters ---------- filters : iterable The collection of filters to check. Each element must be a two-element tuple of floats or ints. Returns ------- The input as-is, or None if it ...
[ "def", "check_filters", "(", "filters", ")", ":", "if", "not", "filters", ":", "return", "None", "try", ":", "return", "[", "range_check", "(", "f", "[", "0", "]", ",", "f", "[", "1", "]", ")", "for", "f", "in", "filters", "]", "except", "ValueErro...
Execute range_check for every element of an iterable. Parameters ---------- filters : iterable The collection of filters to check. Each element must be a two-element tuple of floats or ints. Returns ------- The input as-is, or None if it evaluates to False. Raises ----...
[ "Execute", "range_check", "for", "every", "element", "of", "an", "iterable", "." ]
ea0d37ef790b42c424a096e079edd9ea0d5717e3
https://github.com/SethMMorton/natsort/blob/ea0d37ef790b42c424a096e079edd9ea0d5717e3/natsort/__main__.py#L169-L194
train
SethMMorton/natsort
natsort/__main__.py
keep_entry_range
def keep_entry_range(entry, lows, highs, converter, regex): """ Check if an entry falls into a desired range. Every number in the entry will be extracted using *regex*, if any are within a given low to high range the entry will be kept. Parameters ---------- entry : str lows : iter...
python
def keep_entry_range(entry, lows, highs, converter, regex): """ Check if an entry falls into a desired range. Every number in the entry will be extracted using *regex*, if any are within a given low to high range the entry will be kept. Parameters ---------- entry : str lows : iter...
[ "def", "keep_entry_range", "(", "entry", ",", "lows", ",", "highs", ",", "converter", ",", "regex", ")", ":", "return", "any", "(", "low", "<=", "converter", "(", "num", ")", "<=", "high", "for", "num", "in", "regex", ".", "findall", "(", "entry", ")...
Check if an entry falls into a desired range. Every number in the entry will be extracted using *regex*, if any are within a given low to high range the entry will be kept. Parameters ---------- entry : str lows : iterable Collection of low values against which to compare the entry...
[ "Check", "if", "an", "entry", "falls", "into", "a", "desired", "range", "." ]
ea0d37ef790b42c424a096e079edd9ea0d5717e3
https://github.com/SethMMorton/natsort/blob/ea0d37ef790b42c424a096e079edd9ea0d5717e3/natsort/__main__.py#L197-L226
train
SethMMorton/natsort
natsort/__main__.py
keep_entry_value
def keep_entry_value(entry, values, converter, regex): """ Check if an entry does not match a given value. Every number in the entry will be extracted using *regex*, if any match a given value the entry will not be kept. Parameters ---------- entry : str values : iterable Colle...
python
def keep_entry_value(entry, values, converter, regex): """ Check if an entry does not match a given value. Every number in the entry will be extracted using *regex*, if any match a given value the entry will not be kept. Parameters ---------- entry : str values : iterable Colle...
[ "def", "keep_entry_value", "(", "entry", ",", "values", ",", "converter", ",", "regex", ")", ":", "return", "not", "any", "(", "converter", "(", "num", ")", "in", "values", "for", "num", "in", "regex", ".", "findall", "(", "entry", ")", ")" ]
Check if an entry does not match a given value. Every number in the entry will be extracted using *regex*, if any match a given value the entry will not be kept. Parameters ---------- entry : str values : iterable Collection of values against which to compare the entry. converter :...
[ "Check", "if", "an", "entry", "does", "not", "match", "a", "given", "value", "." ]
ea0d37ef790b42c424a096e079edd9ea0d5717e3
https://github.com/SethMMorton/natsort/blob/ea0d37ef790b42c424a096e079edd9ea0d5717e3/natsort/__main__.py#L229-L251
train
SethMMorton/natsort
natsort/__main__.py
sort_and_print_entries
def sort_and_print_entries(entries, args): """Sort the entries, applying the filters first if necessary.""" # Extract the proper number type. is_float = args.number_type in ("float", "real", "f", "r") signed = args.signed or args.number_type in ("real", "r") alg = ( natsort.ns.FLOAT * is_fl...
python
def sort_and_print_entries(entries, args): """Sort the entries, applying the filters first if necessary.""" # Extract the proper number type. is_float = args.number_type in ("float", "real", "f", "r") signed = args.signed or args.number_type in ("real", "r") alg = ( natsort.ns.FLOAT * is_fl...
[ "def", "sort_and_print_entries", "(", "entries", ",", "args", ")", ":", "is_float", "=", "args", ".", "number_type", "in", "(", "\"float\"", ",", "\"real\"", ",", "\"f\"", ",", "\"r\"", ")", "signed", "=", "args", ".", "signed", "or", "args", ".", "numbe...
Sort the entries, applying the filters first if necessary.
[ "Sort", "the", "entries", "applying", "the", "filters", "first", "if", "necessary", "." ]
ea0d37ef790b42c424a096e079edd9ea0d5717e3
https://github.com/SethMMorton/natsort/blob/ea0d37ef790b42c424a096e079edd9ea0d5717e3/natsort/__main__.py#L254-L306
train
SethMMorton/natsort
natsort/utils.py
regex_chooser
def regex_chooser(alg): """ Select an appropriate regex for the type of number of interest. Parameters ---------- alg : ns enum Used to indicate the regular expression to select. Returns ------- regex : compiled regex object Regular expression object that matches the de...
python
def regex_chooser(alg): """ Select an appropriate regex for the type of number of interest. Parameters ---------- alg : ns enum Used to indicate the regular expression to select. Returns ------- regex : compiled regex object Regular expression object that matches the de...
[ "def", "regex_chooser", "(", "alg", ")", ":", "if", "alg", "&", "ns", ".", "FLOAT", ":", "alg", "&=", "ns", ".", "FLOAT", "|", "ns", ".", "SIGNED", "|", "ns", ".", "NOEXP", "else", ":", "alg", "&=", "ns", ".", "INT", "|", "ns", ".", "SIGNED", ...
Select an appropriate regex for the type of number of interest. Parameters ---------- alg : ns enum Used to indicate the regular expression to select. Returns ------- regex : compiled regex object Regular expression object that matches the desired number type.
[ "Select", "an", "appropriate", "regex", "for", "the", "type", "of", "number", "of", "interest", "." ]
ea0d37ef790b42c424a096e079edd9ea0d5717e3
https://github.com/SethMMorton/natsort/blob/ea0d37ef790b42c424a096e079edd9ea0d5717e3/natsort/utils.py#L127-L154
train
SethMMorton/natsort
natsort/utils.py
_normalize_input_factory
def _normalize_input_factory(alg): """ Create a function that will normalize unicode input data. Parameters ---------- alg : ns enum Used to indicate how to normalize unicode. Returns ------- func : callable A function that accepts string (unicode) input and returns the...
python
def _normalize_input_factory(alg): """ Create a function that will normalize unicode input data. Parameters ---------- alg : ns enum Used to indicate how to normalize unicode. Returns ------- func : callable A function that accepts string (unicode) input and returns the...
[ "def", "_normalize_input_factory", "(", "alg", ")", ":", "normalization_form", "=", "\"NFKD\"", "if", "alg", "&", "ns", ".", "COMPATIBILITYNORMALIZE", "else", "\"NFD\"", "wrapped", "=", "partial", "(", "normalize", ",", "normalization_form", ")", "if", "NEWPY", ...
Create a function that will normalize unicode input data. Parameters ---------- alg : ns enum Used to indicate how to normalize unicode. Returns ------- func : callable A function that accepts string (unicode) input and returns the the input normalized with the desired ...
[ "Create", "a", "function", "that", "will", "normalize", "unicode", "input", "data", "." ]
ea0d37ef790b42c424a096e079edd9ea0d5717e3
https://github.com/SethMMorton/natsort/blob/ea0d37ef790b42c424a096e079edd9ea0d5717e3/natsort/utils.py#L162-L183
train
SethMMorton/natsort
natsort/utils.py
natsort_key
def natsort_key(val, key, string_func, bytes_func, num_func): """ Key to sort strings and numbers naturally. It works by splitting the string into components of strings and numbers, and then converting the numbers into actual ints or floats. Parameters ---------- val : str | unicode | byte...
python
def natsort_key(val, key, string_func, bytes_func, num_func): """ Key to sort strings and numbers naturally. It works by splitting the string into components of strings and numbers, and then converting the numbers into actual ints or floats. Parameters ---------- val : str | unicode | byte...
[ "def", "natsort_key", "(", "val", ",", "key", ",", "string_func", ",", "bytes_func", ",", "num_func", ")", ":", "if", "key", "is", "not", "None", ":", "val", "=", "key", "(", "val", ")", "try", ":", "return", "string_func", "(", "val", ")", "except",...
Key to sort strings and numbers naturally. It works by splitting the string into components of strings and numbers, and then converting the numbers into actual ints or floats. Parameters ---------- val : str | unicode | bytes | int | float | iterable key : callable | None A key to appl...
[ "Key", "to", "sort", "strings", "and", "numbers", "naturally", "." ]
ea0d37ef790b42c424a096e079edd9ea0d5717e3
https://github.com/SethMMorton/natsort/blob/ea0d37ef790b42c424a096e079edd9ea0d5717e3/natsort/utils.py#L186-L251
train
SethMMorton/natsort
natsort/utils.py
parse_number_factory
def parse_number_factory(alg, sep, pre_sep): """ Create a function that will format a number into a tuple. Parameters ---------- alg : ns enum Indicate how to format the *bytes*. sep : str The string character to be inserted before the number in the returned tuple. p...
python
def parse_number_factory(alg, sep, pre_sep): """ Create a function that will format a number into a tuple. Parameters ---------- alg : ns enum Indicate how to format the *bytes*. sep : str The string character to be inserted before the number in the returned tuple. p...
[ "def", "parse_number_factory", "(", "alg", ",", "sep", ",", "pre_sep", ")", ":", "nan_replace", "=", "float", "(", "\"+inf\"", ")", "if", "alg", "&", "ns", ".", "NANLAST", "else", "float", "(", "\"-inf\"", ")", "def", "func", "(", "val", ",", "_nan_rep...
Create a function that will format a number into a tuple. Parameters ---------- alg : ns enum Indicate how to format the *bytes*. sep : str The string character to be inserted before the number in the returned tuple. pre_sep : str In the event that *alg* contains ``U...
[ "Create", "a", "function", "that", "will", "format", "a", "number", "into", "a", "tuple", "." ]
ea0d37ef790b42c424a096e079edd9ea0d5717e3
https://github.com/SethMMorton/natsort/blob/ea0d37ef790b42c424a096e079edd9ea0d5717e3/natsort/utils.py#L287-L330
train
SethMMorton/natsort
natsort/utils.py
sep_inserter
def sep_inserter(iterable, sep): """ Insert '' between numbers in an iterable. Parameters ---------- iterable sep : str The string character to be inserted between adjacent numeric objects. Yields ------ The values of *iterable* in order, with *sep* inserted where adjacent ...
python
def sep_inserter(iterable, sep): """ Insert '' between numbers in an iterable. Parameters ---------- iterable sep : str The string character to be inserted between adjacent numeric objects. Yields ------ The values of *iterable* in order, with *sep* inserted where adjacent ...
[ "def", "sep_inserter", "(", "iterable", ",", "sep", ")", ":", "try", ":", "types", "=", "(", "int", ",", "float", ",", "long", ")", "first", "=", "next", "(", "iterable", ")", "if", "type", "(", "first", ")", "in", "types", ":", "yield", "sep", "...
Insert '' between numbers in an iterable. Parameters ---------- iterable sep : str The string character to be inserted between adjacent numeric objects. Yields ------ The values of *iterable* in order, with *sep* inserted where adjacent elements are numeric. If the first elemen...
[ "Insert", "between", "numbers", "in", "an", "iterable", "." ]
ea0d37ef790b42c424a096e079edd9ea0d5717e3
https://github.com/SethMMorton/natsort/blob/ea0d37ef790b42c424a096e079edd9ea0d5717e3/natsort/utils.py#L428-L470
train
SethMMorton/natsort
natsort/utils.py
input_string_transform_factory
def input_string_transform_factory(alg): """ Create a function to transform a string. Parameters ---------- alg : ns enum Indicate how to format the *str*. Returns ------- func : callable A function to be used as the *input_transform* argument to *parse_string_f...
python
def input_string_transform_factory(alg): """ Create a function to transform a string. Parameters ---------- alg : ns enum Indicate how to format the *str*. Returns ------- func : callable A function to be used as the *input_transform* argument to *parse_string_f...
[ "def", "input_string_transform_factory", "(", "alg", ")", ":", "lowfirst", "=", "alg", "&", "ns", ".", "LOWERCASEFIRST", "dumb", "=", "alg", "&", "NS_DUMB", "function_chain", "=", "[", "]", "if", "(", "dumb", "and", "not", "lowfirst", ")", "or", "(", "lo...
Create a function to transform a string. Parameters ---------- alg : ns enum Indicate how to format the *str*. Returns ------- func : callable A function to be used as the *input_transform* argument to *parse_string_factory*. See Also -------- parse_string_...
[ "Create", "a", "function", "to", "transform", "a", "string", "." ]
ea0d37ef790b42c424a096e079edd9ea0d5717e3
https://github.com/SethMMorton/natsort/blob/ea0d37ef790b42c424a096e079edd9ea0d5717e3/natsort/utils.py#L473-L544
train
SethMMorton/natsort
natsort/utils.py
string_component_transform_factory
def string_component_transform_factory(alg): """ Create a function to either transform a string or convert to a number. Parameters ---------- alg : ns enum Indicate how to format the *str*. Returns ------- func : callable A function to be used as the *component_transfor...
python
def string_component_transform_factory(alg): """ Create a function to either transform a string or convert to a number. Parameters ---------- alg : ns enum Indicate how to format the *str*. Returns ------- func : callable A function to be used as the *component_transfor...
[ "def", "string_component_transform_factory", "(", "alg", ")", ":", "use_locale", "=", "alg", "&", "ns", ".", "LOCALEALPHA", "dumb", "=", "alg", "&", "NS_DUMB", "group_letters", "=", "(", "alg", "&", "ns", ".", "GROUPLETTERS", ")", "or", "(", "use_locale", ...
Create a function to either transform a string or convert to a number. Parameters ---------- alg : ns enum Indicate how to format the *str*. Returns ------- func : callable A function to be used as the *component_transform* argument to *parse_string_factory*. See A...
[ "Create", "a", "function", "to", "either", "transform", "a", "string", "or", "convert", "to", "a", "number", "." ]
ea0d37ef790b42c424a096e079edd9ea0d5717e3
https://github.com/SethMMorton/natsort/blob/ea0d37ef790b42c424a096e079edd9ea0d5717e3/natsort/utils.py#L547-L587
train
SethMMorton/natsort
natsort/utils.py
final_data_transform_factory
def final_data_transform_factory(alg, sep, pre_sep): """ Create a function to transform a tuple. Parameters ---------- alg : ns enum Indicate how to format the *str*. sep : str Separator that was passed to *parse_string_factory*. pre_sep : str String separator to ins...
python
def final_data_transform_factory(alg, sep, pre_sep): """ Create a function to transform a tuple. Parameters ---------- alg : ns enum Indicate how to format the *str*. sep : str Separator that was passed to *parse_string_factory*. pre_sep : str String separator to ins...
[ "def", "final_data_transform_factory", "(", "alg", ",", "sep", ",", "pre_sep", ")", ":", "if", "alg", "&", "ns", ".", "UNGROUPLETTERS", "and", "alg", "&", "ns", ".", "LOCALEALPHA", ":", "swap", "=", "alg", "&", "NS_DUMB", "and", "alg", "&", "ns", ".", ...
Create a function to transform a tuple. Parameters ---------- alg : ns enum Indicate how to format the *str*. sep : str Separator that was passed to *parse_string_factory*. pre_sep : str String separator to insert at the at the front of the return tuple in the case t...
[ "Create", "a", "function", "to", "transform", "a", "tuple", "." ]
ea0d37ef790b42c424a096e079edd9ea0d5717e3
https://github.com/SethMMorton/natsort/blob/ea0d37ef790b42c424a096e079edd9ea0d5717e3/natsort/utils.py#L590-L637
train
SethMMorton/natsort
natsort/utils.py
groupletters
def groupletters(x, _low=lower_function): """ Double all characters, making doubled letters lowercase. Parameters ---------- x : str Returns ------- str Examples -------- >>> groupletters("Apple") {u}'aAppppllee' """ return "".join(ichain.from_iterabl...
python
def groupletters(x, _low=lower_function): """ Double all characters, making doubled letters lowercase. Parameters ---------- x : str Returns ------- str Examples -------- >>> groupletters("Apple") {u}'aAppppllee' """ return "".join(ichain.from_iterabl...
[ "def", "groupletters", "(", "x", ",", "_low", "=", "lower_function", ")", ":", "return", "\"\"", ".", "join", "(", "ichain", ".", "from_iterable", "(", "(", "_low", "(", "y", ")", ",", "y", ")", "for", "y", "in", "x", ")", ")" ]
Double all characters, making doubled letters lowercase. Parameters ---------- x : str Returns ------- str Examples -------- >>> groupletters("Apple") {u}'aAppppllee'
[ "Double", "all", "characters", "making", "doubled", "letters", "lowercase", "." ]
ea0d37ef790b42c424a096e079edd9ea0d5717e3
https://github.com/SethMMorton/natsort/blob/ea0d37ef790b42c424a096e079edd9ea0d5717e3/natsort/utils.py#L645-L664
train
SethMMorton/natsort
natsort/utils.py
chain_functions
def chain_functions(functions): """ Chain a list of single-argument functions together and return. The functions are applied in list order, and the output of the previous functions is passed to the next function. Parameters ---------- functions : list A list of single-argument func...
python
def chain_functions(functions): """ Chain a list of single-argument functions together and return. The functions are applied in list order, and the output of the previous functions is passed to the next function. Parameters ---------- functions : list A list of single-argument func...
[ "def", "chain_functions", "(", "functions", ")", ":", "functions", "=", "list", "(", "functions", ")", "if", "not", "functions", ":", "return", "_no_op", "elif", "len", "(", "functions", ")", "==", "1", ":", "return", "functions", "[", "0", "]", "else", ...
Chain a list of single-argument functions together and return. The functions are applied in list order, and the output of the previous functions is passed to the next function. Parameters ---------- functions : list A list of single-argument functions to chain together. Returns --...
[ "Chain", "a", "list", "of", "single", "-", "argument", "functions", "together", "and", "return", "." ]
ea0d37ef790b42c424a096e079edd9ea0d5717e3
https://github.com/SethMMorton/natsort/blob/ea0d37ef790b42c424a096e079edd9ea0d5717e3/natsort/utils.py#L667-L701
train
SethMMorton/natsort
natsort/utils.py
path_splitter
def path_splitter(s, _d_match=re.compile(r"\.\d").match): """ Split a string into its path components. Assumes a string is a path or is path-like. Parameters ---------- s : str | pathlib.Path Returns ------- split : tuple The path split by directory components and extensio...
python
def path_splitter(s, _d_match=re.compile(r"\.\d").match): """ Split a string into its path components. Assumes a string is a path or is path-like. Parameters ---------- s : str | pathlib.Path Returns ------- split : tuple The path split by directory components and extensio...
[ "def", "path_splitter", "(", "s", ",", "_d_match", "=", "re", ".", "compile", "(", "r\"\\.\\d\"", ")", ".", "match", ")", ":", "if", "has_pathlib", "and", "isinstance", "(", "s", ",", "PurePath", ")", ":", "s", "=", "py23_str", "(", "s", ")", "path_p...
Split a string into its path components. Assumes a string is a path or is path-like. Parameters ---------- s : str | pathlib.Path Returns ------- split : tuple The path split by directory components and extensions. Examples -------- >>> tuple(path_splitter("this/...
[ "Split", "a", "string", "into", "its", "path", "components", "." ]
ea0d37ef790b42c424a096e079edd9ea0d5717e3
https://github.com/SethMMorton/natsort/blob/ea0d37ef790b42c424a096e079edd9ea0d5717e3/natsort/utils.py#L729-L791
train
SethMMorton/natsort
natsort/utils.py
NumericalRegularExpressions._construct_regex
def _construct_regex(cls, fmt): """Given a format string, construct the regex with class attributes.""" return re.compile(fmt.format(**vars(cls)), flags=re.U)
python
def _construct_regex(cls, fmt): """Given a format string, construct the regex with class attributes.""" return re.compile(fmt.format(**vars(cls)), flags=re.U)
[ "def", "_construct_regex", "(", "cls", ",", "fmt", ")", ":", "return", "re", ".", "compile", "(", "fmt", ".", "format", "(", "**", "vars", "(", "cls", ")", ")", ",", "flags", "=", "re", ".", "U", ")" ]
Given a format string, construct the regex with class attributes.
[ "Given", "a", "format", "string", "construct", "the", "regex", "with", "class", "attributes", "." ]
ea0d37ef790b42c424a096e079edd9ea0d5717e3
https://github.com/SethMMorton/natsort/blob/ea0d37ef790b42c424a096e079edd9ea0d5717e3/natsort/utils.py#L92-L94
train
SethMMorton/natsort
natsort/natsort.py
natsort_keygen
def natsort_keygen(key=None, alg=ns.DEFAULT): """ Generate a key to sort strings and numbers naturally. This key is designed for use as the `key` argument to functions such as the `sorted` builtin. The user may customize the generated function with the arguments to `natsort_keygen`, including ...
python
def natsort_keygen(key=None, alg=ns.DEFAULT): """ Generate a key to sort strings and numbers naturally. This key is designed for use as the `key` argument to functions such as the `sorted` builtin. The user may customize the generated function with the arguments to `natsort_keygen`, including ...
[ "def", "natsort_keygen", "(", "key", "=", "None", ",", "alg", "=", "ns", ".", "DEFAULT", ")", ":", "try", ":", "ns", ".", "DEFAULT", "|", "alg", "except", "TypeError", ":", "msg", "=", "\"natsort_keygen: 'alg' argument must be from the enum 'ns'\"", "raise", "...
Generate a key to sort strings and numbers naturally. This key is designed for use as the `key` argument to functions such as the `sorted` builtin. The user may customize the generated function with the arguments to `natsort_keygen`, including an optional `key` function. Parameters ------...
[ "Generate", "a", "key", "to", "sort", "strings", "and", "numbers", "naturally", "." ]
ea0d37ef790b42c424a096e079edd9ea0d5717e3
https://github.com/SethMMorton/natsort/blob/ea0d37ef790b42c424a096e079edd9ea0d5717e3/natsort/natsort.py#L111-L203
train
SethMMorton/natsort
natsort/natsort.py
natsorted
def natsorted(seq, key=None, reverse=False, alg=ns.DEFAULT): """ Sorts an iterable naturally. Parameters ---------- seq : iterable The input to sort. key : callable, optional A key used to determine how to sort each element of the iterable. It is **not** applied recursi...
python
def natsorted(seq, key=None, reverse=False, alg=ns.DEFAULT): """ Sorts an iterable naturally. Parameters ---------- seq : iterable The input to sort. key : callable, optional A key used to determine how to sort each element of the iterable. It is **not** applied recursi...
[ "def", "natsorted", "(", "seq", ",", "key", "=", "None", ",", "reverse", "=", "False", ",", "alg", "=", "ns", ".", "DEFAULT", ")", ":", "key", "=", "natsort_keygen", "(", "key", ",", "alg", ")", "return", "sorted", "(", "seq", ",", "reverse", "=", ...
Sorts an iterable naturally. Parameters ---------- seq : iterable The input to sort. key : callable, optional A key used to determine how to sort each element of the iterable. It is **not** applied recursively. It should accept a single argument and return a single valu...
[ "Sorts", "an", "iterable", "naturally", "." ]
ea0d37ef790b42c424a096e079edd9ea0d5717e3
https://github.com/SethMMorton/natsort/blob/ea0d37ef790b42c424a096e079edd9ea0d5717e3/natsort/natsort.py#L222-L267
train
SethMMorton/natsort
natsort/natsort.py
humansorted
def humansorted(seq, key=None, reverse=False, alg=ns.DEFAULT): """ Convenience function to properly sort non-numeric characters. This is a wrapper around ``natsorted(seq, alg=ns.LOCALE)``. Parameters ---------- seq : iterable The input to sort. key : callable, optional A k...
python
def humansorted(seq, key=None, reverse=False, alg=ns.DEFAULT): """ Convenience function to properly sort non-numeric characters. This is a wrapper around ``natsorted(seq, alg=ns.LOCALE)``. Parameters ---------- seq : iterable The input to sort. key : callable, optional A k...
[ "def", "humansorted", "(", "seq", ",", "key", "=", "None", ",", "reverse", "=", "False", ",", "alg", "=", "ns", ".", "DEFAULT", ")", ":", "return", "natsorted", "(", "seq", ",", "key", ",", "reverse", ",", "alg", "|", "ns", ".", "LOCALE", ")" ]
Convenience function to properly sort non-numeric characters. This is a wrapper around ``natsorted(seq, alg=ns.LOCALE)``. Parameters ---------- seq : iterable The input to sort. key : callable, optional A key used to determine how to sort each element of the sequence. It i...
[ "Convenience", "function", "to", "properly", "sort", "non", "-", "numeric", "characters", "." ]
ea0d37ef790b42c424a096e079edd9ea0d5717e3
https://github.com/SethMMorton/natsort/blob/ea0d37ef790b42c424a096e079edd9ea0d5717e3/natsort/natsort.py#L271-L320
train
SethMMorton/natsort
natsort/natsort.py
realsorted
def realsorted(seq, key=None, reverse=False, alg=ns.DEFAULT): """ Convenience function to properly sort signed floats. A signed float in a string could be "a-5.7". This is a wrapper around ``natsorted(seq, alg=ns.REAL)``. The behavior of :func:`realsorted` for `natsort` version >= 4.0.0 was th...
python
def realsorted(seq, key=None, reverse=False, alg=ns.DEFAULT): """ Convenience function to properly sort signed floats. A signed float in a string could be "a-5.7". This is a wrapper around ``natsorted(seq, alg=ns.REAL)``. The behavior of :func:`realsorted` for `natsort` version >= 4.0.0 was th...
[ "def", "realsorted", "(", "seq", ",", "key", "=", "None", ",", "reverse", "=", "False", ",", "alg", "=", "ns", ".", "DEFAULT", ")", ":", "return", "natsorted", "(", "seq", ",", "key", ",", "reverse", ",", "alg", "|", "ns", ".", "REAL", ")" ]
Convenience function to properly sort signed floats. A signed float in a string could be "a-5.7". This is a wrapper around ``natsorted(seq, alg=ns.REAL)``. The behavior of :func:`realsorted` for `natsort` version >= 4.0.0 was the default behavior of :func:`natsorted` for `natsort` version < 4.0.0....
[ "Convenience", "function", "to", "properly", "sort", "signed", "floats", "." ]
ea0d37ef790b42c424a096e079edd9ea0d5717e3
https://github.com/SethMMorton/natsort/blob/ea0d37ef790b42c424a096e079edd9ea0d5717e3/natsort/natsort.py#L324-L374
train
SethMMorton/natsort
natsort/natsort.py
index_natsorted
def index_natsorted(seq, key=None, reverse=False, alg=ns.DEFAULT): """ Determine the list of the indexes used to sort the input sequence. Sorts a sequence naturally, but returns a list of sorted the indexes and not the sorted list itself. This list of indexes can be used to sort multiple lists by t...
python
def index_natsorted(seq, key=None, reverse=False, alg=ns.DEFAULT): """ Determine the list of the indexes used to sort the input sequence. Sorts a sequence naturally, but returns a list of sorted the indexes and not the sorted list itself. This list of indexes can be used to sort multiple lists by t...
[ "def", "index_natsorted", "(", "seq", ",", "key", "=", "None", ",", "reverse", "=", "False", ",", "alg", "=", "ns", ".", "DEFAULT", ")", ":", "if", "key", "is", "None", ":", "newkey", "=", "itemgetter", "(", "1", ")", "else", ":", "def", "newkey", ...
Determine the list of the indexes used to sort the input sequence. Sorts a sequence naturally, but returns a list of sorted the indexes and not the sorted list itself. This list of indexes can be used to sort multiple lists by the sorted order of the given sequence. Parameters ---------- s...
[ "Determine", "the", "list", "of", "the", "indexes", "used", "to", "sort", "the", "input", "sequence", "." ]
ea0d37ef790b42c424a096e079edd9ea0d5717e3
https://github.com/SethMMorton/natsort/blob/ea0d37ef790b42c424a096e079edd9ea0d5717e3/natsort/natsort.py#L378-L444
train
SethMMorton/natsort
natsort/natsort.py
order_by_index
def order_by_index(seq, index, iter=False): """ Order a given sequence by an index sequence. The output of `index_natsorted` is a sequence of integers (index) that correspond to how its input sequence **would** be sorted. The idea is that this index can be used to reorder multiple sequences by ...
python
def order_by_index(seq, index, iter=False): """ Order a given sequence by an index sequence. The output of `index_natsorted` is a sequence of integers (index) that correspond to how its input sequence **would** be sorted. The idea is that this index can be used to reorder multiple sequences by ...
[ "def", "order_by_index", "(", "seq", ",", "index", ",", "iter", "=", "False", ")", ":", "return", "(", "seq", "[", "i", "]", "for", "i", "in", "index", ")", "if", "iter", "else", "[", "seq", "[", "i", "]", "for", "i", "in", "index", "]" ]
Order a given sequence by an index sequence. The output of `index_natsorted` is a sequence of integers (index) that correspond to how its input sequence **would** be sorted. The idea is that this index can be used to reorder multiple sequences by the sorted order of the first sequence. This functio...
[ "Order", "a", "given", "sequence", "by", "an", "index", "sequence", "." ]
ea0d37ef790b42c424a096e079edd9ea0d5717e3
https://github.com/SethMMorton/natsort/blob/ea0d37ef790b42c424a096e079edd9ea0d5717e3/natsort/natsort.py#L545-L601
train
vpelletier/pprofile
zpprofile.py
ZopeMixIn._iterOutFiles
def _iterOutFiles(self): """ Yields path, data, mimetype for each file involved on or produced by profiling. """ out = StringIO() self.callgrind(out, relative_path=True) yield ( 'cachegrind.out.pprofile', out.getvalue(), 'applic...
python
def _iterOutFiles(self): """ Yields path, data, mimetype for each file involved on or produced by profiling. """ out = StringIO() self.callgrind(out, relative_path=True) yield ( 'cachegrind.out.pprofile', out.getvalue(), 'applic...
[ "def", "_iterOutFiles", "(", "self", ")", ":", "out", "=", "StringIO", "(", ")", "self", ".", "callgrind", "(", "out", ",", "relative_path", "=", "True", ")", "yield", "(", "'cachegrind.out.pprofile'", ",", "out", ".", "getvalue", "(", ")", ",", "'applic...
Yields path, data, mimetype for each file involved on or produced by profiling.
[ "Yields", "path", "data", "mimetype", "for", "each", "file", "involved", "on", "or", "produced", "by", "profiling", "." ]
51a36896727565faf23e5abccc9204e5f935fe1e
https://github.com/vpelletier/pprofile/blob/51a36896727565faf23e5abccc9204e5f935fe1e/zpprofile.py#L407-L486
train
vpelletier/pprofile
pprofile.py
run
def run(cmd, filename=None, threads=True, verbose=False): """Similar to profile.run .""" _run(threads, verbose, 'run', filename, cmd)
python
def run(cmd, filename=None, threads=True, verbose=False): """Similar to profile.run .""" _run(threads, verbose, 'run', filename, cmd)
[ "def", "run", "(", "cmd", ",", "filename", "=", "None", ",", "threads", "=", "True", ",", "verbose", "=", "False", ")", ":", "_run", "(", "threads", ",", "verbose", ",", "'run'", ",", "filename", ",", "cmd", ")" ]
Similar to profile.run .
[ "Similar", "to", "profile", ".", "run", "." ]
51a36896727565faf23e5abccc9204e5f935fe1e
https://github.com/vpelletier/pprofile/blob/51a36896727565faf23e5abccc9204e5f935fe1e/pprofile.py#L1182-L1184
train
vpelletier/pprofile
pprofile.py
runctx
def runctx(cmd, globals, locals, filename=None, threads=True, verbose=False): """Similar to profile.runctx .""" _run(threads, verbose, 'runctx', filename, cmd, globals, locals)
python
def runctx(cmd, globals, locals, filename=None, threads=True, verbose=False): """Similar to profile.runctx .""" _run(threads, verbose, 'runctx', filename, cmd, globals, locals)
[ "def", "runctx", "(", "cmd", ",", "globals", ",", "locals", ",", "filename", "=", "None", ",", "threads", "=", "True", ",", "verbose", "=", "False", ")", ":", "_run", "(", "threads", ",", "verbose", ",", "'runctx'", ",", "filename", ",", "cmd", ",", ...
Similar to profile.runctx .
[ "Similar", "to", "profile", ".", "runctx", "." ]
51a36896727565faf23e5abccc9204e5f935fe1e
https://github.com/vpelletier/pprofile/blob/51a36896727565faf23e5abccc9204e5f935fe1e/pprofile.py#L1186-L1188
train
vpelletier/pprofile
pprofile.py
runfile
def runfile(fd, argv, fd_name='<unknown>', compile_flags=0, dont_inherit=1, filename=None, threads=True, verbose=False): """ Run code from given file descriptor with profiling enabled. Closes fd before executing contained code. """ _run(threads, verbose, 'runfile', filename, fd, argv, fd_nam...
python
def runfile(fd, argv, fd_name='<unknown>', compile_flags=0, dont_inherit=1, filename=None, threads=True, verbose=False): """ Run code from given file descriptor with profiling enabled. Closes fd before executing contained code. """ _run(threads, verbose, 'runfile', filename, fd, argv, fd_nam...
[ "def", "runfile", "(", "fd", ",", "argv", ",", "fd_name", "=", "'<unknown>'", ",", "compile_flags", "=", "0", ",", "dont_inherit", "=", "1", ",", "filename", "=", "None", ",", "threads", "=", "True", ",", "verbose", "=", "False", ")", ":", "_run", "(...
Run code from given file descriptor with profiling enabled. Closes fd before executing contained code.
[ "Run", "code", "from", "given", "file", "descriptor", "with", "profiling", "enabled", ".", "Closes", "fd", "before", "executing", "contained", "code", "." ]
51a36896727565faf23e5abccc9204e5f935fe1e
https://github.com/vpelletier/pprofile/blob/51a36896727565faf23e5abccc9204e5f935fe1e/pprofile.py#L1190-L1197
train
vpelletier/pprofile
pprofile.py
runpath
def runpath(path, argv, filename=None, threads=True, verbose=False): """ Run code from open-accessible file path with profiling enabled. """ _run(threads, verbose, 'runpath', filename, path, argv)
python
def runpath(path, argv, filename=None, threads=True, verbose=False): """ Run code from open-accessible file path with profiling enabled. """ _run(threads, verbose, 'runpath', filename, path, argv)
[ "def", "runpath", "(", "path", ",", "argv", ",", "filename", "=", "None", ",", "threads", "=", "True", ",", "verbose", "=", "False", ")", ":", "_run", "(", "threads", ",", "verbose", ",", "'runpath'", ",", "filename", ",", "path", ",", "argv", ")" ]
Run code from open-accessible file path with profiling enabled.
[ "Run", "code", "from", "open", "-", "accessible", "file", "path", "with", "profiling", "enabled", "." ]
51a36896727565faf23e5abccc9204e5f935fe1e
https://github.com/vpelletier/pprofile/blob/51a36896727565faf23e5abccc9204e5f935fe1e/pprofile.py#L1199-L1203
train
vpelletier/pprofile
pprofile.py
pprofile
def pprofile(line, cell=None): """ Profile line execution. """ if cell is None: # TODO: detect and use arguments (statistical profiling, ...) ? return run(line) return _main( ['%%pprofile', '-m', '-'] + shlex.split(line), io.StringIO(cell), )
python
def pprofile(line, cell=None): """ Profile line execution. """ if cell is None: # TODO: detect and use arguments (statistical profiling, ...) ? return run(line) return _main( ['%%pprofile', '-m', '-'] + shlex.split(line), io.StringIO(cell), )
[ "def", "pprofile", "(", "line", ",", "cell", "=", "None", ")", ":", "if", "cell", "is", "None", ":", "return", "run", "(", "line", ")", "return", "_main", "(", "[", "'%%pprofile'", ",", "'-m'", ",", "'-'", "]", "+", "shlex", ".", "split", "(", "l...
Profile line execution.
[ "Profile", "line", "execution", "." ]
51a36896727565faf23e5abccc9204e5f935fe1e
https://github.com/vpelletier/pprofile/blob/51a36896727565faf23e5abccc9204e5f935fe1e/pprofile.py#L1388-L1398
train
vpelletier/pprofile
pprofile.py
_FileTiming.hit
def hit(self, code, line, duration): """ A line has finished executing. code (code) container function's code object line (int) line number of just executed line duration (float) duration of the line, in seconds """ entry = self.line...
python
def hit(self, code, line, duration): """ A line has finished executing. code (code) container function's code object line (int) line number of just executed line duration (float) duration of the line, in seconds """ entry = self.line...
[ "def", "hit", "(", "self", ",", "code", ",", "line", ",", "duration", ")", ":", "entry", "=", "self", ".", "line_dict", "[", "line", "]", "[", "code", "]", "entry", "[", "0", "]", "+=", "1", "entry", "[", "1", "]", "+=", "duration" ]
A line has finished executing. code (code) container function's code object line (int) line number of just executed line duration (float) duration of the line, in seconds
[ "A", "line", "has", "finished", "executing", "." ]
51a36896727565faf23e5abccc9204e5f935fe1e
https://github.com/vpelletier/pprofile/blob/51a36896727565faf23e5abccc9204e5f935fe1e/pprofile.py#L192-L205
train
vpelletier/pprofile
pprofile.py
_FileTiming.call
def call(self, code, line, callee_file_timing, callee, duration, frame): """ A call originating from this file returned. code (code) caller's code object line (int) caller's line number callee_file_timing (FileTiming) callee's FileTiming cal...
python
def call(self, code, line, callee_file_timing, callee, duration, frame): """ A call originating from this file returned. code (code) caller's code object line (int) caller's line number callee_file_timing (FileTiming) callee's FileTiming cal...
[ "def", "call", "(", "self", ",", "code", ",", "line", ",", "callee_file_timing", ",", "callee", ",", "duration", ",", "frame", ")", ":", "try", ":", "entry", "=", "self", ".", "call_dict", "[", "(", "code", ",", "line", ",", "callee", ")", "]", "ex...
A call originating from this file returned. code (code) caller's code object line (int) caller's line number callee_file_timing (FileTiming) callee's FileTiming callee (code) callee's code object duration (float) duration of the ...
[ "A", "call", "originating", "from", "this", "file", "returned", "." ]
51a36896727565faf23e5abccc9204e5f935fe1e
https://github.com/vpelletier/pprofile/blob/51a36896727565faf23e5abccc9204e5f935fe1e/pprofile.py#L207-L230
train
vpelletier/pprofile
pprofile.py
ProfileBase.dump_stats
def dump_stats(self, filename): """ Similar to profile.Profile.dump_stats - but different output format ! """ if _isCallgrindName(filename): with open(filename, 'w') as out: self.callgrind(out) else: with io.open(filename, 'w', errors='repl...
python
def dump_stats(self, filename): """ Similar to profile.Profile.dump_stats - but different output format ! """ if _isCallgrindName(filename): with open(filename, 'w') as out: self.callgrind(out) else: with io.open(filename, 'w', errors='repl...
[ "def", "dump_stats", "(", "self", ",", "filename", ")", ":", "if", "_isCallgrindName", "(", "filename", ")", ":", "with", "open", "(", "filename", ",", "'w'", ")", "as", "out", ":", "self", ".", "callgrind", "(", "out", ")", "else", ":", "with", "io"...
Similar to profile.Profile.dump_stats - but different output format !
[ "Similar", "to", "profile", ".", "Profile", ".", "dump_stats", "-", "but", "different", "output", "format", "!" ]
51a36896727565faf23e5abccc9204e5f935fe1e
https://github.com/vpelletier/pprofile/blob/51a36896727565faf23e5abccc9204e5f935fe1e/pprofile.py#L723-L732
train
vpelletier/pprofile
pprofile.py
ProfileRunnerBase.runctx
def runctx(self, cmd, globals, locals): """Similar to profile.Profile.runctx .""" with self(): exec(cmd, globals, locals) return self
python
def runctx(self, cmd, globals, locals): """Similar to profile.Profile.runctx .""" with self(): exec(cmd, globals, locals) return self
[ "def", "runctx", "(", "self", ",", "cmd", ",", "globals", ",", "locals", ")", ":", "with", "self", "(", ")", ":", "exec", "(", "cmd", ",", "globals", ",", "locals", ")", "return", "self" ]
Similar to profile.Profile.runctx .
[ "Similar", "to", "profile", ".", "Profile", ".", "runctx", "." ]
51a36896727565faf23e5abccc9204e5f935fe1e
https://github.com/vpelletier/pprofile/blob/51a36896727565faf23e5abccc9204e5f935fe1e/pprofile.py#L752-L756
train
vpelletier/pprofile
pprofile.py
Profile.enable
def enable(self): """ Enable profiling. """ if self.enabled_start: warn('Duplicate "enable" call') else: self._enable() sys.settrace(self._global_trace)
python
def enable(self): """ Enable profiling. """ if self.enabled_start: warn('Duplicate "enable" call') else: self._enable() sys.settrace(self._global_trace)
[ "def", "enable", "(", "self", ")", ":", "if", "self", ".", "enabled_start", ":", "warn", "(", "'Duplicate \"enable\" call'", ")", "else", ":", "self", ".", "_enable", "(", ")", "sys", ".", "settrace", "(", "self", ".", "_global_trace", ")" ]
Enable profiling.
[ "Enable", "profiling", "." ]
51a36896727565faf23e5abccc9204e5f935fe1e
https://github.com/vpelletier/pprofile/blob/51a36896727565faf23e5abccc9204e5f935fe1e/pprofile.py#L843-L851
train
vpelletier/pprofile
pprofile.py
Profile._disable
def _disable(self): """ Overload this method when subclassing. Called after actually disabling trace. """ self.total_time += time() - self.enabled_start self.enabled_start = None del self.stack
python
def _disable(self): """ Overload this method when subclassing. Called after actually disabling trace. """ self.total_time += time() - self.enabled_start self.enabled_start = None del self.stack
[ "def", "_disable", "(", "self", ")", ":", "self", ".", "total_time", "+=", "time", "(", ")", "-", "self", ".", "enabled_start", "self", ".", "enabled_start", "=", "None", "del", "self", ".", "stack" ]
Overload this method when subclassing. Called after actually disabling trace.
[ "Overload", "this", "method", "when", "subclassing", ".", "Called", "after", "actually", "disabling", "trace", "." ]
51a36896727565faf23e5abccc9204e5f935fe1e
https://github.com/vpelletier/pprofile/blob/51a36896727565faf23e5abccc9204e5f935fe1e/pprofile.py#L853-L860
train
rsinger86/drf-flex-fields
rest_flex_fields/serializers.py
FlexFieldsSerializerMixin._make_expanded_field_serializer
def _make_expanded_field_serializer( self, name, nested_expand, nested_fields, nested_omit ): """ Returns an instance of the dynamically created nested serializer. """ field_options = self.expandable_fields[name] serializer_class = field_options[0] serializer_...
python
def _make_expanded_field_serializer( self, name, nested_expand, nested_fields, nested_omit ): """ Returns an instance of the dynamically created nested serializer. """ field_options = self.expandable_fields[name] serializer_class = field_options[0] serializer_...
[ "def", "_make_expanded_field_serializer", "(", "self", ",", "name", ",", "nested_expand", ",", "nested_fields", ",", "nested_omit", ")", ":", "field_options", "=", "self", ".", "expandable_fields", "[", "name", "]", "serializer_class", "=", "field_options", "[", "...
Returns an instance of the dynamically created nested serializer.
[ "Returns", "an", "instance", "of", "the", "dynamically", "created", "nested", "serializer", "." ]
56495f15977d76697972acac571792e8fd67003d
https://github.com/rsinger86/drf-flex-fields/blob/56495f15977d76697972acac571792e8fd67003d/rest_flex_fields/serializers.py#L50-L75
train
rsinger86/drf-flex-fields
rest_flex_fields/serializers.py
FlexFieldsSerializerMixin._clean_fields
def _clean_fields(self, omit_fields, sparse_fields, next_level_omits): """ Remove fields that are found in omit list, and if sparse names are passed, remove any fields not found in that list. """ sparse = len(sparse_fields) > 0 to_remove = [] if not spars...
python
def _clean_fields(self, omit_fields, sparse_fields, next_level_omits): """ Remove fields that are found in omit list, and if sparse names are passed, remove any fields not found in that list. """ sparse = len(sparse_fields) > 0 to_remove = [] if not spars...
[ "def", "_clean_fields", "(", "self", ",", "omit_fields", ",", "sparse_fields", ",", "next_level_omits", ")", ":", "sparse", "=", "len", "(", "sparse_fields", ")", ">", "0", "to_remove", "=", "[", "]", "if", "not", "sparse", "and", "len", "(", "omit_fields"...
Remove fields that are found in omit list, and if sparse names are passed, remove any fields not found in that list.
[ "Remove", "fields", "that", "are", "found", "in", "omit", "list", "and", "if", "sparse", "names", "are", "passed", "remove", "any", "fields", "not", "found", "in", "that", "list", "." ]
56495f15977d76697972acac571792e8fd67003d
https://github.com/rsinger86/drf-flex-fields/blob/56495f15977d76697972acac571792e8fd67003d/rest_flex_fields/serializers.py#L92-L112
train
rsinger86/drf-flex-fields
rest_flex_fields/serializers.py
FlexFieldsSerializerMixin._can_access_request
def _can_access_request(self): """ Can access current request object if all are true - The serializer is the root. - A request context was passed in. - The request method is GET. """ if self.parent: return False if not hasattr(self, "context")...
python
def _can_access_request(self): """ Can access current request object if all are true - The serializer is the root. - A request context was passed in. - The request method is GET. """ if self.parent: return False if not hasattr(self, "context")...
[ "def", "_can_access_request", "(", "self", ")", ":", "if", "self", ".", "parent", ":", "return", "False", "if", "not", "hasattr", "(", "self", ",", "\"context\"", ")", "or", "not", "self", ".", "context", ".", "get", "(", "\"request\"", ",", "None", ")...
Can access current request object if all are true - The serializer is the root. - A request context was passed in. - The request method is GET.
[ "Can", "access", "current", "request", "object", "if", "all", "are", "true", "-", "The", "serializer", "is", "the", "root", ".", "-", "A", "request", "context", "was", "passed", "in", ".", "-", "The", "request", "method", "is", "GET", "." ]
56495f15977d76697972acac571792e8fd67003d
https://github.com/rsinger86/drf-flex-fields/blob/56495f15977d76697972acac571792e8fd67003d/rest_flex_fields/serializers.py#L158-L171
train
rsinger86/drf-flex-fields
rest_flex_fields/serializers.py
FlexFieldsSerializerMixin._get_expand_input
def _get_expand_input(self, passed_settings): """ If expand value is explicitliy passed, just return it. If parsing from request, ensure that the value complies with the "permitted_expands" list passed into the context from the FlexFieldsMixin. """ ...
python
def _get_expand_input(self, passed_settings): """ If expand value is explicitliy passed, just return it. If parsing from request, ensure that the value complies with the "permitted_expands" list passed into the context from the FlexFieldsMixin. """ ...
[ "def", "_get_expand_input", "(", "self", ",", "passed_settings", ")", ":", "value", "=", "passed_settings", ".", "get", "(", "\"expand\"", ")", "if", "len", "(", "value", ")", ">", "0", ":", "return", "value", "if", "not", "self", ".", "_can_access_request...
If expand value is explicitliy passed, just return it. If parsing from request, ensure that the value complies with the "permitted_expands" list passed into the context from the FlexFieldsMixin.
[ "If", "expand", "value", "is", "explicitliy", "passed", "just", "return", "it", ".", "If", "parsing", "from", "request", "ensure", "that", "the", "value", "complies", "with", "the", "permitted_expands", "list", "passed", "into", "the", "context", "from", "the"...
56495f15977d76697972acac571792e8fd67003d
https://github.com/rsinger86/drf-flex-fields/blob/56495f15977d76697972acac571792e8fd67003d/rest_flex_fields/serializers.py#L196-L221
train
rsinger86/drf-flex-fields
rest_flex_fields/utils.py
is_expanded
def is_expanded(request, key): """ Examines request object to return boolean of whether passed field is expanded. """ expand = request.query_params.get("expand", "") expand_fields = [] for e in expand.split(","): expand_fields.extend([e for e in e.split(".")]) return "~all" in ...
python
def is_expanded(request, key): """ Examines request object to return boolean of whether passed field is expanded. """ expand = request.query_params.get("expand", "") expand_fields = [] for e in expand.split(","): expand_fields.extend([e for e in e.split(".")]) return "~all" in ...
[ "def", "is_expanded", "(", "request", ",", "key", ")", ":", "expand", "=", "request", ".", "query_params", ".", "get", "(", "\"expand\"", ",", "\"\"", ")", "expand_fields", "=", "[", "]", "for", "e", "in", "expand", ".", "split", "(", "\",\"", ")", "...
Examines request object to return boolean of whether passed field is expanded.
[ "Examines", "request", "object", "to", "return", "boolean", "of", "whether", "passed", "field", "is", "expanded", "." ]
56495f15977d76697972acac571792e8fd67003d
https://github.com/rsinger86/drf-flex-fields/blob/56495f15977d76697972acac571792e8fd67003d/rest_flex_fields/utils.py#L1-L11
train
chinuno-usami/CuteR
CuteR/CuteR.py
color_replace
def color_replace(image, color): """Replace black with other color :color: custom color (r,g,b,a) :image: image to replace color :returns: TODO """ pixels = image.load() size = image.size[0] for width in range(size): for height in range(size): r, g, b, a = pixels[wi...
python
def color_replace(image, color): """Replace black with other color :color: custom color (r,g,b,a) :image: image to replace color :returns: TODO """ pixels = image.load() size = image.size[0] for width in range(size): for height in range(size): r, g, b, a = pixels[wi...
[ "def", "color_replace", "(", "image", ",", "color", ")", ":", "pixels", "=", "image", ".", "load", "(", ")", "size", "=", "image", ".", "size", "[", "0", "]", "for", "width", "in", "range", "(", "size", ")", ":", "for", "height", "in", "range", "...
Replace black with other color :color: custom color (r,g,b,a) :image: image to replace color :returns: TODO
[ "Replace", "black", "with", "other", "color" ]
ba4e017d3460bda9c1ccaf90723ddbfd4cc5426c
https://github.com/chinuno-usami/CuteR/blob/ba4e017d3460bda9c1ccaf90723ddbfd4cc5426c/CuteR/CuteR.py#L10-L26
train
maroba/findiff
findiff/vector.py
wrap_in_ndarray
def wrap_in_ndarray(value): """Wraps the argument in a numpy.ndarray. If value is a scalar, it is converted in a list first. If value is array-like, the shape is conserved. """ if hasattr(value, "__len__"): return np.array(value) else: return np.array([value])
python
def wrap_in_ndarray(value): """Wraps the argument in a numpy.ndarray. If value is a scalar, it is converted in a list first. If value is array-like, the shape is conserved. """ if hasattr(value, "__len__"): return np.array(value) else: return np.array([value])
[ "def", "wrap_in_ndarray", "(", "value", ")", ":", "if", "hasattr", "(", "value", ",", "\"__len__\"", ")", ":", "return", "np", ".", "array", "(", "value", ")", "else", ":", "return", "np", ".", "array", "(", "[", "value", "]", ")" ]
Wraps the argument in a numpy.ndarray. If value is a scalar, it is converted in a list first. If value is array-like, the shape is conserved.
[ "Wraps", "the", "argument", "in", "a", "numpy", ".", "ndarray", "." ]
5d1ccfa966ce2bd556b4425583f8b9bbcbf183ac
https://github.com/maroba/findiff/blob/5d1ccfa966ce2bd556b4425583f8b9bbcbf183ac/findiff/vector.py#L264-L275
train
maroba/findiff
findiff/coefs.py
coefficients_non_uni
def coefficients_non_uni(deriv, acc, coords, idx): """ Calculates the finite difference coefficients for given derivative order and accuracy order. Assumes that the underlying grid is non-uniform. :param deriv: int > 0: The derivative order. :param acc: even int > 0: The accuracy order. ...
python
def coefficients_non_uni(deriv, acc, coords, idx): """ Calculates the finite difference coefficients for given derivative order and accuracy order. Assumes that the underlying grid is non-uniform. :param deriv: int > 0: The derivative order. :param acc: even int > 0: The accuracy order. ...
[ "def", "coefficients_non_uni", "(", "deriv", ",", "acc", ",", "coords", ",", "idx", ")", ":", "if", "acc", "%", "2", "==", "1", ":", "acc", "+=", "1", "num_central", "=", "2", "*", "math", ".", "floor", "(", "(", "deriv", "+", "1", ")", "/", "2...
Calculates the finite difference coefficients for given derivative order and accuracy order. Assumes that the underlying grid is non-uniform. :param deriv: int > 0: The derivative order. :param acc: even int > 0: The accuracy order. :param coords: 1D numpy.ndarray: the coordinates of the axis ...
[ "Calculates", "the", "finite", "difference", "coefficients", "for", "given", "derivative", "order", "and", "accuracy", "order", ".", "Assumes", "that", "the", "underlying", "grid", "is", "non", "-", "uniform", "." ]
5d1ccfa966ce2bd556b4425583f8b9bbcbf183ac
https://github.com/maroba/findiff/blob/5d1ccfa966ce2bd556b4425583f8b9bbcbf183ac/findiff/coefs.py#L63-L120
train
maroba/findiff
findiff/coefs.py
_build_matrix
def _build_matrix(p, q, deriv): """Constructs the equation system matrix for the finite difference coefficients""" A = [([1 for _ in range(-p, q+1)])] for i in range(1, p + q + 1): A.append([j**i for j in range(-p, q+1)]) return np.array(A)
python
def _build_matrix(p, q, deriv): """Constructs the equation system matrix for the finite difference coefficients""" A = [([1 for _ in range(-p, q+1)])] for i in range(1, p + q + 1): A.append([j**i for j in range(-p, q+1)]) return np.array(A)
[ "def", "_build_matrix", "(", "p", ",", "q", ",", "deriv", ")", ":", "A", "=", "[", "(", "[", "1", "for", "_", "in", "range", "(", "-", "p", ",", "q", "+", "1", ")", "]", ")", "]", "for", "i", "in", "range", "(", "1", ",", "p", "+", "q",...
Constructs the equation system matrix for the finite difference coefficients
[ "Constructs", "the", "equation", "system", "matrix", "for", "the", "finite", "difference", "coefficients" ]
5d1ccfa966ce2bd556b4425583f8b9bbcbf183ac
https://github.com/maroba/findiff/blob/5d1ccfa966ce2bd556b4425583f8b9bbcbf183ac/findiff/coefs.py#L123-L128
train
maroba/findiff
findiff/coefs.py
_build_rhs
def _build_rhs(p, q, deriv): """The right hand side of the equation system matrix""" b = [0 for _ in range(p+q+1)] b[deriv] = math.factorial(deriv) return np.array(b)
python
def _build_rhs(p, q, deriv): """The right hand side of the equation system matrix""" b = [0 for _ in range(p+q+1)] b[deriv] = math.factorial(deriv) return np.array(b)
[ "def", "_build_rhs", "(", "p", ",", "q", ",", "deriv", ")", ":", "b", "=", "[", "0", "for", "_", "in", "range", "(", "p", "+", "q", "+", "1", ")", "]", "b", "[", "deriv", "]", "=", "math", ".", "factorial", "(", "deriv", ")", "return", "np"...
The right hand side of the equation system matrix
[ "The", "right", "hand", "side", "of", "the", "equation", "system", "matrix" ]
5d1ccfa966ce2bd556b4425583f8b9bbcbf183ac
https://github.com/maroba/findiff/blob/5d1ccfa966ce2bd556b4425583f8b9bbcbf183ac/findiff/coefs.py#L131-L136
train
maroba/findiff
findiff/coefs.py
_build_matrix_non_uniform
def _build_matrix_non_uniform(p, q, coords, k): """Constructs the equation matrix for the finite difference coefficients of non-uniform grids at location k""" A = [[1] * (p+q+1)] for i in range(1, p + q + 1): line = [(coords[k+j] - coords[k])**i for j in range(-p, q+1)] A.append(line) re...
python
def _build_matrix_non_uniform(p, q, coords, k): """Constructs the equation matrix for the finite difference coefficients of non-uniform grids at location k""" A = [[1] * (p+q+1)] for i in range(1, p + q + 1): line = [(coords[k+j] - coords[k])**i for j in range(-p, q+1)] A.append(line) re...
[ "def", "_build_matrix_non_uniform", "(", "p", ",", "q", ",", "coords", ",", "k", ")", ":", "A", "=", "[", "[", "1", "]", "*", "(", "p", "+", "q", "+", "1", ")", "]", "for", "i", "in", "range", "(", "1", ",", "p", "+", "q", "+", "1", ")", ...
Constructs the equation matrix for the finite difference coefficients of non-uniform grids at location k
[ "Constructs", "the", "equation", "matrix", "for", "the", "finite", "difference", "coefficients", "of", "non", "-", "uniform", "grids", "at", "location", "k" ]
5d1ccfa966ce2bd556b4425583f8b9bbcbf183ac
https://github.com/maroba/findiff/blob/5d1ccfa966ce2bd556b4425583f8b9bbcbf183ac/findiff/coefs.py#L139-L145
train
maroba/findiff
findiff/operators.py
FinDiff.set_accuracy
def set_accuracy(self, acc): """ Sets the accuracy order of the finite difference scheme. If the FinDiff object is not a raw partial derivative but a composition of derivatives the accuracy order will be propagated to the child operators. """ self.acc = acc if sel...
python
def set_accuracy(self, acc): """ Sets the accuracy order of the finite difference scheme. If the FinDiff object is not a raw partial derivative but a composition of derivatives the accuracy order will be propagated to the child operators. """ self.acc = acc if sel...
[ "def", "set_accuracy", "(", "self", ",", "acc", ")", ":", "self", ".", "acc", "=", "acc", "if", "self", ".", "child", ":", "self", ".", "child", ".", "set_accuracy", "(", "acc", ")" ]
Sets the accuracy order of the finite difference scheme. If the FinDiff object is not a raw partial derivative but a composition of derivatives the accuracy order will be propagated to the child operators.
[ "Sets", "the", "accuracy", "order", "of", "the", "finite", "difference", "scheme", ".", "If", "the", "FinDiff", "object", "is", "not", "a", "raw", "partial", "derivative", "but", "a", "composition", "of", "derivatives", "the", "accuracy", "order", "will", "b...
5d1ccfa966ce2bd556b4425583f8b9bbcbf183ac
https://github.com/maroba/findiff/blob/5d1ccfa966ce2bd556b4425583f8b9bbcbf183ac/findiff/operators.py#L166-L173
train
maroba/findiff
findiff/operators.py
FinDiff.diff
def diff(self, y, h, deriv, dim, coefs): """The core function to take a partial derivative on a uniform grid. """ try: npts = y.shape[dim] except AttributeError as err: raise ValueError("FinDiff objects can only be applied to arrays or evaluated(!) functions retu...
python
def diff(self, y, h, deriv, dim, coefs): """The core function to take a partial derivative on a uniform grid. """ try: npts = y.shape[dim] except AttributeError as err: raise ValueError("FinDiff objects can only be applied to arrays or evaluated(!) functions retu...
[ "def", "diff", "(", "self", ",", "y", ",", "h", ",", "deriv", ",", "dim", ",", "coefs", ")", ":", "try", ":", "npts", "=", "y", ".", "shape", "[", "dim", "]", "except", "AttributeError", "as", "err", ":", "raise", "ValueError", "(", "\"FinDiff obje...
The core function to take a partial derivative on a uniform grid.
[ "The", "core", "function", "to", "take", "a", "partial", "derivative", "on", "a", "uniform", "grid", "." ]
5d1ccfa966ce2bd556b4425583f8b9bbcbf183ac
https://github.com/maroba/findiff/blob/5d1ccfa966ce2bd556b4425583f8b9bbcbf183ac/findiff/operators.py#L215-L255
train
maroba/findiff
findiff/operators.py
FinDiff.diff_non_uni
def diff_non_uni(self, y, coords, dim, coefs): """The core function to take a partial derivative on a non-uniform grid""" yd = np.zeros_like(y) ndims = len(y.shape) multi_slice = [slice(None, None)] * ndims ref_multi_slice = [slice(None, None)] * ndims for i, x in enum...
python
def diff_non_uni(self, y, coords, dim, coefs): """The core function to take a partial derivative on a non-uniform grid""" yd = np.zeros_like(y) ndims = len(y.shape) multi_slice = [slice(None, None)] * ndims ref_multi_slice = [slice(None, None)] * ndims for i, x in enum...
[ "def", "diff_non_uni", "(", "self", ",", "y", ",", "coords", ",", "dim", ",", "coefs", ")", ":", "yd", "=", "np", ".", "zeros_like", "(", "y", ")", "ndims", "=", "len", "(", "y", ".", "shape", ")", "multi_slice", "=", "[", "slice", "(", "None", ...
The core function to take a partial derivative on a non-uniform grid
[ "The", "core", "function", "to", "take", "a", "partial", "derivative", "on", "a", "non", "-", "uniform", "grid" ]
5d1ccfa966ce2bd556b4425583f8b9bbcbf183ac
https://github.com/maroba/findiff/blob/5d1ccfa966ce2bd556b4425583f8b9bbcbf183ac/findiff/operators.py#L257-L275
train
maroba/findiff
findiff/operators.py
FinDiff._apply_to_array
def _apply_to_array(self, yd, y, weights, off_slices, ref_slice, dim): """Applies the finite differences only to slices along a given axis""" ndims = len(y.shape) all = slice(None, None, 1) ref_multi_slice = [all] * ndims ref_multi_slice[dim] = ref_slice for w, s in z...
python
def _apply_to_array(self, yd, y, weights, off_slices, ref_slice, dim): """Applies the finite differences only to slices along a given axis""" ndims = len(y.shape) all = slice(None, None, 1) ref_multi_slice = [all] * ndims ref_multi_slice[dim] = ref_slice for w, s in z...
[ "def", "_apply_to_array", "(", "self", ",", "yd", ",", "y", ",", "weights", ",", "off_slices", ",", "ref_slice", ",", "dim", ")", ":", "ndims", "=", "len", "(", "y", ".", "shape", ")", "all", "=", "slice", "(", "None", ",", "None", ",", "1", ")",...
Applies the finite differences only to slices along a given axis
[ "Applies", "the", "finite", "differences", "only", "to", "slices", "along", "a", "given", "axis" ]
5d1ccfa966ce2bd556b4425583f8b9bbcbf183ac
https://github.com/maroba/findiff/blob/5d1ccfa966ce2bd556b4425583f8b9bbcbf183ac/findiff/operators.py#L277-L293
train
anchore/anchore
anchore/anchore_auth.py
get_current_user_info
def get_current_user_info(anchore_auth): """ Return the metadata about the current user as supplied by the anchore.io service. Includes permissions and tier access. :return: Dict of user metadata """ user_url = anchore_auth['client_info_url'] + '/' + anchore_auth['username'] user_timeout = 60 ...
python
def get_current_user_info(anchore_auth): """ Return the metadata about the current user as supplied by the anchore.io service. Includes permissions and tier access. :return: Dict of user metadata """ user_url = anchore_auth['client_info_url'] + '/' + anchore_auth['username'] user_timeout = 60 ...
[ "def", "get_current_user_info", "(", "anchore_auth", ")", ":", "user_url", "=", "anchore_auth", "[", "'client_info_url'", "]", "+", "'/'", "+", "anchore_auth", "[", "'username'", "]", "user_timeout", "=", "60", "retries", "=", "3", "result", "=", "requests", "...
Return the metadata about the current user as supplied by the anchore.io service. Includes permissions and tier access. :return: Dict of user metadata
[ "Return", "the", "metadata", "about", "the", "current", "user", "as", "supplied", "by", "the", "anchore", ".", "io", "service", ".", "Includes", "permissions", "and", "tier", "access", "." ]
8a4d5b9708e27856312d303aae3f04f3c72039d6
https://github.com/anchore/anchore/blob/8a4d5b9708e27856312d303aae3f04f3c72039d6/anchore/anchore_auth.py#L47-L62
train
anchore/anchore
anchore/cli/policybundle.py
show
def show(details): """ Show list of Anchore data policies. """ ecode = 0 try: policymeta = anchore_policy.load_policymeta() if details: anchore_print(policymeta, do_formatting=True) else: output = {} name = policymeta['name'] ...
python
def show(details): """ Show list of Anchore data policies. """ ecode = 0 try: policymeta = anchore_policy.load_policymeta() if details: anchore_print(policymeta, do_formatting=True) else: output = {} name = policymeta['name'] ...
[ "def", "show", "(", "details", ")", ":", "ecode", "=", "0", "try", ":", "policymeta", "=", "anchore_policy", ".", "load_policymeta", "(", ")", "if", "details", ":", "anchore_print", "(", "policymeta", ",", "do_formatting", "=", "True", ")", "else", ":", ...
Show list of Anchore data policies.
[ "Show", "list", "of", "Anchore", "data", "policies", "." ]
8a4d5b9708e27856312d303aae3f04f3c72039d6
https://github.com/anchore/anchore/blob/8a4d5b9708e27856312d303aae3f04f3c72039d6/anchore/cli/policybundle.py#L30-L58
train
anchore/anchore
anchore/cli/common.py
extended_help_option
def extended_help_option(extended_help=None, *param_decls, **attrs): """ Based on the click.help_option code. Adds a ``--extended-help`` option which immediately ends the program printing out the extended extended-help page. Defaults to using the callback's doc string, but can be given an explicit ...
python
def extended_help_option(extended_help=None, *param_decls, **attrs): """ Based on the click.help_option code. Adds a ``--extended-help`` option which immediately ends the program printing out the extended extended-help page. Defaults to using the callback's doc string, but can be given an explicit ...
[ "def", "extended_help_option", "(", "extended_help", "=", "None", ",", "*", "param_decls", ",", "**", "attrs", ")", ":", "def", "decorator", "(", "f", ")", ":", "def", "callback", "(", "ctx", ",", "param", ",", "value", ")", ":", "if", "value", "and", ...
Based on the click.help_option code. Adds a ``--extended-help`` option which immediately ends the program printing out the extended extended-help page. Defaults to using the callback's doc string, but can be given an explicit value as well. This is intended for use as a decorator on a command to provi...
[ "Based", "on", "the", "click", ".", "help_option", "code", "." ]
8a4d5b9708e27856312d303aae3f04f3c72039d6
https://github.com/anchore/anchore/blob/8a4d5b9708e27856312d303aae3f04f3c72039d6/anchore/cli/common.py#L14-L49
train
anchore/anchore
anchore/cli/common.py
anchore_print
def anchore_print(msg, do_formatting=False): """ Print to stdout using the proper formatting for the command. :param msg: output to be printed, either an object or a string. Objects will be serialized according to config :return: """ if do_formatting: click.echo(formatter(msg)) else...
python
def anchore_print(msg, do_formatting=False): """ Print to stdout using the proper formatting for the command. :param msg: output to be printed, either an object or a string. Objects will be serialized according to config :return: """ if do_formatting: click.echo(formatter(msg)) else...
[ "def", "anchore_print", "(", "msg", ",", "do_formatting", "=", "False", ")", ":", "if", "do_formatting", ":", "click", ".", "echo", "(", "formatter", "(", "msg", ")", ")", "else", ":", "click", ".", "echo", "(", "msg", ")" ]
Print to stdout using the proper formatting for the command. :param msg: output to be printed, either an object or a string. Objects will be serialized according to config :return:
[ "Print", "to", "stdout", "using", "the", "proper", "formatting", "for", "the", "command", "." ]
8a4d5b9708e27856312d303aae3f04f3c72039d6
https://github.com/anchore/anchore/blob/8a4d5b9708e27856312d303aae3f04f3c72039d6/anchore/cli/common.py#L106-L116
train
anchore/anchore
anchore/cli/common.py
build_image_list
def build_image_list(config, image, imagefile, all_local, include_allanchore, dockerfile=None, exclude_file=None): """Given option inputs from the cli, construct a list of image ids. Includes all found with no exclusion logic""" if not image and not (imagefile or all_local): raise click.BadOptionUsage(...
python
def build_image_list(config, image, imagefile, all_local, include_allanchore, dockerfile=None, exclude_file=None): """Given option inputs from the cli, construct a list of image ids. Includes all found with no exclusion logic""" if not image and not (imagefile or all_local): raise click.BadOptionUsage(...
[ "def", "build_image_list", "(", "config", ",", "image", ",", "imagefile", ",", "all_local", ",", "include_allanchore", ",", "dockerfile", "=", "None", ",", "exclude_file", "=", "None", ")", ":", "if", "not", "image", "and", "not", "(", "imagefile", "or", "...
Given option inputs from the cli, construct a list of image ids. Includes all found with no exclusion logic
[ "Given", "option", "inputs", "from", "the", "cli", "construct", "a", "list", "of", "image", "ids", ".", "Includes", "all", "found", "with", "no", "exclusion", "logic" ]
8a4d5b9708e27856312d303aae3f04f3c72039d6
https://github.com/anchore/anchore/blob/8a4d5b9708e27856312d303aae3f04f3c72039d6/anchore/cli/common.py#L119-L172
train
anchore/anchore
anchore/cli/logs.py
init_output_formatters
def init_output_formatters(output_verbosity='normal', stderr=sys.stderr, logfile=None, debug_logfile=None): """ Initialize the CLI logging scheme. :param output_verbosity: 'quiet','normal','verbose', or 'debug' controls the output to stdout and its format :param stderr: stream for stderr output, defaul...
python
def init_output_formatters(output_verbosity='normal', stderr=sys.stderr, logfile=None, debug_logfile=None): """ Initialize the CLI logging scheme. :param output_verbosity: 'quiet','normal','verbose', or 'debug' controls the output to stdout and its format :param stderr: stream for stderr output, defaul...
[ "def", "init_output_formatters", "(", "output_verbosity", "=", "'normal'", ",", "stderr", "=", "sys", ".", "stderr", ",", "logfile", "=", "None", ",", "debug_logfile", "=", "None", ")", ":", "if", "output_verbosity", "not", "in", "console_verbosity_options", ":"...
Initialize the CLI logging scheme. :param output_verbosity: 'quiet','normal','verbose', or 'debug' controls the output to stdout and its format :param stderr: stream for stderr output, default=stderr, pass a file path/string to have stderr in a file :return:
[ "Initialize", "the", "CLI", "logging", "scheme", "." ]
8a4d5b9708e27856312d303aae3f04f3c72039d6
https://github.com/anchore/anchore/blob/8a4d5b9708e27856312d303aae3f04f3c72039d6/anchore/cli/logs.py#L105-L160
train
anchore/anchore
anchore/cli/__init__.py
main_entry
def main_entry(ctx, verbose, debug, quiet, json, plain, html, config_override): """ Anchore is a tool to analyze, query, and curate container images. The options at this top level control stdout and stderr verbosity and format. After installation, the first command run should be: 'anchore feeds lis...
python
def main_entry(ctx, verbose, debug, quiet, json, plain, html, config_override): """ Anchore is a tool to analyze, query, and curate container images. The options at this top level control stdout and stderr verbosity and format. After installation, the first command run should be: 'anchore feeds lis...
[ "def", "main_entry", "(", "ctx", ",", "verbose", ",", "debug", ",", "quiet", ",", "json", ",", "plain", ",", "html", ",", "config_override", ")", ":", "logfile", "=", "None", "debug_logfile", "=", "None", "try", ":", "try", ":", "config_overrides", "=", ...
Anchore is a tool to analyze, query, and curate container images. The options at this top level control stdout and stderr verbosity and format. After installation, the first command run should be: 'anchore feeds list' to initialize the system and load feed data. High-level example flows: Initial...
[ "Anchore", "is", "a", "tool", "to", "analyze", "query", "and", "curate", "container", "images", ".", "The", "options", "at", "this", "top", "level", "control", "stdout", "and", "stderr", "verbosity", "and", "format", "." ]
8a4d5b9708e27856312d303aae3f04f3c72039d6
https://github.com/anchore/anchore/blob/8a4d5b9708e27856312d303aae3f04f3c72039d6/anchore/cli/__init__.py#L101-L186
train
anchore/anchore
anchore/util/resources.py
get_user_agent
def get_user_agent(): """ Construct and informative user-agent string. Includes OS version and docker version info Not thread-safe :return: """ global user_agent_string if user_agent_string is None: # get OS type try: sysinfo = subprocess.check_output('lsb_r...
python
def get_user_agent(): """ Construct and informative user-agent string. Includes OS version and docker version info Not thread-safe :return: """ global user_agent_string if user_agent_string is None: # get OS type try: sysinfo = subprocess.check_output('lsb_r...
[ "def", "get_user_agent", "(", ")", ":", "global", "user_agent_string", "if", "user_agent_string", "is", "None", ":", "try", ":", "sysinfo", "=", "subprocess", ".", "check_output", "(", "'lsb_release -i -r -s'", ".", "split", "(", "' '", ")", ")", "dockerinfo", ...
Construct and informative user-agent string. Includes OS version and docker version info Not thread-safe :return:
[ "Construct", "and", "informative", "user", "-", "agent", "string", ".", "Includes", "OS", "version", "and", "docker", "version", "info" ]
8a4d5b9708e27856312d303aae3f04f3c72039d6
https://github.com/anchore/anchore/blob/8a4d5b9708e27856312d303aae3f04f3c72039d6/anchore/util/resources.py#L36-L57
train
anchore/anchore
anchore/util/resources.py
normalize_headers
def normalize_headers(headers): """ Convert useful headers to a normalized type and return in a new dict Only processes content-type, content-length, etag, and last-modified :param headers: :return: """ for (k, v) in headers.items(): headers.pop(k) headers[k.lower()] = v ...
python
def normalize_headers(headers): """ Convert useful headers to a normalized type and return in a new dict Only processes content-type, content-length, etag, and last-modified :param headers: :return: """ for (k, v) in headers.items(): headers.pop(k) headers[k.lower()] = v ...
[ "def", "normalize_headers", "(", "headers", ")", ":", "for", "(", "k", ",", "v", ")", "in", "headers", ".", "items", "(", ")", ":", "headers", ".", "pop", "(", "k", ")", "headers", "[", "k", ".", "lower", "(", ")", "]", "=", "v", "result", "=",...
Convert useful headers to a normalized type and return in a new dict Only processes content-type, content-length, etag, and last-modified :param headers: :return:
[ "Convert", "useful", "headers", "to", "a", "normalized", "type", "and", "return", "in", "a", "new", "dict" ]
8a4d5b9708e27856312d303aae3f04f3c72039d6
https://github.com/anchore/anchore/blob/8a4d5b9708e27856312d303aae3f04f3c72039d6/anchore/util/resources.py#L117-L156
train
anchore/anchore
anchore/util/resources.py
get_resource_retriever
def get_resource_retriever(url): """ Get the appropriate retriever object for the specified url based on url scheme. Makes assumption that HTTP urls do not require any special authorization. For HTTP urls: returns HTTPResourceRetriever For s3:// urls returns S3ResourceRetriever :param url: url...
python
def get_resource_retriever(url): """ Get the appropriate retriever object for the specified url based on url scheme. Makes assumption that HTTP urls do not require any special authorization. For HTTP urls: returns HTTPResourceRetriever For s3:// urls returns S3ResourceRetriever :param url: url...
[ "def", "get_resource_retriever", "(", "url", ")", ":", "if", "url", ".", "startswith", "(", "'http://'", ")", "or", "url", ".", "startswith", "(", "'https://'", ")", ":", "return", "HttpResourceRetriever", "(", "url", ")", "else", ":", "raise", "ValueError",...
Get the appropriate retriever object for the specified url based on url scheme. Makes assumption that HTTP urls do not require any special authorization. For HTTP urls: returns HTTPResourceRetriever For s3:// urls returns S3ResourceRetriever :param url: url of the resource to be retrieved :return:...
[ "Get", "the", "appropriate", "retriever", "object", "for", "the", "specified", "url", "based", "on", "url", "scheme", ".", "Makes", "assumption", "that", "HTTP", "urls", "do", "not", "require", "any", "special", "authorization", "." ]
8a4d5b9708e27856312d303aae3f04f3c72039d6
https://github.com/anchore/anchore/blob/8a4d5b9708e27856312d303aae3f04f3c72039d6/anchore/util/resources.py#L158-L173
train
anchore/anchore
anchore/util/resources.py
ResourceCache.get
def get(self, url): """ Lookup the given url and return an entry if found. Else return None. The returned entry is a dict with metadata about the content and a 'content' key with a file path value :param url: :return: """ self._load(url) self._flush() ...
python
def get(self, url): """ Lookup the given url and return an entry if found. Else return None. The returned entry is a dict with metadata about the content and a 'content' key with a file path value :param url: :return: """ self._load(url) self._flush() ...
[ "def", "get", "(", "self", ",", "url", ")", ":", "self", ".", "_load", "(", "url", ")", "self", ".", "_flush", "(", ")", "return", "self", ".", "metadata", "[", "url", "]" ]
Lookup the given url and return an entry if found. Else return None. The returned entry is a dict with metadata about the content and a 'content' key with a file path value :param url: :return:
[ "Lookup", "the", "given", "url", "and", "return", "an", "entry", "if", "found", ".", "Else", "return", "None", ".", "The", "returned", "entry", "is", "a", "dict", "with", "metadata", "about", "the", "content", "and", "a", "content", "key", "with", "a", ...
8a4d5b9708e27856312d303aae3f04f3c72039d6
https://github.com/anchore/anchore/blob/8a4d5b9708e27856312d303aae3f04f3c72039d6/anchore/util/resources.py#L240-L251
train
anchore/anchore
anchore/util/resources.py
ResourceCache._load
def _load(self, url): """ Load from remote, but check local file content to identify duplicate content. If local file is found with same hash then it is used with metadata from remote object to avoid fetching full content. :param url: :return: """ self._logger.de...
python
def _load(self, url): """ Load from remote, but check local file content to identify duplicate content. If local file is found with same hash then it is used with metadata from remote object to avoid fetching full content. :param url: :return: """ self._logger.de...
[ "def", "_load", "(", "self", ",", "url", ")", ":", "self", ".", "_logger", ".", "debug", "(", "'Loading url %s into resource cache'", "%", "url", ")", "retriever", "=", "get_resource_retriever", "(", "url", ")", "content_path", "=", "os", ".", "path", ".", ...
Load from remote, but check local file content to identify duplicate content. If local file is found with same hash then it is used with metadata from remote object to avoid fetching full content. :param url: :return:
[ "Load", "from", "remote", "but", "check", "local", "file", "content", "to", "identify", "duplicate", "content", ".", "If", "local", "file", "is", "found", "with", "same", "hash", "then", "it", "is", "used", "with", "metadata", "from", "remote", "object", "...
8a4d5b9708e27856312d303aae3f04f3c72039d6
https://github.com/anchore/anchore/blob/8a4d5b9708e27856312d303aae3f04f3c72039d6/anchore/util/resources.py#L271-L315
train
anchore/anchore
anchore/util/fs_util.py
calc_file_md5
def calc_file_md5(filepath, chunk_size=None): """ Calculate a file's md5 checksum. Use the specified chunk_size for IO or the default 256KB :param filepath: :param chunk_size: :return: """ if chunk_size is None: chunk_size = 256 * 1024 md5sum = hashlib.md5() with io.open...
python
def calc_file_md5(filepath, chunk_size=None): """ Calculate a file's md5 checksum. Use the specified chunk_size for IO or the default 256KB :param filepath: :param chunk_size: :return: """ if chunk_size is None: chunk_size = 256 * 1024 md5sum = hashlib.md5() with io.open...
[ "def", "calc_file_md5", "(", "filepath", ",", "chunk_size", "=", "None", ")", ":", "if", "chunk_size", "is", "None", ":", "chunk_size", "=", "256", "*", "1024", "md5sum", "=", "hashlib", ".", "md5", "(", ")", "with", "io", ".", "open", "(", "filepath",...
Calculate a file's md5 checksum. Use the specified chunk_size for IO or the default 256KB :param filepath: :param chunk_size: :return:
[ "Calculate", "a", "file", "s", "md5", "checksum", ".", "Use", "the", "specified", "chunk_size", "for", "IO", "or", "the", "default", "256KB" ]
8a4d5b9708e27856312d303aae3f04f3c72039d6
https://github.com/anchore/anchore/blob/8a4d5b9708e27856312d303aae3f04f3c72039d6/anchore/util/fs_util.py#L59-L77
train
anchore/anchore
anchore/cli/toolbox.py
toolbox
def toolbox(anchore_config, ctx, image, imageid): """ A collection of tools for operating on images and containers and building anchore modules. Subcommands operate on the specified image passed in as --image <imgid> """ global config, imagelist, nav config = anchore_config ecode = 0 ...
python
def toolbox(anchore_config, ctx, image, imageid): """ A collection of tools for operating on images and containers and building anchore modules. Subcommands operate on the specified image passed in as --image <imgid> """ global config, imagelist, nav config = anchore_config ecode = 0 ...
[ "def", "toolbox", "(", "anchore_config", ",", "ctx", ",", "image", ",", "imageid", ")", ":", "global", "config", ",", "imagelist", ",", "nav", "config", "=", "anchore_config", "ecode", "=", "0", "try", ":", "if", "image", ":", "imagelist", "=", "[", "i...
A collection of tools for operating on images and containers and building anchore modules. Subcommands operate on the specified image passed in as --image <imgid>
[ "A", "collection", "of", "tools", "for", "operating", "on", "images", "and", "containers", "and", "building", "anchore", "modules", "." ]
8a4d5b9708e27856312d303aae3f04f3c72039d6
https://github.com/anchore/anchore/blob/8a4d5b9708e27856312d303aae3f04f3c72039d6/anchore/cli/toolbox.py#L24-L71
train
anchore/anchore
anchore/cli/toolbox.py
unpack
def unpack(destdir): """Unpack and Squash image to local filesystem""" if not nav: sys.exit(1) ecode = 0 try: anchore_print("Unpacking images: " + ' '.join(nav.get_images())) result = nav.unpack(destdir=destdir) if not result: anchore_print_err("no images un...
python
def unpack(destdir): """Unpack and Squash image to local filesystem""" if not nav: sys.exit(1) ecode = 0 try: anchore_print("Unpacking images: " + ' '.join(nav.get_images())) result = nav.unpack(destdir=destdir) if not result: anchore_print_err("no images un...
[ "def", "unpack", "(", "destdir", ")", ":", "if", "not", "nav", ":", "sys", ".", "exit", "(", "1", ")", "ecode", "=", "0", "try", ":", "anchore_print", "(", "\"Unpacking images: \"", "+", "' '", ".", "join", "(", "nav", ".", "get_images", "(", ")", ...
Unpack and Squash image to local filesystem
[ "Unpack", "and", "Squash", "image", "to", "local", "filesystem" ]
8a4d5b9708e27856312d303aae3f04f3c72039d6
https://github.com/anchore/anchore/blob/8a4d5b9708e27856312d303aae3f04f3c72039d6/anchore/cli/toolbox.py#L117-L140
train
anchore/anchore
anchore/cli/toolbox.py
show_analyzer_status
def show_analyzer_status(): """Show analyzer status for specified image""" ecode = 0 try: image=contexts['anchore_allimages'][imagelist[0]] analyzer_status = contexts['anchore_db'].load_analyzer_manifest(image.meta['imageId']) result = {image.meta['imageId']:{'result':{'header':['An...
python
def show_analyzer_status(): """Show analyzer status for specified image""" ecode = 0 try: image=contexts['anchore_allimages'][imagelist[0]] analyzer_status = contexts['anchore_db'].load_analyzer_manifest(image.meta['imageId']) result = {image.meta['imageId']:{'result':{'header':['An...
[ "def", "show_analyzer_status", "(", ")", ":", "ecode", "=", "0", "try", ":", "image", "=", "contexts", "[", "'anchore_allimages'", "]", "[", "imagelist", "[", "0", "]", "]", "analyzer_status", "=", "contexts", "[", "'anchore_db'", "]", ".", "load_analyzer_ma...
Show analyzer status for specified image
[ "Show", "analyzer", "status", "for", "specified", "image" ]
8a4d5b9708e27856312d303aae3f04f3c72039d6
https://github.com/anchore/anchore/blob/8a4d5b9708e27856312d303aae3f04f3c72039d6/anchore/cli/toolbox.py#L333-L356
train
anchore/anchore
anchore/cli/toolbox.py
export
def export(outfile): """Export image anchore data to a JSON file.""" if not nav: sys.exit(1) ecode = 0 savelist = list() for imageId in imagelist: try: record = {} record['image'] = {} record['image']['imageId'] = imageId record['ima...
python
def export(outfile): """Export image anchore data to a JSON file.""" if not nav: sys.exit(1) ecode = 0 savelist = list() for imageId in imagelist: try: record = {} record['image'] = {} record['image']['imageId'] = imageId record['ima...
[ "def", "export", "(", "outfile", ")", ":", "if", "not", "nav", ":", "sys", ".", "exit", "(", "1", ")", "ecode", "=", "0", "savelist", "=", "list", "(", ")", "for", "imageId", "in", "imagelist", ":", "try", ":", "record", "=", "{", "}", "record", ...
Export image anchore data to a JSON file.
[ "Export", "image", "anchore", "data", "to", "a", "JSON", "file", "." ]
8a4d5b9708e27856312d303aae3f04f3c72039d6
https://github.com/anchore/anchore/blob/8a4d5b9708e27856312d303aae3f04f3c72039d6/anchore/cli/toolbox.py#L360-L392
train
anchore/anchore
anchore/cli/toolbox.py
image_import
def image_import(infile, force): """Import image anchore data from a JSON file.""" ecode = 0 try: with open(infile, 'r') as FH: savelist = json.loads(FH.read()) except Exception as err: anchore_print_err("could not load input file: " + str(err)) ecode = 1 if...
python
def image_import(infile, force): """Import image anchore data from a JSON file.""" ecode = 0 try: with open(infile, 'r') as FH: savelist = json.loads(FH.read()) except Exception as err: anchore_print_err("could not load input file: " + str(err)) ecode = 1 if...
[ "def", "image_import", "(", "infile", ",", "force", ")", ":", "ecode", "=", "0", "try", ":", "with", "open", "(", "infile", ",", "'r'", ")", "as", "FH", ":", "savelist", "=", "json", ".", "loads", "(", "FH", ".", "read", "(", ")", ")", "except", ...
Import image anchore data from a JSON file.
[ "Import", "image", "anchore", "data", "from", "a", "JSON", "file", "." ]
8a4d5b9708e27856312d303aae3f04f3c72039d6
https://github.com/anchore/anchore/blob/8a4d5b9708e27856312d303aae3f04f3c72039d6/anchore/cli/toolbox.py#L421-L452
train
anchore/anchore
anchore/cli/system.py
status
def status(conf): """ Show anchore system status. """ ecode = 0 try: if conf: if config.cliargs['json']: anchore_print(config.data, do_formatting=True) else: anchore_print(yaml.safe_dump(config.data, indent=True, default_flow_style=Fal...
python
def status(conf): """ Show anchore system status. """ ecode = 0 try: if conf: if config.cliargs['json']: anchore_print(config.data, do_formatting=True) else: anchore_print(yaml.safe_dump(config.data, indent=True, default_flow_style=Fal...
[ "def", "status", "(", "conf", ")", ":", "ecode", "=", "0", "try", ":", "if", "conf", ":", "if", "config", ".", "cliargs", "[", "'json'", "]", ":", "anchore_print", "(", "config", ".", "data", ",", "do_formatting", "=", "True", ")", "else", ":", "an...
Show anchore system status.
[ "Show", "anchore", "system", "status", "." ]
8a4d5b9708e27856312d303aae3f04f3c72039d6
https://github.com/anchore/anchore/blob/8a4d5b9708e27856312d303aae3f04f3c72039d6/anchore/cli/system.py#L25-L79
train
anchore/anchore
anchore/cli/system.py
show_schemas
def show_schemas(schemaname): """ Show anchore document schemas. """ ecode = 0 try: schemas = {} schema_dir = os.path.join(contexts['anchore_config']['pkg_dir'], 'schemas') for f in os.listdir(schema_dir): sdata = {} try: with open(os....
python
def show_schemas(schemaname): """ Show anchore document schemas. """ ecode = 0 try: schemas = {} schema_dir = os.path.join(contexts['anchore_config']['pkg_dir'], 'schemas') for f in os.listdir(schema_dir): sdata = {} try: with open(os....
[ "def", "show_schemas", "(", "schemaname", ")", ":", "ecode", "=", "0", "try", ":", "schemas", "=", "{", "}", "schema_dir", "=", "os", ".", "path", ".", "join", "(", "contexts", "[", "'anchore_config'", "]", "[", "'pkg_dir'", "]", ",", "'schemas'", ")",...
Show anchore document schemas.
[ "Show", "anchore", "document", "schemas", "." ]
8a4d5b9708e27856312d303aae3f04f3c72039d6
https://github.com/anchore/anchore/blob/8a4d5b9708e27856312d303aae3f04f3c72039d6/anchore/cli/system.py#L83-L112
train
anchore/anchore
anchore/cli/system.py
backup
def backup(outputdir): """ Backup an anchore installation to a tarfile. """ ecode = 0 try: anchore_print('Backing up anchore system to directory '+str(outputdir)+' ...') backupfile = config.backup(outputdir) anchore_print({"anchore_backup_tarball":str(backupfile)}, do_format...
python
def backup(outputdir): """ Backup an anchore installation to a tarfile. """ ecode = 0 try: anchore_print('Backing up anchore system to directory '+str(outputdir)+' ...') backupfile = config.backup(outputdir) anchore_print({"anchore_backup_tarball":str(backupfile)}, do_format...
[ "def", "backup", "(", "outputdir", ")", ":", "ecode", "=", "0", "try", ":", "anchore_print", "(", "'Backing up anchore system to directory '", "+", "str", "(", "outputdir", ")", "+", "' ...'", ")", "backupfile", "=", "config", ".", "backup", "(", "outputdir", ...
Backup an anchore installation to a tarfile.
[ "Backup", "an", "anchore", "installation", "to", "a", "tarfile", "." ]
8a4d5b9708e27856312d303aae3f04f3c72039d6
https://github.com/anchore/anchore/blob/8a4d5b9708e27856312d303aae3f04f3c72039d6/anchore/cli/system.py#L116-L130
train
anchore/anchore
anchore/cli/system.py
restore
def restore(inputfile, destination_root): """ Restore an anchore installation from a previously backed up tar file. """ ecode = 0 try: anchore_print('Restoring anchore system from backup file %s ...' % (str(inputfile.name))) restoredir = config.restore(destination_root, inputfile) ...
python
def restore(inputfile, destination_root): """ Restore an anchore installation from a previously backed up tar file. """ ecode = 0 try: anchore_print('Restoring anchore system from backup file %s ...' % (str(inputfile.name))) restoredir = config.restore(destination_root, inputfile) ...
[ "def", "restore", "(", "inputfile", ",", "destination_root", ")", ":", "ecode", "=", "0", "try", ":", "anchore_print", "(", "'Restoring anchore system from backup file %s ...'", "%", "(", "str", "(", "inputfile", ".", "name", ")", ")", ")", "restoredir", "=", ...
Restore an anchore installation from a previously backed up tar file.
[ "Restore", "an", "anchore", "installation", "from", "a", "previously", "backed", "up", "tar", "file", "." ]
8a4d5b9708e27856312d303aae3f04f3c72039d6
https://github.com/anchore/anchore/blob/8a4d5b9708e27856312d303aae3f04f3c72039d6/anchore/cli/system.py#L135-L149
train
anchore/anchore
anchore/cli/system.py
exportdb
def exportdb(outdir): """Export all anchore images to JSON files""" ecode = 0 try: imgdir = os.path.join(outdir, "images") feeddir = os.path.join(outdir, "feeds") storedir = os.path.join(outdir, "storedfiles") for d in [outdir, imgdir, feeddir, storedir]: if not ...
python
def exportdb(outdir): """Export all anchore images to JSON files""" ecode = 0 try: imgdir = os.path.join(outdir, "images") feeddir = os.path.join(outdir, "feeds") storedir = os.path.join(outdir, "storedfiles") for d in [outdir, imgdir, feeddir, storedir]: if not ...
[ "def", "exportdb", "(", "outdir", ")", ":", "ecode", "=", "0", "try", ":", "imgdir", "=", "os", ".", "path", ".", "join", "(", "outdir", ",", "\"images\"", ")", "feeddir", "=", "os", ".", "path", ".", "join", "(", "outdir", ",", "\"feeds\"", ")", ...
Export all anchore images to JSON files
[ "Export", "all", "anchore", "images", "to", "JSON", "files" ]
8a4d5b9708e27856312d303aae3f04f3c72039d6
https://github.com/anchore/anchore/blob/8a4d5b9708e27856312d303aae3f04f3c72039d6/anchore/cli/system.py#L153-L207
train
anchore/anchore
anchore/apk.py
next_token
def next_token(expected_type, data): """ Based on the expected next type, consume the next token returning the type found and an updated buffer with the found token removed :param expected_type: :param data: :return: (TokenType, str) tuple where TokenType is the type of the next token expected ...
python
def next_token(expected_type, data): """ Based on the expected next type, consume the next token returning the type found and an updated buffer with the found token removed :param expected_type: :param data: :return: (TokenType, str) tuple where TokenType is the type of the next token expected ...
[ "def", "next_token", "(", "expected_type", ",", "data", ")", ":", "next_data", "=", "copy", ".", "copy", "(", "data", ")", "next_type", "=", "TokenType", ".", "INVALID", "if", "len", "(", "next_data", ")", "==", "0", "or", "next_data", "[", "0", "]", ...
Based on the expected next type, consume the next token returning the type found and an updated buffer with the found token removed :param expected_type: :param data: :return: (TokenType, str) tuple where TokenType is the type of the next token expected
[ "Based", "on", "the", "expected", "next", "type", "consume", "the", "next", "token", "returning", "the", "type", "found", "and", "an", "updated", "buffer", "with", "the", "found", "token", "removed" ]
8a4d5b9708e27856312d303aae3f04f3c72039d6
https://github.com/anchore/anchore/blob/8a4d5b9708e27856312d303aae3f04f3c72039d6/anchore/apk.py#L31-L74
train
anchore/anchore
anchore/cli/feeds.py
show
def show(feed): """ Show detailed feed information """ ecode = 0 try: feedmeta = anchore_feeds.load_anchore_feedmeta() if feed in feedmeta: result = {} groups = feedmeta[feed].get('groups',{}).values() result['name'] = feed result['acc...
python
def show(feed): """ Show detailed feed information """ ecode = 0 try: feedmeta = anchore_feeds.load_anchore_feedmeta() if feed in feedmeta: result = {} groups = feedmeta[feed].get('groups',{}).values() result['name'] = feed result['acc...
[ "def", "show", "(", "feed", ")", ":", "ecode", "=", "0", "try", ":", "feedmeta", "=", "anchore_feeds", ".", "load_anchore_feedmeta", "(", ")", "if", "feed", "in", "feedmeta", ":", "result", "=", "{", "}", "groups", "=", "feedmeta", "[", "feed", "]", ...
Show detailed feed information
[ "Show", "detailed", "feed", "information" ]
8a4d5b9708e27856312d303aae3f04f3c72039d6
https://github.com/anchore/anchore/blob/8a4d5b9708e27856312d303aae3f04f3c72039d6/anchore/cli/feeds.py#L42-L77
train
anchore/anchore
anchore/cli/feeds.py
list
def list(showgroups): """ Show list of Anchore data feeds. """ ecode = 0 try: result = {} subscribed = {} available = {} unavailable = {} current_user_data = contexts['anchore_auth']['user_info'] feedmeta = anchore_feeds.load_anchore_feedmeta() ...
python
def list(showgroups): """ Show list of Anchore data feeds. """ ecode = 0 try: result = {} subscribed = {} available = {} unavailable = {} current_user_data = contexts['anchore_auth']['user_info'] feedmeta = anchore_feeds.load_anchore_feedmeta() ...
[ "def", "list", "(", "showgroups", ")", ":", "ecode", "=", "0", "try", ":", "result", "=", "{", "}", "subscribed", "=", "{", "}", "available", "=", "{", "}", "unavailable", "=", "{", "}", "current_user_data", "=", "contexts", "[", "'anchore_auth'", "]",...
Show list of Anchore data feeds.
[ "Show", "list", "of", "Anchore", "data", "feeds", "." ]
8a4d5b9708e27856312d303aae3f04f3c72039d6
https://github.com/anchore/anchore/blob/8a4d5b9708e27856312d303aae3f04f3c72039d6/anchore/cli/feeds.py#L81-L131
train
anchore/anchore
anchore/analyzer.py
SelectionStrategy.evaluate_familytree
def evaluate_familytree(self, family_tree, image_set): """ Evaluate strategy for the given family tree and return a dict of images to analyze that match the strategy :param family_tree: the family tree to traverse and evaluate :param image_set: list of all images in the context ...
python
def evaluate_familytree(self, family_tree, image_set): """ Evaluate strategy for the given family tree and return a dict of images to analyze that match the strategy :param family_tree: the family tree to traverse and evaluate :param image_set: list of all images in the context ...
[ "def", "evaluate_familytree", "(", "self", ",", "family_tree", ",", "image_set", ")", ":", "if", "family_tree", "is", "None", "or", "image_set", "is", "None", ":", "raise", "ValueError", "(", "'Cannot execute analysis strategy on None image or image with no familytree dat...
Evaluate strategy for the given family tree and return a dict of images to analyze that match the strategy :param family_tree: the family tree to traverse and evaluate :param image_set: list of all images in the context :return:
[ "Evaluate", "strategy", "for", "the", "given", "family", "tree", "and", "return", "a", "dict", "of", "images", "to", "analyze", "that", "match", "the", "strategy" ]
8a4d5b9708e27856312d303aae3f04f3c72039d6
https://github.com/anchore/anchore/blob/8a4d5b9708e27856312d303aae3f04f3c72039d6/anchore/analyzer.py#L23-L42
train
anchore/anchore
anchore/cli/login.py
logout
def logout(anchore_config): """ Log out of Anchore service """ ecode = 0 try: aa = contexts['anchore_auth'] if aa: anchore_auth.anchore_auth_invalidate(aa) if 'auth_file' in aa: os.remove(aa['auth_file']) print "Logout successful." ...
python
def logout(anchore_config): """ Log out of Anchore service """ ecode = 0 try: aa = contexts['anchore_auth'] if aa: anchore_auth.anchore_auth_invalidate(aa) if 'auth_file' in aa: os.remove(aa['auth_file']) print "Logout successful." ...
[ "def", "logout", "(", "anchore_config", ")", ":", "ecode", "=", "0", "try", ":", "aa", "=", "contexts", "[", "'anchore_auth'", "]", "if", "aa", ":", "anchore_auth", ".", "anchore_auth_invalidate", "(", "aa", ")", "if", "'auth_file'", "in", "aa", ":", "os...
Log out of Anchore service
[ "Log", "out", "of", "Anchore", "service" ]
8a4d5b9708e27856312d303aae3f04f3c72039d6
https://github.com/anchore/anchore/blob/8a4d5b9708e27856312d303aae3f04f3c72039d6/anchore/cli/login.py#L81-L97
train
joanvila/aioredlock
aioredlock/redis.py
Instance.connect
async def connect(self): """ Get an connection for the self instance """ if isinstance(self.connection, dict): # a dict like {'host': 'localhost', 'port': 6379, # 'db': 0, 'password': 'pass'} kwargs = self.connection.copy() ad...
python
async def connect(self): """ Get an connection for the self instance """ if isinstance(self.connection, dict): # a dict like {'host': 'localhost', 'port': 6379, # 'db': 0, 'password': 'pass'} kwargs = self.connection.copy() ad...
[ "async", "def", "connect", "(", "self", ")", ":", "if", "isinstance", "(", "self", ".", "connection", ",", "dict", ")", ":", "kwargs", "=", "self", ".", "connection", ".", "copy", "(", ")", "address", "=", "(", "kwargs", ".", "pop", "(", "'host'", ...
Get an connection for the self instance
[ "Get", "an", "connection", "for", "the", "self", "instance" ]
6c62f0895c93b26b87ca8e3fe36bc024c81be421
https://github.com/joanvila/aioredlock/blob/6c62f0895c93b26b87ca8e3fe36bc024c81be421/aioredlock/redis.py#L85-L116
train
joanvila/aioredlock
aioredlock/redis.py
Instance.close
async def close(self): """ Closes connection and resets pool """ if self._pool is not None and not isinstance(self.connection, aioredis.Redis): self._pool.close() await self._pool.wait_closed() self._pool = None
python
async def close(self): """ Closes connection and resets pool """ if self._pool is not None and not isinstance(self.connection, aioredis.Redis): self._pool.close() await self._pool.wait_closed() self._pool = None
[ "async", "def", "close", "(", "self", ")", ":", "if", "self", ".", "_pool", "is", "not", "None", "and", "not", "isinstance", "(", "self", ".", "connection", ",", "aioredis", ".", "Redis", ")", ":", "self", ".", "_pool", ".", "close", "(", ")", "awa...
Closes connection and resets pool
[ "Closes", "connection", "and", "resets", "pool" ]
6c62f0895c93b26b87ca8e3fe36bc024c81be421
https://github.com/joanvila/aioredlock/blob/6c62f0895c93b26b87ca8e3fe36bc024c81be421/aioredlock/redis.py#L118-L125
train
joanvila/aioredlock
aioredlock/redis.py
Redis.set_lock
async def set_lock(self, resource, lock_identifier): """ Tries to set the lock to all the redis instances :param resource: The resource string name to lock :param lock_identifier: The id of the lock. A unique string :return float: The elapsed time that took to lock the instances...
python
async def set_lock(self, resource, lock_identifier): """ Tries to set the lock to all the redis instances :param resource: The resource string name to lock :param lock_identifier: The id of the lock. A unique string :return float: The elapsed time that took to lock the instances...
[ "async", "def", "set_lock", "(", "self", ",", "resource", ",", "lock_identifier", ")", ":", "start_time", "=", "time", ".", "time", "(", ")", "lock_timeout", "=", "self", ".", "lock_timeout", "successes", "=", "await", "asyncio", ".", "gather", "(", "*", ...
Tries to set the lock to all the redis instances :param resource: The resource string name to lock :param lock_identifier: The id of the lock. A unique string :return float: The elapsed time that took to lock the instances in seconds :raises: LockError if the lock has not be...
[ "Tries", "to", "set", "the", "lock", "to", "all", "the", "redis", "instances" ]
6c62f0895c93b26b87ca8e3fe36bc024c81be421
https://github.com/joanvila/aioredlock/blob/6c62f0895c93b26b87ca8e3fe36bc024c81be421/aioredlock/redis.py#L227-L256
train
joanvila/aioredlock
aioredlock/redis.py
Redis.unset_lock
async def unset_lock(self, resource, lock_identifier): """ Tries to unset the lock to all the redis instances :param resource: The resource string name to lock :param lock_identifier: The id of the lock. A unique string :return float: The elapsed time that took to lock the insta...
python
async def unset_lock(self, resource, lock_identifier): """ Tries to unset the lock to all the redis instances :param resource: The resource string name to lock :param lock_identifier: The id of the lock. A unique string :return float: The elapsed time that took to lock the insta...
[ "async", "def", "unset_lock", "(", "self", ",", "resource", ",", "lock_identifier", ")", ":", "start_time", "=", "time", ".", "time", "(", ")", "successes", "=", "await", "asyncio", ".", "gather", "(", "*", "[", "i", ".", "unset_lock", "(", "resource", ...
Tries to unset the lock to all the redis instances :param resource: The resource string name to lock :param lock_identifier: The id of the lock. A unique string :return float: The elapsed time that took to lock the instances in iseconds :raises: LockError if the lock has not matching id...
[ "Tries", "to", "unset", "the", "lock", "to", "all", "the", "redis", "instances" ]
6c62f0895c93b26b87ca8e3fe36bc024c81be421
https://github.com/joanvila/aioredlock/blob/6c62f0895c93b26b87ca8e3fe36bc024c81be421/aioredlock/redis.py#L258-L285
train
nanoporetech/ont_fast5_api
ont_fast5_api/fast5_info.py
_clean
def _clean(value): """ Convert numpy numeric types to their python equivalents. """ if isinstance(value, np.ndarray): if value.dtype.kind == 'S': return np.char.decode(value).tolist() else: return value.tolist() elif type(value).__module__ == np.__name__: # h5...
python
def _clean(value): """ Convert numpy numeric types to their python equivalents. """ if isinstance(value, np.ndarray): if value.dtype.kind == 'S': return np.char.decode(value).tolist() else: return value.tolist() elif type(value).__module__ == np.__name__: # h5...
[ "def", "_clean", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "np", ".", "ndarray", ")", ":", "if", "value", ".", "dtype", ".", "kind", "==", "'S'", ":", "return", "np", ".", "char", ".", "decode", "(", "value", ")", ".", "tolis...
Convert numpy numeric types to their python equivalents.
[ "Convert", "numpy", "numeric", "types", "to", "their", "python", "equivalents", "." ]
352b3903155fcf4f19234c4f429dcefaa6d6bc4a
https://github.com/nanoporetech/ont_fast5_api/blob/352b3903155fcf4f19234c4f429dcefaa6d6bc4a/ont_fast5_api/fast5_info.py#L169-L187
train
nanoporetech/ont_fast5_api
ont_fast5_api/analysis_tools/basecall_2d.py
Basecall2DTools.get_prior_alignment
def get_prior_alignment(self): """ Return the prior alignment that was used for 2D basecalling. :return: Alignment data table. """ data_group = '{}/HairpinAlign'.format(self.group_name) data = self.handle.get_analysis_dataset(data_group, 'Alignment') return data
python
def get_prior_alignment(self): """ Return the prior alignment that was used for 2D basecalling. :return: Alignment data table. """ data_group = '{}/HairpinAlign'.format(self.group_name) data = self.handle.get_analysis_dataset(data_group, 'Alignment') return data
[ "def", "get_prior_alignment", "(", "self", ")", ":", "data_group", "=", "'{}/HairpinAlign'", ".", "format", "(", "self", ".", "group_name", ")", "data", "=", "self", ".", "handle", ".", "get_analysis_dataset", "(", "data_group", ",", "'Alignment'", ")", "retur...
Return the prior alignment that was used for 2D basecalling. :return: Alignment data table.
[ "Return", "the", "prior", "alignment", "that", "was", "used", "for", "2D", "basecalling", "." ]
352b3903155fcf4f19234c4f429dcefaa6d6bc4a
https://github.com/nanoporetech/ont_fast5_api/blob/352b3903155fcf4f19234c4f429dcefaa6d6bc4a/ont_fast5_api/analysis_tools/basecall_2d.py#L17-L24
train
nanoporetech/ont_fast5_api
ont_fast5_api/analysis_tools/basecall_2d.py
Basecall2DTools.get_2d_call_alignment
def get_2d_call_alignment(self): """ Return the alignment and model_states from the 2D basecall. :return: Alignment data table. """ data_group = '{}/BaseCalled_2D'.format(self.group_name) data = self.handle.get_analysis_dataset(data_group, 'Alignment') return data
python
def get_2d_call_alignment(self): """ Return the alignment and model_states from the 2D basecall. :return: Alignment data table. """ data_group = '{}/BaseCalled_2D'.format(self.group_name) data = self.handle.get_analysis_dataset(data_group, 'Alignment') return data
[ "def", "get_2d_call_alignment", "(", "self", ")", ":", "data_group", "=", "'{}/BaseCalled_2D'", ".", "format", "(", "self", ".", "group_name", ")", "data", "=", "self", ".", "handle", ".", "get_analysis_dataset", "(", "data_group", ",", "'Alignment'", ")", "re...
Return the alignment and model_states from the 2D basecall. :return: Alignment data table.
[ "Return", "the", "alignment", "and", "model_states", "from", "the", "2D", "basecall", "." ]
352b3903155fcf4f19234c4f429dcefaa6d6bc4a
https://github.com/nanoporetech/ont_fast5_api/blob/352b3903155fcf4f19234c4f429dcefaa6d6bc4a/ont_fast5_api/analysis_tools/basecall_2d.py#L26-L33
train
nanoporetech/ont_fast5_api
ont_fast5_api/analysis_tools/alignment.py
AlignmentTools.get_results
def get_results(self): """ Get details about the alignments that have been performed. :return: A dict of dicts. The keys of the top level are 'template', 'complement' and '2d'. Each of these dicts contains the following fields: * status: Can be 'no data', 'no match found',...
python
def get_results(self): """ Get details about the alignments that have been performed. :return: A dict of dicts. The keys of the top level are 'template', 'complement' and '2d'. Each of these dicts contains the following fields: * status: Can be 'no data', 'no match found',...
[ "def", "get_results", "(", "self", ")", ":", "summary", "=", "self", ".", "handle", ".", "get_summary_data", "(", "self", ".", "group_name", ")", "results", "=", "{", "'template'", ":", "{", "'status'", ":", "'no data'", "}", ",", "'complement'", ":", "{...
Get details about the alignments that have been performed. :return: A dict of dicts. The keys of the top level are 'template', 'complement' and '2d'. Each of these dicts contains the following fields: * status: Can be 'no data', 'no match found', or 'match found'. * di...
[ "Get", "details", "about", "the", "alignments", "that", "have", "been", "performed", "." ]
352b3903155fcf4f19234c4f429dcefaa6d6bc4a
https://github.com/nanoporetech/ont_fast5_api/blob/352b3903155fcf4f19234c4f429dcefaa6d6bc4a/ont_fast5_api/analysis_tools/alignment.py#L62-L100
train
nanoporetech/ont_fast5_api
ont_fast5_api/analysis_tools/alignment.py
AlignmentTools.calculate_speed
def calculate_speed(self, section, alignment_results=None): """ Calculate speed using alignment information. :param section: The section (template or complement) we're calculating speed for. :param alignment_results: Optional dictionary of the alignment summary, so that ...
python
def calculate_speed(self, section, alignment_results=None): """ Calculate speed using alignment information. :param section: The section (template or complement) we're calculating speed for. :param alignment_results: Optional dictionary of the alignment summary, so that ...
[ "def", "calculate_speed", "(", "self", ",", "section", ",", "alignment_results", "=", "None", ")", ":", "speed", "=", "0.0", "if", "alignment_results", ":", "results", "=", "self", ".", "_get_results", "(", "alignment_results", ")", "else", ":", "results", "...
Calculate speed using alignment information. :param section: The section (template or complement) we're calculating speed for. :param alignment_results: Optional dictionary of the alignment summary, so that speed can be calculated without having to write the summary ...
[ "Calculate", "speed", "using", "alignment", "information", "." ]
352b3903155fcf4f19234c4f429dcefaa6d6bc4a
https://github.com/nanoporetech/ont_fast5_api/blob/352b3903155fcf4f19234c4f429dcefaa6d6bc4a/ont_fast5_api/analysis_tools/alignment.py#L134-L181
train
nanoporetech/ont_fast5_api
ont_fast5_api/fast5_read.py
Fast5Read.add_raw_data
def add_raw_data(self, data, attrs): """ Add raw data for a read. :param data: The raw data DAQ values (16 bit integers). The read must already exist in the file. It must not already have raw data. """ self.assert_writeable() if "Raw" not in self.handle: ...
python
def add_raw_data(self, data, attrs): """ Add raw data for a read. :param data: The raw data DAQ values (16 bit integers). The read must already exist in the file. It must not already have raw data. """ self.assert_writeable() if "Raw" not in self.handle: ...
[ "def", "add_raw_data", "(", "self", ",", "data", ",", "attrs", ")", ":", "self", ".", "assert_writeable", "(", ")", "if", "\"Raw\"", "not", "in", "self", ".", "handle", ":", "self", ".", "handle", ".", "create_group", "(", "\"Raw\"", ")", "if", "\"Sign...
Add raw data for a read. :param data: The raw data DAQ values (16 bit integers). The read must already exist in the file. It must not already have raw data.
[ "Add", "raw", "data", "for", "a", "read", "." ]
352b3903155fcf4f19234c4f429dcefaa6d6bc4a
https://github.com/nanoporetech/ont_fast5_api/blob/352b3903155fcf4f19234c4f429dcefaa6d6bc4a/ont_fast5_api/fast5_read.py#L26-L41
train
nanoporetech/ont_fast5_api
ont_fast5_api/fast5_read.py
Fast5Read.add_channel_info
def add_channel_info(self, attrs, clear=False): """ Add channel info data to the channel_id group. :param data: A dictionary of key/value pairs. Keys must be strings. Values can be strings or numeric values. :param clear: If set, any existing channel info data will be removed. ...
python
def add_channel_info(self, attrs, clear=False): """ Add channel info data to the channel_id group. :param data: A dictionary of key/value pairs. Keys must be strings. Values can be strings or numeric values. :param clear: If set, any existing channel info data will be removed. ...
[ "def", "add_channel_info", "(", "self", ",", "attrs", ",", "clear", "=", "False", ")", ":", "self", ".", "assert_writeable", "(", ")", "if", "'channel_id'", "not", "in", "self", ".", "handle", ":", "self", ".", "handle", ".", "create_group", "(", "'chann...
Add channel info data to the channel_id group. :param data: A dictionary of key/value pairs. Keys must be strings. Values can be strings or numeric values. :param clear: If set, any existing channel info data will be removed.
[ "Add", "channel", "info", "data", "to", "the", "channel_id", "group", "." ]
352b3903155fcf4f19234c4f429dcefaa6d6bc4a
https://github.com/nanoporetech/ont_fast5_api/blob/352b3903155fcf4f19234c4f429dcefaa6d6bc4a/ont_fast5_api/fast5_read.py#L43-L53
train
nanoporetech/ont_fast5_api
ont_fast5_api/fast5_read.py
Fast5Read.add_analysis
def add_analysis(self, component, group_name, attrs, config=None): """ Add a new analysis group to the file. :param component: The component name. :param group_name: The name to use for the group. Must not already exist in the file e.g. 'Test_000'. :param attrs: A dictionary...
python
def add_analysis(self, component, group_name, attrs, config=None): """ Add a new analysis group to the file. :param component: The component name. :param group_name: The name to use for the group. Must not already exist in the file e.g. 'Test_000'. :param attrs: A dictionary...
[ "def", "add_analysis", "(", "self", ",", "component", ",", "group_name", ",", "attrs", ",", "config", "=", "None", ")", ":", "if", "\"Analyses\"", "not", "in", "self", ".", "handle", ":", "self", ".", "handle", ".", "create_group", "(", "\"Analyses\"", "...
Add a new analysis group to the file. :param component: The component name. :param group_name: The name to use for the group. Must not already exist in the file e.g. 'Test_000'. :param attrs: A dictionary containing the key-value pairs to put in the analysis group as att...
[ "Add", "a", "new", "analysis", "group", "to", "the", "file", "." ]
352b3903155fcf4f19234c4f429dcefaa6d6bc4a
https://github.com/nanoporetech/ont_fast5_api/blob/352b3903155fcf4f19234c4f429dcefaa6d6bc4a/ont_fast5_api/fast5_read.py#L61-L76
train
nanoporetech/ont_fast5_api
ont_fast5_api/fast5_writer.py
Fast5Writer.write_strand
def write_strand(self, strand): """ Writes a Strand object to the stream. """ if strand['channel'] != self._current_channel \ or self._strand_counter == self._reads_per_file: self._start_new_file(strand) fname = self._write_strand(strand) self._index.write('{}\t{}\...
python
def write_strand(self, strand): """ Writes a Strand object to the stream. """ if strand['channel'] != self._current_channel \ or self._strand_counter == self._reads_per_file: self._start_new_file(strand) fname = self._write_strand(strand) self._index.write('{}\t{}\...
[ "def", "write_strand", "(", "self", ",", "strand", ")", ":", "if", "strand", "[", "'channel'", "]", "!=", "self", ".", "_current_channel", "or", "self", ".", "_strand_counter", "==", "self", ".", "_reads_per_file", ":", "self", ".", "_start_new_file", "(", ...
Writes a Strand object to the stream.
[ "Writes", "a", "Strand", "object", "to", "the", "stream", "." ]
352b3903155fcf4f19234c4f429dcefaa6d6bc4a
https://github.com/nanoporetech/ont_fast5_api/blob/352b3903155fcf4f19234c4f429dcefaa6d6bc4a/ont_fast5_api/fast5_writer.py#L53-L62
train
nanoporetech/ont_fast5_api
ont_fast5_api/fast5_file.py
AbstractFast5File.close
def close(self): """ Closes the object. """ if self._is_open: self.mode = None if self.handle: self.handle.close() self.handle = None self.filename = None self._is_open = False self.status = None
python
def close(self): """ Closes the object. """ if self._is_open: self.mode = None if self.handle: self.handle.close() self.handle = None self.filename = None self._is_open = False self.status = None
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "_is_open", ":", "self", ".", "mode", "=", "None", "if", "self", ".", "handle", ":", "self", ".", "handle", ".", "close", "(", ")", "self", ".", "handle", "=", "None", "self", ".", "filena...
Closes the object.
[ "Closes", "the", "object", "." ]
352b3903155fcf4f19234c4f429dcefaa6d6bc4a
https://github.com/nanoporetech/ont_fast5_api/blob/352b3903155fcf4f19234c4f429dcefaa6d6bc4a/ont_fast5_api/fast5_file.py#L72-L82
train
nanoporetech/ont_fast5_api
ont_fast5_api/fast5_file.py
Fast5File.add_chain
def add_chain(self, group_name, component_map): """ Adds the component chain to ``group_name`` in the fast5. These are added as attributes to the group. :param group_name: The group name you wish to add chaining data to, e.g. ``Test_000`` :param component_map: The se...
python
def add_chain(self, group_name, component_map): """ Adds the component chain to ``group_name`` in the fast5. These are added as attributes to the group. :param group_name: The group name you wish to add chaining data to, e.g. ``Test_000`` :param component_map: The se...
[ "def", "add_chain", "(", "self", ",", "group_name", ",", "component_map", ")", ":", "self", ".", "assert_writeable", "(", ")", "for", "component", ",", "path", "in", "component_map", ".", "items", "(", ")", ":", "if", "not", "path", ".", "startswith", "(...
Adds the component chain to ``group_name`` in the fast5. These are added as attributes to the group. :param group_name: The group name you wish to add chaining data to, e.g. ``Test_000`` :param component_map: The set of components and corresponding group names or group p...
[ "Adds", "the", "component", "chain", "to", "group_name", "in", "the", "fast5", ".", "These", "are", "added", "as", "attributes", "to", "the", "group", "." ]
352b3903155fcf4f19234c4f429dcefaa6d6bc4a
https://github.com/nanoporetech/ont_fast5_api/blob/352b3903155fcf4f19234c4f429dcefaa6d6bc4a/ont_fast5_api/fast5_file.py#L288-L313
train
nanoporetech/ont_fast5_api
ont_fast5_api/fast5_file.py
Fast5File.add_read
def add_read(self, read_number, read_id, start_time, duration, mux, median_before): """ Add a new read to the file. :param read_number: The read number to assign to the read. :param read_id: The unique read-id for the read. :param start_time: The start time (in samples) of the read. ...
python
def add_read(self, read_number, read_id, start_time, duration, mux, median_before): """ Add a new read to the file. :param read_number: The read number to assign to the read. :param read_id: The unique read-id for the read. :param start_time: The start time (in samples) of the read. ...
[ "def", "add_read", "(", "self", ",", "read_number", ",", "read_id", ",", "start_time", ",", "duration", ",", "mux", ",", "median_before", ")", ":", "self", ".", "assert_writeable", "(", ")", "read_info", "=", "ReadInfo", "(", "read_number", ",", "read_id", ...
Add a new read to the file. :param read_number: The read number to assign to the read. :param read_id: The unique read-id for the read. :param start_time: The start time (in samples) of the read. :param duration: The duration (in samples) of the read. :param mux: The mux set at ...
[ "Add", "a", "new", "read", "to", "the", "file", "." ]
352b3903155fcf4f19234c4f429dcefaa6d6bc4a
https://github.com/nanoporetech/ont_fast5_api/blob/352b3903155fcf4f19234c4f429dcefaa6d6bc4a/ont_fast5_api/fast5_file.py#L348-L375
train
nanoporetech/ont_fast5_api
ont_fast5_api/fast5_file.py
Fast5File.set_summary_data
def set_summary_data(self, group_name, section_name, data): """ Set the summary data for an analysis group. :param group_name: The name of the analysis group. :param section_name: The analysis step. This will become a subfolder in the Summary section. :param data: A dictiona...
python
def set_summary_data(self, group_name, section_name, data): """ Set the summary data for an analysis group. :param group_name: The name of the analysis group. :param section_name: The analysis step. This will become a subfolder in the Summary section. :param data: A dictiona...
[ "def", "set_summary_data", "(", "self", ",", "group_name", ",", "section_name", ",", "data", ")", ":", "self", ".", "assert_writeable", "(", ")", "group", "=", "'Analyses/{}/Summary/{}'", ".", "format", "(", "group_name", ",", "section_name", ")", "self", ".",...
Set the summary data for an analysis group. :param group_name: The name of the analysis group. :param section_name: The analysis step. This will become a subfolder in the Summary section. :param data: A dictionary containing keys which are the summary fields, and values ...
[ "Set", "the", "summary", "data", "for", "an", "analysis", "group", "." ]
352b3903155fcf4f19234c4f429dcefaa6d6bc4a
https://github.com/nanoporetech/ont_fast5_api/blob/352b3903155fcf4f19234c4f429dcefaa6d6bc4a/ont_fast5_api/fast5_file.py#L413-L424
train
nanoporetech/ont_fast5_api
ont_fast5_api/fast5_file.py
Fast5File.get_analysis_config
def get_analysis_config(self, group_name): """ Gets any config data saved for the analysis. :param group_name: The name of the analysis group. :returns: A dictionary of dictionaries. Each key represents an analysis step. Each value is a dictionary containing the analysis...
python
def get_analysis_config(self, group_name): """ Gets any config data saved for the analysis. :param group_name: The name of the analysis group. :returns: A dictionary of dictionaries. Each key represents an analysis step. Each value is a dictionary containing the analysis...
[ "def", "get_analysis_config", "(", "self", ",", "group_name", ")", ":", "self", ".", "assert_open", "(", ")", "group", "=", "'Analyses/{}/Configuration'", ".", "format", "(", "group_name", ")", "config", "=", "None", "if", "group", "in", "self", ".", "handle...
Gets any config data saved for the analysis. :param group_name: The name of the analysis group. :returns: A dictionary of dictionaries. Each key represents an analysis step. Each value is a dictionary containing the analysis parameters as key/value pairs. Returns None if no ...
[ "Gets", "any", "config", "data", "saved", "for", "the", "analysis", "." ]
352b3903155fcf4f19234c4f429dcefaa6d6bc4a
https://github.com/nanoporetech/ont_fast5_api/blob/352b3903155fcf4f19234c4f429dcefaa6d6bc4a/ont_fast5_api/fast5_file.py#L454-L468
train
nanoporetech/ont_fast5_api
ont_fast5_api/fast5_file.py
Fast5File.read_summary_data
def read_summary_data(fname, component): """ Read summary data suitable to encode as a json packet. :param fname: The fast5 file to pull the summary data from. :param component: The component name to pull summary data for. :returns: A dictionary containing the summary data. """...
python
def read_summary_data(fname, component): """ Read summary data suitable to encode as a json packet. :param fname: The fast5 file to pull the summary data from. :param component: The component name to pull summary data for. :returns: A dictionary containing the summary data. """...
[ "def", "read_summary_data", "(", "fname", ",", "component", ")", ":", "summary", "=", "{", "}", "with", "Fast5File", "(", "fname", ",", "mode", "=", "'r'", ")", "as", "fh", ":", "summary", "[", "'tracking_id'", "]", "=", "fh", ".", "get_tracking_id", "...
Read summary data suitable to encode as a json packet. :param fname: The fast5 file to pull the summary data from. :param component: The component name to pull summary data for. :returns: A dictionary containing the summary data.
[ "Read", "summary", "data", "suitable", "to", "encode", "as", "a", "json", "packet", "." ]
352b3903155fcf4f19234c4f429dcefaa6d6bc4a
https://github.com/nanoporetech/ont_fast5_api/blob/352b3903155fcf4f19234c4f429dcefaa6d6bc4a/ont_fast5_api/fast5_file.py#L644-L674
train
mrjoes/sockjs-tornado
sockjs/tornado/transports/base.py
BaseTransportMixin.get_conn_info
def get_conn_info(self): """Return `ConnectionInfo` object from current transport""" return session.ConnectionInfo(self.request.remote_ip, self.request.cookies, self.request.arguments, self....
python
def get_conn_info(self): """Return `ConnectionInfo` object from current transport""" return session.ConnectionInfo(self.request.remote_ip, self.request.cookies, self.request.arguments, self....
[ "def", "get_conn_info", "(", "self", ")", ":", "return", "session", ".", "ConnectionInfo", "(", "self", ".", "request", ".", "remote_ip", ",", "self", ".", "request", ".", "cookies", ",", "self", ".", "request", ".", "arguments", ",", "self", ".", "reque...
Return `ConnectionInfo` object from current transport
[ "Return", "ConnectionInfo", "object", "from", "current", "transport" ]
bd3a99b407f1181f054b3b1730f438dde375ca1c
https://github.com/mrjoes/sockjs-tornado/blob/bd3a99b407f1181f054b3b1730f438dde375ca1c/sockjs/tornado/transports/base.py#L12-L18
train