repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
jaredLunde/vital-tools
vital/debug/__init__.py
RandData.randtld
def randtld(self): """ -> a random #str tld via :mod:tlds """ self.tlds = tuple(tlds.tlds) if not self.tlds else self.tlds return self.random.choice(self.tlds)
python
def randtld(self): """ -> a random #str tld via :mod:tlds """ self.tlds = tuple(tlds.tlds) if not self.tlds else self.tlds return self.random.choice(self.tlds)
[ "def", "randtld", "(", "self", ")", ":", "self", ".", "tlds", "=", "tuple", "(", "tlds", ".", "tlds", ")", "if", "not", "self", ".", "tlds", "else", "self", ".", "tlds", "return", "self", ".", "random", ".", "choice", "(", "self", ".", "tlds", ")...
-> a random #str tld via :mod:tlds
[ "-", ">", "a", "random", "#str", "tld", "via", ":", "mod", ":", "tlds" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L879-L882
jaredLunde/vital-tools
vital/debug/__init__.py
RandData.randurl
def randurl(self): """ -> a random url-like #str via :prop:randdomain, :prop:randtld, and :prop:randpath """ return "{}://{}.{}/{}".format( self.random.choice(("http", "https")), self.randdomain, self.randtld, self.randpath)
python
def randurl(self): """ -> a random url-like #str via :prop:randdomain, :prop:randtld, and :prop:randpath """ return "{}://{}.{}/{}".format( self.random.choice(("http", "https")), self.randdomain, self.randtld, self.randpath)
[ "def", "randurl", "(", "self", ")", ":", "return", "\"{}://{}.{}/{}\"", ".", "format", "(", "self", ".", "random", ".", "choice", "(", "(", "\"http\"", ",", "\"https\"", ")", ")", ",", "self", ".", "randdomain", ",", "self", ".", "randtld", ",", "self"...
-> a random url-like #str via :prop:randdomain, :prop:randtld, and :prop:randpath
[ "-", ">", "a", "random", "url", "-", "like", "#str", "via", ":", "prop", ":", "randdomain", ":", "prop", ":", "randtld", "and", ":", "prop", ":", "randpath" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L885-L891
jaredLunde/vital-tools
vital/debug/__init__.py
RandData.randtuple
def randtuple(self): """ -> a #tuple of random #int """ return tuple( self.randint for x in range(0, self.random.randint(3, 10)))
python
def randtuple(self): """ -> a #tuple of random #int """ return tuple( self.randint for x in range(0, self.random.randint(3, 10)))
[ "def", "randtuple", "(", "self", ")", ":", "return", "tuple", "(", "self", ".", "randint", "for", "x", "in", "range", "(", "0", ",", "self", ".", "random", ".", "randint", "(", "3", ",", "10", ")", ")", ")" ]
-> a #tuple of random #int
[ "-", ">", "a", "#tuple", "of", "random", "#int" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L926-L930
jaredLunde/vital-tools
vital/debug/__init__.py
RandData.randdeque
def randdeque(self): """ -> a :class:collections.deque of random #int """ return deque( self.randint for x in range(0, self.random.randint(3, 10)))
python
def randdeque(self): """ -> a :class:collections.deque of random #int """ return deque( self.randint for x in range(0, self.random.randint(3, 10)))
[ "def", "randdeque", "(", "self", ")", ":", "return", "deque", "(", "self", ".", "randint", "for", "x", "in", "range", "(", "0", ",", "self", ".", "random", ".", "randint", "(", "3", ",", "10", ")", ")", ")" ]
-> a :class:collections.deque of random #int
[ "-", ">", "a", ":", "class", ":", "collections", ".", "deque", "of", "random", "#int" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L933-L937
jaredLunde/vital-tools
vital/debug/__init__.py
RandData.randdict
def randdict(self): """ -> a #dict of |{random_string: random_int}| """ return { self.randstr: self._map_type(int) for x in range(self.random.randint(3, 10))}
python
def randdict(self): """ -> a #dict of |{random_string: random_int}| """ return { self.randstr: self._map_type(int) for x in range(self.random.randint(3, 10))}
[ "def", "randdict", "(", "self", ")", ":", "return", "{", "self", ".", "randstr", ":", "self", ".", "_map_type", "(", "int", ")", "for", "x", "in", "range", "(", "self", ".", "random", ".", "randint", "(", "3", ",", "10", ")", ")", "}" ]
-> a #dict of |{random_string: random_int}|
[ "-", ">", "a", "#dict", "of", "|", "{", "random_string", ":", "random_int", "}", "|" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L940-L944
jaredLunde/vital-tools
vital/debug/__init__.py
RandData.randset
def randset(self): """ -> a #set of random integers """ return { self._map_type(int) for x in range(self.random.randint(3, 10))}
python
def randset(self): """ -> a #set of random integers """ return { self._map_type(int) for x in range(self.random.randint(3, 10))}
[ "def", "randset", "(", "self", ")", ":", "return", "{", "self", ".", "_map_type", "(", "int", ")", "for", "x", "in", "range", "(", "self", ".", "random", ".", "randint", "(", "3", ",", "10", ")", ")", "}" ]
-> a #set of random integers
[ "-", ">", "a", "#set", "of", "random", "integers" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L947-L951
jaredLunde/vital-tools
vital/debug/__init__.py
RandData._to_tuple
def _to_tuple(self, _list): """ Recursively converts lists to tuples """ result = list() for l in _list: if isinstance(l, list): result.append(tuple(self._to_tuple(l))) else: result.append(l) return tuple(result)
python
def _to_tuple(self, _list): """ Recursively converts lists to tuples """ result = list() for l in _list: if isinstance(l, list): result.append(tuple(self._to_tuple(l))) else: result.append(l) return tuple(result)
[ "def", "_to_tuple", "(", "self", ",", "_list", ")", ":", "result", "=", "list", "(", ")", "for", "l", "in", "_list", ":", "if", "isinstance", "(", "l", ",", "list", ")", ":", "result", ".", "append", "(", "tuple", "(", "self", ".", "_to_tuple", "...
Recursively converts lists to tuples
[ "Recursively", "converts", "lists", "to", "tuples" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L959-L967
jaredLunde/vital-tools
vital/debug/__init__.py
RandData.dict
def dict(self, key_depth=1000, tree_depth=1): """ Creates a random #dict @key_depth: #int number of keys per @tree_depth to generate random values for @tree_depth: #int dict tree dimensions size, i.e. 1=|{key: value}| 2=|{key: {key: value}...
python
def dict(self, key_depth=1000, tree_depth=1): """ Creates a random #dict @key_depth: #int number of keys per @tree_depth to generate random values for @tree_depth: #int dict tree dimensions size, i.e. 1=|{key: value}| 2=|{key: {key: value}...
[ "def", "dict", "(", "self", ",", "key_depth", "=", "1000", ",", "tree_depth", "=", "1", ")", ":", "if", "not", "tree_depth", ":", "return", "self", ".", "_map_type", "(", ")", "return", "{", "self", ".", "randstr", ":", "self", ".", "dict", "(", "k...
Creates a random #dict @key_depth: #int number of keys per @tree_depth to generate random values for @tree_depth: #int dict tree dimensions size, i.e. 1=|{key: value}| 2=|{key: {key: value}, key2: {key2: value2}}| -> random #dict
[ "Creates", "a", "random", "#dict" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L975-L990
jaredLunde/vital-tools
vital/debug/__init__.py
RandData.defaultdict
def defaultdict(self, key_depth=1000, tree_depth=1): """ Creates a random :class:collections.defaultdict @key_depth: #int number of keys per @tree_depth to generate random values for @tree_depth: #int dict tree dimensions size, i.e. 1=|{key: value}| ...
python
def defaultdict(self, key_depth=1000, tree_depth=1): """ Creates a random :class:collections.defaultdict @key_depth: #int number of keys per @tree_depth to generate random values for @tree_depth: #int dict tree dimensions size, i.e. 1=|{key: value}| ...
[ "def", "defaultdict", "(", "self", ",", "key_depth", "=", "1000", ",", "tree_depth", "=", "1", ")", ":", "if", "not", "tree_depth", ":", "return", "self", ".", "_map_type", "(", ")", "_dict", "=", "defaultdict", "(", ")", "_dict", ".", "update", "(", ...
Creates a random :class:collections.defaultdict @key_depth: #int number of keys per @tree_depth to generate random values for @tree_depth: #int dict tree dimensions size, i.e. 1=|{key: value}| 2=|{key: {key: value}, key2: {key2: value2}}| ...
[ "Creates", "a", "random", ":", "class", ":", "collections", ".", "defaultdict" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L992-L1009
jaredLunde/vital-tools
vital/debug/__init__.py
RandData.tuple
def tuple(self, size=1000, tree_depth=1): """ Creates a random #tuple @size: #int number of random values to include in each @tree_depth @tree_depth: #int dict tree dimensions size, i.e. 1=|(value1, value2)| 2=|((value1, value2), (value1, value2))| ...
python
def tuple(self, size=1000, tree_depth=1): """ Creates a random #tuple @size: #int number of random values to include in each @tree_depth @tree_depth: #int dict tree dimensions size, i.e. 1=|(value1, value2)| 2=|((value1, value2), (value1, value2))| ...
[ "def", "tuple", "(", "self", ",", "size", "=", "1000", ",", "tree_depth", "=", "1", ")", ":", "if", "not", "tree_depth", ":", "return", "self", ".", "_map_type", "(", ")", "return", "tuple", "(", "self", ".", "tuple", "(", "size", ",", "tree_depth", ...
Creates a random #tuple @size: #int number of random values to include in each @tree_depth @tree_depth: #int dict tree dimensions size, i.e. 1=|(value1, value2)| 2=|((value1, value2), (value1, value2))| -> random #tuple
[ "Creates", "a", "random", "#tuple" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1011-L1023
jaredLunde/vital-tools
vital/debug/__init__.py
RandData.generator
def generator(self, size=1000, tree_depth=1): """ Creates a random #generator @size: #int number of random values to include in each @tree_depth @tree_depth: #int dict tree dimensions size, i.e. 1=|(value1, value2)| 2=|((value1, value2), (value1, value2))...
python
def generator(self, size=1000, tree_depth=1): """ Creates a random #generator @size: #int number of random values to include in each @tree_depth @tree_depth: #int dict tree dimensions size, i.e. 1=|(value1, value2)| 2=|((value1, value2), (value1, value2))...
[ "def", "generator", "(", "self", ",", "size", "=", "1000", ",", "tree_depth", "=", "1", ")", ":", "if", "not", "tree_depth", ":", "return", "self", ".", "_map_type", "(", ")", "return", "(", "self", ".", "generator", "(", "size", ",", "tree_depth", "...
Creates a random #generator @size: #int number of random values to include in each @tree_depth @tree_depth: #int dict tree dimensions size, i.e. 1=|(value1, value2)| 2=|((value1, value2), (value1, value2))| -> random :class:collections.deque
[ "Creates", "a", "random", "#generator" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1062-L1074
jaredLunde/vital-tools
vital/debug/__init__.py
RandData.sequence
def sequence(self, struct, size=1000, tree_depth=1, append_callable=None): """ Generates random values for sequence-like objects @struct: the sequence-like structure you want to fill with random data @size: #int number of random values to include in each @tree_depth ...
python
def sequence(self, struct, size=1000, tree_depth=1, append_callable=None): """ Generates random values for sequence-like objects @struct: the sequence-like structure you want to fill with random data @size: #int number of random values to include in each @tree_depth ...
[ "def", "sequence", "(", "self", ",", "struct", ",", "size", "=", "1000", ",", "tree_depth", "=", "1", ",", "append_callable", "=", "None", ")", ":", "if", "not", "tree_depth", ":", "return", "self", ".", "_map_type", "(", ")", "_struct", "=", "struct",...
Generates random values for sequence-like objects @struct: the sequence-like structure you want to fill with random data @size: #int number of random values to include in each @tree_depth @tree_depth: #int dict tree dimensions size, i.e. 1=|(value1, v...
[ "Generates", "random", "values", "for", "sequence", "-", "like", "objects" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1076-L1111
jaredLunde/vital-tools
vital/debug/__init__.py
RandData.mapping
def mapping(self, struct, key_depth=1000, tree_depth=1, update_callable=None): """ Generates random values for dict-like objects @struct: the dict-like structure you want to fill with random data @size: #int number of random values to include in each @tree_depth ...
python
def mapping(self, struct, key_depth=1000, tree_depth=1, update_callable=None): """ Generates random values for dict-like objects @struct: the dict-like structure you want to fill with random data @size: #int number of random values to include in each @tree_depth ...
[ "def", "mapping", "(", "self", ",", "struct", ",", "key_depth", "=", "1000", ",", "tree_depth", "=", "1", ",", "update_callable", "=", "None", ")", ":", "if", "not", "tree_depth", ":", "return", "self", ".", "_map_type", "(", ")", "_struct", "=", "stru...
Generates random values for dict-like objects @struct: the dict-like structure you want to fill with random data @size: #int number of random values to include in each @tree_depth @tree_depth: #int dict tree dimensions size, i.e. 1=|{key: value}| 2=|{...
[ "Generates", "random", "values", "for", "dict", "-", "like", "objects" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1113-L1153
jaredLunde/vital-tools
vital/debug/__init__.py
Look._dict_prefix
def _dict_prefix(self, key, value, i, dj=0, color=None, separator=":"): just = self._justify if i > 0 else dj key = cut(str(key), self._key_maxlen).rjust(just) key = colorize(key, color=color) pref = "{}{} {}".format(key, separator, value) """pref = "{}{} {}".format(colorize(str(...
python
def _dict_prefix(self, key, value, i, dj=0, color=None, separator=":"): just = self._justify if i > 0 else dj key = cut(str(key), self._key_maxlen).rjust(just) key = colorize(key, color=color) pref = "{}{} {}".format(key, separator, value) """pref = "{}{} {}".format(colorize(str(...
[ "def", "_dict_prefix", "(", "self", ",", "key", ",", "value", ",", "i", ",", "dj", "=", "0", ",", "color", "=", "None", ",", "separator", "=", "\":\"", ")", ":", "just", "=", "self", ".", "_justify", "if", "i", ">", "0", "else", "dj", "key", "=...
pref = "{}{} {}".format(colorize(str(key)[:self._key_maxlen]\ .rjust(just), color=color), separator, value)
[ "pref", "=", "{}", "{}", "{}", ".", "format", "(", "colorize", "(", "str", "(", "key", ")", "[", ":", "self", ".", "_key_maxlen", "]", "\\", ".", "rjust", "(", "just", ")", "color", "=", "color", ")", "separator", "value", ")" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1208-L1215
jaredLunde/vital-tools
vital/debug/__init__.py
Look._format_numeric_sequence
def _format_numeric_sequence(self, _sequence, separator="."): """ Length of the highest index in chars = justification size """ if not _sequence: return colorize(_sequence, "purple") _sequence = _sequence if _sequence is not None else self.obj minus = (2 if self._depth > 0 el...
python
def _format_numeric_sequence(self, _sequence, separator="."): """ Length of the highest index in chars = justification size """ if not _sequence: return colorize(_sequence, "purple") _sequence = _sequence if _sequence is not None else self.obj minus = (2 if self._depth > 0 el...
[ "def", "_format_numeric_sequence", "(", "self", ",", "_sequence", ",", "separator", "=", "\".\"", ")", ":", "if", "not", "_sequence", ":", "return", "colorize", "(", "_sequence", ",", "\"purple\"", ")", "_sequence", "=", "_sequence", "if", "_sequence", "is", ...
Length of the highest index in chars = justification size
[ "Length", "of", "the", "highest", "index", "in", "chars", "=", "justification", "size" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1238-L1256
jaredLunde/vital-tools
vital/debug/__init__.py
Look.objname
def objname(self, obj=None): """ Formats object names in a pretty fashion """ obj = obj or self.obj _objname = self.pretty_objname(obj, color=None) _objname = "'{}'".format(colorize(_objname, "blue")) return _objname
python
def objname(self, obj=None): """ Formats object names in a pretty fashion """ obj = obj or self.obj _objname = self.pretty_objname(obj, color=None) _objname = "'{}'".format(colorize(_objname, "blue")) return _objname
[ "def", "objname", "(", "self", ",", "obj", "=", "None", ")", ":", "obj", "=", "obj", "or", "self", ".", "obj", "_objname", "=", "self", ".", "pretty_objname", "(", "obj", ",", "color", "=", "None", ")", "_objname", "=", "\"'{}'\"", ".", "format", "...
Formats object names in a pretty fashion
[ "Formats", "object", "names", "in", "a", "pretty", "fashion" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1347-L1352
jaredLunde/vital-tools
vital/debug/__init__.py
Look.pretty
def pretty(self, obj=None, display=True): """ Formats @obj or :prop:obj @obj: the object you'd like to prettify -> #str pretty object """ ret = self._format_obj(obj if obj is not None else self.obj) if display: print(ret) else: re...
python
def pretty(self, obj=None, display=True): """ Formats @obj or :prop:obj @obj: the object you'd like to prettify -> #str pretty object """ ret = self._format_obj(obj if obj is not None else self.obj) if display: print(ret) else: re...
[ "def", "pretty", "(", "self", ",", "obj", "=", "None", ",", "display", "=", "True", ")", ":", "ret", "=", "self", ".", "_format_obj", "(", "obj", "if", "obj", "is", "not", "None", "else", "self", ".", "obj", ")", "if", "display", ":", "print", "(...
Formats @obj or :prop:obj @obj: the object you'd like to prettify -> #str pretty object
[ "Formats", "@obj", "or", ":", "prop", ":", "obj" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1354-L1365
jaredLunde/vital-tools
vital/debug/__init__.py
Look._format_obj
def _format_obj(self, item=None): """ Determines the type of the object and maps it to the correct formatter """ # Order here matters, odd behavior with tuples if item is None: return getattr(self, 'number')(item) elif isinstance(item, self.str_): ...
python
def _format_obj(self, item=None): """ Determines the type of the object and maps it to the correct formatter """ # Order here matters, odd behavior with tuples if item is None: return getattr(self, 'number')(item) elif isinstance(item, self.str_): ...
[ "def", "_format_obj", "(", "self", ",", "item", "=", "None", ")", ":", "# Order here matters, odd behavior with tuples", "if", "item", "is", "None", ":", "return", "getattr", "(", "self", ",", "'number'", ")", "(", "item", ")", "elif", "isinstance", "(", "it...
Determines the type of the object and maps it to the correct formatter
[ "Determines", "the", "type", "of", "the", "object", "and", "maps", "it", "to", "the", "correct", "formatter" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1367-L1405
jaredLunde/vital-tools
vital/debug/__init__.py
Look.pretty_objname
def pretty_objname(self, obj=None, maxlen=50, color="boldcyan"): """ Pretty prints object name @obj: the object whose name you want to pretty print @maxlen: #int maximum length of an object name to print @color: your choice of :mod:colors or |None| -> #str prett...
python
def pretty_objname(self, obj=None, maxlen=50, color="boldcyan"): """ Pretty prints object name @obj: the object whose name you want to pretty print @maxlen: #int maximum length of an object name to print @color: your choice of :mod:colors or |None| -> #str prett...
[ "def", "pretty_objname", "(", "self", ",", "obj", "=", "None", ",", "maxlen", "=", "50", ",", "color", "=", "\"boldcyan\"", ")", ":", "parent_name", "=", "lambda_sub", "(", "\"\"", ",", "get_parent_name", "(", "obj", ")", "or", "\"\"", ")", "objname", ...
Pretty prints object name @obj: the object whose name you want to pretty print @maxlen: #int maximum length of an object name to print @color: your choice of :mod:colors or |None| -> #str pretty object name .. from vital.debug import Look ...
[ "Pretty", "prints", "object", "name" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1408-L1432
jaredLunde/vital-tools
vital/debug/__init__.py
Logg.set_level
def set_level(self, level): """ Sets :attr:loglevel to @level @level: #str one or several :attr:levels """ if not level: return None self.levelmap = set() for char in level: self.levelmap = self.levelmap.union(self.levels[char]) self.l...
python
def set_level(self, level): """ Sets :attr:loglevel to @level @level: #str one or several :attr:levels """ if not level: return None self.levelmap = set() for char in level: self.levelmap = self.levelmap.union(self.levels[char]) self.l...
[ "def", "set_level", "(", "self", ",", "level", ")", ":", "if", "not", "level", ":", "return", "None", "self", ".", "levelmap", "=", "set", "(", ")", "for", "char", "in", "level", ":", "self", ".", "levelmap", "=", "self", ".", "levelmap", ".", "uni...
Sets :attr:loglevel to @level @level: #str one or several :attr:levels
[ "Sets", ":", "attr", ":", "loglevel", "to", "@level" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1567-L1578
jaredLunde/vital-tools
vital/debug/__init__.py
Logg.log
def log(self, flag_message=None, padding=None, color=None, force=False): """ Log Level: :attr:LOG @flag_message: #str flags the message with the given text using :func:flag @padding: #str 'top', 'bottom' or 'all', adds a new line to the specified area wit...
python
def log(self, flag_message=None, padding=None, color=None, force=False): """ Log Level: :attr:LOG @flag_message: #str flags the message with the given text using :func:flag @padding: #str 'top', 'bottom' or 'all', adds a new line to the specified area wit...
[ "def", "log", "(", "self", ",", "flag_message", "=", "None", ",", "padding", "=", "None", ",", "color", "=", "None", ",", "force", "=", "False", ")", ":", "if", "self", ".", "should_log", "(", "self", ".", "LOG", ")", "or", "force", ":", "self", ...
Log Level: :attr:LOG @flag_message: #str flags the message with the given text using :func:flag @padding: #str 'top', 'bottom' or 'all', adds a new line to the specified area with :func:padd @color: #str colorizes @flag_message using :func:colorize ...
[ "Log", "Level", ":", ":", "attr", ":", "LOG" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1588-L1613
jaredLunde/vital-tools
vital/debug/__init__.py
Logg.success
def success(self, flag_message="Success", padding=None, force=False): """ Log Level: :attr:SUCCESS @flag_message: #str flags the message with the given text using :func:flag @padding: #str 'top', 'bottom' or 'all', adds a new line to the specified area wi...
python
def success(self, flag_message="Success", padding=None, force=False): """ Log Level: :attr:SUCCESS @flag_message: #str flags the message with the given text using :func:flag @padding: #str 'top', 'bottom' or 'all', adds a new line to the specified area wi...
[ "def", "success", "(", "self", ",", "flag_message", "=", "\"Success\"", ",", "padding", "=", "None", ",", "force", "=", "False", ")", ":", "if", "self", ".", "should_log", "(", "self", ".", "SUCCESS", ")", "or", "force", ":", "self", ".", "_print_messa...
Log Level: :attr:SUCCESS @flag_message: #str flags the message with the given text using :func:flag @padding: #str 'top', 'bottom' or 'all', adds a new line to the specified area with :func:padd @color: #str colorizes @flag_message using :func:coloriz...
[ "Log", "Level", ":", ":", "attr", ":", "SUCCESS" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1615-L1640
jaredLunde/vital-tools
vital/debug/__init__.py
Logg.complete
def complete(self, flag_message="Complete", padding=None, force=False): """ Log Level: :attr:COMPLETE @flag_message: #str flags the message with the given text using :func:flag @padding: #str 'top', 'bottom' or 'all', adds a new line to the specified area...
python
def complete(self, flag_message="Complete", padding=None, force=False): """ Log Level: :attr:COMPLETE @flag_message: #str flags the message with the given text using :func:flag @padding: #str 'top', 'bottom' or 'all', adds a new line to the specified area...
[ "def", "complete", "(", "self", ",", "flag_message", "=", "\"Complete\"", ",", "padding", "=", "None", ",", "force", "=", "False", ")", ":", "if", "self", ".", "should_log", "(", "self", ".", "COMPLETE", ")", "or", "force", ":", "self", ".", "_print_me...
Log Level: :attr:COMPLETE @flag_message: #str flags the message with the given text using :func:flag @padding: #str 'top', 'bottom' or 'all', adds a new line to the specified area with :func:padd @color: #str colorizes @flag_message using :func:colori...
[ "Log", "Level", ":", ":", "attr", ":", "COMPLETE" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1642-L1667
jaredLunde/vital-tools
vital/debug/__init__.py
Logg.notice
def notice(self, flag_message="Notice", padding=None, force=False): """ Log Level: :attr:NOTICE @flag_message: #str flags the message with the given text using :func:flag @padding: #str 'top', 'bottom' or 'all', adds a new line to the specified area with ...
python
def notice(self, flag_message="Notice", padding=None, force=False): """ Log Level: :attr:NOTICE @flag_message: #str flags the message with the given text using :func:flag @padding: #str 'top', 'bottom' or 'all', adds a new line to the specified area with ...
[ "def", "notice", "(", "self", ",", "flag_message", "=", "\"Notice\"", ",", "padding", "=", "None", ",", "force", "=", "False", ")", ":", "if", "self", ".", "should_log", "(", "self", ".", "NOTICE", ")", "or", "force", ":", "self", ".", "_print_message"...
Log Level: :attr:NOTICE @flag_message: #str flags the message with the given text using :func:flag @padding: #str 'top', 'bottom' or 'all', adds a new line to the specified area with :func:padd @color: #str colorizes @flag_message using :func:colorize...
[ "Log", "Level", ":", ":", "attr", ":", "NOTICE" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1669-L1694
jaredLunde/vital-tools
vital/debug/__init__.py
Logg.warning
def warning(self, flag_message="Warning", padding=None, force=False): """ Log Level: :attr:WARNING @flag_message: #str flags the message with the given text using :func:flag @padding: #str 'top', 'bottom' or 'all', adds a new line to the specified area wi...
python
def warning(self, flag_message="Warning", padding=None, force=False): """ Log Level: :attr:WARNING @flag_message: #str flags the message with the given text using :func:flag @padding: #str 'top', 'bottom' or 'all', adds a new line to the specified area wi...
[ "def", "warning", "(", "self", ",", "flag_message", "=", "\"Warning\"", ",", "padding", "=", "None", ",", "force", "=", "False", ")", ":", "if", "self", ".", "should_log", "(", "self", ".", "WARNING", ")", "or", "force", ":", "self", ".", "_print_messa...
Log Level: :attr:WARNING @flag_message: #str flags the message with the given text using :func:flag @padding: #str 'top', 'bottom' or 'all', adds a new line to the specified area with :func:padd @color: #str colorizes @flag_message using :func:coloriz...
[ "Log", "Level", ":", ":", "attr", ":", "WARNING" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1696-L1721
jaredLunde/vital-tools
vital/debug/__init__.py
Logg.error
def error(self, flag_message="Error", padding=None, force=False): """ Log Level: :attr:ERROR @flag_message: #str flags the message with the given text using :func:flag @padding: #str 'top', 'bottom' or 'all', adds a new line to the specified area with :fu...
python
def error(self, flag_message="Error", padding=None, force=False): """ Log Level: :attr:ERROR @flag_message: #str flags the message with the given text using :func:flag @padding: #str 'top', 'bottom' or 'all', adds a new line to the specified area with :fu...
[ "def", "error", "(", "self", ",", "flag_message", "=", "\"Error\"", ",", "padding", "=", "None", ",", "force", "=", "False", ")", ":", "if", "self", ".", "should_log", "(", "self", ".", "ERROR", ")", "or", "force", ":", "self", ".", "_print_message", ...
Log Level: :attr:ERROR @flag_message: #str flags the message with the given text using :func:flag @padding: #str 'top', 'bottom' or 'all', adds a new line to the specified area with :func:padd @color: #str colorizes @flag_message using :func:colorize ...
[ "Log", "Level", ":", ":", "attr", ":", "ERROR" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1723-L1748
jaredLunde/vital-tools
vital/debug/__init__.py
Logg.timing
def timing(self, flag_message, padding=None, force=False): """ Log Level: :attr:TIMING @flag_message: time-like #float @padding: #str 'top', 'bottom' or 'all', adds a new line to the specified area with :func:padd @force: #bool whether or not to force the mes...
python
def timing(self, flag_message, padding=None, force=False): """ Log Level: :attr:TIMING @flag_message: time-like #float @padding: #str 'top', 'bottom' or 'all', adds a new line to the specified area with :func:padd @force: #bool whether or not to force the mes...
[ "def", "timing", "(", "self", ",", "flag_message", ",", "padding", "=", "None", ",", "force", "=", "False", ")", ":", "if", "self", ".", "should_log", "(", "self", ".", "TIMING", ")", "or", "force", ":", "self", ".", "_print_message", "(", "flag_messag...
Log Level: :attr:TIMING @flag_message: time-like #float @padding: #str 'top', 'bottom' or 'all', adds a new line to the specified area with :func:padd @force: #bool whether or not to force the message to log in spite of the assigned log level ...
[ "Log", "Level", ":", ":", "attr", ":", "TIMING" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1750-L1773
jaredLunde/vital-tools
vital/debug/__init__.py
Logg.count
def count(self, flag_message, padding=None, force=False): """ Log Level: :attr:COUNT @flag_message: time-like #float @padding: #str 'top', 'bottom' or 'all', adds a new line to the specified area with :func:padd @force: #bool whether or not to force the messa...
python
def count(self, flag_message, padding=None, force=False): """ Log Level: :attr:COUNT @flag_message: time-like #float @padding: #str 'top', 'bottom' or 'all', adds a new line to the specified area with :func:padd @force: #bool whether or not to force the messa...
[ "def", "count", "(", "self", ",", "flag_message", ",", "padding", "=", "None", ",", "force", "=", "False", ")", ":", "if", "self", ".", "should_log", "(", "self", ".", "COUNT", ")", "or", "force", ":", "flag_message", "=", "flag_message", "if", "isinst...
Log Level: :attr:COUNT @flag_message: time-like #float @padding: #str 'top', 'bottom' or 'all', adds a new line to the specified area with :func:padd @force: #bool whether or not to force the message to log in spite of the assigned log level ...
[ "Log", "Level", ":", ":", "attr", ":", "COUNT" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1775-L1801
jaredLunde/vital-tools
vital/debug/__init__.py
Logg.format_message
def format_message(self, message): """ Formats a message with :class:Look """ look = Look(message) return look.pretty(display=False)
python
def format_message(self, message): """ Formats a message with :class:Look """ look = Look(message) return look.pretty(display=False)
[ "def", "format_message", "(", "self", ",", "message", ")", ":", "look", "=", "Look", "(", "message", ")", "return", "look", ".", "pretty", "(", "display", "=", "False", ")" ]
Formats a message with :class:Look
[ "Formats", "a", "message", "with", ":", "class", ":", "Look" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1804-L1807
jaredLunde/vital-tools
vital/debug/__init__.py
Logg.format_messages
def format_messages(self, messages): """ Formats several messages with :class:Look, encodes them with :func:vital.tools.encoding.stdout_encode """ mess = "" for message in self.message: if self.pretty: mess = "{}{}".format(mess, self.format_message(message...
python
def format_messages(self, messages): """ Formats several messages with :class:Look, encodes them with :func:vital.tools.encoding.stdout_encode """ mess = "" for message in self.message: if self.pretty: mess = "{}{}".format(mess, self.format_message(message...
[ "def", "format_messages", "(", "self", ",", "messages", ")", ":", "mess", "=", "\"\"", "for", "message", "in", "self", ".", "message", ":", "if", "self", ".", "pretty", ":", "mess", "=", "\"{}{}\"", ".", "format", "(", "mess", ",", "self", ".", "form...
Formats several messages with :class:Look, encodes them with :func:vital.tools.encoding.stdout_encode
[ "Formats", "several", "messages", "with", ":", "class", ":", "Look", "encodes", "them", "with", ":", "func", ":", "vital", ".", "tools", ".", "encoding", ".", "stdout_encode" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1809-L1821
jaredLunde/vital-tools
vital/debug/__init__.py
Logg._print_message
def _print_message(self, flag_message=None, color=None, padding=None, reverse=False): """ Outputs the message to the terminal """ if flag_message: flag_message = stdout_encode(flag(flag_message, color=color if self.pretty e...
python
def _print_message(self, flag_message=None, color=None, padding=None, reverse=False): """ Outputs the message to the terminal """ if flag_message: flag_message = stdout_encode(flag(flag_message, color=color if self.pretty e...
[ "def", "_print_message", "(", "self", ",", "flag_message", "=", "None", ",", "color", "=", "None", ",", "padding", "=", "None", ",", "reverse", "=", "False", ")", ":", "if", "flag_message", ":", "flag_message", "=", "stdout_encode", "(", "flag", "(", "fl...
Outputs the message to the terminal
[ "Outputs", "the", "message", "to", "the", "terminal" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1824-L1839
jaredLunde/vital-tools
vital/debug/__init__.py
ProgressBar.format_bar
def format_bar(self): """ Builds the progress bar """ pct = floor(round(self.progress/self.size, 2)*100) pr = floor(pct*.33) bar = "".join( ["‒" for x in range(pr)] + ["↦"] + [" " for o in range(self._barsize-pr-1)]) subprogress = self.format_parent_bar() ...
python
def format_bar(self): """ Builds the progress bar """ pct = floor(round(self.progress/self.size, 2)*100) pr = floor(pct*.33) bar = "".join( ["‒" for x in range(pr)] + ["↦"] + [" " for o in range(self._barsize-pr-1)]) subprogress = self.format_parent_bar() ...
[ "def", "format_bar", "(", "self", ")", ":", "pct", "=", "floor", "(", "round", "(", "self", ".", "progress", "/", "self", ".", "size", ",", "2", ")", "*", "100", ")", "pr", "=", "floor", "(", "pct", "*", ".33", ")", "bar", "=", "\"\"", ".", "...
Builds the progress bar
[ "Builds", "the", "progress", "bar" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1914-L1923
jaredLunde/vital-tools
vital/debug/__init__.py
ProgressBar.finish
def finish(self): """ Resets the progress bar and clears it from the terminal """ pct = floor(round(self.progress/self.size, 2)*100) pr = floor(pct*.33) bar = "".join([" " for x in range(pr-1)] + ["↦"]) subprogress = self.format_parent_bar() if self.parent_bar else "" fin...
python
def finish(self): """ Resets the progress bar and clears it from the terminal """ pct = floor(round(self.progress/self.size, 2)*100) pr = floor(pct*.33) bar = "".join([" " for x in range(pr-1)] + ["↦"]) subprogress = self.format_parent_bar() if self.parent_bar else "" fin...
[ "def", "finish", "(", "self", ")", ":", "pct", "=", "floor", "(", "round", "(", "self", ".", "progress", "/", "self", ".", "size", ",", "2", ")", "*", "100", ")", "pr", "=", "floor", "(", "pct", "*", ".33", ")", "bar", "=", "\"\"", ".", "join...
Resets the progress bar and clears it from the terminal
[ "Resets", "the", "progress", "bar", "and", "clears", "it", "from", "the", "terminal" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1925-L1935
jaredLunde/vital-tools
vital/debug/__init__.py
ProgressBar.update
def update(self, progress=0): """ Updates the progress bar with @progress if given, otherwise increments :prop:progress by 1. Also prints the progress bar. @progress: #int to assign to :prop:progress """ self.progress += (progress or 1) if self.visible: ...
python
def update(self, progress=0): """ Updates the progress bar with @progress if given, otherwise increments :prop:progress by 1. Also prints the progress bar. @progress: #int to assign to :prop:progress """ self.progress += (progress or 1) if self.visible: ...
[ "def", "update", "(", "self", ",", "progress", "=", "0", ")", ":", "self", ".", "progress", "+=", "(", "progress", "or", "1", ")", "if", "self", ".", "visible", ":", "if", "self", ".", "progress", "%", "self", ".", "_mod", "==", "1", "or", "self"...
Updates the progress bar with @progress if given, otherwise increments :prop:progress by 1. Also prints the progress bar. @progress: #int to assign to :prop:progress
[ "Updates", "the", "progress", "bar", "with", "@progress", "if", "given", "otherwise", "increments", ":", "prop", ":", "progress", "by", "1", ".", "Also", "prints", "the", "progress", "bar", "." ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1937-L1949
jaredLunde/vital-tools
vital/debug/__init__.py
Timer.start
def start(self): """ Starts the timer """ if not self._start: self._first_start = time.perf_counter() self._start = self._first_start else: self._start = time.perf_counter()
python
def start(self): """ Starts the timer """ if not self._start: self._first_start = time.perf_counter() self._start = self._first_start else: self._start = time.perf_counter()
[ "def", "start", "(", "self", ")", ":", "if", "not", "self", ".", "_start", ":", "self", ".", "_first_start", "=", "time", ".", "perf_counter", "(", ")", "self", ".", "_start", "=", "self", ".", "_first_start", "else", ":", "self", ".", "_start", "=",...
Starts the timer
[ "Starts", "the", "timer" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L2046-L2052
jaredLunde/vital-tools
vital/debug/__init__.py
Timer.stop
def stop(self, precision=0): """ Stops the timer, adds it as an interval to :prop:intervals @precision: #int number of decimal places to round to -> #str formatted interval time """ self._stop = time.perf_counter() return self.add_interval(precision)
python
def stop(self, precision=0): """ Stops the timer, adds it as an interval to :prop:intervals @precision: #int number of decimal places to round to -> #str formatted interval time """ self._stop = time.perf_counter() return self.add_interval(precision)
[ "def", "stop", "(", "self", ",", "precision", "=", "0", ")", ":", "self", ".", "_stop", "=", "time", ".", "perf_counter", "(", ")", "return", "self", ".", "add_interval", "(", "precision", ")" ]
Stops the timer, adds it as an interval to :prop:intervals @precision: #int number of decimal places to round to -> #str formatted interval time
[ "Stops", "the", "timer", "adds", "it", "as", "an", "interval", "to", ":", "prop", ":", "intervals", "@precision", ":", "#int", "number", "of", "decimal", "places", "to", "round", "to" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L2054-L2061
jaredLunde/vital-tools
vital/debug/__init__.py
Timer.format_time
def format_time(self, sec): """ Pretty-formats a given time in a readable manner @sec: #int or #float seconds -> #str formatted time """ # µsec if sec < 0.001: return "{}{}".format( colorize(round(sec*1000000, 2), "purple"), bold("µs")...
python
def format_time(self, sec): """ Pretty-formats a given time in a readable manner @sec: #int or #float seconds -> #str formatted time """ # µsec if sec < 0.001: return "{}{}".format( colorize(round(sec*1000000, 2), "purple"), bold("µs")...
[ "def", "format_time", "(", "self", ",", "sec", ")", ":", "# µsec", "if", "sec", "<", "0.001", ":", "return", "\"{}{}\"", ".", "format", "(", "colorize", "(", "round", "(", "sec", "*", "1000000", ",", "2", ")", ",", "\"purple\"", ")", ",", "bold", "...
Pretty-formats a given time in a readable manner @sec: #int or #float seconds -> #str formatted time
[ "Pretty", "-", "formats", "a", "given", "time", "in", "a", "readable", "manner", "@sec", ":", "#int", "or", "#float", "seconds" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L2064-L2088
jaredLunde/vital-tools
vital/debug/__init__.py
Timer.format_size
def format_size(self, bytes): """ Pretty-formats given bytes size in a readable manner @bytes: #int or #float bytes -> #str formatted bytes """ # b if bytes < 1024: return "{}{}".format(colorize(round( bytes, 2), "purple"), ...
python
def format_size(self, bytes): """ Pretty-formats given bytes size in a readable manner @bytes: #int or #float bytes -> #str formatted bytes """ # b if bytes < 1024: return "{}{}".format(colorize(round( bytes, 2), "purple"), ...
[ "def", "format_size", "(", "self", ",", "bytes", ")", ":", "# b", "if", "bytes", "<", "1024", ":", "return", "\"{}{}\"", ".", "format", "(", "colorize", "(", "round", "(", "bytes", ",", "2", ")", ",", "\"purple\"", ")", ",", "bold", "(", "\"bytes\"",...
Pretty-formats given bytes size in a readable manner @bytes: #int or #float bytes -> #str formatted bytes
[ "Pretty", "-", "formats", "given", "bytes", "size", "in", "a", "readable", "manner", "@bytes", ":", "#int", "or", "#float", "bytes" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L2090-L2110
jaredLunde/vital-tools
vital/debug/__init__.py
Timer.add_interval
def add_interval(self, precision=0): """ Adds an interval to :prop:intervals -> #str formatted time """ precision = precision or self.precision interval = round((self._stop - self._start), precision) self.intervals.append(interval) self._intervals_len += 1 ...
python
def add_interval(self, precision=0): """ Adds an interval to :prop:intervals -> #str formatted time """ precision = precision or self.precision interval = round((self._stop - self._start), precision) self.intervals.append(interval) self._intervals_len += 1 ...
[ "def", "add_interval", "(", "self", ",", "precision", "=", "0", ")", ":", "precision", "=", "precision", "or", "self", ".", "precision", "interval", "=", "round", "(", "(", "self", ".", "_stop", "-", "self", ".", "_start", ")", ",", "precision", ")", ...
Adds an interval to :prop:intervals -> #str formatted time
[ "Adds", "an", "interval", "to", ":", "prop", ":", "intervals", "-", ">", "#str", "formatted", "time" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L2112-L2121
jaredLunde/vital-tools
vital/debug/__init__.py
Timer.time
def time(self, intervals=1, *args, _show_progress=True, _print=True, _collect_garbage=True, _quiet=True, **kwargs): """ Measures the execution time of :prop:_callable for @intervals @intervals: #int number of intervals to measure the execution time of the function for ...
python
def time(self, intervals=1, *args, _show_progress=True, _print=True, _collect_garbage=True, _quiet=True, **kwargs): """ Measures the execution time of :prop:_callable for @intervals @intervals: #int number of intervals to measure the execution time of the function for ...
[ "def", "time", "(", "self", ",", "intervals", "=", "1", ",", "*", "args", ",", "_show_progress", "=", "True", ",", "_print", "=", "True", ",", "_collect_garbage", "=", "True", ",", "_quiet", "=", "True", ",", "*", "*", "kwargs", ")", ":", "self", "...
Measures the execution time of :prop:_callable for @intervals @intervals: #int number of intervals to measure the execution time of the function for @*args: arguments to pass to the callable being timed @**kwargs: arguments to pass to the callable being timed ...
[ "Measures", "the", "execution", "time", "of", ":", "prop", ":", "_callable", "for", "@intervals" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L2123-L2165
jaredLunde/vital-tools
vital/debug/__init__.py
Timer.mean
def mean(self): """ -> #float :func:numpy.mean of the timing intervals """ return round(np.mean(self.array), self.precision)\ if len(self.array) else None
python
def mean(self): """ -> #float :func:numpy.mean of the timing intervals """ return round(np.mean(self.array), self.precision)\ if len(self.array) else None
[ "def", "mean", "(", "self", ")", ":", "return", "round", "(", "np", ".", "mean", "(", "self", ".", "array", ")", ",", "self", ".", "precision", ")", "if", "len", "(", "self", ".", "array", ")", "else", "None" ]
-> #float :func:numpy.mean of the timing intervals
[ "-", ">", "#float", ":", "func", ":", "numpy", ".", "mean", "of", "the", "timing", "intervals" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L2168-L2171
jaredLunde/vital-tools
vital/debug/__init__.py
Timer.median
def median(self): """ -> #float :func:numpy.median of the timing intervals """ return round(float(np.median(self.array)), self.precision)\ if len(self.array) else None
python
def median(self): """ -> #float :func:numpy.median of the timing intervals """ return round(float(np.median(self.array)), self.precision)\ if len(self.array) else None
[ "def", "median", "(", "self", ")", ":", "return", "round", "(", "float", "(", "np", ".", "median", "(", "self", ".", "array", ")", ")", ",", "self", ".", "precision", ")", "if", "len", "(", "self", ".", "array", ")", "else", "None" ]
-> #float :func:numpy.median of the timing intervals
[ "-", ">", "#float", ":", "func", ":", "numpy", ".", "median", "of", "the", "timing", "intervals" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L2174-L2177
jaredLunde/vital-tools
vital/debug/__init__.py
Timer.max
def max(self): """ -> #float :func:numpy.max of the timing intervals """ return round(np.max(self.array), self.precision)\ if len(self.array) else None
python
def max(self): """ -> #float :func:numpy.max of the timing intervals """ return round(np.max(self.array), self.precision)\ if len(self.array) else None
[ "def", "max", "(", "self", ")", ":", "return", "round", "(", "np", ".", "max", "(", "self", ".", "array", ")", ",", "self", ".", "precision", ")", "if", "len", "(", "self", ".", "array", ")", "else", "None" ]
-> #float :func:numpy.max of the timing intervals
[ "-", ">", "#float", ":", "func", ":", "numpy", ".", "max", "of", "the", "timing", "intervals" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L2180-L2183
jaredLunde/vital-tools
vital/debug/__init__.py
Timer.min
def min(self): """ -> #float :func:numpy.min of the timing intervals """ return round(np.min(self.array), self.precision)\ if len(self.array) else None
python
def min(self): """ -> #float :func:numpy.min of the timing intervals """ return round(np.min(self.array), self.precision)\ if len(self.array) else None
[ "def", "min", "(", "self", ")", ":", "return", "round", "(", "np", ".", "min", "(", "self", ".", "array", ")", ",", "self", ".", "precision", ")", "if", "len", "(", "self", ".", "array", ")", "else", "None" ]
-> #float :func:numpy.min of the timing intervals
[ "-", ">", "#float", ":", "func", ":", "numpy", ".", "min", "of", "the", "timing", "intervals" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L2186-L2189
jaredLunde/vital-tools
vital/debug/__init__.py
Timer.stdev
def stdev(self): """ -> #float :func:numpy.std of the timing intervals """ return round(np.std(self.array), self.precision)\ if len(self.array) else None
python
def stdev(self): """ -> #float :func:numpy.std of the timing intervals """ return round(np.std(self.array), self.precision)\ if len(self.array) else None
[ "def", "stdev", "(", "self", ")", ":", "return", "round", "(", "np", ".", "std", "(", "self", ".", "array", ")", ",", "self", ".", "precision", ")", "if", "len", "(", "self", ".", "array", ")", "else", "None" ]
-> #float :func:numpy.std of the timing intervals
[ "-", ">", "#float", ":", "func", ":", "numpy", ".", "std", "of", "the", "timing", "intervals" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L2192-L2195
jaredLunde/vital-tools
vital/debug/__init__.py
Timer.stats
def stats(self): """ -> :class:collections.OrderedDict of stats about the time intervals """ return OrderedDict([ ("Intervals", len(self.array)), ("Mean", self.format_time(self.mean or 0)), ("Min", self.format_time(self.min or 0)), ("Median", self....
python
def stats(self): """ -> :class:collections.OrderedDict of stats about the time intervals """ return OrderedDict([ ("Intervals", len(self.array)), ("Mean", self.format_time(self.mean or 0)), ("Min", self.format_time(self.min or 0)), ("Median", self....
[ "def", "stats", "(", "self", ")", ":", "return", "OrderedDict", "(", "[", "(", "\"Intervals\"", ",", "len", "(", "self", ".", "array", ")", ")", ",", "(", "\"Mean\"", ",", "self", ".", "format_time", "(", "self", ".", "mean", "or", "0", ")", ")", ...
-> :class:collections.OrderedDict of stats about the time intervals
[ "-", ">", ":", "class", ":", "collections", ".", "OrderedDict", "of", "stats", "about", "the", "time", "intervals" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L2208-L2219
jaredLunde/vital-tools
vital/debug/__init__.py
Compare._pct_diff
def _pct_diff(self, best, other): """ Calculates and colorizes the percent difference between @best and @other """ return colorize("{}%".format( round(((best-other)/best)*100, 2)).rjust(10), "red")
python
def _pct_diff(self, best, other): """ Calculates and colorizes the percent difference between @best and @other """ return colorize("{}%".format( round(((best-other)/best)*100, 2)).rjust(10), "red")
[ "def", "_pct_diff", "(", "self", ",", "best", ",", "other", ")", ":", "return", "colorize", "(", "\"{}%\"", ".", "format", "(", "round", "(", "(", "(", "best", "-", "other", ")", "/", "best", ")", "*", "100", ",", "2", ")", ")", ".", "rjust", "...
Calculates and colorizes the percent difference between @best and @other
[ "Calculates", "and", "colorizes", "the", "percent", "difference", "between" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L2367-L2372
jaredLunde/vital-tools
vital/debug/__init__.py
Compare.info
def info(self, verbose=None): """ Prints and formats the results of the timing @_print: #bool whether or not to print out to terminal @verbose: #bool True if you'd like to print the individual timing results in additions to the comparison results """ if se...
python
def info(self, verbose=None): """ Prints and formats the results of the timing @_print: #bool whether or not to print out to terminal @verbose: #bool True if you'd like to print the individual timing results in additions to the comparison results """ if se...
[ "def", "info", "(", "self", ",", "verbose", "=", "None", ")", ":", "if", "self", ".", "name", ":", "flag", "(", "bold", "(", "self", ".", "name", ")", ")", "flag", "(", "\"Results after {} intervals\"", ".", "format", "(", "bold", "(", "self", ".", ...
Prints and formats the results of the timing @_print: #bool whether or not to print out to terminal @verbose: #bool True if you'd like to print the individual timing results in additions to the comparison results
[ "Prints", "and", "formats", "the", "results", "of", "the", "timing" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L2374-L2408
kajala/django-jutil
jutil/management/commands/bank_const_fi.py
fi_iban_load_map
def fi_iban_load_map(filename: str) -> dict: """ Loads Finnish monetary institution codes and BICs in CSV format. Map which is based on 3 digits as in FIXX<3 digits>. Can be used to map Finnish IBAN number to bank information. Format: dict('<3 digits': (BIC, name), ...) :param filename: CSV file...
python
def fi_iban_load_map(filename: str) -> dict: """ Loads Finnish monetary institution codes and BICs in CSV format. Map which is based on 3 digits as in FIXX<3 digits>. Can be used to map Finnish IBAN number to bank information. Format: dict('<3 digits': (BIC, name), ...) :param filename: CSV file...
[ "def", "fi_iban_load_map", "(", "filename", ":", "str", ")", "->", "dict", ":", "out", "=", "{", "}", "with", "open", "(", "filename", ",", "'rt'", ")", "as", "fp", ":", "lines", "=", "[", "line", ".", "strip", "(", ")", ".", "split", "(", "','",...
Loads Finnish monetary institution codes and BICs in CSV format. Map which is based on 3 digits as in FIXX<3 digits>. Can be used to map Finnish IBAN number to bank information. Format: dict('<3 digits': (BIC, name), ...) :param filename: CSV file name of the BIC definitions. Columns: National ID, BIC C...
[ "Loads", "Finnish", "monetary", "institution", "codes", "and", "BICs", "in", "CSV", "format", ".", "Map", "which", "is", "based", "on", "3", "digits", "as", "in", "FIXX<3", "digits", ">", ".", "Can", "be", "used", "to", "map", "Finnish", "IBAN", "number"...
train
https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/management/commands/bank_const_fi.py#L9-L30
jaredLunde/vital-tools
vital/cache/async_decorators.py
async_lru
def async_lru(size=100): """ An LRU cache for asyncio coroutines in Python 3.5 .. @async_lru(1024) async def slow_coroutine(*args, **kwargs): return await some_other_slow_coroutine() .. """ cache = collections.OrderedDict() def decorator(fn): ...
python
def async_lru(size=100): """ An LRU cache for asyncio coroutines in Python 3.5 .. @async_lru(1024) async def slow_coroutine(*args, **kwargs): return await some_other_slow_coroutine() .. """ cache = collections.OrderedDict() def decorator(fn): ...
[ "def", "async_lru", "(", "size", "=", "100", ")", ":", "cache", "=", "collections", ".", "OrderedDict", "(", ")", "def", "decorator", "(", "fn", ")", ":", "@", "wraps", "(", "fn", ")", "@", "asyncio", ".", "coroutine", "def", "memoizer", "(", "*", ...
An LRU cache for asyncio coroutines in Python 3.5 .. @async_lru(1024) async def slow_coroutine(*args, **kwargs): return await some_other_slow_coroutine() ..
[ "An", "LRU", "cache", "for", "asyncio", "coroutines", "in", "Python", "3", ".", "5", ".." ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/cache/async_decorators.py#L7-L31
kajala/django-jutil
jutil/dict.py
choices_label
def choices_label(choices: tuple, value) -> str: """ Iterates (value,label) list and returns label matching the choice :param choices: [(choice1, label1), (choice2, label2), ...] :param value: Value to find :return: label or None """ for key, label in choices: if key == value: ...
python
def choices_label(choices: tuple, value) -> str: """ Iterates (value,label) list and returns label matching the choice :param choices: [(choice1, label1), (choice2, label2), ...] :param value: Value to find :return: label or None """ for key, label in choices: if key == value: ...
[ "def", "choices_label", "(", "choices", ":", "tuple", ",", "value", ")", "->", "str", ":", "for", "key", ",", "label", "in", "choices", ":", "if", "key", "==", "value", ":", "return", "label", "return", "''" ]
Iterates (value,label) list and returns label matching the choice :param choices: [(choice1, label1), (choice2, label2), ...] :param value: Value to find :return: label or None
[ "Iterates", "(", "value", "label", ")", "list", "and", "returns", "label", "matching", "the", "choice", ":", "param", "choices", ":", "[", "(", "choice1", "label1", ")", "(", "choice2", "label2", ")", "...", "]", ":", "param", "value", ":", "Value", "t...
train
https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/dict.py#L13-L23
novopl/peltak
src/peltak/core/log.py
info
def info(msg, *args, **kw): # type: (str, *Any, **Any) -> None """ Print sys message to stdout. System messages should inform about the flow of the script. This should be a major milestones during the build. """ if len(args) or len(kw): msg = msg.format(*args, **kw) shell.cprint('-...
python
def info(msg, *args, **kw): # type: (str, *Any, **Any) -> None """ Print sys message to stdout. System messages should inform about the flow of the script. This should be a major milestones during the build. """ if len(args) or len(kw): msg = msg.format(*args, **kw) shell.cprint('-...
[ "def", "info", "(", "msg", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "# type: (str, *Any, **Any) -> None", "if", "len", "(", "args", ")", "or", "len", "(", "kw", ")", ":", "msg", "=", "msg", ".", "format", "(", "*", "args", ",", "*", "*", ...
Print sys message to stdout. System messages should inform about the flow of the script. This should be a major milestones during the build.
[ "Print", "sys", "message", "to", "stdout", "." ]
train
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/log.py#L28-L38
novopl/peltak
src/peltak/core/log.py
err
def err(msg, *args, **kw): # type: (str, *Any, **Any) -> None """ Per step status messages Use this locally in a command definition to highlight more important information. """ if len(args) or len(kw): msg = msg.format(*args, **kw) shell.cprint('-- <31>{}<0>'.format(msg))
python
def err(msg, *args, **kw): # type: (str, *Any, **Any) -> None """ Per step status messages Use this locally in a command definition to highlight more important information. """ if len(args) or len(kw): msg = msg.format(*args, **kw) shell.cprint('-- <31>{}<0>'.format(msg))
[ "def", "err", "(", "msg", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "# type: (str, *Any, **Any) -> None", "if", "len", "(", "args", ")", "or", "len", "(", "kw", ")", ":", "msg", "=", "msg", ".", "format", "(", "*", "args", ",", "*", "*", ...
Per step status messages Use this locally in a command definition to highlight more important information.
[ "Per", "step", "status", "messages" ]
train
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/log.py#L41-L51
jaredLunde/vital-tools
vital/tools/strings.py
is_username
def is_username(string, minlen=1, maxlen=15): """ Determines whether the @string pattern is username-like @string: #str being tested @minlen: minimum required username length @maxlen: maximum username length -> #bool """ if string: string = string.strip() ret...
python
def is_username(string, minlen=1, maxlen=15): """ Determines whether the @string pattern is username-like @string: #str being tested @minlen: minimum required username length @maxlen: maximum username length -> #bool """ if string: string = string.strip() ret...
[ "def", "is_username", "(", "string", ",", "minlen", "=", "1", ",", "maxlen", "=", "15", ")", ":", "if", "string", ":", "string", "=", "string", ".", "strip", "(", ")", "return", "username_re", ".", "match", "(", "string", ")", "and", "(", "minlen", ...
Determines whether the @string pattern is username-like @string: #str being tested @minlen: minimum required username length @maxlen: maximum username length -> #bool
[ "Determines", "whether", "the", "@string", "pattern", "is", "username", "-", "like", "@string", ":", "#str", "being", "tested", "@minlen", ":", "minimum", "required", "username", "length", "@maxlen", ":", "maximum", "username", "length" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/tools/strings.py#L61-L72
jaredLunde/vital-tools
vital/tools/strings.py
bigint_to_string
def bigint_to_string(val): """ Converts @val to a string if it is a big integer (|>2**53-1|) @val: #int or #float -> #str if @val is a big integer, otherwise @val """ if isinstance(val, _NUMBERS) and not abs(val) <= 2**53-1: return str(val) return val
python
def bigint_to_string(val): """ Converts @val to a string if it is a big integer (|>2**53-1|) @val: #int or #float -> #str if @val is a big integer, otherwise @val """ if isinstance(val, _NUMBERS) and not abs(val) <= 2**53-1: return str(val) return val
[ "def", "bigint_to_string", "(", "val", ")", ":", "if", "isinstance", "(", "val", ",", "_NUMBERS", ")", "and", "not", "abs", "(", "val", ")", "<=", "2", "**", "53", "-", "1", ":", "return", "str", "(", "val", ")", "return", "val" ]
Converts @val to a string if it is a big integer (|>2**53-1|) @val: #int or #float -> #str if @val is a big integer, otherwise @val
[ "Converts", "@val", "to", "a", "string", "if", "it", "is", "a", "big", "integer", "(", "|", ">", "2", "**", "53", "-", "1|", ")" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/tools/strings.py#L91-L100
jaredLunde/vital-tools
vital/tools/strings.py
rbigint_to_string
def rbigint_to_string(obj): """ Recursively converts big integers (|>2**53-1|) to strings @obj: Any python object -> @obj, with any big integers converted to #str objects """ if isinstance(obj, (str, bytes)) or not obj: # the input is the desired one, return as is return ob...
python
def rbigint_to_string(obj): """ Recursively converts big integers (|>2**53-1|) to strings @obj: Any python object -> @obj, with any big integers converted to #str objects """ if isinstance(obj, (str, bytes)) or not obj: # the input is the desired one, return as is return ob...
[ "def", "rbigint_to_string", "(", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "(", "str", ",", "bytes", ")", ")", "or", "not", "obj", ":", "# the input is the desired one, return as is", "return", "obj", "elif", "hasattr", "(", "obj", ",", "'items'"...
Recursively converts big integers (|>2**53-1|) to strings @obj: Any python object -> @obj, with any big integers converted to #str objects
[ "Recursively", "converts", "big", "integers", "(", "|", ">", "2", "**", "53", "-", "1|", ")", "to", "strings" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/tools/strings.py#L104-L127
jaredLunde/vital-tools
vital/tools/strings.py
remove_blank_lines
def remove_blank_lines(string): """ Removes all blank lines in @string -> #str without blank lines """ return "\n".join(line for line in string.split("\n") if len(line.strip()))
python
def remove_blank_lines(string): """ Removes all blank lines in @string -> #str without blank lines """ return "\n".join(line for line in string.split("\n") if len(line.strip()))
[ "def", "remove_blank_lines", "(", "string", ")", ":", "return", "\"\\n\"", ".", "join", "(", "line", "for", "line", "in", "string", ".", "split", "(", "\"\\n\"", ")", "if", "len", "(", "line", ".", "strip", "(", ")", ")", ")" ]
Removes all blank lines in @string -> #str without blank lines
[ "Removes", "all", "blank", "lines", "in", "@string" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/tools/strings.py#L214-L221
novopl/peltak
src/peltak_django/cli.py
_manage_cmd
def _manage_cmd(cmd, settings=None): # type: () -> None """ Run django ./manage.py command manually. This function eliminates the need for having ``manage.py`` (reduces file clutter). """ import sys from os import environ from peltak.core import conf from peltak.core import context ...
python
def _manage_cmd(cmd, settings=None): # type: () -> None """ Run django ./manage.py command manually. This function eliminates the need for having ``manage.py`` (reduces file clutter). """ import sys from os import environ from peltak.core import conf from peltak.core import context ...
[ "def", "_manage_cmd", "(", "cmd", ",", "settings", "=", "None", ")", ":", "# type: () -> None", "import", "sys", "from", "os", "import", "environ", "from", "peltak", ".", "core", "import", "conf", "from", "peltak", ".", "core", "import", "context", "from", ...
Run django ./manage.py command manually. This function eliminates the need for having ``manage.py`` (reduces file clutter).
[ "Run", "django", ".", "/", "manage", ".", "py", "command", "manually", "." ]
train
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak_django/cli.py#L172-L196
novopl/peltak
src/peltak/core/git.py
current_branch
def current_branch(): # type: () -> BranchDetails """ Return the BranchDetails for the current branch. Return: BranchDetails: The details of the current branch. """ cmd = 'git symbolic-ref --short HEAD' branch_name = shell.run( cmd, capture=True, never_pretend=Tr...
python
def current_branch(): # type: () -> BranchDetails """ Return the BranchDetails for the current branch. Return: BranchDetails: The details of the current branch. """ cmd = 'git symbolic-ref --short HEAD' branch_name = shell.run( cmd, capture=True, never_pretend=Tr...
[ "def", "current_branch", "(", ")", ":", "# type: () -> BranchDetails", "cmd", "=", "'git symbolic-ref --short HEAD'", "branch_name", "=", "shell", ".", "run", "(", "cmd", ",", "capture", "=", "True", ",", "never_pretend", "=", "True", ")", ".", "stdout", ".", ...
Return the BranchDetails for the current branch. Return: BranchDetails: The details of the current branch.
[ "Return", "the", "BranchDetails", "for", "the", "current", "branch", "." ]
train
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L181-L195
novopl/peltak
src/peltak/core/git.py
commit_branches
def commit_branches(sha1): # type: (str) -> List[str] """ Get the name of the branches that this commit belongs to. """ cmd = 'git branch --contains {}'.format(sha1) return shell.run( cmd, capture=True, never_pretend=True ).stdout.strip().split()
python
def commit_branches(sha1): # type: (str) -> List[str] """ Get the name of the branches that this commit belongs to. """ cmd = 'git branch --contains {}'.format(sha1) return shell.run( cmd, capture=True, never_pretend=True ).stdout.strip().split()
[ "def", "commit_branches", "(", "sha1", ")", ":", "# type: (str) -> List[str]", "cmd", "=", "'git branch --contains {}'", ".", "format", "(", "sha1", ")", "return", "shell", ".", "run", "(", "cmd", ",", "capture", "=", "True", ",", "never_pretend", "=", "True",...
Get the name of the branches that this commit belongs to.
[ "Get", "the", "name", "of", "the", "branches", "that", "this", "commit", "belongs", "to", "." ]
train
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L226-L234
novopl/peltak
src/peltak/core/git.py
guess_base_branch
def guess_base_branch(): # type: (str) -> Optional[str, None] """ Try to guess the base branch for the current branch. Do not trust this guess. git makes it pretty much impossible to guess the base branch reliably so this function implements few heuristics that will work on most common use cases bu...
python
def guess_base_branch(): # type: (str) -> Optional[str, None] """ Try to guess the base branch for the current branch. Do not trust this guess. git makes it pretty much impossible to guess the base branch reliably so this function implements few heuristics that will work on most common use cases bu...
[ "def", "guess_base_branch", "(", ")", ":", "# type: (str) -> Optional[str, None]", "my_branch", "=", "current_branch", "(", "refresh", "=", "True", ")", ".", "name", "curr", "=", "latest_commit", "(", ")", "if", "len", "(", "curr", ".", "branches", ")", ">", ...
Try to guess the base branch for the current branch. Do not trust this guess. git makes it pretty much impossible to guess the base branch reliably so this function implements few heuristics that will work on most common use cases but anything a bit crazy will probably trip this function. Returns:...
[ "Try", "to", "guess", "the", "base", "branch", "for", "the", "current", "branch", "." ]
train
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L238-L291
novopl/peltak
src/peltak/core/git.py
commit_author
def commit_author(sha1=''): # type: (str) -> Author """ Return the author of the given commit. Args: sha1 (str): The sha1 of the commit to query. If not given, it will return the sha1 for the current commit. Returns: Author: A named tuple ``(name, email)`` with t...
python
def commit_author(sha1=''): # type: (str) -> Author """ Return the author of the given commit. Args: sha1 (str): The sha1 of the commit to query. If not given, it will return the sha1 for the current commit. Returns: Author: A named tuple ``(name, email)`` with t...
[ "def", "commit_author", "(", "sha1", "=", "''", ")", ":", "# type: (str) -> Author", "with", "conf", ".", "within_proj_dir", "(", ")", ":", "cmd", "=", "'git show -s --format=\"%an||%ae\" {}'", ".", "format", "(", "sha1", ")", "result", "=", "shell", ".", "run...
Return the author of the given commit. Args: sha1 (str): The sha1 of the commit to query. If not given, it will return the sha1 for the current commit. Returns: Author: A named tuple ``(name, email)`` with the commit author details.
[ "Return", "the", "author", "of", "the", "given", "commit", "." ]
train
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L295-L314
novopl/peltak
src/peltak/core/git.py
unstaged
def unstaged(): # type: () -> List[str] """ Return a list of unstaged files in the project repository. Returns: list[str]: The list of files not tracked by project git repo. """ with conf.within_proj_dir(): status = shell.run( 'git status --porcelain', captur...
python
def unstaged(): # type: () -> List[str] """ Return a list of unstaged files in the project repository. Returns: list[str]: The list of files not tracked by project git repo. """ with conf.within_proj_dir(): status = shell.run( 'git status --porcelain', captur...
[ "def", "unstaged", "(", ")", ":", "# type: () -> List[str]", "with", "conf", ".", "within_proj_dir", "(", ")", ":", "status", "=", "shell", ".", "run", "(", "'git status --porcelain'", ",", "capture", "=", "True", ",", "never_pretend", "=", "True", ")", ".",...
Return a list of unstaged files in the project repository. Returns: list[str]: The list of files not tracked by project git repo.
[ "Return", "a", "list", "of", "unstaged", "files", "in", "the", "project", "repository", "." ]
train
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L341-L360
novopl/peltak
src/peltak/core/git.py
ignore
def ignore(): # type: () -> List[str] """ Return a list of patterns in the project .gitignore Returns: list[str]: List of patterns set to be ignored by git. """ def parse_line(line): # pylint: disable=missing-docstring # Decode if necessary if not isinstance(line, string_...
python
def ignore(): # type: () -> List[str] """ Return a list of patterns in the project .gitignore Returns: list[str]: List of patterns set to be ignored by git. """ def parse_line(line): # pylint: disable=missing-docstring # Decode if necessary if not isinstance(line, string_...
[ "def", "ignore", "(", ")", ":", "# type: () -> List[str]", "def", "parse_line", "(", "line", ")", ":", "# pylint: disable=missing-docstring", "# Decode if necessary", "if", "not", "isinstance", "(", "line", ",", "string_types", ")", ":", "line", "=", "line", ".", ...
Return a list of patterns in the project .gitignore Returns: list[str]: List of patterns set to be ignored by git.
[ "Return", "a", "list", "of", "patterns", "in", "the", "project", ".", "gitignore" ]
train
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L387-L420
novopl/peltak
src/peltak/core/git.py
branches
def branches(): # type: () -> List[str] """ Return a list of branches in the current repo. Returns: list[str]: A list of branches in the current repo. """ out = shell.run( 'git branch', capture=True, never_pretend=True ).stdout.strip() return [x.strip('* \t\n...
python
def branches(): # type: () -> List[str] """ Return a list of branches in the current repo. Returns: list[str]: A list of branches in the current repo. """ out = shell.run( 'git branch', capture=True, never_pretend=True ).stdout.strip() return [x.strip('* \t\n...
[ "def", "branches", "(", ")", ":", "# type: () -> List[str]", "out", "=", "shell", ".", "run", "(", "'git branch'", ",", "capture", "=", "True", ",", "never_pretend", "=", "True", ")", ".", "stdout", ".", "strip", "(", ")", "return", "[", "x", ".", "str...
Return a list of branches in the current repo. Returns: list[str]: A list of branches in the current repo.
[ "Return", "a", "list", "of", "branches", "in", "the", "current", "repo", "." ]
train
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L424-L436
novopl/peltak
src/peltak/core/git.py
tag
def tag(name, message, author=None): # type: (str, str, Author, bool) -> None """ Tag the current commit. Args: name (str): The tag name. message (str): The tag message. Same as ``-m`` parameter in ``git tag``. author (Author): The commit author. ...
python
def tag(name, message, author=None): # type: (str, str, Author, bool) -> None """ Tag the current commit. Args: name (str): The tag name. message (str): The tag message. Same as ``-m`` parameter in ``git tag``. author (Author): The commit author. ...
[ "def", "tag", "(", "name", ",", "message", ",", "author", "=", "None", ")", ":", "# type: (str, str, Author, bool) -> None", "cmd", "=", "(", "'git -c \"user.name={author.name}\" -c \"user.email={author.email}\" '", "'tag -a \"{name}\" -m \"{message}\"'", ")", ".", "format", ...
Tag the current commit. Args: name (str): The tag name. message (str): The tag message. Same as ``-m`` parameter in ``git tag``. author (Author): The commit author. Will default to the author of the commit. pretend (bool): If set to **...
[ "Tag", "the", "current", "commit", "." ]
train
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L439-L462
novopl/peltak
src/peltak/core/git.py
config
def config(): # type: () -> dict[str, Any] """ Return the current git configuration. Returns: dict[str, Any]: The current git config taken from ``git config --list``. """ out = shell.run( 'git config --list', capture=True, never_pretend=True ).stdout.strip() ...
python
def config(): # type: () -> dict[str, Any] """ Return the current git configuration. Returns: dict[str, Any]: The current git config taken from ``git config --list``. """ out = shell.run( 'git config --list', capture=True, never_pretend=True ).stdout.strip() ...
[ "def", "config", "(", ")", ":", "# type: () -> dict[str, Any]", "out", "=", "shell", ".", "run", "(", "'git config --list'", ",", "capture", "=", "True", ",", "never_pretend", "=", "True", ")", ".", "stdout", ".", "strip", "(", ")", "result", "=", "{", "...
Return the current git configuration. Returns: dict[str, Any]: The current git config taken from ``git config --list``.
[ "Return", "the", "current", "git", "configuration", "." ]
train
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L466-L484
novopl/peltak
src/peltak/core/git.py
tags
def tags(): # type: () -> List[str] """ Returns all tags in the repo. Returns: list[str]: List of all tags in the repo, sorted as versions. All tags returned by this function will be parsed as if the contained versions (using ``v:refname`` sorting). """ return shell.run( 'g...
python
def tags(): # type: () -> List[str] """ Returns all tags in the repo. Returns: list[str]: List of all tags in the repo, sorted as versions. All tags returned by this function will be parsed as if the contained versions (using ``v:refname`` sorting). """ return shell.run( 'g...
[ "def", "tags", "(", ")", ":", "# type: () -> List[str]", "return", "shell", ".", "run", "(", "'git tag --sort=v:refname'", ",", "capture", "=", "True", ",", "never_pretend", "=", "True", ")", ".", "stdout", ".", "strip", "(", ")", ".", "splitlines", "(", "...
Returns all tags in the repo. Returns: list[str]: List of all tags in the repo, sorted as versions. All tags returned by this function will be parsed as if the contained versions (using ``v:refname`` sorting).
[ "Returns", "all", "tags", "in", "the", "repo", "." ]
train
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L488-L502
novopl/peltak
src/peltak/core/git.py
verify_branch
def verify_branch(branch_name): # type: (str) -> bool """ Verify if the given branch exists. Args: branch_name (str): The name of the branch to check. Returns: bool: **True** if a branch with name *branch_name* exits, **False** otherwise. """ try: sh...
python
def verify_branch(branch_name): # type: (str) -> bool """ Verify if the given branch exists. Args: branch_name (str): The name of the branch to check. Returns: bool: **True** if a branch with name *branch_name* exits, **False** otherwise. """ try: sh...
[ "def", "verify_branch", "(", "branch_name", ")", ":", "# type: (str) -> bool", "try", ":", "shell", ".", "run", "(", "'git rev-parse --verify {}'", ".", "format", "(", "branch_name", ")", ",", "never_pretend", "=", "True", ")", "return", "True", "except", "IOErr...
Verify if the given branch exists. Args: branch_name (str): The name of the branch to check. Returns: bool: **True** if a branch with name *branch_name* exits, **False** otherwise.
[ "Verify", "if", "the", "given", "branch", "exists", "." ]
train
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L505-L524
novopl/peltak
src/peltak/core/git.py
protected_branches
def protected_branches(): # type: () -> list[str] """ Return branches protected by deletion. By default those are master and devel branches as configured in pelconf. Returns: list[str]: Names of important branches that should not be deleted. """ master = conf.get('git.master_branch', '...
python
def protected_branches(): # type: () -> list[str] """ Return branches protected by deletion. By default those are master and devel branches as configured in pelconf. Returns: list[str]: Names of important branches that should not be deleted. """ master = conf.get('git.master_branch', '...
[ "def", "protected_branches", "(", ")", ":", "# type: () -> list[str]", "master", "=", "conf", ".", "get", "(", "'git.master_branch'", ",", "'master'", ")", "develop", "=", "conf", ".", "get", "(", "'git.devel_branch'", ",", "'develop'", ")", "return", "conf", ...
Return branches protected by deletion. By default those are master and devel branches as configured in pelconf. Returns: list[str]: Names of important branches that should not be deleted.
[ "Return", "branches", "protected", "by", "deletion", "." ]
train
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L528-L539
novopl/peltak
src/peltak/core/git.py
CommitDetails.branches
def branches(self): # type: () -> List[str] """ List of all branches this commit is a part of. """ if self._branches is None: cmd = 'git branch --contains {}'.format(self.sha1) out = shell.run( cmd, capture=True, never_prete...
python
def branches(self): # type: () -> List[str] """ List of all branches this commit is a part of. """ if self._branches is None: cmd = 'git branch --contains {}'.format(self.sha1) out = shell.run( cmd, capture=True, never_prete...
[ "def", "branches", "(", "self", ")", ":", "# type: () -> List[str]", "if", "self", ".", "_branches", "is", "None", ":", "cmd", "=", "'git branch --contains {}'", ".", "format", "(", "self", ".", "sha1", ")", "out", "=", "shell", ".", "run", "(", "cmd", "...
List of all branches this commit is a part of.
[ "List", "of", "all", "branches", "this", "commit", "is", "a", "part", "of", "." ]
train
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L107-L119
novopl/peltak
src/peltak/core/git.py
CommitDetails.parents
def parents(self): # type: () -> List[CommitDetails] """ Parents of the this commit. """ if self._parents is None: self._parents = [CommitDetails.get(x) for x in self.parents_sha1] return self._parents
python
def parents(self): # type: () -> List[CommitDetails] """ Parents of the this commit. """ if self._parents is None: self._parents = [CommitDetails.get(x) for x in self.parents_sha1] return self._parents
[ "def", "parents", "(", "self", ")", ":", "# type: () -> List[CommitDetails]", "if", "self", ".", "_parents", "is", "None", ":", "self", ".", "_parents", "=", "[", "CommitDetails", ".", "get", "(", "x", ")", "for", "x", "in", "self", ".", "parents_sha1", ...
Parents of the this commit.
[ "Parents", "of", "the", "this", "commit", "." ]
train
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L122-L128
novopl/peltak
src/peltak/core/git.py
CommitDetails.number
def number(self): # type: () -> int """ Return this commits number. This is the same as the total number of commits in history up until this commit. This value can be useful in some CI scenarios as it allows to track progress on any given branch (although there can be t...
python
def number(self): # type: () -> int """ Return this commits number. This is the same as the total number of commits in history up until this commit. This value can be useful in some CI scenarios as it allows to track progress on any given branch (although there can be t...
[ "def", "number", "(", "self", ")", ":", "# type: () -> int", "cmd", "=", "'git log --oneline {}'", ".", "format", "(", "self", ".", "sha1", ")", "out", "=", "shell", ".", "run", "(", "cmd", ",", "capture", "=", "True", ",", "never_pretend", "=", "True", ...
Return this commits number. This is the same as the total number of commits in history up until this commit. This value can be useful in some CI scenarios as it allows to track progress on any given branch (although there can be two commits with the same number existing on diff...
[ "Return", "this", "commits", "number", "." ]
train
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L131-L147
novopl/peltak
src/peltak/core/git.py
CommitDetails.get
def get(cls, sha1=''): # type: (str) -> CommitDetails """ Return details about a given commit. Args: sha1 (str): The sha1 of the commit to query. If not given, it will return the details for the latest commit. Returns: CommitDetai...
python
def get(cls, sha1=''): # type: (str) -> CommitDetails """ Return details about a given commit. Args: sha1 (str): The sha1 of the commit to query. If not given, it will return the details for the latest commit. Returns: CommitDetai...
[ "def", "get", "(", "cls", ",", "sha1", "=", "''", ")", ":", "# type: (str) -> CommitDetails", "with", "conf", ".", "within_proj_dir", "(", ")", ":", "cmd", "=", "'git show -s --format=\"%H||%an||%ae||%s||%b||%P\" {}'", ".", "format", "(", "sha1", ")", "result", ...
Return details about a given commit. Args: sha1 (str): The sha1 of the commit to query. If not given, it will return the details for the latest commit. Returns: CommitDetails: Commit details. You can use the instance of the class to q...
[ "Return", "details", "about", "a", "given", "commit", "." ]
train
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L150-L177
cons3rt/pycons3rt
pycons3rt/logify.py
main
def main(): """Sample usage for this python module This main method simply illustrates sample usage for this python module. :return: None """ log = logging.getLogger(Logify.get_name() + '.logify.main') log.info('logger name is: %s', Logify.get_name()) log.debug('This is DEBUG') log...
python
def main(): """Sample usage for this python module This main method simply illustrates sample usage for this python module. :return: None """ log = logging.getLogger(Logify.get_name() + '.logify.main') log.info('logger name is: %s', Logify.get_name()) log.debug('This is DEBUG') log...
[ "def", "main", "(", ")", ":", "log", "=", "logging", ".", "getLogger", "(", "Logify", ".", "get_name", "(", ")", "+", "'.logify.main'", ")", "log", ".", "info", "(", "'logger name is: %s'", ",", "Logify", ".", "get_name", "(", ")", ")", "log", ".", "...
Sample usage for this python module This main method simply illustrates sample usage for this python module. :return: None
[ "Sample", "usage", "for", "this", "python", "module" ]
train
https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/logify.py#L127-L140
cons3rt/pycons3rt
pycons3rt/logify.py
Logify.set_log_level
def set_log_level(cls, log_level): """Sets the log level for cons3rt assets This method sets the logging level for cons3rt assets using pycons3rt. The loglevel is read in from a deployment property called loglevel and set appropriately. :type log_level: str :return: Tru...
python
def set_log_level(cls, log_level): """Sets the log level for cons3rt assets This method sets the logging level for cons3rt assets using pycons3rt. The loglevel is read in from a deployment property called loglevel and set appropriately. :type log_level: str :return: Tru...
[ "def", "set_log_level", "(", "cls", ",", "log_level", ")", ":", "log", "=", "logging", ".", "getLogger", "(", "cls", ".", "cls_logger", "+", "'.set_log_level'", ")", "log", ".", "info", "(", "'Attempting to set the log level...'", ")", "if", "log_level", "is",...
Sets the log level for cons3rt assets This method sets the logging level for cons3rt assets using pycons3rt. The loglevel is read in from a deployment property called loglevel and set appropriately. :type log_level: str :return: True if log level was set, False otherwise.
[ "Sets", "the", "log", "level", "for", "cons3rt", "assets" ]
train
https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/logify.py#L83-L117
nathankw/pulsarpy
pulsarpy/elasticsearch_utils.py
Connection.get_record_by_name
def get_record_by_name(self, index, name): """ Searches for a single document in the given index on the 'name' field . Performs a case-insensitive search by utilizing Elasticsearch's `match_phrase` query. Args: index: `str`. The name of an Elasticsearch index (i.e. biosa...
python
def get_record_by_name(self, index, name): """ Searches for a single document in the given index on the 'name' field . Performs a case-insensitive search by utilizing Elasticsearch's `match_phrase` query. Args: index: `str`. The name of an Elasticsearch index (i.e. biosa...
[ "def", "get_record_by_name", "(", "self", ",", "index", ",", "name", ")", ":", "result", "=", "self", ".", "ES", ".", "search", "(", "index", "=", "index", ",", "body", "=", "{", "\"query\"", ":", "{", "\"match_phrase\"", ":", "{", "\"name\"", ":", "...
Searches for a single document in the given index on the 'name' field . Performs a case-insensitive search by utilizing Elasticsearch's `match_phrase` query. Args: index: `str`. The name of an Elasticsearch index (i.e. biosamples). name: `str`. The value of a document's name...
[ "Searches", "for", "a", "single", "document", "in", "the", "given", "index", "on", "the", "name", "field", ".", "Performs", "a", "case", "-", "insensitive", "search", "by", "utilizing", "Elasticsearch", "s", "match_phrase", "query", ".", "Args", ":", "index"...
train
https://github.com/nathankw/pulsarpy/blob/359b040c0f2383b88c0b5548715fefd35f5f634c/pulsarpy/elasticsearch_utils.py#L38-L77
jaredLunde/vital-tools
vital/tools/__init__.py
getattr_in
def getattr_in(obj, name): """ Finds an in @obj via a period-delimited string @name. @obj: (#object) @name: (#str) |.|-separated keys to search @obj in .. obj.deep.attr = 'deep value' getattr_in(obj, 'obj.deep.attr') .. |'deep value'| """ for p...
python
def getattr_in(obj, name): """ Finds an in @obj via a period-delimited string @name. @obj: (#object) @name: (#str) |.|-separated keys to search @obj in .. obj.deep.attr = 'deep value' getattr_in(obj, 'obj.deep.attr') .. |'deep value'| """ for p...
[ "def", "getattr_in", "(", "obj", ",", "name", ")", ":", "for", "part", "in", "name", ".", "split", "(", "'.'", ")", ":", "obj", "=", "getattr", "(", "obj", ",", "part", ")", "return", "obj" ]
Finds an in @obj via a period-delimited string @name. @obj: (#object) @name: (#str) |.|-separated keys to search @obj in .. obj.deep.attr = 'deep value' getattr_in(obj, 'obj.deep.attr') .. |'deep value'|
[ "Finds", "an", "in" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/tools/__init__.py#L20-L32
jaredLunde/vital-tools
vital/tools/__init__.py
import_from
def import_from(name): """ Imports a module, class or method from string and unwraps it if wrapped by functools @name: (#str) name of the python object -> imported object """ obj = name if isinstance(name, str) and len(name): try: obj = locate(name) ...
python
def import_from(name): """ Imports a module, class or method from string and unwraps it if wrapped by functools @name: (#str) name of the python object -> imported object """ obj = name if isinstance(name, str) and len(name): try: obj = locate(name) ...
[ "def", "import_from", "(", "name", ")", ":", "obj", "=", "name", "if", "isinstance", "(", "name", ",", "str", ")", "and", "len", "(", "name", ")", ":", "try", ":", "obj", "=", "locate", "(", "name", ")", "assert", "obj", "is", "not", "None", "exc...
Imports a module, class or method from string and unwraps it if wrapped by functools @name: (#str) name of the python object -> imported object
[ "Imports", "a", "module", "class", "or", "method", "from", "string", "and", "unwraps", "it", "if", "wrapped", "by", "functools" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/tools/__init__.py#L35-L67
jaredLunde/vital-tools
vital/tools/__init__.py
unwrap_obj
def unwrap_obj(obj): """ Gets the actual object from a decorated or wrapped function @obj: (#object) the object to unwrap """ try: obj = obj.fget except (AttributeError, TypeError): pass try: # Cached properties if obj.func.__doc__ == obj.__doc__: ...
python
def unwrap_obj(obj): """ Gets the actual object from a decorated or wrapped function @obj: (#object) the object to unwrap """ try: obj = obj.fget except (AttributeError, TypeError): pass try: # Cached properties if obj.func.__doc__ == obj.__doc__: ...
[ "def", "unwrap_obj", "(", "obj", ")", ":", "try", ":", "obj", "=", "obj", ".", "fget", "except", "(", "AttributeError", ",", "TypeError", ")", ":", "pass", "try", ":", "# Cached properties", "if", "obj", ".", "func", ".", "__doc__", "==", "obj", ".", ...
Gets the actual object from a decorated or wrapped function @obj: (#object) the object to unwrap
[ "Gets", "the", "actual", "object", "from", "a", "decorated", "or", "wrapped", "function" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/tools/__init__.py#L70-L94
gpiantoni/bidso
bidso/utils.py
add_modality
def add_modality(output_path, modality): """Modality can be appended to the file name (such as 'bold') or use in the folder (such as "func"). You should always use the specific modality ('bold'). This function converts it to the folder name. """ if modality is None: return output_path el...
python
def add_modality(output_path, modality): """Modality can be appended to the file name (such as 'bold') or use in the folder (such as "func"). You should always use the specific modality ('bold'). This function converts it to the folder name. """ if modality is None: return output_path el...
[ "def", "add_modality", "(", "output_path", ",", "modality", ")", ":", "if", "modality", "is", "None", ":", "return", "output_path", "else", ":", "if", "modality", "in", "(", "'T1w'", ",", "'T2star'", ",", "'FLAIR'", ",", "'PD'", ")", ":", "modality", "="...
Modality can be appended to the file name (such as 'bold') or use in the folder (such as "func"). You should always use the specific modality ('bold'). This function converts it to the folder name.
[ "Modality", "can", "be", "appended", "to", "the", "file", "name", "(", "such", "as", "bold", ")", "or", "use", "in", "the", "folder", "(", "such", "as", "func", ")", ".", "You", "should", "always", "use", "the", "specific", "modality", "(", "bold", "...
train
https://github.com/gpiantoni/bidso/blob/af163b921ec4e3d70802de07f174de184491cfce/bidso/utils.py#L92-L115
novopl/peltak
src/peltak/core/conf.py
load
def load(): # type: () -> None """ Load configuration from file. This will search the directory structure upwards to find the project root (directory containing ``pelconf.py`` file). Once found it will import the config file which should initialize all the configuration (using `peltak.core.conf...
python
def load(): # type: () -> None """ Load configuration from file. This will search the directory structure upwards to find the project root (directory containing ``pelconf.py`` file). Once found it will import the config file which should initialize all the configuration (using `peltak.core.conf...
[ "def", "load", "(", ")", ":", "# type: () -> None", "with", "within_proj_dir", "(", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "'pelconf.yaml'", ")", ":", "load_yaml_config", "(", "'pelconf.yaml'", ")", "if", "os", ".", "path", ".", "exists", ...
Load configuration from file. This will search the directory structure upwards to find the project root (directory containing ``pelconf.py`` file). Once found it will import the config file which should initialize all the configuration (using `peltak.core.conf.init()` function). You can also have ...
[ "Load", "configuration", "from", "file", "." ]
train
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/conf.py#L91-L109
novopl/peltak
src/peltak/core/conf.py
load_yaml_config
def load_yaml_config(conf_file): # type: (str) -> None """ Load a YAML configuration. This will not update the configuration but replace it entirely. Args: conf_file (str): Path to the YAML config. This function will not check the file name or extension and will just cr...
python
def load_yaml_config(conf_file): # type: (str) -> None """ Load a YAML configuration. This will not update the configuration but replace it entirely. Args: conf_file (str): Path to the YAML config. This function will not check the file name or extension and will just cr...
[ "def", "load_yaml_config", "(", "conf_file", ")", ":", "# type: (str) -> None", "global", "g_config", "with", "open", "(", "conf_file", ")", "as", "fp", ":", "# Initialize config", "g_config", "=", "util", ".", "yaml_load", "(", "fp", ")", "# Add src_dir to sys.pa...
Load a YAML configuration. This will not update the configuration but replace it entirely. Args: conf_file (str): Path to the YAML config. This function will not check the file name or extension and will just crash if the given file does not exist or is not a valid ...
[ "Load", "a", "YAML", "configuration", "." ]
train
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/conf.py#L112-L137
novopl/peltak
src/peltak/core/conf.py
load_py_config
def load_py_config(conf_file): # type: (str) -> None """ Import configuration from a python file. This will just import the file into python. Sky is the limit. The file has to deal with the configuration all by itself (i.e. call conf.init()). You will also need to add your src directory to sys.path...
python
def load_py_config(conf_file): # type: (str) -> None """ Import configuration from a python file. This will just import the file into python. Sky is the limit. The file has to deal with the configuration all by itself (i.e. call conf.init()). You will also need to add your src directory to sys.path...
[ "def", "load_py_config", "(", "conf_file", ")", ":", "# type: (str) -> None", "if", "sys", ".", "version_info", ">=", "(", "3", ",", "5", ")", ":", "from", "importlib", "import", "util", "spec", "=", "util", ".", "spec_from_file_location", "(", "'pelconf'", ...
Import configuration from a python file. This will just import the file into python. Sky is the limit. The file has to deal with the configuration all by itself (i.e. call conf.init()). You will also need to add your src directory to sys.paths if it's not the current working directory. This is done aut...
[ "Import", "configuration", "from", "a", "python", "file", "." ]
train
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/conf.py#L140-L171
novopl/peltak
src/peltak/core/conf.py
load_template
def load_template(filename): # type: (str) -> str """ Load template from file. The templates are part of the package and must be included as ``package_data`` in project ``setup.py``. Args: filename (str): The template path. Relative to `peltak` package directory. Returns: ...
python
def load_template(filename): # type: (str) -> str """ Load template from file. The templates are part of the package and must be included as ``package_data`` in project ``setup.py``. Args: filename (str): The template path. Relative to `peltak` package directory. Returns: ...
[ "def", "load_template", "(", "filename", ")", ":", "# type: (str) -> str", "template_file", "=", "os", ".", "path", ".", "join", "(", "PKG_DIR", ",", "'templates'", ",", "filename", ")", "with", "open", "(", "template_file", ")", "as", "fp", ":", "return", ...
Load template from file. The templates are part of the package and must be included as ``package_data`` in project ``setup.py``. Args: filename (str): The template path. Relative to `peltak` package directory. Returns: str: The content of the chosen template.
[ "Load", "template", "from", "file", "." ]
train
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/conf.py#L174-L190
novopl/peltak
src/peltak/core/conf.py
proj_path
def proj_path(*path_parts): # type: (str) -> str """ Return absolute path to the repo dir (root project directory). Args: path (str): The path relative to the project root (pelconf.yaml). Returns: str: The given path converted to an absolute path. """ path_parts = p...
python
def proj_path(*path_parts): # type: (str) -> str """ Return absolute path to the repo dir (root project directory). Args: path (str): The path relative to the project root (pelconf.yaml). Returns: str: The given path converted to an absolute path. """ path_parts = p...
[ "def", "proj_path", "(", "*", "path_parts", ")", ":", "# type: (str) -> str", "path_parts", "=", "path_parts", "or", "[", "'.'", "]", "# If path represented by path_parts is absolute, do not modify it.", "if", "not", "os", ".", "path", ".", "isabs", "(", "path_parts",...
Return absolute path to the repo dir (root project directory). Args: path (str): The path relative to the project root (pelconf.yaml). Returns: str: The given path converted to an absolute path.
[ "Return", "absolute", "path", "to", "the", "repo", "dir", "(", "root", "project", "directory", ")", "." ]
train
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/conf.py#L204-L224
novopl/peltak
src/peltak/core/conf.py
within_proj_dir
def within_proj_dir(path='.'): # type: (Optional[str]) -> str """ Return an absolute path to the given project relative path. :param path: Project relative path that will be converted to the system wide absolute path. :return: Absolute path. """ curr_dir = os.getcwd() ...
python
def within_proj_dir(path='.'): # type: (Optional[str]) -> str """ Return an absolute path to the given project relative path. :param path: Project relative path that will be converted to the system wide absolute path. :return: Absolute path. """ curr_dir = os.getcwd() ...
[ "def", "within_proj_dir", "(", "path", "=", "'.'", ")", ":", "# type: (Optional[str]) -> str", "curr_dir", "=", "os", ".", "getcwd", "(", ")", "os", ".", "chdir", "(", "proj_path", "(", "path", ")", ")", "yield", "os", ".", "chdir", "(", "curr_dir", ")" ...
Return an absolute path to the given project relative path. :param path: Project relative path that will be converted to the system wide absolute path. :return: Absolute path.
[ "Return", "an", "absolute", "path", "to", "the", "given", "project", "relative", "path", "." ]
train
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/conf.py#L228-L244
novopl/peltak
src/peltak/core/conf.py
get
def get(name, *default): # type: (str, Any) -> Any """ Get config value with the given name and optional default. Args: name (str): The name of the config value. *default (Any): If given and the key doesn't not exist, this will be returned instead. If it'...
python
def get(name, *default): # type: (str, Any) -> Any """ Get config value with the given name and optional default. Args: name (str): The name of the config value. *default (Any): If given and the key doesn't not exist, this will be returned instead. If it'...
[ "def", "get", "(", "name", ",", "*", "default", ")", ":", "# type: (str, Any) -> Any", "global", "g_config", "curr", "=", "g_config", "for", "part", "in", "name", ".", "split", "(", "'.'", ")", ":", "if", "part", "in", "curr", ":", "curr", "=", "curr",...
Get config value with the given name and optional default. Args: name (str): The name of the config value. *default (Any): If given and the key doesn't not exist, this will be returned instead. If it's not given and the config value does not exist, At...
[ "Get", "config", "value", "with", "the", "given", "name", "and", "optional", "default", "." ]
train
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/conf.py#L247-L280
novopl/peltak
src/peltak/core/conf.py
get_path
def get_path(name, *default): # type: (str, Any) -> Any """ Get config value as path relative to the project directory. This allows easily defining the project configuration within the fabfile as always relative to that fabfile. Args: name (str): The name of the config value co...
python
def get_path(name, *default): # type: (str, Any) -> Any """ Get config value as path relative to the project directory. This allows easily defining the project configuration within the fabfile as always relative to that fabfile. Args: name (str): The name of the config value co...
[ "def", "get_path", "(", "name", ",", "*", "default", ")", ":", "# type: (str, Any) -> Any", "global", "g_config", "value", "=", "get", "(", "name", ",", "*", "default", ")", "if", "value", "is", "None", ":", "return", "None", "return", "proj_path", "(", ...
Get config value as path relative to the project directory. This allows easily defining the project configuration within the fabfile as always relative to that fabfile. Args: name (str): The name of the config value containing the path. *default (Any): If given and ...
[ "Get", "config", "value", "as", "path", "relative", "to", "the", "project", "directory", "." ]
train
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/conf.py#L283-L313
novopl/peltak
src/peltak/core/conf.py
_find_proj_root
def _find_proj_root(): # type: () -> Optional[str] """ Find the project path by going up the file tree. This will look in the current directory and upwards for the pelconf file (.yaml or .py) """ proj_files = frozenset(('pelconf.py', 'pelconf.yaml')) curr = os.getcwd() while curr.start...
python
def _find_proj_root(): # type: () -> Optional[str] """ Find the project path by going up the file tree. This will look in the current directory and upwards for the pelconf file (.yaml or .py) """ proj_files = frozenset(('pelconf.py', 'pelconf.yaml')) curr = os.getcwd() while curr.start...
[ "def", "_find_proj_root", "(", ")", ":", "# type: () -> Optional[str]", "proj_files", "=", "frozenset", "(", "(", "'pelconf.py'", ",", "'pelconf.yaml'", ")", ")", "curr", "=", "os", ".", "getcwd", "(", ")", "while", "curr", ".", "startswith", "(", "'/'", ")"...
Find the project path by going up the file tree. This will look in the current directory and upwards for the pelconf file (.yaml or .py)
[ "Find", "the", "project", "path", "by", "going", "up", "the", "file", "tree", "." ]
train
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/conf.py#L317-L333
ktsstudio/tornkts
tornkts/modules/verification/verification_handler.py
VerificationHandler.verify
def verify(verified_entity, verification_key): """ Метод должен райзить ошибки :param verified_entity: сущность :param verification_key: ключ :return: """ verification = get_object_or_none(Verification, verified_entity=verified_entity) if verification is ...
python
def verify(verified_entity, verification_key): """ Метод должен райзить ошибки :param verified_entity: сущность :param verification_key: ключ :return: """ verification = get_object_or_none(Verification, verified_entity=verified_entity) if verification is ...
[ "def", "verify", "(", "verified_entity", ",", "verification_key", ")", ":", "verification", "=", "get_object_or_none", "(", "Verification", ",", "verified_entity", "=", "verified_entity", ")", "if", "verification", "is", "None", ":", "raise", "ServerError", "(", "...
Метод должен райзить ошибки :param verified_entity: сущность :param verification_key: ключ :return:
[ "Метод", "должен", "райзить", "ошибки", ":", "param", "verified_entity", ":", "сущность", ":", "param", "verification_key", ":", "ключ", ":", "return", ":" ]
train
https://github.com/ktsstudio/tornkts/blob/db47e4550426282960a7e4486dcc4399c8d52e02/tornkts/modules/verification/verification_handler.py#L59-L74
kajala/django-jutil
jutil/xml.py
_xml_element_value
def _xml_element_value(el: Element, int_tags: list): """ Gets XML Element value. :param el: Element :param int_tags: List of tags that should be treated as ints :return: value of the element (int/str) """ # None if el.text is None: return None # int try: if el.tag...
python
def _xml_element_value(el: Element, int_tags: list): """ Gets XML Element value. :param el: Element :param int_tags: List of tags that should be treated as ints :return: value of the element (int/str) """ # None if el.text is None: return None # int try: if el.tag...
[ "def", "_xml_element_value", "(", "el", ":", "Element", ",", "int_tags", ":", "list", ")", ":", "# None", "if", "el", ".", "text", "is", "None", ":", "return", "None", "# int", "try", ":", "if", "el", ".", "tag", "in", "int_tags", ":", "return", "int...
Gets XML Element value. :param el: Element :param int_tags: List of tags that should be treated as ints :return: value of the element (int/str)
[ "Gets", "XML", "Element", "value", ".", ":", "param", "el", ":", "Element", ":", "param", "int_tags", ":", "List", "of", "tags", "that", "should", "be", "treated", "as", "ints", ":", "return", ":", "value", "of", "the", "element", "(", "int", "/", "s...
train
https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/xml.py#L6-L24
kajala/django-jutil
jutil/xml.py
_xml_tag_filter
def _xml_tag_filter(s: str, strip_namespaces: bool) -> str: """ Returns tag name and optionally strips namespaces. :param el: Element :param strip_namespaces: Strip namespace prefix :return: str """ if strip_namespaces: ns_end = s.find('}') if ns_end != -1: s = s[...
python
def _xml_tag_filter(s: str, strip_namespaces: bool) -> str: """ Returns tag name and optionally strips namespaces. :param el: Element :param strip_namespaces: Strip namespace prefix :return: str """ if strip_namespaces: ns_end = s.find('}') if ns_end != -1: s = s[...
[ "def", "_xml_tag_filter", "(", "s", ":", "str", ",", "strip_namespaces", ":", "bool", ")", "->", "str", ":", "if", "strip_namespaces", ":", "ns_end", "=", "s", ".", "find", "(", "'}'", ")", "if", "ns_end", "!=", "-", "1", ":", "s", "=", "s", "[", ...
Returns tag name and optionally strips namespaces. :param el: Element :param strip_namespaces: Strip namespace prefix :return: str
[ "Returns", "tag", "name", "and", "optionally", "strips", "namespaces", ".", ":", "param", "el", ":", "Element", ":", "param", "strip_namespaces", ":", "Strip", "namespace", "prefix", ":", "return", ":", "str" ]
train
https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/xml.py#L27-L42
kajala/django-jutil
jutil/xml.py
xml_to_dict
def xml_to_dict(xml_bytes: bytes, tags: list=[], array_tags: list=[], int_tags: list=[], strip_namespaces: bool=True, parse_attributes: bool=True, value_key: str='@', attribute_prefix: str='@', document_tag: bool=False) -> dict: """ Parses XML string to dict. In c...
python
def xml_to_dict(xml_bytes: bytes, tags: list=[], array_tags: list=[], int_tags: list=[], strip_namespaces: bool=True, parse_attributes: bool=True, value_key: str='@', attribute_prefix: str='@', document_tag: bool=False) -> dict: """ Parses XML string to dict. In c...
[ "def", "xml_to_dict", "(", "xml_bytes", ":", "bytes", ",", "tags", ":", "list", "=", "[", "]", ",", "array_tags", ":", "list", "=", "[", "]", ",", "int_tags", ":", "list", "=", "[", "]", ",", "strip_namespaces", ":", "bool", "=", "True", ",", "pars...
Parses XML string to dict. In case of simple elements (no children, no attributes) value is stored as is. For complex elements value is stored in key '@', attributes '@xxx' and children as sub-dicts. Optionally strips namespaces. For example: <Doc version="1.2"> <A class="x"> ...
[ "Parses", "XML", "string", "to", "dict", ".", "In", "case", "of", "simple", "elements", "(", "no", "children", "no", "attributes", ")", "value", "is", "stored", "as", "is", ".", "For", "complex", "elements", "value", "is", "stored", "in", "key", "@", "...
train
https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/xml.py#L87-L148
kajala/django-jutil
jutil/xml.py
dict_to_element
def dict_to_element(doc: dict, value_key: str='@', attribute_prefix: str='@') -> Element: """ Generates XML Element from dict. Generates complex elements by assuming element attributes are prefixed with '@', and value is stored to plain '@' in case of complex element. Children are sub-dicts. For ex...
python
def dict_to_element(doc: dict, value_key: str='@', attribute_prefix: str='@') -> Element: """ Generates XML Element from dict. Generates complex elements by assuming element attributes are prefixed with '@', and value is stored to plain '@' in case of complex element. Children are sub-dicts. For ex...
[ "def", "dict_to_element", "(", "doc", ":", "dict", ",", "value_key", ":", "str", "=", "'@'", ",", "attribute_prefix", ":", "str", "=", "'@'", ")", "->", "Element", ":", "from", "xml", ".", "etree", "import", "ElementTree", "as", "ET", "if", "len", "(",...
Generates XML Element from dict. Generates complex elements by assuming element attributes are prefixed with '@', and value is stored to plain '@' in case of complex element. Children are sub-dicts. For example: { 'Doc': { '@version': '1.2', 'A': [{'@clas...
[ "Generates", "XML", "Element", "from", "dict", ".", "Generates", "complex", "elements", "by", "assuming", "element", "attributes", "are", "prefixed", "with", "@", "and", "value", "is", "stored", "to", "plain", "@", "in", "case", "of", "complex", "element", "...
train
https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/xml.py#L175-L218
jaredLunde/vital-tools
vital/cache/__init__.py
local_property
def local_property(): """ Property structure which maps within the :func:local() thread (c)2014, Marcel Hellkamp """ ls = local() def fget(self): try: return ls.var except AttributeError: raise RuntimeError("Request context not initialized.") def fse...
python
def local_property(): """ Property structure which maps within the :func:local() thread (c)2014, Marcel Hellkamp """ ls = local() def fget(self): try: return ls.var except AttributeError: raise RuntimeError("Request context not initialized.") def fse...
[ "def", "local_property", "(", ")", ":", "ls", "=", "local", "(", ")", "def", "fget", "(", "self", ")", ":", "try", ":", "return", "ls", ".", "var", "except", "AttributeError", ":", "raise", "RuntimeError", "(", "\"Request context not initialized.\"", ")", ...
Property structure which maps within the :func:local() thread (c)2014, Marcel Hellkamp
[ "Property", "structure", "which", "maps", "within", "the", ":", "func", ":", "local", "()", "thread", "(", "c", ")", "2014", "Marcel", "Hellkamp" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/cache/__init__.py#L37-L55
cons3rt/pycons3rt
pycons3rt/awsapi/s3util.py
download
def download(download_info): """Module method for downloading from S3 This public module method takes a key and the full path to the destination directory, assumes that the args have been validated by the public caller methods, and attempts to download the specified key to the dest_dir. :para...
python
def download(download_info): """Module method for downloading from S3 This public module method takes a key and the full path to the destination directory, assumes that the args have been validated by the public caller methods, and attempts to download the specified key to the dest_dir. :para...
[ "def", "download", "(", "download_info", ")", ":", "log", "=", "logging", ".", "getLogger", "(", "mod_logger", "+", "'.download'", ")", "# Ensure the passed arg is a dict", "if", "not", "isinstance", "(", "download_info", ",", "dict", ")", ":", "msg", "=", "'d...
Module method for downloading from S3 This public module method takes a key and the full path to the destination directory, assumes that the args have been validated by the public caller methods, and attempts to download the specified key to the dest_dir. :param download_info: (dict) Contains the...
[ "Module", "method", "for", "downloading", "from", "S3" ]
train
https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/s3util.py#L363-L467
cons3rt/pycons3rt
pycons3rt/awsapi/s3util.py
find_bucket_keys
def find_bucket_keys(bucket_name, regex, region_name=None, aws_access_key_id=None, aws_secret_access_key=None): """Finds a list of S3 keys matching the passed regex Given a regular expression, this method searches the S3 bucket for matching keys, and returns an array of strings for matched keys, an emp...
python
def find_bucket_keys(bucket_name, regex, region_name=None, aws_access_key_id=None, aws_secret_access_key=None): """Finds a list of S3 keys matching the passed regex Given a regular expression, this method searches the S3 bucket for matching keys, and returns an array of strings for matched keys, an emp...
[ "def", "find_bucket_keys", "(", "bucket_name", ",", "regex", ",", "region_name", "=", "None", ",", "aws_access_key_id", "=", "None", ",", "aws_secret_access_key", "=", "None", ")", ":", "log", "=", "logging", ".", "getLogger", "(", "mod_logger", "+", "'.find_b...
Finds a list of S3 keys matching the passed regex Given a regular expression, this method searches the S3 bucket for matching keys, and returns an array of strings for matched keys, an empty array if non are found. :param regex: (str) Regular expression to use is the key search :param bucket_name:...
[ "Finds", "a", "list", "of", "S3", "keys", "matching", "the", "passed", "regex" ]
train
https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/s3util.py#L470-L505
cons3rt/pycons3rt
pycons3rt/awsapi/s3util.py
main
def main(): """Sample usage for this python module This main method simply illustrates sample usage for this python module. :return: None """ log = logging.getLogger(mod_logger + '.main') log.debug('This is DEBUG!') log.info('This is INFO!') log.warning('This is WARNING!') log....
python
def main(): """Sample usage for this python module This main method simply illustrates sample usage for this python module. :return: None """ log = logging.getLogger(mod_logger + '.main') log.debug('This is DEBUG!') log.info('This is INFO!') log.warning('This is WARNING!') log....
[ "def", "main", "(", ")", ":", "log", "=", "logging", ".", "getLogger", "(", "mod_logger", "+", "'.main'", ")", "log", ".", "debug", "(", "'This is DEBUG!'", ")", "log", ".", "info", "(", "'This is INFO!'", ")", "log", ".", "warning", "(", "'This is WARNI...
Sample usage for this python module This main method simply illustrates sample usage for this python module. :return: None
[ "Sample", "usage", "for", "this", "python", "module" ]
train
https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/s3util.py#L508-L537
cons3rt/pycons3rt
pycons3rt/awsapi/s3util.py
S3Util.validate_bucket
def validate_bucket(self): """Verify the specified bucket exists This method validates that the bucket name passed in the S3Util constructor actually exists. :return: None """ log = logging.getLogger(self.cls_logger + '.validate_bucket') log.info('Attempting to ...
python
def validate_bucket(self): """Verify the specified bucket exists This method validates that the bucket name passed in the S3Util constructor actually exists. :return: None """ log = logging.getLogger(self.cls_logger + '.validate_bucket') log.info('Attempting to ...
[ "def", "validate_bucket", "(", "self", ")", ":", "log", "=", "logging", ".", "getLogger", "(", "self", ".", "cls_logger", "+", "'.validate_bucket'", ")", "log", ".", "info", "(", "'Attempting to get bucket: {b}'", ".", "format", "(", "b", "=", "self", ".", ...
Verify the specified bucket exists This method validates that the bucket name passed in the S3Util constructor actually exists. :return: None
[ "Verify", "the", "specified", "bucket", "exists" ]
train
https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/s3util.py#L85-L131