repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
eclipse/unide.python
src/unide/util.py
loads
def loads(data, validate=False, **kwargs): """Load a PPMP message from the JSON-formatted string in `data`. When `validate` is set, raise `ValidationError`. Additional keyword arguments are the same that are accepted by `json.loads`, e.g. `indent` to get a pretty output. """ d = json.loads(data,...
python
def loads(data, validate=False, **kwargs): """Load a PPMP message from the JSON-formatted string in `data`. When `validate` is set, raise `ValidationError`. Additional keyword arguments are the same that are accepted by `json.loads`, e.g. `indent` to get a pretty output. """ d = json.loads(data,...
[ "def", "loads", "(", "data", ",", "validate", "=", "False", ",", "*", "*", "kwargs", ")", ":", "d", "=", "json", ".", "loads", "(", "data", ",", "*", "*", "kwargs", ")", "content_spec", "=", "d", "[", "\"content-spec\"", "]", "Payload", "=", "CONTE...
Load a PPMP message from the JSON-formatted string in `data`. When `validate` is set, raise `ValidationError`. Additional keyword arguments are the same that are accepted by `json.loads`, e.g. `indent` to get a pretty output.
[ "Load", "a", "PPMP", "message", "from", "the", "JSON", "-", "formatted", "string", "in", "data", ".", "When", "validate", "is", "set", "raise", "ValidationError", ".", "Additional", "keyword", "arguments", "are", "the", "same", "that", "are", "accepted", "by...
b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493
https://github.com/eclipse/unide.python/blob/b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493/src/unide/util.py#L51-L65
train
Load a PPMP message from the JSON - formatted string in data.
eclipse/unide.python
src/unide/util.py
dumps
def dumps(data, **kwargs): """Convert a PPMP entity to JSON. Additional arguments are the same as accepted by `json.dumps`.""" def _encoder(value): if isinstance(value, datetime.datetime): return value.isoformat() if hasattr(value, "_data"): return value._data ...
python
def dumps(data, **kwargs): """Convert a PPMP entity to JSON. Additional arguments are the same as accepted by `json.dumps`.""" def _encoder(value): if isinstance(value, datetime.datetime): return value.isoformat() if hasattr(value, "_data"): return value._data ...
[ "def", "dumps", "(", "data", ",", "*", "*", "kwargs", ")", ":", "def", "_encoder", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "datetime", ".", "datetime", ")", ":", "return", "value", ".", "isoformat", "(", ")", "if", "hasattr", ...
Convert a PPMP entity to JSON. Additional arguments are the same as accepted by `json.dumps`.
[ "Convert", "a", "PPMP", "entity", "to", "JSON", ".", "Additional", "arguments", "are", "the", "same", "as", "accepted", "by", "json", ".", "dumps", "." ]
b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493
https://github.com/eclipse/unide.python/blob/b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493/src/unide/util.py#L68-L81
train
Convert a PPMP entity to JSON. Additional arguments are the same as accepted by json. dumps.
Godley/MuseParse
MuseParse/classes/Output/helpers.py
setup_lilypond
def setup_lilypond(path_to_lilypond_folder="default"): ''' Optional helper method which works out the platform and calls the relevant setup method * param path_to_lilypond_folder: the path where lilypond.exe or the lilypond runner tool in mac is located. Not needed if setup is default, or if using linu...
python
def setup_lilypond(path_to_lilypond_folder="default"): ''' Optional helper method which works out the platform and calls the relevant setup method * param path_to_lilypond_folder: the path where lilypond.exe or the lilypond runner tool in mac is located. Not needed if setup is default, or if using linu...
[ "def", "setup_lilypond", "(", "path_to_lilypond_folder", "=", "\"default\"", ")", ":", "options", "=", "{", "\"win32\"", ":", "setup_lilypond_windows", ",", "\"darwin\"", ":", "setup_lilypond_osx", "}", "if", "platform", ".", "startswith", "(", "\"linux\"", ")", "...
Optional helper method which works out the platform and calls the relevant setup method * param path_to_lilypond_folder: the path where lilypond.exe or the lilypond runner tool in mac is located. Not needed if setup is default, or if using linux * :return: None
[ "Optional", "helper", "method", "which", "works", "out", "the", "platform", "and", "calls", "the", "relevant", "setup", "method" ]
23cecafa1fdc0f2d6a87760553572b459f3c9904
https://github.com/Godley/MuseParse/blob/23cecafa1fdc0f2d6a87760553572b459f3c9904/MuseParse/classes/Output/helpers.py#L13-L26
train
This function is used to setup the lilypond system.
Godley/MuseParse
MuseParse/classes/Output/helpers.py
setup_lilypond_windows
def setup_lilypond_windows(path="default"): ''' Optional helper method which does the environment setup for lilypond in windows. If you've ran this method, you do not need and should not provide a lyscript when you instantiate this class. As this method is static, you can run this method before you set up t...
python
def setup_lilypond_windows(path="default"): ''' Optional helper method which does the environment setup for lilypond in windows. If you've ran this method, you do not need and should not provide a lyscript when you instantiate this class. As this method is static, you can run this method before you set up t...
[ "def", "setup_lilypond_windows", "(", "path", "=", "\"default\"", ")", ":", "default", "=", "\"C:/Program Files (x86)/LilyPond/usr/bin\"", "path_variable", "=", "os", ".", "environ", "[", "'PATH'", "]", ".", "split", "(", "\";\"", ")", "if", "path", "==", "\"def...
Optional helper method which does the environment setup for lilypond in windows. If you've ran this method, you do not need and should not provide a lyscript when you instantiate this class. As this method is static, you can run this method before you set up the LilypondRenderer instance. * parameter: path...
[ "Optional", "helper", "method", "which", "does", "the", "environment", "setup", "for", "lilypond", "in", "windows", ".", "If", "you", "ve", "ran", "this", "method", "you", "do", "not", "need", "and", "should", "not", "provide", "a", "lyscript", "when", "yo...
23cecafa1fdc0f2d6a87760553572b459f3c9904
https://github.com/Godley/MuseParse/blob/23cecafa1fdc0f2d6a87760553572b459f3c9904/MuseParse/classes/Output/helpers.py#L29-L46
train
This method is used to set up the environment for lilypond in windows.
blockstack/python-utilitybelt
utilitybelt/dicts.py
recursive_dict_to_dict
def recursive_dict_to_dict(rdict): """ Convert a recursive dict to a plain ol' dict. """ d = {} for (k, v) in rdict.items(): if isinstance(v, defaultdict): d[k] = recursive_dict_to_dict(v) else: d[k] = v return d
python
def recursive_dict_to_dict(rdict): """ Convert a recursive dict to a plain ol' dict. """ d = {} for (k, v) in rdict.items(): if isinstance(v, defaultdict): d[k] = recursive_dict_to_dict(v) else: d[k] = v return d
[ "def", "recursive_dict_to_dict", "(", "rdict", ")", ":", "d", "=", "{", "}", "for", "(", "k", ",", "v", ")", "in", "rdict", ".", "items", "(", ")", ":", "if", "isinstance", "(", "v", ",", "defaultdict", ")", ":", "d", "[", "k", "]", "=", "recur...
Convert a recursive dict to a plain ol' dict.
[ "Convert", "a", "recursive", "dict", "to", "a", "plain", "ol", "dict", "." ]
13d3502aa1a486c9d775ad2c551fb8e7e48b0d96
https://github.com/blockstack/python-utilitybelt/blob/13d3502aa1a486c9d775ad2c551fb8e7e48b0d96/utilitybelt/dicts.py#L17-L26
train
Convert a recursive dict to a plain ol' dict.
blockstack/python-utilitybelt
utilitybelt/dicts.py
scrub_dict
def scrub_dict(d): """ Recursively inspect a dictionary and remove all empty values, including empty strings, lists, and dictionaries. """ if type(d) is dict: return dict( (k, scrub_dict(v)) for k, v in d.iteritems() if v and scrub_dict(v) ) elif type(d) is list: ...
python
def scrub_dict(d): """ Recursively inspect a dictionary and remove all empty values, including empty strings, lists, and dictionaries. """ if type(d) is dict: return dict( (k, scrub_dict(v)) for k, v in d.iteritems() if v and scrub_dict(v) ) elif type(d) is list: ...
[ "def", "scrub_dict", "(", "d", ")", ":", "if", "type", "(", "d", ")", "is", "dict", ":", "return", "dict", "(", "(", "k", ",", "scrub_dict", "(", "v", ")", ")", "for", "k", ",", "v", "in", "d", ".", "iteritems", "(", ")", "if", "v", "and", ...
Recursively inspect a dictionary and remove all empty values, including empty strings, lists, and dictionaries.
[ "Recursively", "inspect", "a", "dictionary", "and", "remove", "all", "empty", "values", "including", "empty", "strings", "lists", "and", "dictionaries", "." ]
13d3502aa1a486c9d775ad2c551fb8e7e48b0d96
https://github.com/blockstack/python-utilitybelt/blob/13d3502aa1a486c9d775ad2c551fb8e7e48b0d96/utilitybelt/dicts.py#L29-L42
train
Recursively inspect a dictionary and remove all empty values including empty strings lists and dictionaries.
blockstack/python-utilitybelt
utilitybelt/dicts.py
_to_json_type
def _to_json_type(obj, classkey=None): """ Recursively convert the object instance into a valid JSON type. """ if isinstance(obj, dict): data = {} for (k, v) in obj.items(): data[k] = _to_json_type(v, classkey) return data elif hasattr(obj, "_ast"): return _to...
python
def _to_json_type(obj, classkey=None): """ Recursively convert the object instance into a valid JSON type. """ if isinstance(obj, dict): data = {} for (k, v) in obj.items(): data[k] = _to_json_type(v, classkey) return data elif hasattr(obj, "_ast"): return _to...
[ "def", "_to_json_type", "(", "obj", ",", "classkey", "=", "None", ")", ":", "if", "isinstance", "(", "obj", ",", "dict", ")", ":", "data", "=", "{", "}", "for", "(", "k", ",", "v", ")", "in", "obj", ".", "items", "(", ")", ":", "data", "[", "...
Recursively convert the object instance into a valid JSON type.
[ "Recursively", "convert", "the", "object", "instance", "into", "a", "valid", "JSON", "type", "." ]
13d3502aa1a486c9d775ad2c551fb8e7e48b0d96
https://github.com/blockstack/python-utilitybelt/blob/13d3502aa1a486c9d775ad2c551fb8e7e48b0d96/utilitybelt/dicts.py#L45-L67
train
Recursively convert the object instance into a valid JSON type.
blockstack/python-utilitybelt
utilitybelt/dicts.py
to_dict
def to_dict(obj): """ Convert an instance of an object into a dict. """ d = _to_json_type(obj) if isinstance(d, dict): return scrub_dict(d) else: raise ValueError("The value provided must be an object.")
python
def to_dict(obj): """ Convert an instance of an object into a dict. """ d = _to_json_type(obj) if isinstance(d, dict): return scrub_dict(d) else: raise ValueError("The value provided must be an object.")
[ "def", "to_dict", "(", "obj", ")", ":", "d", "=", "_to_json_type", "(", "obj", ")", "if", "isinstance", "(", "d", ",", "dict", ")", ":", "return", "scrub_dict", "(", "d", ")", "else", ":", "raise", "ValueError", "(", "\"The value provided must be an object...
Convert an instance of an object into a dict.
[ "Convert", "an", "instance", "of", "an", "object", "into", "a", "dict", "." ]
13d3502aa1a486c9d775ad2c551fb8e7e48b0d96
https://github.com/blockstack/python-utilitybelt/blob/13d3502aa1a486c9d775ad2c551fb8e7e48b0d96/utilitybelt/dicts.py#L70-L77
train
Convert an instance of an object into a dict.
TylerTemp/docpie
docpie/tracemore.py
print_exc_plus
def print_exc_plus(stream=sys.stdout): '''print normal traceback information with some local arg values''' # code of this mothod is mainly from <Python Cookbook> write = stream.write # assert the mothod exists flush = stream.flush tp, value, tb = sys.exc_info() while tb.tb_next: tb = ...
python
def print_exc_plus(stream=sys.stdout): '''print normal traceback information with some local arg values''' # code of this mothod is mainly from <Python Cookbook> write = stream.write # assert the mothod exists flush = stream.flush tp, value, tb = sys.exc_info() while tb.tb_next: tb = ...
[ "def", "print_exc_plus", "(", "stream", "=", "sys", ".", "stdout", ")", ":", "# code of this mothod is mainly from <Python Cookbook>", "write", "=", "stream", ".", "write", "# assert the mothod exists", "flush", "=", "stream", ".", "flush", "tp", ",", "value", ",", ...
print normal traceback information with some local arg values
[ "print", "normal", "traceback", "information", "with", "some", "local", "arg", "values" ]
e658454b81b6c79a020d499f12ad73496392c09a
https://github.com/TylerTemp/docpie/blob/e658454b81b6c79a020d499f12ad73496392c09a/docpie/tracemore.py#L22-L56
train
print normal traceback information with some local arg values
MacHu-GWU/single_file_module-project
sfm/textformatter.py
format_single_space_only
def format_single_space_only(text): """Revise consecutive empty space to single space. Example:: " I feel so GOOD!" => "This is so GOOD!" **中文文档** 确保文本中不会出现多余连续1次的空格。 """ return " ".join([word for word in text.strip().split(" ") if len(word) >= 1])
python
def format_single_space_only(text): """Revise consecutive empty space to single space. Example:: " I feel so GOOD!" => "This is so GOOD!" **中文文档** 确保文本中不会出现多余连续1次的空格。 """ return " ".join([word for word in text.strip().split(" ") if len(word) >= 1])
[ "def", "format_single_space_only", "(", "text", ")", ":", "return", "\" \"", ".", "join", "(", "[", "word", "for", "word", "in", "text", ".", "strip", "(", ")", ".", "split", "(", "\" \"", ")", "if", "len", "(", "word", ")", ">=", "1", "]", ")" ]
Revise consecutive empty space to single space. Example:: " I feel so GOOD!" => "This is so GOOD!" **中文文档** 确保文本中不会出现多余连续1次的空格。
[ "Revise", "consecutive", "empty", "space", "to", "single", "space", "." ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/textformatter.py#L26-L37
train
Revise consecutive empty space to single space.
MacHu-GWU/single_file_module-project
sfm/textformatter.py
format_title
def format_title(text): """Capitalize first letter for each words except function words. Example:: title = "Beautiful is Better than Ugly" **中文文档** 将文本 "标题化", 即除了虚词, 每一个英文单词的第一个字母大写。 """ text = text.strip() # if empty string, return "" if len(text) == 0: return text ...
python
def format_title(text): """Capitalize first letter for each words except function words. Example:: title = "Beautiful is Better than Ugly" **中文文档** 将文本 "标题化", 即除了虚词, 每一个英文单词的第一个字母大写。 """ text = text.strip() # if empty string, return "" if len(text) == 0: return text ...
[ "def", "format_title", "(", "text", ")", ":", "text", "=", "text", ".", "strip", "(", ")", "# if empty string, return \"\"", "if", "len", "(", "text", ")", "==", "0", ":", "return", "text", "else", ":", "text", "=", "text", ".", "lower", "(", ")", "#...
Capitalize first letter for each words except function words. Example:: title = "Beautiful is Better than Ugly" **中文文档** 将文本 "标题化", 即除了虚词, 每一个英文单词的第一个字母大写。
[ "Capitalize", "first", "letter", "for", "each", "words", "except", "function", "words", "." ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/textformatter.py#L40-L71
train
Format the title of the text.
MacHu-GWU/single_file_module-project
sfm/textformatter.py
format_person_name
def format_person_name(text): """Capitalize first letter for each part of the name. Example:: person_name = "James Bond" **中文文档** 将文本修改为人名格式。每个单词的第一个字母大写。 """ text = text.strip() if len(text) == 0: # if empty string, return it return text else: text = text.lo...
python
def format_person_name(text): """Capitalize first letter for each part of the name. Example:: person_name = "James Bond" **中文文档** 将文本修改为人名格式。每个单词的第一个字母大写。 """ text = text.strip() if len(text) == 0: # if empty string, return it return text else: text = text.lo...
[ "def", "format_person_name", "(", "text", ")", ":", "text", "=", "text", ".", "strip", "(", ")", "if", "len", "(", "text", ")", "==", "0", ":", "# if empty string, return it", "return", "text", "else", ":", "text", "=", "text", ".", "lower", "(", ")", ...
Capitalize first letter for each part of the name. Example:: person_name = "James Bond" **中文文档** 将文本修改为人名格式。每个单词的第一个字母大写。
[ "Capitalize", "first", "letter", "for", "each", "part", "of", "the", "name", "." ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/textformatter.py#L74-L93
train
Format a person name into a random name.
MacHu-GWU/single_file_module-project
sfm/textformatter.py
format_camel_case
def format_camel_case(text): """ Example:: ThisIsVeryGood **中文文档** 将文本格式化为各单词首字母大写, 拼接而成的长变量名。 """ text = text.strip() if len(text) == 0: # if empty string, return it raise ValueError("can not be empty string!") else: text = text.lower() # lower all char ...
python
def format_camel_case(text): """ Example:: ThisIsVeryGood **中文文档** 将文本格式化为各单词首字母大写, 拼接而成的长变量名。 """ text = text.strip() if len(text) == 0: # if empty string, return it raise ValueError("can not be empty string!") else: text = text.lower() # lower all char ...
[ "def", "format_camel_case", "(", "text", ")", ":", "text", "=", "text", ".", "strip", "(", ")", "if", "len", "(", "text", ")", "==", "0", ":", "# if empty string, return it", "raise", "ValueError", "(", "\"can not be empty string!\"", ")", "else", ":", "text...
Example:: ThisIsVeryGood **中文文档** 将文本格式化为各单词首字母大写, 拼接而成的长变量名。
[ "Example", "::" ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/textformatter.py#L108-L137
train
format a string to be used in a camel case version of the language
MacHu-GWU/single_file_module-project
sfm/textformatter.py
format_unix_var
def format_unix_var(text): """ Example:: this_is_very_good """ text = text.strip() if len(text) == 0: # if empty string, return it raise ValueError("can not be empty string!") else: if text[0] in string.digits: raise ValueError("variable can not start with d...
python
def format_unix_var(text): """ Example:: this_is_very_good """ text = text.strip() if len(text) == 0: # if empty string, return it raise ValueError("can not be empty string!") else: if text[0] in string.digits: raise ValueError("variable can not start with d...
[ "def", "format_unix_var", "(", "text", ")", ":", "text", "=", "text", ".", "strip", "(", ")", "if", "len", "(", "text", ")", "==", "0", ":", "# if empty string, return it", "raise", "ValueError", "(", "\"can not be empty string!\"", ")", "else", ":", "if", ...
Example:: this_is_very_good
[ "Example", "::" ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/textformatter.py#L150-L176
train
Format a string in Unix format.
pyros-dev/pyzmp
pyzmp/coprocess.py
CoProcess.daemon
def daemon(self): """ Return whether process is a daemon :return: """ if self._process: return self._process.daemon else: return self._pargs.get('daemonic', False)
python
def daemon(self): """ Return whether process is a daemon :return: """ if self._process: return self._process.daemon else: return self._pargs.get('daemonic', False)
[ "def", "daemon", "(", "self", ")", ":", "if", "self", ".", "_process", ":", "return", "self", ".", "_process", ".", "daemon", "else", ":", "return", "self", ".", "_pargs", ".", "get", "(", "'daemonic'", ",", "False", ")" ]
Return whether process is a daemon :return:
[ "Return", "whether", "process", "is", "a", "daemon", ":", "return", ":" ]
fac0b719b25996ce94a80ca2118f3eba5779d53d
https://github.com/pyros-dev/pyzmp/blob/fac0b719b25996ce94a80ca2118f3eba5779d53d/pyzmp/coprocess.py#L246-L254
train
Return whether the process is a daemon or not
pyros-dev/pyzmp
pyzmp/coprocess.py
CoProcess.daemon
def daemon(self, daemonic): """ Set whether process is a daemon :param daemonic: :return: """ if self._process: self._process.daemonic = daemonic else: self._pargs['daemonic'] = daemonic
python
def daemon(self, daemonic): """ Set whether process is a daemon :param daemonic: :return: """ if self._process: self._process.daemonic = daemonic else: self._pargs['daemonic'] = daemonic
[ "def", "daemon", "(", "self", ",", "daemonic", ")", ":", "if", "self", ".", "_process", ":", "self", ".", "_process", ".", "daemonic", "=", "daemonic", "else", ":", "self", ".", "_pargs", "[", "'daemonic'", "]", "=", "daemonic" ]
Set whether process is a daemon :param daemonic: :return:
[ "Set", "whether", "process", "is", "a", "daemon", ":", "param", "daemonic", ":", ":", "return", ":" ]
fac0b719b25996ce94a80ca2118f3eba5779d53d
https://github.com/pyros-dev/pyzmp/blob/fac0b719b25996ce94a80ca2118f3eba5779d53d/pyzmp/coprocess.py#L257-L266
train
Sets the daemonic flag.
pyros-dev/pyzmp
pyzmp/coprocess.py
CoProcess.start
def start(self, timeout=None): """ Start child process :param timeout: the maximum time to wait for child process to report it has actually started. None waits until the context manager has been entered, but update might not have been called yet. """ # we lazily create o...
python
def start(self, timeout=None): """ Start child process :param timeout: the maximum time to wait for child process to report it has actually started. None waits until the context manager has been entered, but update might not have been called yet. """ # we lazily create o...
[ "def", "start", "(", "self", ",", "timeout", "=", "None", ")", ":", "# we lazily create our process delegate (with same arguments)", "if", "self", ".", "daemon", ":", "daemonic", "=", "True", "else", ":", "daemonic", "=", "False", "pargs", "=", "self", ".", "_...
Start child process :param timeout: the maximum time to wait for child process to report it has actually started. None waits until the context manager has been entered, but update might not have been called yet.
[ "Start", "child", "process", ":", "param", "timeout", ":", "the", "maximum", "time", "to", "wait", "for", "child", "process", "to", "report", "it", "has", "actually", "started", ".", "None", "waits", "until", "the", "context", "manager", "has", "been", "en...
fac0b719b25996ce94a80ca2118f3eba5779d53d
https://github.com/pyros-dev/pyzmp/blob/fac0b719b25996ce94a80ca2118f3eba5779d53d/pyzmp/coprocess.py#L303-L342
train
Start a child process and return the zmp url.
pyros-dev/pyzmp
pyzmp/coprocess.py
CoProcess.shutdown
def shutdown(self, join=True, timeout=None): """ Clean shutdown of the node. :param join: optionally wait for the process to end (default : True) :return: None """ if self.is_alive(): # check if process started print("Shutdown initiated") self.exi...
python
def shutdown(self, join=True, timeout=None): """ Clean shutdown of the node. :param join: optionally wait for the process to end (default : True) :return: None """ if self.is_alive(): # check if process started print("Shutdown initiated") self.exi...
[ "def", "shutdown", "(", "self", ",", "join", "=", "True", ",", "timeout", "=", "None", ")", ":", "if", "self", ".", "is_alive", "(", ")", ":", "# check if process started", "print", "(", "\"Shutdown initiated\"", ")", "self", ".", "exit", ".", "set", "("...
Clean shutdown of the node. :param join: optionally wait for the process to end (default : True) :return: None
[ "Clean", "shutdown", "of", "the", "node", ".", ":", "param", "join", ":", "optionally", "wait", "for", "the", "process", "to", "end", "(", "default", ":", "True", ")", ":", "return", ":", "None" ]
fac0b719b25996ce94a80ca2118f3eba5779d53d
https://github.com/pyros-dev/pyzmp/blob/fac0b719b25996ce94a80ca2118f3eba5779d53d/pyzmp/coprocess.py#L356-L370
train
Clean shutdown of the node.
pyros-dev/pyzmp
pyzmp/coprocess.py
CoProcess.eventloop
def eventloop(self, *args, **kwargs): """ Hand crafted event loop, with only one event possible : exit More events ( and signals ) can be added later, after converting to asyncio. """ # Setting status status = None # Starting the clock start = time.time(...
python
def eventloop(self, *args, **kwargs): """ Hand crafted event loop, with only one event possible : exit More events ( and signals ) can be added later, after converting to asyncio. """ # Setting status status = None # Starting the clock start = time.time(...
[ "def", "eventloop", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Setting status", "status", "=", "None", "# Starting the clock", "start", "=", "time", ".", "time", "(", ")", "first_loop", "=", "True", "# loop running target, maybe more ...
Hand crafted event loop, with only one event possible : exit More events ( and signals ) can be added later, after converting to asyncio.
[ "Hand", "crafted", "event", "loop", "with", "only", "one", "event", "possible", ":", "exit", "More", "events", "(", "and", "signals", ")", "can", "be", "added", "later", "after", "converting", "to", "asyncio", "." ]
fac0b719b25996ce94a80ca2118f3eba5779d53d
https://github.com/pyros-dev/pyzmp/blob/fac0b719b25996ce94a80ca2118f3eba5779d53d/pyzmp/coprocess.py#L377-L429
train
This is the main event loop for the process.
pyros-dev/pyzmp
pyzmp/coprocess.py
CoProcess.run
def run(self, *args, **kwargs): """ The Node main method, running in a child process (similar to Process.run() but also accepts args) A children class can override this method, but it needs to call super().run(*args, **kwargs) for the node to start properly and call update() as expected....
python
def run(self, *args, **kwargs): """ The Node main method, running in a child process (similar to Process.run() but also accepts args) A children class can override this method, but it needs to call super().run(*args, **kwargs) for the node to start properly and call update() as expected....
[ "def", "run", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# TODO : make use of the arguments ? since run is now the target for Process...", "exitstatus", "=", "None", "# keeping the semantic of multiprocessing.Process : running process has None", "if", "s...
The Node main method, running in a child process (similar to Process.run() but also accepts args) A children class can override this method, but it needs to call super().run(*args, **kwargs) for the node to start properly and call update() as expected. :param args: arguments to pass to update() ...
[ "The", "Node", "main", "method", "running", "in", "a", "child", "process", "(", "similar", "to", "Process", ".", "run", "()", "but", "also", "accepts", "args", ")", "A", "children", "class", "can", "override", "this", "method", "but", "it", "needs", "to"...
fac0b719b25996ce94a80ca2118f3eba5779d53d
https://github.com/pyros-dev/pyzmp/blob/fac0b719b25996ce94a80ca2118f3eba5779d53d/pyzmp/coprocess.py#L431-L458
train
This method is called by the main process when the node is started.
MacHu-GWU/single_file_module-project
sfm/dtree.py
DictTree.dump
def dump(self, path): """ dump DictTree data to json files. """ try: with open(path, "wb") as f: f.write(self.__str__().encode("utf-8")) except: pass with open(path, "wb") as f: pickle.dump(self.__data__, f)
python
def dump(self, path): """ dump DictTree data to json files. """ try: with open(path, "wb") as f: f.write(self.__str__().encode("utf-8")) except: pass with open(path, "wb") as f: pickle.dump(self.__data__, f)
[ "def", "dump", "(", "self", ",", "path", ")", ":", "try", ":", "with", "open", "(", "path", ",", "\"wb\"", ")", "as", "f", ":", "f", ".", "write", "(", "self", ".", "__str__", "(", ")", ".", "encode", "(", "\"utf-8\"", ")", ")", "except", ":", ...
dump DictTree data to json files.
[ "dump", "DictTree", "data", "to", "json", "files", "." ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/dtree.py#L117-L128
train
dump DictTree data to json files.
MacHu-GWU/single_file_module-project
sfm/dtree.py
DictTree.load
def load(cls, path): """ load DictTree from json files. """ try: with open(path, "rb") as f: return cls(__data__=json.loads(f.read().decode("utf-8"))) except: pass with open(path, "rb") as f: return cls(__data__=pickle....
python
def load(cls, path): """ load DictTree from json files. """ try: with open(path, "rb") as f: return cls(__data__=json.loads(f.read().decode("utf-8"))) except: pass with open(path, "rb") as f: return cls(__data__=pickle....
[ "def", "load", "(", "cls", ",", "path", ")", ":", "try", ":", "with", "open", "(", "path", ",", "\"rb\"", ")", "as", "f", ":", "return", "cls", "(", "__data__", "=", "json", ".", "loads", "(", "f", ".", "read", "(", ")", ".", "decode", "(", "...
load DictTree from json files.
[ "load", "DictTree", "from", "json", "files", "." ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/dtree.py#L131-L142
train
load DictTree from json files.
MacHu-GWU/single_file_module-project
sfm/dtree.py
DictTree.values
def values(self): """ Iterate values. """ for key, value in self.__data__.items(): if key not in (META, KEY): yield DictTree(__data__=value)
python
def values(self): """ Iterate values. """ for key, value in self.__data__.items(): if key not in (META, KEY): yield DictTree(__data__=value)
[ "def", "values", "(", "self", ")", ":", "for", "key", ",", "value", "in", "self", ".", "__data__", ".", "items", "(", ")", ":", "if", "key", "not", "in", "(", "META", ",", "KEY", ")", ":", "yield", "DictTree", "(", "__data__", "=", "value", ")" ]
Iterate values.
[ "Iterate", "values", "." ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/dtree.py#L202-L208
train
Iterate values.
MacHu-GWU/single_file_module-project
sfm/dtree.py
DictTree.keys_at
def keys_at(self, depth, counter=1): """ Iterate keys at specified depth. """ if depth < 1: yield ROOT else: if counter == depth: for key in self.keys(): yield key else: counter += 1 ...
python
def keys_at(self, depth, counter=1): """ Iterate keys at specified depth. """ if depth < 1: yield ROOT else: if counter == depth: for key in self.keys(): yield key else: counter += 1 ...
[ "def", "keys_at", "(", "self", ",", "depth", ",", "counter", "=", "1", ")", ":", "if", "depth", "<", "1", ":", "yield", "ROOT", "else", ":", "if", "counter", "==", "depth", ":", "for", "key", "in", "self", ".", "keys", "(", ")", ":", "yield", "...
Iterate keys at specified depth.
[ "Iterate", "keys", "at", "specified", "depth", "." ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/dtree.py#L219-L233
train
Iterate keys at specified depth.
MacHu-GWU/single_file_module-project
sfm/dtree.py
DictTree.values_at
def values_at(self, depth): """ Iterate values at specified depth. """ if depth < 1: yield self else: for dict_tree in self.values(): for value in dict_tree.values_at(depth - 1): yield value
python
def values_at(self, depth): """ Iterate values at specified depth. """ if depth < 1: yield self else: for dict_tree in self.values(): for value in dict_tree.values_at(depth - 1): yield value
[ "def", "values_at", "(", "self", ",", "depth", ")", ":", "if", "depth", "<", "1", ":", "yield", "self", "else", ":", "for", "dict_tree", "in", "self", ".", "values", "(", ")", ":", "for", "value", "in", "dict_tree", ".", "values_at", "(", "depth", ...
Iterate values at specified depth.
[ "Iterate", "values", "at", "specified", "depth", "." ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/dtree.py#L235-L244
train
Iterate values at specified depth.
MacHu-GWU/single_file_module-project
sfm/dtree.py
DictTree.items_at
def items_at(self, depth): """ Iterate items at specified depth. """ if depth < 1: yield ROOT, self elif depth == 1: for key, value in self.items(): yield key, value else: for dict_tree in self.values(): ...
python
def items_at(self, depth): """ Iterate items at specified depth. """ if depth < 1: yield ROOT, self elif depth == 1: for key, value in self.items(): yield key, value else: for dict_tree in self.values(): ...
[ "def", "items_at", "(", "self", ",", "depth", ")", ":", "if", "depth", "<", "1", ":", "yield", "ROOT", ",", "self", "elif", "depth", "==", "1", ":", "for", "key", ",", "value", "in", "self", ".", "items", "(", ")", ":", "yield", "key", ",", "va...
Iterate items at specified depth.
[ "Iterate", "items", "at", "specified", "depth", "." ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/dtree.py#L246-L258
train
Iterate items at specified depth.
MacHu-GWU/single_file_module-project
sfm/dtree.py
DictTree.length_at
def length_at(self, depth): """Get the number of nodes on specific depth. """ if depth == 0: return 1 counter = 0 for dict_tree in self.values_at(depth - 1): counter += len(dict_tree) return counter
python
def length_at(self, depth): """Get the number of nodes on specific depth. """ if depth == 0: return 1 counter = 0 for dict_tree in self.values_at(depth - 1): counter += len(dict_tree) return counter
[ "def", "length_at", "(", "self", ",", "depth", ")", ":", "if", "depth", "==", "0", ":", "return", "1", "counter", "=", "0", "for", "dict_tree", "in", "self", ".", "values_at", "(", "depth", "-", "1", ")", ":", "counter", "+=", "len", "(", "dict_tre...
Get the number of nodes on specific depth.
[ "Get", "the", "number", "of", "nodes", "on", "specific", "depth", "." ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/dtree.py#L260-L269
train
Get the number of nodes on specific depth.
MacHu-GWU/single_file_module-project
sfm/dtree.py
DictTree.stats
def stats(self, result=None, counter=0): """ Display the node stats info on specific depth in this dict. :: [ {"depth": 0, "leaf": M0, "root": N0}, {"depth": 1, "leaf": M1, "root": N1}, ... {"depth": k, "leaf": Mk, "ro...
python
def stats(self, result=None, counter=0): """ Display the node stats info on specific depth in this dict. :: [ {"depth": 0, "leaf": M0, "root": N0}, {"depth": 1, "leaf": M1, "root": N1}, ... {"depth": k, "leaf": Mk, "ro...
[ "def", "stats", "(", "self", ",", "result", "=", "None", ",", "counter", "=", "0", ")", ":", "if", "result", "is", "None", ":", "result", "=", "dict", "(", ")", "if", "counter", "==", "0", ":", "if", "len", "(", "self", ")", ":", "result", "[",...
Display the node stats info on specific depth in this dict. :: [ {"depth": 0, "leaf": M0, "root": N0}, {"depth": 1, "leaf": M1, "root": N1}, ... {"depth": k, "leaf": Mk, "root": Nk}, ]
[ "Display", "the", "node", "stats", "info", "on", "specific", "depth", "in", "this", "dict", "." ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/dtree.py#L271-L311
train
Display the node stats on specific depth in this dict.
igorcoding/asynctnt-queue
asynctnt_queue/tube.py
Tube.put
async def put(self, data, *, pri=None, ttl=None, ttr=None, delay=None): """ Puts data to the queue and returns a newly created Task :param data: Arbitrary task payload :param pri: Task priority (0 by default) :param ttl: Task time-to-live :param ttr: ...
python
async def put(self, data, *, pri=None, ttl=None, ttr=None, delay=None): """ Puts data to the queue and returns a newly created Task :param data: Arbitrary task payload :param pri: Task priority (0 by default) :param ttl: Task time-to-live :param ttr: ...
[ "async", "def", "put", "(", "self", ",", "data", ",", "*", ",", "pri", "=", "None", ",", "ttl", "=", "None", ",", "ttr", "=", "None", ",", "delay", "=", "None", ")", ":", "opts", "=", "{", "}", "if", "pri", "is", "not", "None", ":", "opts", ...
Puts data to the queue and returns a newly created Task :param data: Arbitrary task payload :param pri: Task priority (0 by default) :param ttl: Task time-to-live :param ttr: Task time-to-run :param delay: Task delay :return: Task instance
[ "Puts", "data", "to", "the", "queue", "and", "returns", "a", "newly", "created", "Task" ]
75719b2dd27e8314ae924aea6a7a85be8f48ecc5
https://github.com/igorcoding/asynctnt-queue/blob/75719b2dd27e8314ae924aea6a7a85be8f48ecc5/asynctnt_queue/tube.py#L74-L100
train
Put data to the queue and returns a Task instance
igorcoding/asynctnt-queue
asynctnt_queue/tube.py
Tube.take
async def take(self, timeout=None): """ Takes task from the queue, waiting the timeout if specified :param timeout: Seconds to wait for ready tasks :return: Task instance """ args = None if timeout is not None: args = (timeout,) r...
python
async def take(self, timeout=None): """ Takes task from the queue, waiting the timeout if specified :param timeout: Seconds to wait for ready tasks :return: Task instance """ args = None if timeout is not None: args = (timeout,) r...
[ "async", "def", "take", "(", "self", ",", "timeout", "=", "None", ")", ":", "args", "=", "None", "if", "timeout", "is", "not", "None", ":", "args", "=", "(", "timeout", ",", ")", "res", "=", "await", "self", ".", "conn", ".", "call", "(", "self",...
Takes task from the queue, waiting the timeout if specified :param timeout: Seconds to wait for ready tasks :return: Task instance
[ "Takes", "task", "from", "the", "queue", "waiting", "the", "timeout", "if", "specified" ]
75719b2dd27e8314ae924aea6a7a85be8f48ecc5
https://github.com/igorcoding/asynctnt-queue/blob/75719b2dd27e8314ae924aea6a7a85be8f48ecc5/asynctnt_queue/tube.py#L102-L116
train
Takes a task from the queue waiting the timeout if specified
igorcoding/asynctnt-queue
asynctnt_queue/tube.py
Tube.touch
async def touch(self, task_id, increment): """ Update task ttl and/or ttr by increment value :param task_id: Task id :param increment: Seconds to add to ttr :return: Task instance """ args = (task_id, increment) res = await self.conn.call(...
python
async def touch(self, task_id, increment): """ Update task ttl and/or ttr by increment value :param task_id: Task id :param increment: Seconds to add to ttr :return: Task instance """ args = (task_id, increment) res = await self.conn.call(...
[ "async", "def", "touch", "(", "self", ",", "task_id", ",", "increment", ")", ":", "args", "=", "(", "task_id", ",", "increment", ")", "res", "=", "await", "self", ".", "conn", ".", "call", "(", "self", ".", "__funcs", "[", "'touch'", "]", ",", "arg...
Update task ttl and/or ttr by increment value :param task_id: Task id :param increment: Seconds to add to ttr :return: Task instance
[ "Update", "task", "ttl", "and", "/", "or", "ttr", "by", "increment", "value" ]
75719b2dd27e8314ae924aea6a7a85be8f48ecc5
https://github.com/igorcoding/asynctnt-queue/blob/75719b2dd27e8314ae924aea6a7a85be8f48ecc5/asynctnt_queue/tube.py#L118-L128
train
Update task ttl and ttr by increment value
igorcoding/asynctnt-queue
asynctnt_queue/tube.py
Tube.release
async def release(self, task_id, *, delay=None): """ Release task (return to queue) with delay if specified :param task_id: Task id :param delay: Time in seconds before task will become ready again :return: Task instance """ opts = {} if d...
python
async def release(self, task_id, *, delay=None): """ Release task (return to queue) with delay if specified :param task_id: Task id :param delay: Time in seconds before task will become ready again :return: Task instance """ opts = {} if d...
[ "async", "def", "release", "(", "self", ",", "task_id", ",", "*", ",", "delay", "=", "None", ")", ":", "opts", "=", "{", "}", "if", "delay", "is", "not", "None", ":", "opts", "[", "'delay'", "]", "=", "delay", "args", "=", "(", "task_id", ",", ...
Release task (return to queue) with delay if specified :param task_id: Task id :param delay: Time in seconds before task will become ready again :return: Task instance
[ "Release", "task", "(", "return", "to", "queue", ")", "with", "delay", "if", "specified" ]
75719b2dd27e8314ae924aea6a7a85be8f48ecc5
https://github.com/igorcoding/asynctnt-queue/blob/75719b2dd27e8314ae924aea6a7a85be8f48ecc5/asynctnt_queue/tube.py#L141-L154
train
Release a task from the queue.
igorcoding/asynctnt-queue
asynctnt_queue/tube.py
Tube.peek
async def peek(self, task_id): """ Get task without changing its state :param task_id: Task id :return: Task instance """ args = (task_id,) res = await self.conn.call(self.__funcs['peek'], args) return self._create_task(res.body)
python
async def peek(self, task_id): """ Get task without changing its state :param task_id: Task id :return: Task instance """ args = (task_id,) res = await self.conn.call(self.__funcs['peek'], args) return self._create_task(res.body)
[ "async", "def", "peek", "(", "self", ",", "task_id", ")", ":", "args", "=", "(", "task_id", ",", ")", "res", "=", "await", "self", ".", "conn", ".", "call", "(", "self", ".", "__funcs", "[", "'peek'", "]", ",", "args", ")", "return", "self", ".",...
Get task without changing its state :param task_id: Task id :return: Task instance
[ "Get", "task", "without", "changing", "its", "state" ]
75719b2dd27e8314ae924aea6a7a85be8f48ecc5
https://github.com/igorcoding/asynctnt-queue/blob/75719b2dd27e8314ae924aea6a7a85be8f48ecc5/asynctnt_queue/tube.py#L156-L166
train
Get task without changing its state
igorcoding/asynctnt-queue
asynctnt_queue/tube.py
Tube.kick
async def kick(self, count): """ Kick `count` tasks from queue :param count: Tasks count to kick :return: Number of tasks actually kicked """ args = (count,) res = await self.conn.call(self.__funcs['kick'], args) if self.conn.version < (1, 7):...
python
async def kick(self, count): """ Kick `count` tasks from queue :param count: Tasks count to kick :return: Number of tasks actually kicked """ args = (count,) res = await self.conn.call(self.__funcs['kick'], args) if self.conn.version < (1, 7):...
[ "async", "def", "kick", "(", "self", ",", "count", ")", ":", "args", "=", "(", "count", ",", ")", "res", "=", "await", "self", ".", "conn", ".", "call", "(", "self", ".", "__funcs", "[", "'kick'", "]", ",", "args", ")", "if", "self", ".", "conn...
Kick `count` tasks from queue :param count: Tasks count to kick :return: Number of tasks actually kicked
[ "Kick", "count", "tasks", "from", "queue" ]
75719b2dd27e8314ae924aea6a7a85be8f48ecc5
https://github.com/igorcoding/asynctnt-queue/blob/75719b2dd27e8314ae924aea6a7a85be8f48ecc5/asynctnt_queue/tube.py#L190-L201
train
Kick count tasks from queue
ariebovenberg/snug
examples/slack/query.py
_parse_content
def _parse_content(response): """parse the response body as JSON, raise on errors""" if response.status_code != 200: raise ApiError(f'unknown error: {response.content.decode()}') result = json.loads(response.content) if not result['ok']: raise ApiError(f'{result["error"]}: {result.get("d...
python
def _parse_content(response): """parse the response body as JSON, raise on errors""" if response.status_code != 200: raise ApiError(f'unknown error: {response.content.decode()}') result = json.loads(response.content) if not result['ok']: raise ApiError(f'{result["error"]}: {result.get("d...
[ "def", "_parse_content", "(", "response", ")", ":", "if", "response", ".", "status_code", "!=", "200", ":", "raise", "ApiError", "(", "f'unknown error: {response.content.decode()}'", ")", "result", "=", "json", ".", "loads", "(", "response", ".", "content", ")",...
parse the response body as JSON, raise on errors
[ "parse", "the", "response", "body", "as", "JSON", "raise", "on", "errors" ]
4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef
https://github.com/ariebovenberg/snug/blob/4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef/examples/slack/query.py#L19-L26
train
parse the response body as JSON raise on errors
ariebovenberg/snug
examples/slack/query.py
paginated_retrieval
def paginated_retrieval(methodname, itemtype): """decorator factory for retrieval queries from query params""" return compose( reusable, basic_interaction, map_yield(partial(_params_as_get, methodname)), )
python
def paginated_retrieval(methodname, itemtype): """decorator factory for retrieval queries from query params""" return compose( reusable, basic_interaction, map_yield(partial(_params_as_get, methodname)), )
[ "def", "paginated_retrieval", "(", "methodname", ",", "itemtype", ")", ":", "return", "compose", "(", "reusable", ",", "basic_interaction", ",", "map_yield", "(", "partial", "(", "_params_as_get", ",", "methodname", ")", ")", ",", ")" ]
decorator factory for retrieval queries from query params
[ "decorator", "factory", "for", "retrieval", "queries", "from", "query", "params" ]
4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef
https://github.com/ariebovenberg/snug/blob/4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef/examples/slack/query.py#L49-L55
train
decorator factory for retrieval queries from query params
ariebovenberg/snug
examples/slack/query.py
json_post
def json_post(methodname, rtype, key): """decorator factory for json POST queries""" return compose( reusable, map_return(registry(rtype), itemgetter(key)), basic_interaction, map_yield(partial(_json_as_post, methodname)), oneyield, )
python
def json_post(methodname, rtype, key): """decorator factory for json POST queries""" return compose( reusable, map_return(registry(rtype), itemgetter(key)), basic_interaction, map_yield(partial(_json_as_post, methodname)), oneyield, )
[ "def", "json_post", "(", "methodname", ",", "rtype", ",", "key", ")", ":", "return", "compose", "(", "reusable", ",", "map_return", "(", "registry", "(", "rtype", ")", ",", "itemgetter", "(", "key", ")", ")", ",", "basic_interaction", ",", "map_yield", "...
decorator factory for json POST queries
[ "decorator", "factory", "for", "json", "POST", "queries" ]
4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef
https://github.com/ariebovenberg/snug/blob/4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef/examples/slack/query.py#L62-L70
train
decorator factory for json POST queries
envi-idl/envipyengine
envipyengine/config.py
_user_config_file
def _user_config_file(): """ Returns the path to the settings.cfg file. On Windows the file is located in the AppData/Local/envipyengine directory. On Unix, the file will be located in the ~/.envipyengine directory. :return: String specifying the full path to the settings.cfg file """ if sy...
python
def _user_config_file(): """ Returns the path to the settings.cfg file. On Windows the file is located in the AppData/Local/envipyengine directory. On Unix, the file will be located in the ~/.envipyengine directory. :return: String specifying the full path to the settings.cfg file """ if sy...
[ "def", "_user_config_file", "(", ")", ":", "if", "sys", ".", "platform", "==", "'win32'", ":", "if", "'LOCALAPPDATA'", "in", "os", ".", "environ", ":", "user_dir", "=", "os", ".", "getenv", "(", "'LOCALAPPDATA'", ")", "else", ":", "user_dir", "=", "os", ...
Returns the path to the settings.cfg file. On Windows the file is located in the AppData/Local/envipyengine directory. On Unix, the file will be located in the ~/.envipyengine directory. :return: String specifying the full path to the settings.cfg file
[ "Returns", "the", "path", "to", "the", "settings", ".", "cfg", "file", ".", "On", "Windows", "the", "file", "is", "located", "in", "the", "AppData", "/", "Local", "/", "envipyengine", "directory", ".", "On", "Unix", "the", "file", "will", "be", "located"...
567b639d6592deec3289f6122a9e3d18f2f98432
https://github.com/envi-idl/envipyengine/blob/567b639d6592deec3289f6122a9e3d18f2f98432/envipyengine/config.py#L78-L100
train
Returns the full path to the settings. cfg file.
envi-idl/envipyengine
envipyengine/config.py
_system_config_file
def _system_config_file(): """ Returns the path to the settings.cfg file. On Windows the file is located in the AppData/Local/envipyengine directory. On Unix, the file will be located in the ~/.envipyengine directory. :return: String specifying the full path to the settings.cfg file """ if ...
python
def _system_config_file(): """ Returns the path to the settings.cfg file. On Windows the file is located in the AppData/Local/envipyengine directory. On Unix, the file will be located in the ~/.envipyengine directory. :return: String specifying the full path to the settings.cfg file """ if ...
[ "def", "_system_config_file", "(", ")", ":", "if", "sys", ".", "platform", "==", "'win32'", ":", "config_path", "=", "os", ".", "path", ".", "sep", ".", "join", "(", "[", "_windows_system_appdata", "(", ")", ",", "_APP_DIRNAME", ",", "_CONFIG_FILENAME", "]...
Returns the path to the settings.cfg file. On Windows the file is located in the AppData/Local/envipyengine directory. On Unix, the file will be located in the ~/.envipyengine directory. :return: String specifying the full path to the settings.cfg file
[ "Returns", "the", "path", "to", "the", "settings", ".", "cfg", "file", ".", "On", "Windows", "the", "file", "is", "located", "in", "the", "AppData", "/", "Local", "/", "envipyengine", "directory", ".", "On", "Unix", "the", "file", "will", "be", "located"...
567b639d6592deec3289f6122a9e3d18f2f98432
https://github.com/envi-idl/envipyengine/blob/567b639d6592deec3289f6122a9e3d18f2f98432/envipyengine/config.py#L103-L121
train
Returns the full path to the system config file.
envi-idl/envipyengine
envipyengine/config.py
_windows_system_appdata
def _windows_system_appdata(): """ Return the path to the Windows Common App Data folder. On Windows 7, for example, this is C:\\ProgramData :return: String reprsentation the path to the Windows Common App Data folder """ # Could also use os.environ['ALLUSERSPROFILE'] - maybe? ...
python
def _windows_system_appdata(): """ Return the path to the Windows Common App Data folder. On Windows 7, for example, this is C:\\ProgramData :return: String reprsentation the path to the Windows Common App Data folder """ # Could also use os.environ['ALLUSERSPROFILE'] - maybe? ...
[ "def", "_windows_system_appdata", "(", ")", ":", "# Could also use os.environ['ALLUSERSPROFILE'] - maybe?", "csidl_common_appdata", "=", "35", "sh_get_folder_path", "=", "windll", ".", "shell32", ".", "SHGetFolderPathW", "sh_get_folder_path", ".", "argtypes", "=", "[", "win...
Return the path to the Windows Common App Data folder. On Windows 7, for example, this is C:\\ProgramData :return: String reprsentation the path to the Windows Common App Data folder
[ "Return", "the", "path", "to", "the", "Windows", "Common", "App", "Data", "folder", ".", "On", "Windows", "7", "for", "example", "this", "is", "C", ":", "\\\\", "ProgramData" ]
567b639d6592deec3289f6122a9e3d18f2f98432
https://github.com/envi-idl/envipyengine/blob/567b639d6592deec3289f6122a9e3d18f2f98432/envipyengine/config.py#L124-L142
train
Return the path to the Windows Common App Data folder.
envi-idl/envipyengine
envipyengine/config.py
_read_config
def _read_config(cfg_file): """ Return a ConfigParser object populated from the settings.cfg file. :return: A Config Parser object. """ config = ConfigParser() # maintain case of options config.optionxform = lambda option: option if not os.path.exists(cfg_file): # Create an empt...
python
def _read_config(cfg_file): """ Return a ConfigParser object populated from the settings.cfg file. :return: A Config Parser object. """ config = ConfigParser() # maintain case of options config.optionxform = lambda option: option if not os.path.exists(cfg_file): # Create an empt...
[ "def", "_read_config", "(", "cfg_file", ")", ":", "config", "=", "ConfigParser", "(", ")", "# maintain case of options", "config", ".", "optionxform", "=", "lambda", "option", ":", "option", "if", "not", "os", ".", "path", ".", "exists", "(", "cfg_file", ")"...
Return a ConfigParser object populated from the settings.cfg file. :return: A Config Parser object.
[ "Return", "a", "ConfigParser", "object", "populated", "from", "the", "settings", ".", "cfg", "file", "." ]
567b639d6592deec3289f6122a9e3d18f2f98432
https://github.com/envi-idl/envipyengine/blob/567b639d6592deec3289f6122a9e3d18f2f98432/envipyengine/config.py#L145-L160
train
Read the config file and return a ConfigParser object populated from the settings. cfg file.
envi-idl/envipyengine
envipyengine/config.py
_write_config
def _write_config(config, cfg_file): """ Write a config object to the settings.cfg file. :param config: A ConfigParser object to write to the settings.cfg file. """ directory = os.path.dirname(cfg_file) if not os.path.exists(directory): os.makedirs(directory) with open(cfg_file, "w+...
python
def _write_config(config, cfg_file): """ Write a config object to the settings.cfg file. :param config: A ConfigParser object to write to the settings.cfg file. """ directory = os.path.dirname(cfg_file) if not os.path.exists(directory): os.makedirs(directory) with open(cfg_file, "w+...
[ "def", "_write_config", "(", "config", ",", "cfg_file", ")", ":", "directory", "=", "os", ".", "path", ".", "dirname", "(", "cfg_file", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "directory", ")", ":", "os", ".", "makedirs", "(", "direc...
Write a config object to the settings.cfg file. :param config: A ConfigParser object to write to the settings.cfg file.
[ "Write", "a", "config", "object", "to", "the", "settings", ".", "cfg", "file", "." ]
567b639d6592deec3289f6122a9e3d18f2f98432
https://github.com/envi-idl/envipyengine/blob/567b639d6592deec3289f6122a9e3d18f2f98432/envipyengine/config.py#L163-L173
train
Write a ConfigParser object to the settings. cfg file.
envi-idl/envipyengine
envipyengine/config.py
get_environment
def get_environment(): """ Return all environment values from the config files. Values stored in the user configuration file will take precedence over values stored in the system configuration file. :return: A dictionary containing the name/value pairs of all environment settings in th...
python
def get_environment(): """ Return all environment values from the config files. Values stored in the user configuration file will take precedence over values stored in the system configuration file. :return: A dictionary containing the name/value pairs of all environment settings in th...
[ "def", "get_environment", "(", ")", ":", "section", "=", "_ENVIRONMENT_SECTION_NAME", "# Read system", "sys_cfg", "=", "_read_config", "(", "_SYSTEM_CONFIG_FILE", ")", "sys_env", "=", "dict", "(", "sys_cfg", ".", "items", "(", "section", ")", ")", "if", "sys_cfg...
Return all environment values from the config files. Values stored in the user configuration file will take precedence over values stored in the system configuration file. :return: A dictionary containing the name/value pairs of all environment settings in the config file.
[ "Return", "all", "environment", "values", "from", "the", "config", "files", ".", "Values", "stored", "in", "the", "user", "configuration", "file", "will", "take", "precedence", "over", "values", "stored", "in", "the", "system", "configuration", "file", "." ]
567b639d6592deec3289f6122a9e3d18f2f98432
https://github.com/envi-idl/envipyengine/blob/567b639d6592deec3289f6122a9e3d18f2f98432/envipyengine/config.py#L176-L199
train
Get all environment settings from the config files.
envi-idl/envipyengine
envipyengine/config.py
set_environment
def set_environment(environment, system=False): """ Set engine environment values in the config file. :param environment: A dictionary containing the environment variable settings as key/value pairs. :keyword system: Set to True to modify the system configuration file. ...
python
def set_environment(environment, system=False): """ Set engine environment values in the config file. :param environment: A dictionary containing the environment variable settings as key/value pairs. :keyword system: Set to True to modify the system configuration file. ...
[ "def", "set_environment", "(", "environment", ",", "system", "=", "False", ")", ":", "config_filename", "=", "_SYSTEM_CONFIG_FILE", "if", "system", "is", "True", "else", "_USER_CONFIG_FILE", "config", "=", "_read_config", "(", "config_filename", ")", "section", "=...
Set engine environment values in the config file. :param environment: A dictionary containing the environment variable settings as key/value pairs. :keyword system: Set to True to modify the system configuration file. If not set, the user config file will be modifie...
[ "Set", "engine", "environment", "values", "in", "the", "config", "file", "." ]
567b639d6592deec3289f6122a9e3d18f2f98432
https://github.com/envi-idl/envipyengine/blob/567b639d6592deec3289f6122a9e3d18f2f98432/envipyengine/config.py#L202-L218
train
Set the environment values in the config file.
envi-idl/envipyengine
envipyengine/config.py
remove_environment
def remove_environment(environment_var_name, system=False): """ Remove the specified environment setting from the appropriate config file. :param environment_var_name: The name of the environment setting to remove. :keyword system: Set to True to modify the system configuration file. ...
python
def remove_environment(environment_var_name, system=False): """ Remove the specified environment setting from the appropriate config file. :param environment_var_name: The name of the environment setting to remove. :keyword system: Set to True to modify the system configuration file. ...
[ "def", "remove_environment", "(", "environment_var_name", ",", "system", "=", "False", ")", ":", "config_filename", "=", "_SYSTEM_CONFIG_FILE", "if", "system", "is", "True", "else", "_USER_CONFIG_FILE", "config", "=", "_read_config", "(", "config_filename", ")", "se...
Remove the specified environment setting from the appropriate config file. :param environment_var_name: The name of the environment setting to remove. :keyword system: Set to True to modify the system configuration file. If not set, the user config file will be modified.
[ "Remove", "the", "specified", "environment", "setting", "from", "the", "appropriate", "config", "file", "." ]
567b639d6592deec3289f6122a9e3d18f2f98432
https://github.com/envi-idl/envipyengine/blob/567b639d6592deec3289f6122a9e3d18f2f98432/envipyengine/config.py#L221-L235
train
Removes the specified environment setting from the appropriate config file.
envi-idl/envipyengine
envipyengine/config.py
get
def get(property_name): """ Returns the value of the specified configuration property. Property values stored in the user configuration file take precedence over values stored in the system configuration file. :param property_name: The name of the property to retrieve. :return: The value of...
python
def get(property_name): """ Returns the value of the specified configuration property. Property values stored in the user configuration file take precedence over values stored in the system configuration file. :param property_name: The name of the property to retrieve. :return: The value of...
[ "def", "get", "(", "property_name", ")", ":", "config", "=", "_read_config", "(", "_USER_CONFIG_FILE", ")", "section", "=", "_MAIN_SECTION_NAME", "try", ":", "property_value", "=", "config", ".", "get", "(", "section", ",", "property_name", ")", "except", "(",...
Returns the value of the specified configuration property. Property values stored in the user configuration file take precedence over values stored in the system configuration file. :param property_name: The name of the property to retrieve. :return: The value of the property.
[ "Returns", "the", "value", "of", "the", "specified", "configuration", "property", ".", "Property", "values", "stored", "in", "the", "user", "configuration", "file", "take", "precedence", "over", "values", "stored", "in", "the", "system", "configuration", "file", ...
567b639d6592deec3289f6122a9e3d18f2f98432
https://github.com/envi-idl/envipyengine/blob/567b639d6592deec3289f6122a9e3d18f2f98432/envipyengine/config.py#L238-L261
train
Retrieves the value of the specified configuration property.
envi-idl/envipyengine
envipyengine/config.py
set
def set(property_name, value, system=False): """ Sets the configuration property to the specified value. :param property_name: The name of the property to set. :param value: The value for the property. :keyword system: Set to True to modify the system configuration file. If not...
python
def set(property_name, value, system=False): """ Sets the configuration property to the specified value. :param property_name: The name of the property to set. :param value: The value for the property. :keyword system: Set to True to modify the system configuration file. If not...
[ "def", "set", "(", "property_name", ",", "value", ",", "system", "=", "False", ")", ":", "config_filename", "=", "_SYSTEM_CONFIG_FILE", "if", "system", "is", "True", "else", "_USER_CONFIG_FILE", "config", "=", "_read_config", "(", "config_filename", ")", "sectio...
Sets the configuration property to the specified value. :param property_name: The name of the property to set. :param value: The value for the property. :keyword system: Set to True to modify the system configuration file. If not set, the user config file will be modified.
[ "Sets", "the", "configuration", "property", "to", "the", "specified", "value", "." ]
567b639d6592deec3289f6122a9e3d18f2f98432
https://github.com/envi-idl/envipyengine/blob/567b639d6592deec3289f6122a9e3d18f2f98432/envipyengine/config.py#L264-L279
train
Sets the value of a configuration property in the current configuration file.
envi-idl/envipyengine
envipyengine/config.py
remove
def remove(property_name, system=False): """ Remove a configuration property/value setting from the config file. :param property_name: The name of the property to remove. :keyword system: Set to True to modify the system configuration file. If not set, the user config file will be ...
python
def remove(property_name, system=False): """ Remove a configuration property/value setting from the config file. :param property_name: The name of the property to remove. :keyword system: Set to True to modify the system configuration file. If not set, the user config file will be ...
[ "def", "remove", "(", "property_name", ",", "system", "=", "False", ")", ":", "config_filename", "=", "_SYSTEM_CONFIG_FILE", "if", "system", "is", "True", "else", "_USER_CONFIG_FILE", "config", "=", "_read_config", "(", "config_filename", ")", "section", "=", "_...
Remove a configuration property/value setting from the config file. :param property_name: The name of the property to remove. :keyword system: Set to True to modify the system configuration file. If not set, the user config file will be modified.
[ "Remove", "a", "configuration", "property", "/", "value", "setting", "from", "the", "config", "file", "." ]
567b639d6592deec3289f6122a9e3d18f2f98432
https://github.com/envi-idl/envipyengine/blob/567b639d6592deec3289f6122a9e3d18f2f98432/envipyengine/config.py#L282-L296
train
Removes a configuration property value setting from the config file.
gergelypolonkai/flask-logging-extras
flask_logging_extras/__init__.py
FlaskExtraLoggerFormatter.init_app
def init_app(self, app): """Initialise the formatter with app-specific values from ``app``’s configuration """ if self.__inited: return config = app.config.get( 'FLASK_LOGGING_EXTRAS', {}) blueprint_config = config.get('BLUEPRINT', {}) self.bp_v...
python
def init_app(self, app): """Initialise the formatter with app-specific values from ``app``’s configuration """ if self.__inited: return config = app.config.get( 'FLASK_LOGGING_EXTRAS', {}) blueprint_config = config.get('BLUEPRINT', {}) self.bp_v...
[ "def", "init_app", "(", "self", ",", "app", ")", ":", "if", "self", ".", "__inited", ":", "return", "config", "=", "app", ".", "config", ".", "get", "(", "'FLASK_LOGGING_EXTRAS'", ",", "{", "}", ")", "blueprint_config", "=", "config", ".", "get", "(", ...
Initialise the formatter with app-specific values from ``app``’s configuration
[ "Initialise", "the", "formatter", "with", "app", "-", "specific", "values", "from", "app", "’s", "configuration" ]
0da9bcef66efd2f8a09d9adc6f27014b6390a6bf
https://github.com/gergelypolonkai/flask-logging-extras/blob/0da9bcef66efd2f8a09d9adc6f27014b6390a6bf/flask_logging_extras/__init__.py#L153-L179
train
Initialise the formatter with app - specific values from app s configuration.
bigdatacesga/service-discovery
consul.py
Client.register
def register(self, id, name, address, port=None, tags=None, check=None): """Register a new service with the local consul agent""" service = {} service['ID'] = id service['Name'] = name service['Address'] = address if port: service['Port'] = int(port) i...
python
def register(self, id, name, address, port=None, tags=None, check=None): """Register a new service with the local consul agent""" service = {} service['ID'] = id service['Name'] = name service['Address'] = address if port: service['Port'] = int(port) i...
[ "def", "register", "(", "self", ",", "id", ",", "name", ",", "address", ",", "port", "=", "None", ",", "tags", "=", "None", ",", "check", "=", "None", ")", ":", "service", "=", "{", "}", "service", "[", "'ID'", "]", "=", "id", "service", "[", "...
Register a new service with the local consul agent
[ "Register", "a", "new", "service", "with", "the", "local", "consul", "agent" ]
5298d68e4dbe7b23848c95a6f75b9d469fb29e4a
https://github.com/bigdatacesga/service-discovery/blob/5298d68e4dbe7b23848c95a6f75b9d469fb29e4a/consul.py#L88-L104
train
Register a new service with the local consul agent
bigdatacesga/service-discovery
consul.py
Client.deregister
def deregister(self, id): """Deregister a service with the local consul agent""" r = requests.put('{}/{}'.format(self.url_deregister, id)) if r.status_code != 200: raise consulDeregistrationError( 'PUT returned {}'.format(r.status_code)) return r
python
def deregister(self, id): """Deregister a service with the local consul agent""" r = requests.put('{}/{}'.format(self.url_deregister, id)) if r.status_code != 200: raise consulDeregistrationError( 'PUT returned {}'.format(r.status_code)) return r
[ "def", "deregister", "(", "self", ",", "id", ")", ":", "r", "=", "requests", ".", "put", "(", "'{}/{}'", ".", "format", "(", "self", ".", "url_deregister", ",", "id", ")", ")", "if", "r", ".", "status_code", "!=", "200", ":", "raise", "consulDeregist...
Deregister a service with the local consul agent
[ "Deregister", "a", "service", "with", "the", "local", "consul", "agent" ]
5298d68e4dbe7b23848c95a6f75b9d469fb29e4a
https://github.com/bigdatacesga/service-discovery/blob/5298d68e4dbe7b23848c95a6f75b9d469fb29e4a/consul.py#L106-L112
train
Deregister a service with the local consul agent
bigdatacesga/service-discovery
consul.py
Client.info
def info(self, name): """Info about a given service""" r = requests.get('{}/{}'.format(self.url_service, name)) return r.json()
python
def info(self, name): """Info about a given service""" r = requests.get('{}/{}'.format(self.url_service, name)) return r.json()
[ "def", "info", "(", "self", ",", "name", ")", ":", "r", "=", "requests", ".", "get", "(", "'{}/{}'", ".", "format", "(", "self", ".", "url_service", ",", "name", ")", ")", "return", "r", ".", "json", "(", ")" ]
Info about a given service
[ "Info", "about", "a", "given", "service" ]
5298d68e4dbe7b23848c95a6f75b9d469fb29e4a
https://github.com/bigdatacesga/service-discovery/blob/5298d68e4dbe7b23848c95a6f75b9d469fb29e4a/consul.py#L119-L122
train
Get information about a given service
ariebovenberg/snug
tutorial/relations.py
repo.star
def star(self) -> snug.Query[bool]: """star this repo""" req = snug.PUT(BASE + f'/user/starred/{self.owner}/{self.name}') return (yield req).status_code == 204
python
def star(self) -> snug.Query[bool]: """star this repo""" req = snug.PUT(BASE + f'/user/starred/{self.owner}/{self.name}') return (yield req).status_code == 204
[ "def", "star", "(", "self", ")", "->", "snug", ".", "Query", "[", "bool", "]", ":", "req", "=", "snug", ".", "PUT", "(", "BASE", "+", "f'/user/starred/{self.owner}/{self.name}'", ")", "return", "(", "yield", "req", ")", ".", "status_code", "==", "204" ]
star this repo
[ "star", "this", "repo" ]
4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef
https://github.com/ariebovenberg/snug/blob/4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef/tutorial/relations.py#L15-L18
train
star this repo
Godley/MuseParse
MuseParse/classes/ObjectHierarchy/TreeClasses/PieceTree.py
PieceTree.toLily
def toLily(self): ''' Method which converts the object instance, its attributes and children to a string of lilypond code :return: str of lilypond code ''' lilystring = "\\version \"2.18.2\" \n" partstrings = [] ids_loaded = [] groupings = [] if ...
python
def toLily(self): ''' Method which converts the object instance, its attributes and children to a string of lilypond code :return: str of lilypond code ''' lilystring = "\\version \"2.18.2\" \n" partstrings = [] ids_loaded = [] groupings = [] if ...
[ "def", "toLily", "(", "self", ")", ":", "lilystring", "=", "\"\\\\version \\\"2.18.2\\\" \\n\"", "partstrings", "=", "[", "]", "ids_loaded", "=", "[", "]", "groupings", "=", "[", "]", "if", "len", "(", "self", ".", "groups", ")", ">", "0", ":", "# here w...
Method which converts the object instance, its attributes and children to a string of lilypond code :return: str of lilypond code
[ "Method", "which", "converts", "the", "object", "instance", "its", "attributes", "and", "children", "to", "a", "string", "of", "lilypond", "code" ]
23cecafa1fdc0f2d6a87760553572b459f3c9904
https://github.com/Godley/MuseParse/blob/23cecafa1fdc0f2d6a87760553572b459f3c9904/MuseParse/classes/ObjectHierarchy/TreeClasses/PieceTree.py#L131-L158
train
Method which converts the object instance its attributes and children to a string of lilypond code.
pyros-dev/pyzmp
setup.py
PublishCommand.run
def run(self): """runner""" subprocess.check_call("python setup.py sdist", shell=True) subprocess.check_call("python setup.py bdist_wheel", shell=True) # OLD way: # os.system("python setup.py sdist bdist_wheel upload") # NEW way: # Ref: https://packaging.python.o...
python
def run(self): """runner""" subprocess.check_call("python setup.py sdist", shell=True) subprocess.check_call("python setup.py bdist_wheel", shell=True) # OLD way: # os.system("python setup.py sdist bdist_wheel upload") # NEW way: # Ref: https://packaging.python.o...
[ "def", "run", "(", "self", ")", ":", "subprocess", ".", "check_call", "(", "\"python setup.py sdist\"", ",", "shell", "=", "True", ")", "subprocess", ".", "check_call", "(", "\"python setup.py bdist_wheel\"", ",", "shell", "=", "True", ")", "# OLD way:", "# os.s...
runner
[ "runner" ]
fac0b719b25996ce94a80ca2118f3eba5779d53d
https://github.com/pyros-dev/pyzmp/blob/fac0b719b25996ce94a80ca2118f3eba5779d53d/setup.py#L69-L82
train
run the command line
pyros-dev/pyzmp
setup.py
RosDevelopCommand.run
def run(self): # dynamic import for this command only to not need these in usual python case... import git import yaml """runner""" repo_path = tempfile.mkdtemp(prefix='rosdevelop-' + os.path.dirname(__file__)) # TODO get actual package name ? print("Getting ROS release...
python
def run(self): # dynamic import for this command only to not need these in usual python case... import git import yaml """runner""" repo_path = tempfile.mkdtemp(prefix='rosdevelop-' + os.path.dirname(__file__)) # TODO get actual package name ? print("Getting ROS release...
[ "def", "run", "(", "self", ")", ":", "# dynamic import for this command only to not need these in usual python case...", "import", "git", "import", "yaml", "repo_path", "=", "tempfile", ".", "mkdtemp", "(", "prefix", "=", "'rosdevelop-'", "+", "os", ".", "path", ".", ...
runner
[ "runner" ]
fac0b719b25996ce94a80ca2118f3eba5779d53d
https://github.com/pyros-dev/pyzmp/blob/fac0b719b25996ce94a80ca2118f3eba5779d53d/setup.py#L102-L159
train
Run the command.
eclipse/unide.python
src/unide/message.py
device_message
def device_message(device, code, ts=None, origin=None, type=None, severity=None, title=None, description=None, hint=None, **metaData): # pylint: ...
python
def device_message(device, code, ts=None, origin=None, type=None, severity=None, title=None, description=None, hint=None, **metaData): # pylint: ...
[ "def", "device_message", "(", "device", ",", "code", ",", "ts", "=", "None", ",", "origin", "=", "None", ",", "type", "=", "None", ",", "severity", "=", "None", ",", "title", "=", "None", ",", "description", "=", "None", ",", "hint", "=", "None", "...
This quickly builds a time-stamped message. If `ts` is None, the current time is used.
[ "This", "quickly", "builds", "a", "time", "-", "stamped", "message", ".", "If", "ts", "is", "None", "the", "current", "time", "is", "used", "." ]
b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493
https://github.com/eclipse/unide.python/blob/b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493/src/unide/message.py#L120-L148
train
Builds a message from a device.
MacHu-GWU/single_file_module-project
sfm/obj_file_io.py
_dump
def _dump(obj, abspath, serializer_type, dumper_func=None, compress=True, overwrite=False, verbose=False, **kwargs): """Dump object to file. :param abspath: The file path you want dump to. :type abspath: str :param serializer_type: 'binary' or 'str'. ...
python
def _dump(obj, abspath, serializer_type, dumper_func=None, compress=True, overwrite=False, verbose=False, **kwargs): """Dump object to file. :param abspath: The file path you want dump to. :type abspath: str :param serializer_type: 'binary' or 'str'. ...
[ "def", "_dump", "(", "obj", ",", "abspath", ",", "serializer_type", ",", "dumper_func", "=", "None", ",", "compress", "=", "True", ",", "overwrite", "=", "False", ",", "verbose", "=", "False", ",", "*", "*", "kwargs", ")", ":", "_check_serializer_type", ...
Dump object to file. :param abspath: The file path you want dump to. :type abspath: str :param serializer_type: 'binary' or 'str'. :type serializer_type: str :param dumper_func: A dumper function that takes an object as input, return binary or string. :type dumper_func: callable funct...
[ "Dump", "object", "to", "file", "." ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/obj_file_io.py#L80-L145
train
Dump object to file.
MacHu-GWU/single_file_module-project
sfm/obj_file_io.py
_load
def _load(abspath, serializer_type, loader_func=None, decompress=True, verbose=False, **kwargs): """load object from file. :param abspath: The file path you want load from. :type abspath: str :param serializer_type: 'binary' or 'str'. :type serializer_type: ...
python
def _load(abspath, serializer_type, loader_func=None, decompress=True, verbose=False, **kwargs): """load object from file. :param abspath: The file path you want load from. :type abspath: str :param serializer_type: 'binary' or 'str'. :type serializer_type: ...
[ "def", "_load", "(", "abspath", ",", "serializer_type", ",", "loader_func", "=", "None", ",", "decompress", "=", "True", ",", "verbose", "=", "False", ",", "*", "*", "kwargs", ")", ":", "_check_serializer_type", "(", "serializer_type", ")", "if", "not", "i...
load object from file. :param abspath: The file path you want load from. :type abspath: str :param serializer_type: 'binary' or 'str'. :type serializer_type: str :param loader_func: A loader function that takes binary as input, return an object. :type loader_func: callable function ...
[ "load", "object", "from", "file", "." ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/obj_file_io.py#L148-L196
train
Load object from file.
MacHu-GWU/single_file_module-project
sfm/obj_file_io.py
dump_func
def dump_func(serializer_type): """A decorator for ``_dump(dumper_func=dumper_func, **kwargs)`` """ def outer_wrapper(dumper_func): def wrapper(*args, **kwargs): return _dump( *args, dumper_func=dumper_func, serializer_type=serializer_type, ...
python
def dump_func(serializer_type): """A decorator for ``_dump(dumper_func=dumper_func, **kwargs)`` """ def outer_wrapper(dumper_func): def wrapper(*args, **kwargs): return _dump( *args, dumper_func=dumper_func, serializer_type=serializer_type, ...
[ "def", "dump_func", "(", "serializer_type", ")", ":", "def", "outer_wrapper", "(", "dumper_func", ")", ":", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "_dump", "(", "*", "args", ",", "dumper_func", "=", "dumper_func"...
A decorator for ``_dump(dumper_func=dumper_func, **kwargs)``
[ "A", "decorator", "for", "_dump", "(", "dumper_func", "=", "dumper_func", "**", "kwargs", ")" ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/obj_file_io.py#L199-L213
train
A decorator for _dump
MacHu-GWU/single_file_module-project
sfm/obj_file_io.py
load_func
def load_func(serializer_type): """A decorator for ``_load(loader_func=loader_func, **kwargs)`` """ def outer_wrapper(loader_func): def wrapper(*args, **kwargs): return _load( *args, loader_func=loader_func, serializer_type=serializer_type, ...
python
def load_func(serializer_type): """A decorator for ``_load(loader_func=loader_func, **kwargs)`` """ def outer_wrapper(loader_func): def wrapper(*args, **kwargs): return _load( *args, loader_func=loader_func, serializer_type=serializer_type, ...
[ "def", "load_func", "(", "serializer_type", ")", ":", "def", "outer_wrapper", "(", "loader_func", ")", ":", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "_load", "(", "*", "args", ",", "loader_func", "=", "loader_func"...
A decorator for ``_load(loader_func=loader_func, **kwargs)``
[ "A", "decorator", "for", "_load", "(", "loader_func", "=", "loader_func", "**", "kwargs", ")" ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/obj_file_io.py#L216-L230
train
A decorator for _load
Pythonity/python-ivona-api
ivona_api/ivona_api.py
IvonaAPI._get_response
def _get_response(self, method, endpoint, data=None): """ Helper method for wrapping API requests, mainly for catching errors in one place. :param method: valid HTTP method :type method: str :param endpoint: API endpoint :type endpoint: str :param data: e...
python
def _get_response(self, method, endpoint, data=None): """ Helper method for wrapping API requests, mainly for catching errors in one place. :param method: valid HTTP method :type method: str :param endpoint: API endpoint :type endpoint: str :param data: e...
[ "def", "_get_response", "(", "self", ",", "method", ",", "endpoint", ",", "data", "=", "None", ")", ":", "url", "=", "urljoin", "(", "IVONA_REGION_ENDPOINTS", "[", "self", ".", "region", "]", ",", "endpoint", ")", "response", "=", "getattr", "(", "self",...
Helper method for wrapping API requests, mainly for catching errors in one place. :param method: valid HTTP method :type method: str :param endpoint: API endpoint :type endpoint: str :param data: extra parameters passed with the request :type data: dict :...
[ "Helper", "method", "for", "wrapping", "API", "requests", "mainly", "for", "catching", "errors", "in", "one", "place", "." ]
490a2e502d4aa769b9f41603eb5d5e5ebf1ea912
https://github.com/Pythonity/python-ivona-api/blob/490a2e502d4aa769b9f41603eb5d5e5ebf1ea912/ivona_api/ivona_api.py#L88-L116
train
Wrapper method for wrapping API requests.
Pythonity/python-ivona-api
ivona_api/ivona_api.py
IvonaAPI.get_available_voices
def get_available_voices(self, language=None, gender=None): """ Returns a list of available voices, via 'ListVoices' endpoint Docs: http://developer.ivona.com/en/speechcloud/actions.html#ListVoices :param language: returned voices language :type language: str ...
python
def get_available_voices(self, language=None, gender=None): """ Returns a list of available voices, via 'ListVoices' endpoint Docs: http://developer.ivona.com/en/speechcloud/actions.html#ListVoices :param language: returned voices language :type language: str ...
[ "def", "get_available_voices", "(", "self", ",", "language", "=", "None", ",", "gender", "=", "None", ")", ":", "endpoint", "=", "'ListVoices'", "data", "=", "dict", "(", ")", "if", "language", ":", "data", ".", "update", "(", "{", "'Voice'", ":", "{",...
Returns a list of available voices, via 'ListVoices' endpoint Docs: http://developer.ivona.com/en/speechcloud/actions.html#ListVoices :param language: returned voices language :type language: str :param gender: returned voices gender :type gender: str
[ "Returns", "a", "list", "of", "available", "voices", "via", "ListVoices", "endpoint" ]
490a2e502d4aa769b9f41603eb5d5e5ebf1ea912
https://github.com/Pythonity/python-ivona-api/blob/490a2e502d4aa769b9f41603eb5d5e5ebf1ea912/ivona_api/ivona_api.py#L118-L143
train
Returns a list of available voices via ListVoices endpoint
Pythonity/python-ivona-api
ivona_api/ivona_api.py
IvonaAPI.text_to_speech
def text_to_speech(self, text, file, voice_name=None, language=None): """ Saves given text synthesized audio file, via 'CreateSpeech' endpoint Docs: http://developer.ivona.com/en/speechcloud/actions.html#CreateSpeech :param text: text to synthesize :type text: str ...
python
def text_to_speech(self, text, file, voice_name=None, language=None): """ Saves given text synthesized audio file, via 'CreateSpeech' endpoint Docs: http://developer.ivona.com/en/speechcloud/actions.html#CreateSpeech :param text: text to synthesize :type text: str ...
[ "def", "text_to_speech", "(", "self", ",", "text", ",", "file", ",", "voice_name", "=", "None", ",", "language", "=", "None", ")", ":", "endpoint", "=", "'CreateSpeech'", "data", "=", "{", "'Input'", ":", "{", "'Data'", ":", "text", ",", "}", ",", "'...
Saves given text synthesized audio file, via 'CreateSpeech' endpoint Docs: http://developer.ivona.com/en/speechcloud/actions.html#CreateSpeech :param text: text to synthesize :type text: str :param file: file that will be used to save the audio :type file: file ...
[ "Saves", "given", "text", "synthesized", "audio", "file", "via", "CreateSpeech", "endpoint" ]
490a2e502d4aa769b9f41603eb5d5e5ebf1ea912
https://github.com/Pythonity/python-ivona-api/blob/490a2e502d4aa769b9f41603eb5d5e5ebf1ea912/ivona_api/ivona_api.py#L145-L184
train
Saves given text synthesized audio file via CreateSpeech endpoint
configcat/python-sdk
configcatclient/__init__.py
create_client_with_auto_poll
def create_client_with_auto_poll(api_key, poll_interval_seconds=60, max_init_wait_time_seconds=5, on_configuration_changed_callback=None, config_cache_class=None, base_url=None): """ Create an instance of ConfigCatClient and setup Auto Poll mode ...
python
def create_client_with_auto_poll(api_key, poll_interval_seconds=60, max_init_wait_time_seconds=5, on_configuration_changed_callback=None, config_cache_class=None, base_url=None): """ Create an instance of ConfigCatClient and setup Auto Poll mode ...
[ "def", "create_client_with_auto_poll", "(", "api_key", ",", "poll_interval_seconds", "=", "60", ",", "max_init_wait_time_seconds", "=", "5", ",", "on_configuration_changed_callback", "=", "None", ",", "config_cache_class", "=", "None", ",", "base_url", "=", "None", ")...
Create an instance of ConfigCatClient and setup Auto Poll mode with custom options :param api_key: ConfigCat ApiKey to access your configuration. :param poll_interval_seconds: The client's poll interval in seconds. Default: 60 seconds. :param on_configuration_changed_callback: You can subscribe to configur...
[ "Create", "an", "instance", "of", "ConfigCatClient", "and", "setup", "Auto", "Poll", "mode", "with", "custom", "options" ]
7a893c7958d928276ca02c00d5239987a1acb8d6
https://github.com/configcat/python-sdk/blob/7a893c7958d928276ca02c00d5239987a1acb8d6/configcatclient/__init__.py#L14-L39
train
Create an instance of ConfigCatClient with custom options
configcat/python-sdk
configcatclient/__init__.py
create_client_with_lazy_load
def create_client_with_lazy_load(api_key, cache_time_to_live_seconds=60, config_cache_class=None, base_url=None): """ Create an instance of ConfigCatClient and setup Lazy Load mode with custom options :param api_key: ConfigCat ApiKey to access your configuration. :param...
python
def create_client_with_lazy_load(api_key, cache_time_to_live_seconds=60, config_cache_class=None, base_url=None): """ Create an instance of ConfigCatClient and setup Lazy Load mode with custom options :param api_key: ConfigCat ApiKey to access your configuration. :param...
[ "def", "create_client_with_lazy_load", "(", "api_key", ",", "cache_time_to_live_seconds", "=", "60", ",", "config_cache_class", "=", "None", ",", "base_url", "=", "None", ")", ":", "if", "api_key", "is", "None", ":", "raise", "ConfigCatClientException", "(", "'API...
Create an instance of ConfigCatClient and setup Lazy Load mode with custom options :param api_key: ConfigCat ApiKey to access your configuration. :param cache_time_to_live_seconds: The cache TTL. :param config_cache_class: If you want to use custom caching instead of the client's default InMemoryConfigCach...
[ "Create", "an", "instance", "of", "ConfigCatClient", "and", "setup", "Lazy", "Load", "mode", "with", "custom", "options" ]
7a893c7958d928276ca02c00d5239987a1acb8d6
https://github.com/configcat/python-sdk/blob/7a893c7958d928276ca02c00d5239987a1acb8d6/configcatclient/__init__.py#L42-L60
train
Create an instance of ConfigCatClient and setup Lazy Load mode with custom options.
configcat/python-sdk
configcatclient/__init__.py
create_client_with_manual_poll
def create_client_with_manual_poll(api_key, config_cache_class=None, base_url=None): """ Create an instance of ConfigCatClient and setup Manual Poll mode with custom options :param api_key: ConfigCat ApiKey to access your configuration. :param config_cache_class: If y...
python
def create_client_with_manual_poll(api_key, config_cache_class=None, base_url=None): """ Create an instance of ConfigCatClient and setup Manual Poll mode with custom options :param api_key: ConfigCat ApiKey to access your configuration. :param config_cache_class: If y...
[ "def", "create_client_with_manual_poll", "(", "api_key", ",", "config_cache_class", "=", "None", ",", "base_url", "=", "None", ")", ":", "if", "api_key", "is", "None", ":", "raise", "ConfigCatClientException", "(", "'API Key is required.'", ")", "return", "ConfigCat...
Create an instance of ConfigCatClient and setup Manual Poll mode with custom options :param api_key: ConfigCat ApiKey to access your configuration. :param config_cache_class: If you want to use custom caching instead of the client's default InMemoryConfigCache, You can provide an implementation of ConfigCa...
[ "Create", "an", "instance", "of", "ConfigCatClient", "and", "setup", "Manual", "Poll", "mode", "with", "custom", "options" ]
7a893c7958d928276ca02c00d5239987a1acb8d6
https://github.com/configcat/python-sdk/blob/7a893c7958d928276ca02c00d5239987a1acb8d6/configcatclient/__init__.py#L63-L77
train
Create an instance of ConfigCatClient and setup Manual Poll mode with custom options.
ariebovenberg/snug
examples/ns/query.py
prepare_params
def prepare_params(req: snug.Request) -> snug.Request: """prepare request parameters""" return req.replace( params={key: dump_param(val) for key, val in req.params.items() if val is not None})
python
def prepare_params(req: snug.Request) -> snug.Request: """prepare request parameters""" return req.replace( params={key: dump_param(val) for key, val in req.params.items() if val is not None})
[ "def", "prepare_params", "(", "req", ":", "snug", ".", "Request", ")", "->", "snug", ".", "Request", ":", "return", "req", ".", "replace", "(", "params", "=", "{", "key", ":", "dump_param", "(", "val", ")", "for", "key", ",", "val", "in", "req", "....
prepare request parameters
[ "prepare", "request", "parameters" ]
4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef
https://github.com/ariebovenberg/snug/blob/4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef/examples/ns/query.py#L36-L40
train
prepare request parameters
ariebovenberg/snug
examples/ns/query.py
basic_query
def basic_query(returns): """decorator factory for NS queries""" return compose( reusable, map_send(parse_request), map_yield(prepare_params, snug.prefix_adder(API_PREFIX)), map_return(loads(returns)), oneyield, )
python
def basic_query(returns): """decorator factory for NS queries""" return compose( reusable, map_send(parse_request), map_yield(prepare_params, snug.prefix_adder(API_PREFIX)), map_return(loads(returns)), oneyield, )
[ "def", "basic_query", "(", "returns", ")", ":", "return", "compose", "(", "reusable", ",", "map_send", "(", "parse_request", ")", ",", "map_yield", "(", "prepare_params", ",", "snug", ".", "prefix_adder", "(", "API_PREFIX", ")", ")", ",", "map_return", "(", ...
decorator factory for NS queries
[ "decorator", "factory", "for", "NS", "queries" ]
4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef
https://github.com/ariebovenberg/snug/blob/4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef/examples/ns/query.py#L43-L51
train
decorator factory for NS queries
ariebovenberg/snug
examples/ns/query.py
departures
def departures(station: str) -> snug.Query[t.List[Departure]]: """departures for a station""" return snug.GET('avt', params={'station': station})
python
def departures(station: str) -> snug.Query[t.List[Departure]]: """departures for a station""" return snug.GET('avt', params={'station': station})
[ "def", "departures", "(", "station", ":", "str", ")", "->", "snug", ".", "Query", "[", "t", ".", "List", "[", "Departure", "]", "]", ":", "return", "snug", ".", "GET", "(", "'avt'", ",", "params", "=", "{", "'station'", ":", "station", "}", ")" ]
departures for a station
[ "departures", "for", "a", "station" ]
4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef
https://github.com/ariebovenberg/snug/blob/4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef/examples/ns/query.py#L61-L63
train
get departures for a station
ariebovenberg/snug
examples/ns/query.py
journey_options
def journey_options(origin: str, destination: str, via: t.Optional[str]=None, before: t.Optional[int]=None, after: t.Optional[int]=None, time: t.Optional[datetime]=None, ...
python
def journey_options(origin: str, destination: str, via: t.Optional[str]=None, before: t.Optional[int]=None, after: t.Optional[int]=None, time: t.Optional[datetime]=None, ...
[ "def", "journey_options", "(", "origin", ":", "str", ",", "destination", ":", "str", ",", "via", ":", "t", ".", "Optional", "[", "str", "]", "=", "None", ",", "before", ":", "t", ".", "Optional", "[", "int", "]", "=", "None", ",", "after", ":", "...
journey recommendations from an origin to a destination station
[ "journey", "recommendations", "from", "an", "origin", "to", "a", "destination", "station" ]
4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef
https://github.com/ariebovenberg/snug/blob/4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef/examples/ns/query.py#L67-L86
train
Returns a list of journey recommendations from an origin to a destination station
MacHu-GWU/single_file_module-project
sfm/rnd.py
rand_str
def rand_str(length, allowed=CHARSET_ALPHA_DIGITS): """Generate fixed-length random string from your allowed character pool. :param length: total length of this string. :param allowed: allowed charset. Example:: >>> import string >>> rand_str(32) H6ExQPNLzb4Vp3YZtfpyzLNPFwdfnw...
python
def rand_str(length, allowed=CHARSET_ALPHA_DIGITS): """Generate fixed-length random string from your allowed character pool. :param length: total length of this string. :param allowed: allowed charset. Example:: >>> import string >>> rand_str(32) H6ExQPNLzb4Vp3YZtfpyzLNPFwdfnw...
[ "def", "rand_str", "(", "length", ",", "allowed", "=", "CHARSET_ALPHA_DIGITS", ")", ":", "res", "=", "list", "(", ")", "for", "_", "in", "range", "(", "length", ")", ":", "res", ".", "append", "(", "random", ".", "choice", "(", "allowed", ")", ")", ...
Generate fixed-length random string from your allowed character pool. :param length: total length of this string. :param allowed: allowed charset. Example:: >>> import string >>> rand_str(32) H6ExQPNLzb4Vp3YZtfpyzLNPFwdfnwz6
[ "Generate", "fixed", "-", "length", "random", "string", "from", "your", "allowed", "character", "pool", "." ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/rnd.py#L25-L40
train
Generate a fixed - length random string from your allowed character pool.
MacHu-GWU/single_file_module-project
sfm/rnd.py
rand_hexstr
def rand_hexstr(length, lower=True): """Gererate fixed-length random hexstring, usually for md5. :param length: total length of this string. :param lower: use lower case or upper case. """ if lower: return rand_str(length, allowed=CHARSET_HEXSTR_LOWER) else: return rand_str(leng...
python
def rand_hexstr(length, lower=True): """Gererate fixed-length random hexstring, usually for md5. :param length: total length of this string. :param lower: use lower case or upper case. """ if lower: return rand_str(length, allowed=CHARSET_HEXSTR_LOWER) else: return rand_str(leng...
[ "def", "rand_hexstr", "(", "length", ",", "lower", "=", "True", ")", ":", "if", "lower", ":", "return", "rand_str", "(", "length", ",", "allowed", "=", "CHARSET_HEXSTR_LOWER", ")", "else", ":", "return", "rand_str", "(", "length", ",", "allowed", "=", "C...
Gererate fixed-length random hexstring, usually for md5. :param length: total length of this string. :param lower: use lower case or upper case.
[ "Gererate", "fixed", "-", "length", "random", "hexstring", "usually", "for", "md5", "." ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/rnd.py#L43-L52
train
Gererate fixed - length random hexstring usually for md5.
MacHu-GWU/single_file_module-project
sfm/rnd.py
rand_alphastr
def rand_alphastr(length, lower=True, upper=True): """Generate fixed-length random alpha only string. """ if lower is True and upper is True: return rand_str(length, allowed=string.ascii_letters) if lower is True and upper is False: return rand_str(length, allowed=string.ascii_lowercase)...
python
def rand_alphastr(length, lower=True, upper=True): """Generate fixed-length random alpha only string. """ if lower is True and upper is True: return rand_str(length, allowed=string.ascii_letters) if lower is True and upper is False: return rand_str(length, allowed=string.ascii_lowercase)...
[ "def", "rand_alphastr", "(", "length", ",", "lower", "=", "True", ",", "upper", "=", "True", ")", ":", "if", "lower", "is", "True", "and", "upper", "is", "True", ":", "return", "rand_str", "(", "length", ",", "allowed", "=", "string", ".", "ascii_lette...
Generate fixed-length random alpha only string.
[ "Generate", "fixed", "-", "length", "random", "alpha", "only", "string", "." ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/rnd.py#L55-L65
train
Generate fixed - length random alpha only string.
MacHu-GWU/single_file_module-project
sfm/rnd.py
rand_phone
def rand_phone(): """Random US phone number. (10 digits) Example:: >>> rand_phone() (306)-746-6690 """ return "(%s)-%s-%s" % (rand_str(3, string.digits), rand_str(3, string.digits), rand_str(3, string.digits))
python
def rand_phone(): """Random US phone number. (10 digits) Example:: >>> rand_phone() (306)-746-6690 """ return "(%s)-%s-%s" % (rand_str(3, string.digits), rand_str(3, string.digits), rand_str(3, string.digits))
[ "def", "rand_phone", "(", ")", ":", "return", "\"(%s)-%s-%s\"", "%", "(", "rand_str", "(", "3", ",", "string", ".", "digits", ")", ",", "rand_str", "(", "3", ",", "string", ".", "digits", ")", ",", "rand_str", "(", "3", ",", "string", ".", "digits", ...
Random US phone number. (10 digits) Example:: >>> rand_phone() (306)-746-6690
[ "Random", "US", "phone", "number", ".", "(", "10", "digits", ")" ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/rnd.py#L79-L89
train
Random US phone number.
MacHu-GWU/single_file_module-project
sfm/rnd.py
rand_ssn
def rand_ssn(): """Random SSN. (9 digits) Example:: >>> rand_ssn() 295-50-0178 """ return "%s-%s-%s" % (rand_str(3, string.digits), rand_str(2, string.digits), rand_str(4, string.digits))
python
def rand_ssn(): """Random SSN. (9 digits) Example:: >>> rand_ssn() 295-50-0178 """ return "%s-%s-%s" % (rand_str(3, string.digits), rand_str(2, string.digits), rand_str(4, string.digits))
[ "def", "rand_ssn", "(", ")", ":", "return", "\"%s-%s-%s\"", "%", "(", "rand_str", "(", "3", ",", "string", ".", "digits", ")", ",", "rand_str", "(", "2", ",", "string", ".", "digits", ")", ",", "rand_str", "(", "4", ",", "string", ".", "digits", ")...
Random SSN. (9 digits) Example:: >>> rand_ssn() 295-50-0178
[ "Random", "SSN", ".", "(", "9", "digits", ")" ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/rnd.py#L92-L102
train
Random SSN.
MacHu-GWU/single_file_module-project
sfm/rnd.py
rand_email
def rand_email(): """Random email. Usage Example:: >>> rand_email() Z4Lljcbdw7m@npa.net """ name = rand_str(random.randint(4, 14), string.ascii_lowercase) + \ rand_str(random.randint(1, 4), string.digits) domain = rand_str(random.randint(2, 10), string.ascii_lowercase) ...
python
def rand_email(): """Random email. Usage Example:: >>> rand_email() Z4Lljcbdw7m@npa.net """ name = rand_str(random.randint(4, 14), string.ascii_lowercase) + \ rand_str(random.randint(1, 4), string.digits) domain = rand_str(random.randint(2, 10), string.ascii_lowercase) ...
[ "def", "rand_email", "(", ")", ":", "name", "=", "rand_str", "(", "random", ".", "randint", "(", "4", ",", "14", ")", ",", "string", ".", "ascii_lowercase", ")", "+", "rand_str", "(", "random", ".", "randint", "(", "1", ",", "4", ")", ",", "string"...
Random email. Usage Example:: >>> rand_email() Z4Lljcbdw7m@npa.net
[ "Random", "email", "." ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/rnd.py#L105-L117
train
Random email.
MacHu-GWU/single_file_module-project
sfm/rnd.py
rand_article
def rand_article(num_p=(4, 10), num_s=(2, 15), num_w=(5, 40)): """Random article text. Example:: >>> rand_article() ... """ article = list() for _ in range(random.randint(*num_p)): p = list() for _ in range(random.randint(*num_s)): s = list() ...
python
def rand_article(num_p=(4, 10), num_s=(2, 15), num_w=(5, 40)): """Random article text. Example:: >>> rand_article() ... """ article = list() for _ in range(random.randint(*num_p)): p = list() for _ in range(random.randint(*num_s)): s = list() ...
[ "def", "rand_article", "(", "num_p", "=", "(", "4", ",", "10", ")", ",", "num_s", "=", "(", "2", ",", "15", ")", ",", "num_w", "=", "(", "5", ",", "40", ")", ")", ":", "article", "=", "list", "(", ")", "for", "_", "in", "range", "(", "rando...
Random article text. Example:: >>> rand_article() ...
[ "Random", "article", "text", "." ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/rnd.py#L120-L138
train
Random article text.
Godley/MuseParse
MuseParse/classes/ObjectHierarchy/ItemClasses/Clef.py
Clef.toLily
def toLily(self): ''' Method which converts the object instance and its attributes to a string of lilypond code :return: str of lilypond code ''' val = "\clef " clef = "" if hasattr(self, "sign") and self.sign is not None: key = self.sign.upper() ...
python
def toLily(self): ''' Method which converts the object instance and its attributes to a string of lilypond code :return: str of lilypond code ''' val = "\clef " clef = "" if hasattr(self, "sign") and self.sign is not None: key = self.sign.upper() ...
[ "def", "toLily", "(", "self", ")", ":", "val", "=", "\"\\clef \"", "clef", "=", "\"\"", "if", "hasattr", "(", "self", ",", "\"sign\"", ")", "and", "self", ".", "sign", "is", "not", "None", ":", "key", "=", "self", ".", "sign", ".", "upper", "(", ...
Method which converts the object instance and its attributes to a string of lilypond code :return: str of lilypond code
[ "Method", "which", "converts", "the", "object", "instance", "and", "its", "attributes", "to", "a", "string", "of", "lilypond", "code" ]
23cecafa1fdc0f2d6a87760553572b459f3c9904
https://github.com/Godley/MuseParse/blob/23cecafa1fdc0f2d6a87760553572b459f3c9904/MuseParse/classes/ObjectHierarchy/ItemClasses/Clef.py#L66-L91
train
Method which converts the object instance and its attributes to a string of lilypond code
JanHendrikDolling/configvalidator
configvalidator/tools/parser.py
ParseObj._resolve_dep
def _resolve_dep(self, key): """ this method resolves dependencies for the given key. call the method afther the item "key" was added to the list of avalable items """ if key in self.future_values_key_dep: # there are some dependencies that can be resoled ...
python
def _resolve_dep(self, key): """ this method resolves dependencies for the given key. call the method afther the item "key" was added to the list of avalable items """ if key in self.future_values_key_dep: # there are some dependencies that can be resoled ...
[ "def", "_resolve_dep", "(", "self", ",", "key", ")", ":", "if", "key", "in", "self", ".", "future_values_key_dep", ":", "# there are some dependencies that can be resoled", "dep_list", "=", "self", ".", "future_values_key_dep", "[", "key", "]", "del", "self", ".",...
this method resolves dependencies for the given key. call the method afther the item "key" was added to the list of avalable items
[ "this", "method", "resolves", "dependencies", "for", "the", "given", "key", ".", "call", "the", "method", "afther", "the", "item", "key", "was", "added", "to", "the", "list", "of", "avalable", "items" ]
efde23a9352ae1fd6702b04ad964783ce11cbca5
https://github.com/JanHendrikDolling/configvalidator/blob/efde23a9352ae1fd6702b04ad964783ce11cbca5/configvalidator/tools/parser.py#L132-L148
train
this method resolves dependencies for the given key.
JanHendrikDolling/configvalidator
configvalidator/tools/parser.py
ParseObj._get_all_refs
def _get_all_refs(self, dep, handled_refs=None): """ get al list of all dependencies for the given item "dep" """ if handled_refs is None: handled_refs = [dep] else: if dep in handled_refs: return [] res = [] if dep in self....
python
def _get_all_refs(self, dep, handled_refs=None): """ get al list of all dependencies for the given item "dep" """ if handled_refs is None: handled_refs = [dep] else: if dep in handled_refs: return [] res = [] if dep in self....
[ "def", "_get_all_refs", "(", "self", ",", "dep", ",", "handled_refs", "=", "None", ")", ":", "if", "handled_refs", "is", "None", ":", "handled_refs", "=", "[", "dep", "]", "else", ":", "if", "dep", "in", "handled_refs", ":", "return", "[", "]", "res", ...
get al list of all dependencies for the given item "dep"
[ "get", "al", "list", "of", "all", "dependencies", "for", "the", "given", "item", "dep" ]
efde23a9352ae1fd6702b04ad964783ce11cbca5
https://github.com/JanHendrikDolling/configvalidator/blob/efde23a9352ae1fd6702b04ad964783ce11cbca5/configvalidator/tools/parser.py#L189-L206
train
get al list of all dependencies for the given item dep
ariebovenberg/snug
examples/github/query.py
prepare_params
def prepare_params(request): """prepare request parameters""" return request.replace( params={key: dump_param(val) for key, val in request.params.items() if val is not None})
python
def prepare_params(request): """prepare request parameters""" return request.replace( params={key: dump_param(val) for key, val in request.params.items() if val is not None})
[ "def", "prepare_params", "(", "request", ")", ":", "return", "request", ".", "replace", "(", "params", "=", "{", "key", ":", "dump_param", "(", "val", ")", "for", "key", ",", "val", "in", "request", ".", "params", ".", "items", "(", ")", "if", "val",...
prepare request parameters
[ "prepare", "request", "parameters" ]
4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef
https://github.com/ariebovenberg/snug/blob/4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef/examples/github/query.py#L43-L47
train
prepare request parameters
ariebovenberg/snug
examples/github/query.py
BaseQuery.parse
def parse(response): """check for errors""" if response.status_code == 400: try: msg = json.loads(response.content)['message'] except (KeyError, ValueError): msg = '' raise ApiError(msg) return response
python
def parse(response): """check for errors""" if response.status_code == 400: try: msg = json.loads(response.content)['message'] except (KeyError, ValueError): msg = '' raise ApiError(msg) return response
[ "def", "parse", "(", "response", ")", ":", "if", "response", ".", "status_code", "==", "400", ":", "try", ":", "msg", "=", "json", ".", "loads", "(", "response", ".", "content", ")", "[", "'message'", "]", "except", "(", "KeyError", ",", "ValueError", ...
check for errors
[ "check", "for", "errors" ]
4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef
https://github.com/ariebovenberg/snug/blob/4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef/examples/github/query.py#L68-L76
train
check for errors
nugget/python-anthemav
anthemav/connection.py
Connection.create
def create(cls, host='localhost', port=14999, auto_reconnect=True, loop=None, protocol_class=AVR, update_callback=None): """Initiate a connection to a specific device. Here is where we supply the host and port and callback callables we expect for this AVR class obj...
python
def create(cls, host='localhost', port=14999, auto_reconnect=True, loop=None, protocol_class=AVR, update_callback=None): """Initiate a connection to a specific device. Here is where we supply the host and port and callback callables we expect for this AVR class obj...
[ "def", "create", "(", "cls", ",", "host", "=", "'localhost'", ",", "port", "=", "14999", ",", "auto_reconnect", "=", "True", ",", "loop", "=", "None", ",", "protocol_class", "=", "AVR", ",", "update_callback", "=", "None", ")", ":", "assert", "port", "...
Initiate a connection to a specific device. Here is where we supply the host and port and callback callables we expect for this AVR class object. :param host: Hostname or IP address of the device :param port: TCP port number of the device :param auto_rec...
[ "Initiate", "a", "connection", "to", "a", "specific", "device", "." ]
c3cee38f2d452c1ab1335d9885e0769ec24d5f90
https://github.com/nugget/python-anthemav/blob/c3cee38f2d452c1ab1335d9885e0769ec24d5f90/anthemav/connection.py#L23-L76
train
Initiate a connection to a specific device.
nugget/python-anthemav
anthemav/connection.py
Connection.close
def close(self): """Close the AVR device connection and don't try to reconnect.""" self.log.warning('Closing connection to AVR') self._closing = True if self.protocol.transport: self.protocol.transport.close()
python
def close(self): """Close the AVR device connection and don't try to reconnect.""" self.log.warning('Closing connection to AVR') self._closing = True if self.protocol.transport: self.protocol.transport.close()
[ "def", "close", "(", "self", ")", ":", "self", ".", "log", ".", "warning", "(", "'Closing connection to AVR'", ")", "self", ".", "_closing", "=", "True", "if", "self", ".", "protocol", ".", "transport", ":", "self", ".", "protocol", ".", "transport", "."...
Close the AVR device connection and don't try to reconnect.
[ "Close", "the", "AVR", "device", "connection", "and", "don", "t", "try", "to", "reconnect", "." ]
c3cee38f2d452c1ab1335d9885e0769ec24d5f90
https://github.com/nugget/python-anthemav/blob/c3cee38f2d452c1ab1335d9885e0769ec24d5f90/anthemav/connection.py#L117-L122
train
Close the AVR device connection and don t try to reconnect.
nugget/python-anthemav
anthemav/connection.py
Connection.halt
def halt(self): """Close the AVR device connection and wait for a resume() request.""" self.log.warning('Halting connection to AVR') self._halted = True if self.protocol.transport: self.protocol.transport.close()
python
def halt(self): """Close the AVR device connection and wait for a resume() request.""" self.log.warning('Halting connection to AVR') self._halted = True if self.protocol.transport: self.protocol.transport.close()
[ "def", "halt", "(", "self", ")", ":", "self", ".", "log", ".", "warning", "(", "'Halting connection to AVR'", ")", "self", ".", "_halted", "=", "True", "if", "self", ".", "protocol", ".", "transport", ":", "self", ".", "protocol", ".", "transport", ".", ...
Close the AVR device connection and wait for a resume() request.
[ "Close", "the", "AVR", "device", "connection", "and", "wait", "for", "a", "resume", "()", "request", "." ]
c3cee38f2d452c1ab1335d9885e0769ec24d5f90
https://github.com/nugget/python-anthemav/blob/c3cee38f2d452c1ab1335d9885e0769ec24d5f90/anthemav/connection.py#L124-L129
train
Close the AVR connection and wait for a resume request.
MacHu-GWU/single_file_module-project
sfm/ziplib.py
_compress_obj
def _compress_obj(obj, level): """Compress object to bytes. """ return zlib.compress(pickle.dumps(obj, protocol=2), level)
python
def _compress_obj(obj, level): """Compress object to bytes. """ return zlib.compress(pickle.dumps(obj, protocol=2), level)
[ "def", "_compress_obj", "(", "obj", ",", "level", ")", ":", "return", "zlib", ".", "compress", "(", "pickle", ".", "dumps", "(", "obj", ",", "protocol", "=", "2", ")", ",", "level", ")" ]
Compress object to bytes.
[ "Compress", "object", "to", "bytes", "." ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/ziplib.py#L34-L37
train
Compress object to bytes.
MacHu-GWU/single_file_module-project
sfm/ziplib.py
compress
def compress(obj, level=6, return_type="bytes"): """Compress anything to bytes or string. :param obj: could be any object, usually it could be binary, string, or regular python objec.t :param level: :param return_type: if bytes, then return bytes; if str, then return base64.b64encode by...
python
def compress(obj, level=6, return_type="bytes"): """Compress anything to bytes or string. :param obj: could be any object, usually it could be binary, string, or regular python objec.t :param level: :param return_type: if bytes, then return bytes; if str, then return base64.b64encode by...
[ "def", "compress", "(", "obj", ",", "level", "=", "6", ",", "return_type", "=", "\"bytes\"", ")", ":", "if", "isinstance", "(", "obj", ",", "binary_type", ")", ":", "b", "=", "_compress_bytes", "(", "obj", ",", "level", ")", "elif", "isinstance", "(", ...
Compress anything to bytes or string. :param obj: could be any object, usually it could be binary, string, or regular python objec.t :param level: :param return_type: if bytes, then return bytes; if str, then return base64.b64encode bytes in utf-8 string.
[ "Compress", "anything", "to", "bytes", "or", "string", "." ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/ziplib.py#L52-L73
train
Compress any object to bytes or base64 string.
MacHu-GWU/single_file_module-project
sfm/ziplib.py
decompress
def decompress(obj, return_type="bytes"): """ De-compress it to it's original. :param obj: Compressed object, could be bytes or str. :param return_type: if bytes, then return bytes; if str, then use base64.b64decode; if obj, then use pickle.loads return an object. """ if isinstance(obj,...
python
def decompress(obj, return_type="bytes"): """ De-compress it to it's original. :param obj: Compressed object, could be bytes or str. :param return_type: if bytes, then return bytes; if str, then use base64.b64decode; if obj, then use pickle.loads return an object. """ if isinstance(obj,...
[ "def", "decompress", "(", "obj", ",", "return_type", "=", "\"bytes\"", ")", ":", "if", "isinstance", "(", "obj", ",", "binary_type", ")", ":", "b", "=", "zlib", ".", "decompress", "(", "obj", ")", "elif", "isinstance", "(", "obj", ",", "string_types", ...
De-compress it to it's original. :param obj: Compressed object, could be bytes or str. :param return_type: if bytes, then return bytes; if str, then use base64.b64decode; if obj, then use pickle.loads return an object.
[ "De", "-", "compress", "it", "to", "it", "s", "original", "." ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/ziplib.py#L76-L99
train
Decompress a single object into a new object.
MounirMesselmeni/django-highlightjs
highlightjs/renderer.py
render_tag
def render_tag(attrs=None, content=None): """ Render a HTML tag """ builder = '<pre><code{attrs}>{content}</code></pre>' return builder.format( attrs=flatatt(attrs) if attrs else '', content=escape(text_value(content)), )
python
def render_tag(attrs=None, content=None): """ Render a HTML tag """ builder = '<pre><code{attrs}>{content}</code></pre>' return builder.format( attrs=flatatt(attrs) if attrs else '', content=escape(text_value(content)), )
[ "def", "render_tag", "(", "attrs", "=", "None", ",", "content", "=", "None", ")", ":", "builder", "=", "'<pre><code{attrs}>{content}</code></pre>'", "return", "builder", ".", "format", "(", "attrs", "=", "flatatt", "(", "attrs", ")", "if", "attrs", "else", "...
Render a HTML tag
[ "Render", "a", "HTML", "tag" ]
3758cae67ed15f38641fb51a71ca9ed85af78345
https://github.com/MounirMesselmeni/django-highlightjs/blob/3758cae67ed15f38641fb51a71ca9ed85af78345/highlightjs/renderer.py#L28-L36
train
Render a HTML tag with the given attributes and content.
PSPC-SPAC-buyandsell/didauth
didauth/utils.py
ct_bytes_compare
def ct_bytes_compare(a, b): """ Constant-time string compare. http://codahale.com/a-lesson-in-timing-attacks/ """ if not isinstance(a, bytes): a = a.decode('utf8') if not isinstance(b, bytes): b = b.decode('utf8') if len(a) != len(b): return False result = 0 ...
python
def ct_bytes_compare(a, b): """ Constant-time string compare. http://codahale.com/a-lesson-in-timing-attacks/ """ if not isinstance(a, bytes): a = a.decode('utf8') if not isinstance(b, bytes): b = b.decode('utf8') if len(a) != len(b): return False result = 0 ...
[ "def", "ct_bytes_compare", "(", "a", ",", "b", ")", ":", "if", "not", "isinstance", "(", "a", ",", "bytes", ")", ":", "a", "=", "a", ".", "decode", "(", "'utf8'", ")", "if", "not", "isinstance", "(", "b", ",", "bytes", ")", ":", "b", "=", "b", ...
Constant-time string compare. http://codahale.com/a-lesson-in-timing-attacks/
[ "Constant", "-", "time", "string", "compare", ".", "http", ":", "//", "codahale", ".", "com", "/", "a", "-", "lesson", "-", "in", "-", "timing", "-", "attacks", "/" ]
e242fff8eddebf6ed52a65b161a229cdfbf5226e
https://github.com/PSPC-SPAC-buyandsell/didauth/blob/e242fff8eddebf6ed52a65b161a229cdfbf5226e/didauth/utils.py#L14-L31
train
Constant - time string compare.
PSPC-SPAC-buyandsell/didauth
didauth/utils.py
build_signature_template
def build_signature_template(key_id, algorithm, headers): """ Build the Signature template for use with the Authorization header. key_id is the mandatory label indicating to the server which secret to use algorithm is one of the supported algorithms headers is a list of http headers to be included ...
python
def build_signature_template(key_id, algorithm, headers): """ Build the Signature template for use with the Authorization header. key_id is the mandatory label indicating to the server which secret to use algorithm is one of the supported algorithms headers is a list of http headers to be included ...
[ "def", "build_signature_template", "(", "key_id", ",", "algorithm", ",", "headers", ")", ":", "param_map", "=", "{", "'keyId'", ":", "key_id", ",", "'algorithm'", ":", "algorithm", ",", "'signature'", ":", "'%s'", "}", "if", "headers", ":", "headers", "=", ...
Build the Signature template for use with the Authorization header. key_id is the mandatory label indicating to the server which secret to use algorithm is one of the supported algorithms headers is a list of http headers to be included in the signing string. The signature must be interpolated into th...
[ "Build", "the", "Signature", "template", "for", "use", "with", "the", "Authorization", "header", "." ]
e242fff8eddebf6ed52a65b161a229cdfbf5226e
https://github.com/PSPC-SPAC-buyandsell/didauth/blob/e242fff8eddebf6ed52a65b161a229cdfbf5226e/didauth/utils.py#L115-L135
train
Builds the Signature template for use with the Authorization header.
MacHu-GWU/single_file_module-project
sfm/geo_search.py
GeoSearchEngine.train
def train(self, data, key_id, key_lat, key_lng, clear_old=True): """ Feed data into database. :type data: list :param data: list of point object, can have other metadata, for example: [{"id": 10001, "lat": xxx, "lng": xxx}, ...] :type key_id: callable :param...
python
def train(self, data, key_id, key_lat, key_lng, clear_old=True): """ Feed data into database. :type data: list :param data: list of point object, can have other metadata, for example: [{"id": 10001, "lat": xxx, "lng": xxx}, ...] :type key_id: callable :param...
[ "def", "train", "(", "self", ",", "data", ",", "key_id", ",", "key_lat", ",", "key_lng", ",", "clear_old", "=", "True", ")", ":", "engine", ",", "t_point", "=", "self", ".", "engine", ",", "self", ".", "t_point", "if", "clear_old", ":", "try", ":", ...
Feed data into database. :type data: list :param data: list of point object, can have other metadata, for example: [{"id": 10001, "lat": xxx, "lng": xxx}, ...] :type key_id: callable :param key_id: callable function, take point object as input, return object id,...
[ "Feed", "data", "into", "database", "." ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/geo_search.py#L55-L95
train
Feed data into database.
MacHu-GWU/single_file_module-project
sfm/geo_search.py
GeoSearchEngine.find_n_nearest
def find_n_nearest(self, lat, lng, n=5, radius=None): """Find n nearest point within certain distance from a point. :param lat: latitude of center point. :param lng: longitude of center point. :param n: max number of record to return. :param radius: only search point within ``ra...
python
def find_n_nearest(self, lat, lng, n=5, radius=None): """Find n nearest point within certain distance from a point. :param lat: latitude of center point. :param lng: longitude of center point. :param n: max number of record to return. :param radius: only search point within ``ra...
[ "def", "find_n_nearest", "(", "self", ",", "lat", ",", "lng", ",", "n", "=", "5", ",", "radius", "=", "None", ")", ":", "engine", ",", "t_point", "=", "self", ".", "engine", ",", "self", ".", "t_point", "if", "radius", ":", "# Use a simple box filter t...
Find n nearest point within certain distance from a point. :param lat: latitude of center point. :param lng: longitude of center point. :param n: max number of record to return. :param radius: only search point within ``radius`` distance. **中文文档**
[ "Find", "n", "nearest", "point", "within", "certain", "distance", "from", "a", "point", "." ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/geo_search.py#L97-L141
train
Find n nearest point within certain distance from a point.
SMAPPNYU/pysmap
pysmap/twitterutil/smapp_dataset.py
SmappDataset.sample
def sample(self, k): ''' this method is especially troublesome i do not reccommend making any changes to it you may notice it uplicates code fro smappdragon there is no way around this as far as i can tell it really might screw up a lot of stuff, stip tweets has ...
python
def sample(self, k): ''' this method is especially troublesome i do not reccommend making any changes to it you may notice it uplicates code fro smappdragon there is no way around this as far as i can tell it really might screw up a lot of stuff, stip tweets has ...
[ "def", "sample", "(", "self", ",", "k", ")", ":", "def", "new_get_iterators", "(", ")", ":", "tweet_parser", "=", "smappdragon", ".", "TweetParser", "(", ")", "it", "=", "iter", "(", "self", ".", "get_collection_iterators", "(", ")", ")", "sample", "=", ...
this method is especially troublesome i do not reccommend making any changes to it you may notice it uplicates code fro smappdragon there is no way around this as far as i can tell it really might screw up a lot of stuff, stip tweets has been purposely omitted as it isnt support...
[ "this", "method", "is", "especially", "troublesome", "i", "do", "not", "reccommend", "making", "any", "changes", "to", "it", "you", "may", "notice", "it", "uplicates", "code", "fro", "smappdragon", "there", "is", "no", "way", "around", "this", "as", "far", ...
eb871992f40c53125129535e871525d5623c8c2d
https://github.com/SMAPPNYU/pysmap/blob/eb871992f40c53125129535e871525d5623c8c2d/pysmap/twitterutil/smapp_dataset.py#L451-L478
train
returns a new copy of self with k items randomly generated from the collections
koszullab/metaTOR
metator/scripts/network.py
alignment_to_contacts
def alignment_to_contacts( sam_merged, assembly, output_dir, output_file_network=DEFAULT_NETWORK_FILE_NAME, output_file_chunk_data=DEFAULT_CHUNK_DATA_FILE_NAME, parameters=DEFAULT_PARAMETERS, ): """Generates a network file (in edgelist form) from an alignment in sam or bam format. Contig...
python
def alignment_to_contacts( sam_merged, assembly, output_dir, output_file_network=DEFAULT_NETWORK_FILE_NAME, output_file_chunk_data=DEFAULT_CHUNK_DATA_FILE_NAME, parameters=DEFAULT_PARAMETERS, ): """Generates a network file (in edgelist form) from an alignment in sam or bam format. Contig...
[ "def", "alignment_to_contacts", "(", "sam_merged", ",", "assembly", ",", "output_dir", ",", "output_file_network", "=", "DEFAULT_NETWORK_FILE_NAME", ",", "output_file_chunk_data", "=", "DEFAULT_CHUNK_DATA_FILE_NAME", ",", "parameters", "=", "DEFAULT_PARAMETERS", ",", ")", ...
Generates a network file (in edgelist form) from an alignment in sam or bam format. Contigs are virtually split into 'chunks' of nearly fixed size (by default between 500 and 1000 bp) to reduce size bias. The chunks are the network nodes and the edges are the contact counts. The network is in a str...
[ "Generates", "a", "network", "file", "(", "in", "edgelist", "form", ")", "from", "an", "alignment", "in", "sam", "or", "bam", "format", ".", "Contigs", "are", "virtually", "split", "into", "chunks", "of", "nearly", "fixed", "size", "(", "by", "default", ...
0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a
https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/scripts/network.py#L42-L348
train
Generates a network file from an alignment file.
koszullab/metaTOR
metator/scripts/network.py
merge_networks
def merge_networks(output_file="merged_network.txt", *files): """Merge networks into a larger network. A naive implementation for merging two networks in edgelist format. Parameters --------- output_file : file, str, or pathlib.Path, optional The output file to write the merged network int...
python
def merge_networks(output_file="merged_network.txt", *files): """Merge networks into a larger network. A naive implementation for merging two networks in edgelist format. Parameters --------- output_file : file, str, or pathlib.Path, optional The output file to write the merged network int...
[ "def", "merge_networks", "(", "output_file", "=", "\"merged_network.txt\"", ",", "*", "files", ")", ":", "contacts", "=", "dict", "(", ")", "for", "network_file", "in", "files", ":", "with", "open", "(", "network_file", ")", "as", "network_file_handle", ":", ...
Merge networks into a larger network. A naive implementation for merging two networks in edgelist format. Parameters --------- output_file : file, str, or pathlib.Path, optional The output file to write the merged network into. Default is merged_network.txt `*files` : file, str or ...
[ "Merge", "networks", "into", "a", "larger", "network", "." ]
0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a
https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/scripts/network.py#L351-L388
train
A naive implementation for merging two networks into a larger network.
koszullab/metaTOR
metator/scripts/network.py
merge_chunk_data
def merge_chunk_data(output_file="merged_idx_contig_hit_size_cov.txt", *files): """Merge chunk data from different networks Similarly to merge_network, this merges any number of chunk data files. Parameters --------- output_file : file, str, or pathlib.Path, optional The output file to wri...
python
def merge_chunk_data(output_file="merged_idx_contig_hit_size_cov.txt", *files): """Merge chunk data from different networks Similarly to merge_network, this merges any number of chunk data files. Parameters --------- output_file : file, str, or pathlib.Path, optional The output file to wri...
[ "def", "merge_chunk_data", "(", "output_file", "=", "\"merged_idx_contig_hit_size_cov.txt\"", ",", "*", "files", ")", ":", "chunks", "=", "dict", "(", ")", "for", "chunk_file", "in", "files", ":", "with", "open", "(", "chunk_file", ")", "as", "chunk_file_handle"...
Merge chunk data from different networks Similarly to merge_network, this merges any number of chunk data files. Parameters --------- output_file : file, str, or pathlib.Path, optional The output file to write the merged chunk data files into. Default is merged_idx_contig_hit_size_cov....
[ "Merge", "chunk", "data", "from", "different", "networks" ]
0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a
https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/scripts/network.py#L391-L435
train
This function merges chunk data from different networks into a single file.
koszullab/metaTOR
metator/scripts/network.py
alignment_to_reads
def alignment_to_reads( sam_merged, output_dir, parameters=DEFAULT_PARAMETERS, save_memory=True, *bin_fasta ): """Generate reads from ambiguous alignment file Extract reads found to be mapping an input FASTA bin. If one read maps, the whole pair is extracted and written to the outpu...
python
def alignment_to_reads( sam_merged, output_dir, parameters=DEFAULT_PARAMETERS, save_memory=True, *bin_fasta ): """Generate reads from ambiguous alignment file Extract reads found to be mapping an input FASTA bin. If one read maps, the whole pair is extracted and written to the outpu...
[ "def", "alignment_to_reads", "(", "sam_merged", ",", "output_dir", ",", "parameters", "=", "DEFAULT_PARAMETERS", ",", "save_memory", "=", "True", ",", "*", "bin_fasta", ")", ":", "# Just in case file objects are sent as input", "def", "get_file_string", "(", "file_thi...
Generate reads from ambiguous alignment file Extract reads found to be mapping an input FASTA bin. If one read maps, the whole pair is extracted and written to the output paired-end FASTQ files. Reads that mapped and weren't part of a pair are kept in a third 'single' file for people who need it (e...
[ "Generate", "reads", "from", "ambiguous", "alignment", "file" ]
0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a
https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/scripts/network.py#L438-L574
train
Generate reads from ambiguous alignment file.
Godley/MuseParse
MuseParse/classes/Input/MxmlParser.py
ignore_exception
def ignore_exception(IgnoreException=Exception, DefaultVal=None): """ Decorator for ignoring exception from a function e.g. @ignore_exception(DivideByZero) e.g.2. ignore_exception(DivideByZero)(Divide)(2/0) borrowed from: http://stackoverflow.com/questions/2262333/is-there-a-built-in-or-more-pythonic-...
python
def ignore_exception(IgnoreException=Exception, DefaultVal=None): """ Decorator for ignoring exception from a function e.g. @ignore_exception(DivideByZero) e.g.2. ignore_exception(DivideByZero)(Divide)(2/0) borrowed from: http://stackoverflow.com/questions/2262333/is-there-a-built-in-or-more-pythonic-...
[ "def", "ignore_exception", "(", "IgnoreException", "=", "Exception", ",", "DefaultVal", "=", "None", ")", ":", "def", "dec", "(", "function", ")", ":", "def", "_dec", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "return", "function"...
Decorator for ignoring exception from a function e.g. @ignore_exception(DivideByZero) e.g.2. ignore_exception(DivideByZero)(Divide)(2/0) borrowed from: http://stackoverflow.com/questions/2262333/is-there-a-built-in-or-more-pythonic-way-to-try-to-parse-a-string-to-an-integer
[ "Decorator", "for", "ignoring", "exception", "from", "a", "function", "e", ".", "g", "." ]
23cecafa1fdc0f2d6a87760553572b459f3c9904
https://github.com/Godley/MuseParse/blob/23cecafa1fdc0f2d6a87760553572b459f3c9904/MuseParse/classes/Input/MxmlParser.py#L397-L413
train
Decorator for ignoring exceptions from a function e. g.