partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
ElasticIndex.update
Partial update to a single document. Uses the Update API with the specified partial document.
simple_elastic/index.py
def update(self, doc: dict, doc_id: str): """Partial update to a single document. Uses the Update API with the specified partial document. """ body = { 'doc': doc } self.instance.update(self.index, self.doc_type, doc_id, body=body)
def update(self, doc: dict, doc_id: str): """Partial update to a single document. Uses the Update API with the specified partial document. """ body = { 'doc': doc } self.instance.update(self.index, self.doc_type, doc_id, body=body)
[ "Partial", "update", "to", "a", "single", "document", "." ]
UB-UNIBAS/simple-elastic
python
https://github.com/UB-UNIBAS/simple-elastic/blob/54f2fdd3405a7eafbf8873f337da263b8d47532a/simple_elastic/index.py#L189-L197
[ "def", "update", "(", "self", ",", "doc", ":", "dict", ",", "doc_id", ":", "str", ")", ":", "body", "=", "{", "'doc'", ":", "doc", "}", "self", ".", "instance", ".", "update", "(", "self", ".", "index", ",", "self", ".", "doc_type", ",", "doc_id"...
54f2fdd3405a7eafbf8873f337da263b8d47532a
train
ElasticIndex.script_update
Uses painless script to update a document. See documentation for more information.
simple_elastic/index.py
def script_update(self, script: str, params: Union[dict, None], doc_id: str): """Uses painless script to update a document. See documentation for more information. """ body = { 'script': { 'source': script, 'lang': 'painless' } ...
def script_update(self, script: str, params: Union[dict, None], doc_id: str): """Uses painless script to update a document. See documentation for more information. """ body = { 'script': { 'source': script, 'lang': 'painless' } ...
[ "Uses", "painless", "script", "to", "update", "a", "document", "." ]
UB-UNIBAS/simple-elastic
python
https://github.com/UB-UNIBAS/simple-elastic/blob/54f2fdd3405a7eafbf8873f337da263b8d47532a/simple_elastic/index.py#L199-L212
[ "def", "script_update", "(", "self", ",", "script", ":", "str", ",", "params", ":", "Union", "[", "dict", ",", "None", "]", ",", "doc_id", ":", "str", ")", ":", "body", "=", "{", "'script'", ":", "{", "'source'", ":", "script", ",", "'lang'", ":", ...
54f2fdd3405a7eafbf8873f337da263b8d47532a
train
ElasticIndex.bulk
Takes a list of dictionaries and an identifier key and indexes everything into this index. :param data: List of dictionaries containing the data to be indexed. :param identifier_key: The name of the dictionary element which should be used as _id. This will be removed from ...
simple_elastic/index.py
def bulk(self, data: List[Dict[str, str]], identifier_key: str, op_type='index', upsert=False, keep_id_key=False) -> bool: """ Takes a list of dictionaries and an identifier key and indexes everything into this index. :param data: List of dictionaries containing the data to be indexe...
def bulk(self, data: List[Dict[str, str]], identifier_key: str, op_type='index', upsert=False, keep_id_key=False) -> bool: """ Takes a list of dictionaries and an identifier key and indexes everything into this index. :param data: List of dictionaries containing the data to be indexe...
[ "Takes", "a", "list", "of", "dictionaries", "and", "an", "identifier", "key", "and", "indexes", "everything", "into", "this", "index", "." ]
UB-UNIBAS/simple-elastic
python
https://github.com/UB-UNIBAS/simple-elastic/blob/54f2fdd3405a7eafbf8873f337da263b8d47532a/simple_elastic/index.py#L214-L257
[ "def", "bulk", "(", "self", ",", "data", ":", "List", "[", "Dict", "[", "str", ",", "str", "]", "]", ",", "identifier_key", ":", "str", ",", "op_type", "=", "'index'", ",", "upsert", "=", "False", ",", "keep_id_key", "=", "False", ")", "->", "bool"...
54f2fdd3405a7eafbf8873f337da263b8d47532a
train
ElasticIndex.reindex
Reindex the entire index. Scrolls the old index and bulk indexes all data into the new index. :param new_index_name: :param identifier_key: :param kwargs: Overwrite ElasticIndex __init__ params. :return:
simple_elastic/index.py
def reindex(self, new_index_name: str, identifier_key: str, **kwargs) -> 'ElasticIndex': """Reindex the entire index. Scrolls the old index and bulk indexes all data into the new index. :param new_index_name: :param identifier_key: :param kwargs: Overwrite ElasticIndex...
def reindex(self, new_index_name: str, identifier_key: str, **kwargs) -> 'ElasticIndex': """Reindex the entire index. Scrolls the old index and bulk indexes all data into the new index. :param new_index_name: :param identifier_key: :param kwargs: Overwrite ElasticIndex...
[ "Reindex", "the", "entire", "index", "." ]
UB-UNIBAS/simple-elastic
python
https://github.com/UB-UNIBAS/simple-elastic/blob/54f2fdd3405a7eafbf8873f337da263b8d47532a/simple_elastic/index.py#L259-L279
[ "def", "reindex", "(", "self", ",", "new_index_name", ":", "str", ",", "identifier_key", ":", "str", ",", "*", "*", "kwargs", ")", "->", "'ElasticIndex'", ":", "if", "'url'", "not", "in", "kwargs", ":", "kwargs", "[", "'url'", "]", "=", "self", ".", ...
54f2fdd3405a7eafbf8873f337da263b8d47532a
train
ElasticIndex.dump
Dumps the entire index into a json file. :param path: The path to directory where the dump should be stored. :param file_name: Name of the file the dump should be stored in. If empty the index name is used. :param kwargs: Keyword arguments for the json converter. (ex. indent=4, ensure_ascii=Fa...
simple_elastic/index.py
def dump(self, path: str, file_name: str = "", **kwargs: dict): """ Dumps the entire index into a json file. :param path: The path to directory where the dump should be stored. :param file_name: Name of the file the dump should be stored in. If empty the index name is used. :pa...
def dump(self, path: str, file_name: str = "", **kwargs: dict): """ Dumps the entire index into a json file. :param path: The path to directory where the dump should be stored. :param file_name: Name of the file the dump should be stored in. If empty the index name is used. :pa...
[ "Dumps", "the", "entire", "index", "into", "a", "json", "file", "." ]
UB-UNIBAS/simple-elastic
python
https://github.com/UB-UNIBAS/simple-elastic/blob/54f2fdd3405a7eafbf8873f337da263b8d47532a/simple_elastic/index.py#L281-L306
[ "def", "dump", "(", "self", ",", "path", ":", "str", ",", "file_name", ":", "str", "=", "\"\"", ",", "*", "*", "kwargs", ":", "dict", ")", ":", "export", "=", "list", "(", ")", "for", "results", "in", "self", ".", "scroll", "(", ")", ":", "expo...
54f2fdd3405a7eafbf8873f337da263b8d47532a
train
main
parse command line options and either launch some configuration dialog or start an instance of _MainLoop as a daemon
studdp/studdp.py
def main(): """ parse command line options and either launch some configuration dialog or start an instance of _MainLoop as a daemon """ (options, _) = _parse_args() if options.change_password: c.keyring_set_password(c["username"]) sys.exit(0) if options.select: courses...
def main(): """ parse command line options and either launch some configuration dialog or start an instance of _MainLoop as a daemon """ (options, _) = _parse_args() if options.change_password: c.keyring_set_password(c["username"]) sys.exit(0) if options.select: courses...
[ "parse", "command", "line", "options", "and", "either", "launch", "some", "configuration", "dialog", "or", "start", "an", "instance", "of", "_MainLoop", "as", "a", "daemon" ]
CogSciUOS/StudDP
python
https://github.com/CogSciUOS/StudDP/blob/e953aea51766438f2901c9e87f5b7b9e5bb892f5/studdp/studdp.py#L71-L102
[ "def", "main", "(", ")", ":", "(", "options", ",", "_", ")", "=", "_parse_args", "(", ")", "if", "options", ".", "change_password", ":", "c", ".", "keyring_set_password", "(", "c", "[", "\"username\"", "]", ")", "sys", ".", "exit", "(", "0", ")", "...
e953aea51766438f2901c9e87f5b7b9e5bb892f5
train
SignatureGenerator.generate
Takes data and returns a signature :arg dict signature_data: data to use to generate a signature :returns: ``Result`` instance
siggen/generator.py
def generate(self, signature_data): """Takes data and returns a signature :arg dict signature_data: data to use to generate a signature :returns: ``Result`` instance """ result = Result() for rule in self.pipeline: rule_name = rule.__class__.__name__ ...
def generate(self, signature_data): """Takes data and returns a signature :arg dict signature_data: data to use to generate a signature :returns: ``Result`` instance """ result = Result() for rule in self.pipeline: rule_name = rule.__class__.__name__ ...
[ "Takes", "data", "and", "returns", "a", "signature" ]
willkg/socorro-siggen
python
https://github.com/willkg/socorro-siggen/blob/db7e3233e665a458a961c48da22e93a69b1d08d6/siggen/generator.py#L74-L100
[ "def", "generate", "(", "self", ",", "signature_data", ")", ":", "result", "=", "Result", "(", ")", "for", "rule", "in", "self", ".", "pipeline", ":", "rule_name", "=", "rule", ".", "__class__", ".", "__name__", "try", ":", "if", "rule", ".", "predicat...
db7e3233e665a458a961c48da22e93a69b1d08d6
train
_blast
Helper function to expand (blast) str -> int map into str -> bool map. This is used to send word level inputs to aiger.
aigerbv/aigbv.py
def _blast(bvname2vals, name_map): """Helper function to expand (blast) str -> int map into str -> bool map. This is used to send word level inputs to aiger.""" if len(name_map) == 0: return dict() return fn.merge(*(dict(zip(names, bvname2vals[bvname])) for bvname, names in...
def _blast(bvname2vals, name_map): """Helper function to expand (blast) str -> int map into str -> bool map. This is used to send word level inputs to aiger.""" if len(name_map) == 0: return dict() return fn.merge(*(dict(zip(names, bvname2vals[bvname])) for bvname, names in...
[ "Helper", "function", "to", "expand", "(", "blast", ")", "str", "-", ">", "int", "map", "into", "str", "-", ">", "bool", "map", ".", "This", "is", "used", "to", "send", "word", "level", "inputs", "to", "aiger", "." ]
mvcisback/py-aiger-bv
python
https://github.com/mvcisback/py-aiger-bv/blob/855819844c429c35cdd8dc0b134bcd11f7b2fda3/aigerbv/aigbv.py#L13-L19
[ "def", "_blast", "(", "bvname2vals", ",", "name_map", ")", ":", "if", "len", "(", "name_map", ")", "==", "0", ":", "return", "dict", "(", ")", "return", "fn", ".", "merge", "(", "*", "(", "dict", "(", "zip", "(", "names", ",", "bvname2vals", "[", ...
855819844c429c35cdd8dc0b134bcd11f7b2fda3
train
_unblast
Helper function to lift str -> bool maps used by aiger to the word level. Dual of the `_blast` function.
aigerbv/aigbv.py
def _unblast(name2vals, name_map): """Helper function to lift str -> bool maps used by aiger to the word level. Dual of the `_blast` function.""" def _collect(names): return tuple(name2vals[n] for n in names) return {bvname: _collect(names) for bvname, names in name_map}
def _unblast(name2vals, name_map): """Helper function to lift str -> bool maps used by aiger to the word level. Dual of the `_blast` function.""" def _collect(names): return tuple(name2vals[n] for n in names) return {bvname: _collect(names) for bvname, names in name_map}
[ "Helper", "function", "to", "lift", "str", "-", ">", "bool", "maps", "used", "by", "aiger", "to", "the", "word", "level", ".", "Dual", "of", "the", "_blast", "function", "." ]
mvcisback/py-aiger-bv
python
https://github.com/mvcisback/py-aiger-bv/blob/855819844c429c35cdd8dc0b134bcd11f7b2fda3/aigerbv/aigbv.py#L22-L28
[ "def", "_unblast", "(", "name2vals", ",", "name_map", ")", ":", "def", "_collect", "(", "names", ")", ":", "return", "tuple", "(", "name2vals", "[", "n", "]", "for", "n", "in", "names", ")", "return", "{", "bvname", ":", "_collect", "(", "names", ")"...
855819844c429c35cdd8dc0b134bcd11f7b2fda3
train
LoggerMixin.create_logger
Generates a logger instance from the singleton
bors/app/log.py
def create_logger(self): """Generates a logger instance from the singleton""" name = "bors" if hasattr(self, "name"): name = self.name self.log = logging.getLogger(name) try: lvl = self.conf.get_log_level() except AttributeError: lvl =...
def create_logger(self): """Generates a logger instance from the singleton""" name = "bors" if hasattr(self, "name"): name = self.name self.log = logging.getLogger(name) try: lvl = self.conf.get_log_level() except AttributeError: lvl =...
[ "Generates", "a", "logger", "instance", "from", "the", "singleton" ]
RobotStudio/bors
python
https://github.com/RobotStudio/bors/blob/38bf338fc6905d90819faa56bd832140116720f0/bors/app/log.py#L8-L20
[ "def", "create_logger", "(", "self", ")", ":", "name", "=", "\"bors\"", "if", "hasattr", "(", "self", ",", "\"name\"", ")", ":", "name", "=", "self", ".", "name", "self", ".", "log", "=", "logging", ".", "getLogger", "(", "name", ")", "try", ":", "...
38bf338fc6905d90819faa56bd832140116720f0
train
get_cls
gets class from name and data, sets base level attrs defaults to facsimile.base.Facsimile
facsimile/facs.py
def get_cls(project_name, project_data): """ gets class from name and data, sets base level attrs defaults to facsimile.base.Facsimile """ if project_name: cls = getattr(facsimile.base, project_data.get('class', 'Facsimile')) cls.name = project_name else: cls = facsimile....
def get_cls(project_name, project_data): """ gets class from name and data, sets base level attrs defaults to facsimile.base.Facsimile """ if project_name: cls = getattr(facsimile.base, project_data.get('class', 'Facsimile')) cls.name = project_name else: cls = facsimile....
[ "gets", "class", "from", "name", "and", "data", "sets", "base", "level", "attrs", "defaults", "to", "facsimile", ".", "base", ".", "Facsimile" ]
20c/facsimile
python
https://github.com/20c/facsimile/blob/570e28568475d5be1b1a2c95b8e941fbfbc167eb/facsimile/facs.py#L29-L39
[ "def", "get_cls", "(", "project_name", ",", "project_data", ")", ":", "if", "project_name", ":", "cls", "=", "getattr", "(", "facsimile", ".", "base", ",", "project_data", ".", "get", "(", "'class'", ",", "'Facsimile'", ")", ")", "cls", ".", "name", "=",...
570e28568475d5be1b1a2c95b8e941fbfbc167eb
train
check_recaptcha
Chech that the entered recaptcha data is correct
djlotrek/decorators.py
def check_recaptcha(view_func): """Chech that the entered recaptcha data is correct""" @wraps(view_func) def _wrapped_view(request, *args, **kwargs): request.recaptcha_is_valid = None if request.method == 'POST': recaptcha_response = request.POST.get('g-recaptcha-response') ...
def check_recaptcha(view_func): """Chech that the entered recaptcha data is correct""" @wraps(view_func) def _wrapped_view(request, *args, **kwargs): request.recaptcha_is_valid = None if request.method == 'POST': recaptcha_response = request.POST.get('g-recaptcha-response') ...
[ "Chech", "that", "the", "entered", "recaptcha", "data", "is", "correct" ]
lotrekagency/djlotrek
python
https://github.com/lotrekagency/djlotrek/blob/10a304103768c3d59bdb8859eba86ef3327c9598/djlotrek/decorators.py#L7-L31
[ "def", "check_recaptcha", "(", "view_func", ")", ":", "@", "wraps", "(", "view_func", ")", "def", "_wrapped_view", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "request", ".", "recaptcha_is_valid", "=", "None", "if", "request", "....
10a304103768c3d59bdb8859eba86ef3327c9598
train
SafecastPy._request
Internal request method
SafecastPy/api.py
def _request(self, url, method="GET", params=None, api_call=None): """Internal request method""" method = method.lower() params = params or {} func = getattr(requests, method) requests_args = {} if method == "get" or method == "delete": requests_args["params"]...
def _request(self, url, method="GET", params=None, api_call=None): """Internal request method""" method = method.lower() params = params or {} func = getattr(requests, method) requests_args = {} if method == "get" or method == "delete": requests_args["params"]...
[ "Internal", "request", "method" ]
MonsieurV/SafecastPy
python
https://github.com/MonsieurV/SafecastPy/blob/8d35370dac0b52349af334c80f95f7dc6293e360/SafecastPy/api.py#L38-L74
[ "def", "_request", "(", "self", ",", "url", ",", "method", "=", "\"GET\"", ",", "params", "=", "None", ",", "api_call", "=", "None", ")", ":", "method", "=", "method", ".", "lower", "(", ")", "params", "=", "params", "or", "{", "}", "func", "=", ...
8d35370dac0b52349af334c80f95f7dc6293e360
train
SafecastPy.request
Return dict of response received from Safecast's API :param endpoint: (required) Full url or Safecast API endpoint (e.g. measurements/users) :type endpoint: string :param method: (optional) Method of accessing data, either GET, POST, PUT or DELETE....
SafecastPy/api.py
def request(self, endpoint, method="GET", params=None): """Return dict of response received from Safecast's API :param endpoint: (required) Full url or Safecast API endpoint (e.g. measurements/users) :type endpoint: string :param method: (optional) Method of acce...
def request(self, endpoint, method="GET", params=None): """Return dict of response received from Safecast's API :param endpoint: (required) Full url or Safecast API endpoint (e.g. measurements/users) :type endpoint: string :param method: (optional) Method of acce...
[ "Return", "dict", "of", "response", "received", "from", "Safecast", "s", "API", ":", "param", "endpoint", ":", "(", "required", ")", "Full", "url", "or", "Safecast", "API", "endpoint", "(", "e", ".", "g", ".", "measurements", "/", "users", ")", ":", "t...
MonsieurV/SafecastPy
python
https://github.com/MonsieurV/SafecastPy/blob/8d35370dac0b52349af334c80f95f7dc6293e360/SafecastPy/api.py#L76-L104
[ "def", "request", "(", "self", ",", "endpoint", ",", "method", "=", "\"GET\"", ",", "params", "=", "None", ")", ":", "# In case they want to pass a full Safecast URL", "# i.e. https://api.safecast.org/measurements.json", "if", "endpoint", ".", "startswith", "(", "\"http...
8d35370dac0b52349af334c80f95f7dc6293e360
train
GeneResource.post_list
(Copied from implementation in https://github.com/greenelab/adage-server/blob/master/adage/analyze/api.py) Handle an incoming POST as a GET to work around URI length limitations
genes/api.py
def post_list(self, request, **kwargs): """ (Copied from implementation in https://github.com/greenelab/adage-server/blob/master/adage/analyze/api.py) Handle an incoming POST as a GET to work around URI length limitations """ # The convert_post_to_VERB() technique is bor...
def post_list(self, request, **kwargs): """ (Copied from implementation in https://github.com/greenelab/adage-server/blob/master/adage/analyze/api.py) Handle an incoming POST as a GET to work around URI length limitations """ # The convert_post_to_VERB() technique is bor...
[ "(", "Copied", "from", "implementation", "in", "https", ":", "//", "github", ".", "com", "/", "greenelab", "/", "adage", "-", "server", "/", "blob", "/", "master", "/", "adage", "/", "analyze", "/", "api", ".", "py", ")" ]
greenelab/django-genes
python
https://github.com/greenelab/django-genes/blob/298939adcb115031acfc11cfcef60ea0b596fae5/genes/api.py#L202-L214
[ "def", "post_list", "(", "self", ",", "request", ",", "*", "*", "kwargs", ")", ":", "# The convert_post_to_VERB() technique is borrowed from", "# resources.py in tastypie source. This helps us to convert the POST", "# to a GET in the proper way internally.", "request", ".", "method...
298939adcb115031acfc11cfcef60ea0b596fae5
train
Strategy.execute
Execute the strategies on the given context
bors/app/strategy.py
def execute(self, context): """Execute the strategies on the given context""" for ware in self.middleware: ware.premessage(context) context = ware.bind(context) ware.postmessage(context) return context
def execute(self, context): """Execute the strategies on the given context""" for ware in self.middleware: ware.premessage(context) context = ware.bind(context) ware.postmessage(context) return context
[ "Execute", "the", "strategies", "on", "the", "given", "context" ]
RobotStudio/bors
python
https://github.com/RobotStudio/bors/blob/38bf338fc6905d90819faa56bd832140116720f0/bors/app/strategy.py#L24-L30
[ "def", "execute", "(", "self", ",", "context", ")", ":", "for", "ware", "in", "self", ".", "middleware", ":", "ware", ".", "premessage", "(", "context", ")", "context", "=", "ware", ".", "bind", "(", "context", ")", "ware", ".", "postmessage", "(", "...
38bf338fc6905d90819faa56bd832140116720f0
train
Strategy.shutdown
Perform cleanup! We're goin' down!!!
bors/app/strategy.py
def shutdown(self): """Perform cleanup! We're goin' down!!!""" for ware in self.middleware: ware.preshutdown() self._shutdown() ware.postshutdown()
def shutdown(self): """Perform cleanup! We're goin' down!!!""" for ware in self.middleware: ware.preshutdown() self._shutdown() ware.postshutdown()
[ "Perform", "cleanup!", "We", "re", "goin", "down!!!" ]
RobotStudio/bors
python
https://github.com/RobotStudio/bors/blob/38bf338fc6905d90819faa56bd832140116720f0/bors/app/strategy.py#L35-L40
[ "def", "shutdown", "(", "self", ")", ":", "for", "ware", "in", "self", ".", "middleware", ":", "ware", ".", "preshutdown", "(", ")", "self", ".", "_shutdown", "(", ")", "ware", ".", "postshutdown", "(", ")" ]
38bf338fc6905d90819faa56bd832140116720f0
train
main
Generates documentation for signature generation pipeline
siggen/cmd_doc.py
def main(argv=None): """Generates documentation for signature generation pipeline""" parser = argparse.ArgumentParser(description=DESCRIPTION) parser.add_argument( 'pipeline', help='Python dotted path to rules pipeline to document' ) parser.add_argument('output', help='output file') ...
def main(argv=None): """Generates documentation for signature generation pipeline""" parser = argparse.ArgumentParser(description=DESCRIPTION) parser.add_argument( 'pipeline', help='Python dotted path to rules pipeline to document' ) parser.add_argument('output', help='output file') ...
[ "Generates", "documentation", "for", "signature", "generation", "pipeline" ]
willkg/socorro-siggen
python
https://github.com/willkg/socorro-siggen/blob/db7e3233e665a458a961c48da22e93a69b1d08d6/siggen/cmd_doc.py#L68-L107
[ "def", "main", "(", "argv", "=", "None", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "DESCRIPTION", ")", "parser", ".", "add_argument", "(", "'pipeline'", ",", "help", "=", "'Python dotted path to rules pipeline to document...
db7e3233e665a458a961c48da22e93a69b1d08d6
train
Command.handle
This function is called by the Django API to specify how this object will be saved to the database.
organisms/management/commands/organisms_create_or_update.py
def handle(self, *args, **options): """This function is called by the Django API to specify how this object will be saved to the database. """ taxonomy_id = options['taxonomy_id'] # Remove leading and trailing blank characters in "common_name" # and "scientific_name ...
def handle(self, *args, **options): """This function is called by the Django API to specify how this object will be saved to the database. """ taxonomy_id = options['taxonomy_id'] # Remove leading and trailing blank characters in "common_name" # and "scientific_name ...
[ "This", "function", "is", "called", "by", "the", "Django", "API", "to", "specify", "how", "this", "object", "will", "be", "saved", "to", "the", "database", "." ]
greenelab/django-organisms
python
https://github.com/greenelab/django-organisms/blob/4ec5893e8b9d143fe3aa2be484b2d9c3b931016b/organisms/management/commands/organisms_create_or_update.py#L51-L91
[ "def", "handle", "(", "self", ",", "*", "args", ",", "*", "*", "options", ")", ":", "taxonomy_id", "=", "options", "[", "'taxonomy_id'", "]", "# Remove leading and trailing blank characters in \"common_name\"", "# and \"scientific_name", "common_name", "=", "options", ...
4ec5893e8b9d143fe3aa2be484b2d9c3b931016b
train
init
Creates a window of given resolution. :param resolution: the resolution of the windows as (width, height) in pixels :type resolution: tuple :param pygame_flags: modify the creation of the window. For further information see :ref:`creating_a_window` :type pygame_flags: int :param dis...
pyparadigm/misc.py
def init(resolution, pygame_flags=0, display_pos=(0, 0), interactive_mode=False): """Creates a window of given resolution. :param resolution: the resolution of the windows as (width, height) in pixels :type resolution: tuple :param pygame_flags: modify the creation of the window. For fu...
def init(resolution, pygame_flags=0, display_pos=(0, 0), interactive_mode=False): """Creates a window of given resolution. :param resolution: the resolution of the windows as (width, height) in pixels :type resolution: tuple :param pygame_flags: modify the creation of the window. For fu...
[ "Creates", "a", "window", "of", "given", "resolution", "." ]
KnorrFG/pyparadigm
python
https://github.com/KnorrFG/pyparadigm/blob/69944cdf3ce2f6414ae1aa1d27a0d8c6e5fb3fd3/pyparadigm/misc.py#L32-L68
[ "def", "init", "(", "resolution", ",", "pygame_flags", "=", "0", ",", "display_pos", "=", "(", "0", ",", "0", ")", ",", "interactive_mode", "=", "False", ")", ":", "os", ".", "environ", "[", "'SDL_VIDEO_WINDOW_POS'", "]", "=", "\"{}, {}\"", ".", "format"...
69944cdf3ce2f6414ae1aa1d27a0d8c6e5fb3fd3
train
display
Displays a pygame.Surface in the window. in pygame the window is represented through a surface, on which you can draw as on any other pygame.Surface. A refernce to to the screen can be optained via the :py:func:`pygame.display.get_surface` function. To display the contents of the screen surface in ...
pyparadigm/misc.py
def display(surface): """Displays a pygame.Surface in the window. in pygame the window is represented through a surface, on which you can draw as on any other pygame.Surface. A refernce to to the screen can be optained via the :py:func:`pygame.display.get_surface` function. To display the conte...
def display(surface): """Displays a pygame.Surface in the window. in pygame the window is represented through a surface, on which you can draw as on any other pygame.Surface. A refernce to to the screen can be optained via the :py:func:`pygame.display.get_surface` function. To display the conte...
[ "Displays", "a", "pygame", ".", "Surface", "in", "the", "window", ".", "in", "pygame", "the", "window", "is", "represented", "through", "a", "surface", "on", "which", "you", "can", "draw", "as", "on", "any", "other", "pygame", ".", "Surface", ".", "A", ...
KnorrFG/pyparadigm
python
https://github.com/KnorrFG/pyparadigm/blob/69944cdf3ce2f6414ae1aa1d27a0d8c6e5fb3fd3/pyparadigm/misc.py#L70-L87
[ "def", "display", "(", "surface", ")", ":", "screen", "=", "pygame", ".", "display", ".", "get_surface", "(", ")", "screen", ".", "blit", "(", "surface", ",", "(", "0", ",", "0", ")", ")", "pygame", ".", "display", ".", "flip", "(", ")" ]
69944cdf3ce2f6414ae1aa1d27a0d8c6e5fb3fd3
train
empty_surface
Returns an empty surface filled with fill_color. :param fill_color: color to fill the surface with :type fill_color: pygame.Color :param size: the size of the new surface, if None its created to be the same size as the screen :type size: int-2-tuple
pyparadigm/misc.py
def empty_surface(fill_color, size=None): """Returns an empty surface filled with fill_color. :param fill_color: color to fill the surface with :type fill_color: pygame.Color :param size: the size of the new surface, if None its created to be the same size as the screen :type size: int-2-t...
def empty_surface(fill_color, size=None): """Returns an empty surface filled with fill_color. :param fill_color: color to fill the surface with :type fill_color: pygame.Color :param size: the size of the new surface, if None its created to be the same size as the screen :type size: int-2-t...
[ "Returns", "an", "empty", "surface", "filled", "with", "fill_color", "." ]
KnorrFG/pyparadigm
python
https://github.com/KnorrFG/pyparadigm/blob/69944cdf3ce2f6414ae1aa1d27a0d8c6e5fb3fd3/pyparadigm/misc.py#L114-L127
[ "def", "empty_surface", "(", "fill_color", ",", "size", "=", "None", ")", ":", "sr", "=", "pygame", ".", "display", ".", "get_surface", "(", ")", ".", "get_rect", "(", ")", "surf", "=", "pygame", ".", "Surface", "(", "size", "or", "(", "sr", ".", "...
69944cdf3ce2f6414ae1aa1d27a0d8c6e5fb3fd3
train
process_char
This is a convinience method for use with EventListener.wait_for_unicode_char(). In most cases it simply appends char to buffer. Some replacements are done because presing return will produce '\\r' but for most cases '\\n' would be desireable. Also backspace cant just be added to a string either, ther...
pyparadigm/misc.py
def process_char(buffer: str, char: str, mappings=_char_mappings): """This is a convinience method for use with EventListener.wait_for_unicode_char(). In most cases it simply appends char to buffer. Some replacements are done because presing return will produce '\\r' but for most cases '\\n' would be ...
def process_char(buffer: str, char: str, mappings=_char_mappings): """This is a convinience method for use with EventListener.wait_for_unicode_char(). In most cases it simply appends char to buffer. Some replacements are done because presing return will produce '\\r' but for most cases '\\n' would be ...
[ "This", "is", "a", "convinience", "method", "for", "use", "with", "EventListener", ".", "wait_for_unicode_char", "()", ".", "In", "most", "cases", "it", "simply", "appends", "char", "to", "buffer", ".", "Some", "replacements", "are", "done", "because", "presin...
KnorrFG/pyparadigm
python
https://github.com/KnorrFG/pyparadigm/blob/69944cdf3ce2f6414ae1aa1d27a0d8c6e5fb3fd3/pyparadigm/misc.py#L135-L160
[ "def", "process_char", "(", "buffer", ":", "str", ",", "char", ":", "str", ",", "mappings", "=", "_char_mappings", ")", ":", "if", "char", "in", "mappings", ":", "return", "buffer", "+", "mappings", "[", "char", "]", "elif", "char", "==", "\"\\u0008\"", ...
69944cdf3ce2f6414ae1aa1d27a0d8c6e5fb3fd3
train
SCAdapter.run
Called by internal API subsystem to initialize websockets connections in the API interface
bors/api/adapter/socketcluster.py
def run(self): """ Called by internal API subsystem to initialize websockets connections in the API interface """ self.api = self.context.get("cls")(self.context) self.context["inst"].append(self) # Adapters used by strategies def on_ws_connect(*args, **kwargs):...
def run(self): """ Called by internal API subsystem to initialize websockets connections in the API interface """ self.api = self.context.get("cls")(self.context) self.context["inst"].append(self) # Adapters used by strategies def on_ws_connect(*args, **kwargs):...
[ "Called", "by", "internal", "API", "subsystem", "to", "initialize", "websockets", "connections", "in", "the", "API", "interface" ]
RobotStudio/bors
python
https://github.com/RobotStudio/bors/blob/38bf338fc6905d90819faa56bd832140116720f0/bors/api/adapter/socketcluster.py#L17-L42
[ "def", "run", "(", "self", ")", ":", "self", ".", "api", "=", "self", ".", "context", ".", "get", "(", "\"cls\"", ")", "(", "self", ".", "context", ")", "self", ".", "context", "[", "\"inst\"", "]", ".", "append", "(", "self", ")", "# Adapters used...
38bf338fc6905d90819faa56bd832140116720f0
train
SCAdapter.add_channels
Take a list of SockChannel objects and extend the websock listener
bors/api/adapter/socketcluster.py
def add_channels(self, channels): """ Take a list of SockChannel objects and extend the websock listener """ chans = [ SockChannel(chan, res, self._generate_result) for chan, res in channels.items() ] self.api.channels.extend(chans) self.ap...
def add_channels(self, channels): """ Take a list of SockChannel objects and extend the websock listener """ chans = [ SockChannel(chan, res, self._generate_result) for chan, res in channels.items() ] self.api.channels.extend(chans) self.ap...
[ "Take", "a", "list", "of", "SockChannel", "objects", "and", "extend", "the", "websock", "listener" ]
RobotStudio/bors
python
https://github.com/RobotStudio/bors/blob/38bf338fc6905d90819faa56bd832140116720f0/bors/api/adapter/socketcluster.py#L48-L57
[ "def", "add_channels", "(", "self", ",", "channels", ")", ":", "chans", "=", "[", "SockChannel", "(", "chan", ",", "res", ",", "self", ".", "_generate_result", ")", "for", "chan", ",", "res", "in", "channels", ".", "items", "(", ")", "]", "self", "."...
38bf338fc6905d90819faa56bd832140116720f0
train
SCAdapter._generate_result
Generate the result object
bors/api/adapter/socketcluster.py
def _generate_result(self, res_type, channel, result): """Generate the result object""" schema = self.api.ws_result_schema() schema.context['channel'] = channel schema.context['response_type'] = res_type self.callback(schema.load(result), self.context)
def _generate_result(self, res_type, channel, result): """Generate the result object""" schema = self.api.ws_result_schema() schema.context['channel'] = channel schema.context['response_type'] = res_type self.callback(schema.load(result), self.context)
[ "Generate", "the", "result", "object" ]
RobotStudio/bors
python
https://github.com/RobotStudio/bors/blob/38bf338fc6905d90819faa56bd832140116720f0/bors/api/adapter/socketcluster.py#L59-L64
[ "def", "_generate_result", "(", "self", ",", "res_type", ",", "channel", ",", "result", ")", ":", "schema", "=", "self", ".", "api", ".", "ws_result_schema", "(", ")", "schema", ".", "context", "[", "'channel'", "]", "=", "channel", "schema", ".", "conte...
38bf338fc6905d90819faa56bd832140116720f0
train
rand_elem
returns a random element from seq n times. If n is None, it continues indefinitly
doc/examples/stroop.py
def rand_elem(seq, n=None): """returns a random element from seq n times. If n is None, it continues indefinitly""" return map(random.choice, repeat(seq, n) if n is not None else repeat(seq))
def rand_elem(seq, n=None): """returns a random element from seq n times. If n is None, it continues indefinitly""" return map(random.choice, repeat(seq, n) if n is not None else repeat(seq))
[ "returns", "a", "random", "element", "from", "seq", "n", "times", ".", "If", "n", "is", "None", "it", "continues", "indefinitly" ]
KnorrFG/pyparadigm
python
https://github.com/KnorrFG/pyparadigm/blob/69944cdf3ce2f6414ae1aa1d27a0d8c6e5fb3fd3/doc/examples/stroop.py#L201-L203
[ "def", "rand_elem", "(", "seq", ",", "n", "=", "None", ")", ":", "return", "map", "(", "random", ".", "choice", ",", "repeat", "(", "seq", ",", "n", ")", "if", "n", "is", "not", "None", "else", "repeat", "(", "seq", ")", ")" ]
69944cdf3ce2f6414ae1aa1d27a0d8c6e5fb3fd3
train
first_paragraph
Return first paragraph of multiline_str as a oneliner. When without_trailing_dot is True, the last char of the first paragraph will be removed, if it is a dot ('.'). Examples: >>> multiline_str = 'first line\\nsecond line\\n\\nnext paragraph' >>> print(first_paragraph(multiline_str)) ...
utlz/__init__.py
def first_paragraph(multiline_str, without_trailing_dot=True, maxlength=None): '''Return first paragraph of multiline_str as a oneliner. When without_trailing_dot is True, the last char of the first paragraph will be removed, if it is a dot ('.'). Examples: >>> multiline_str = 'first line\\nse...
def first_paragraph(multiline_str, without_trailing_dot=True, maxlength=None): '''Return first paragraph of multiline_str as a oneliner. When without_trailing_dot is True, the last char of the first paragraph will be removed, if it is a dot ('.'). Examples: >>> multiline_str = 'first line\\nse...
[ "Return", "first", "paragraph", "of", "multiline_str", "as", "a", "oneliner", "." ]
theno/utlz
python
https://github.com/theno/utlz/blob/bf7d2b53f3e0d35c6f8ded81f3f774a74fcd3389/utlz/__init__.py#L67-L109
[ "def", "first_paragraph", "(", "multiline_str", ",", "without_trailing_dot", "=", "True", ",", "maxlength", "=", "None", ")", ":", "stripped", "=", "'\\n'", ".", "join", "(", "[", "line", ".", "strip", "(", ")", "for", "line", "in", "multiline_str", ".", ...
bf7d2b53f3e0d35c6f8ded81f3f774a74fcd3389
train
print_doc1
Print the first paragraph of the docstring of the decorated function. The paragraph will be printed as a oneliner. May be invoked as a simple, argument-less decorator (i.e. ``@print_doc1``) or with named arguments ``color``, ``bold``, ``prefix`` of ``tail`` (eg. ``@print_doc1(color=utils.red, bold=Tru...
utlz/__init__.py
def print_doc1(*args, **kwargs): '''Print the first paragraph of the docstring of the decorated function. The paragraph will be printed as a oneliner. May be invoked as a simple, argument-less decorator (i.e. ``@print_doc1``) or with named arguments ``color``, ``bold``, ``prefix`` of ``tail`` (eg....
def print_doc1(*args, **kwargs): '''Print the first paragraph of the docstring of the decorated function. The paragraph will be printed as a oneliner. May be invoked as a simple, argument-less decorator (i.e. ``@print_doc1``) or with named arguments ``color``, ``bold``, ``prefix`` of ``tail`` (eg....
[ "Print", "the", "first", "paragraph", "of", "the", "docstring", "of", "the", "decorated", "function", "." ]
theno/utlz
python
https://github.com/theno/utlz/blob/bf7d2b53f3e0d35c6f8ded81f3f774a74fcd3389/utlz/__init__.py#L114-L173
[ "def", "print_doc1", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# output settings from kwargs or take defaults", "color", "=", "kwargs", ".", "get", "(", "'color'", ",", "blue", ")", "bold", "=", "kwargs", ".", "get", "(", "'bold'", ",", "False"...
bf7d2b53f3e0d35c6f8ded81f3f774a74fcd3389
train
print_full_name
Decorator, print the full name of the decorated function. May be invoked as a simple, argument-less decorator (i.e. ``@print_doc1``) or with named arguments ``color``, ``bold``, or ``prefix`` (eg. ``@print_doc1(color=utils.red, bold=True, prefix=' ')``).
utlz/__init__.py
def print_full_name(*args, **kwargs): '''Decorator, print the full name of the decorated function. May be invoked as a simple, argument-less decorator (i.e. ``@print_doc1``) or with named arguments ``color``, ``bold``, or ``prefix`` (eg. ``@print_doc1(color=utils.red, bold=True, prefix=' ')``). '''...
def print_full_name(*args, **kwargs): '''Decorator, print the full name of the decorated function. May be invoked as a simple, argument-less decorator (i.e. ``@print_doc1``) or with named arguments ``color``, ``bold``, or ``prefix`` (eg. ``@print_doc1(color=utils.red, bold=True, prefix=' ')``). '''...
[ "Decorator", "print", "the", "full", "name", "of", "the", "decorated", "function", "." ]
theno/utlz
python
https://github.com/theno/utlz/blob/bf7d2b53f3e0d35c6f8ded81f3f774a74fcd3389/utlz/__init__.py#L177-L208
[ "def", "print_full_name", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "color", "=", "kwargs", ".", "get", "(", "'color'", ",", "default_color", ")", "bold", "=", "kwargs", ".", "get", "(", "'bold'", ",", "False", ")", "prefix", "=", "kwargs"...
bf7d2b53f3e0d35c6f8ded81f3f774a74fcd3389
train
filled_out_template_str
Return str template with applied substitutions. Example: >>> template = 'Asyl for {{name}} {{surname}}!' >>> filled_out_template_str(template, name='Edward', surname='Snowden') 'Asyl for Edward Snowden!' >>> template = '[[[foo]]] was substituted by {{foo}}' >>> filled_out_t...
utlz/__init__.py
def filled_out_template_str(template, **substitutions): '''Return str template with applied substitutions. Example: >>> template = 'Asyl for {{name}} {{surname}}!' >>> filled_out_template_str(template, name='Edward', surname='Snowden') 'Asyl for Edward Snowden!' >>> template = ...
def filled_out_template_str(template, **substitutions): '''Return str template with applied substitutions. Example: >>> template = 'Asyl for {{name}} {{surname}}!' >>> filled_out_template_str(template, name='Edward', surname='Snowden') 'Asyl for Edward Snowden!' >>> template = ...
[ "Return", "str", "template", "with", "applied", "substitutions", "." ]
theno/utlz
python
https://github.com/theno/utlz/blob/bf7d2b53f3e0d35c6f8ded81f3f774a74fcd3389/utlz/__init__.py#L278-L303
[ "def", "filled_out_template_str", "(", "template", ",", "*", "*", "substitutions", ")", ":", "template", "=", "template", ".", "replace", "(", "'{'", ",", "'{{'", ")", "template", "=", "template", ".", "replace", "(", "'}'", ",", "'}}'", ")", "template", ...
bf7d2b53f3e0d35c6f8ded81f3f774a74fcd3389
train
filled_out_template
Return content of file filename with applied substitutions.
utlz/__init__.py
def filled_out_template(filename, **substitutions): '''Return content of file filename with applied substitutions.''' res = None with open(filename, 'r') as fp: template = fp.read() res = filled_out_template_str(template, **substitutions) return res
def filled_out_template(filename, **substitutions): '''Return content of file filename with applied substitutions.''' res = None with open(filename, 'r') as fp: template = fp.read() res = filled_out_template_str(template, **substitutions) return res
[ "Return", "content", "of", "file", "filename", "with", "applied", "substitutions", "." ]
theno/utlz
python
https://github.com/theno/utlz/blob/bf7d2b53f3e0d35c6f8ded81f3f774a74fcd3389/utlz/__init__.py#L307-L313
[ "def", "filled_out_template", "(", "filename", ",", "*", "*", "substitutions", ")", ":", "res", "=", "None", "with", "open", "(", "filename", ",", "'r'", ")", "as", "fp", ":", "template", "=", "fp", ".", "read", "(", ")", "res", "=", "filled_out_templa...
bf7d2b53f3e0d35c6f8ded81f3f774a74fcd3389
train
update_or_append_line
Search in file 'filename' for a line starting with 'prefix' and replace the line by 'new_line'. If a line starting with 'prefix' not exists 'new_line' will be appended. If the file not exists, it will be created. Return False if new_line was appended, else True (i.e. if the prefix was found within...
utlz/__init__.py
def update_or_append_line(filename, prefix, new_line, keep_backup=True, append=True): '''Search in file 'filename' for a line starting with 'prefix' and replace the line by 'new_line'. If a line starting with 'prefix' not exists 'new_line' will be appended. If the file not exi...
def update_or_append_line(filename, prefix, new_line, keep_backup=True, append=True): '''Search in file 'filename' for a line starting with 'prefix' and replace the line by 'new_line'. If a line starting with 'prefix' not exists 'new_line' will be appended. If the file not exi...
[ "Search", "in", "file", "filename", "for", "a", "line", "starting", "with", "prefix", "and", "replace", "the", "line", "by", "new_line", "." ]
theno/utlz
python
https://github.com/theno/utlz/blob/bf7d2b53f3e0d35c6f8ded81f3f774a74fcd3389/utlz/__init__.py#L318-L354
[ "def", "update_or_append_line", "(", "filename", ",", "prefix", ",", "new_line", ",", "keep_backup", "=", "True", ",", "append", "=", "True", ")", ":", "same_line_exists", ",", "line_updated", "=", "False", ",", "False", "filename", "=", "os", ".", "path", ...
bf7d2b53f3e0d35c6f8ded81f3f774a74fcd3389
train
comment_out_line
Comment line out by putting a comment sign in front of the line. If the file does not contain the line, the files content will not be changed (but the file will be touched in every case).
utlz/__init__.py
def comment_out_line(filename, line, comment='#', update_or_append_line=update_or_append_line): '''Comment line out by putting a comment sign in front of the line. If the file does not contain the line, the files content will not be changed (but the file will be touched in every case)....
def comment_out_line(filename, line, comment='#', update_or_append_line=update_or_append_line): '''Comment line out by putting a comment sign in front of the line. If the file does not contain the line, the files content will not be changed (but the file will be touched in every case)....
[ "Comment", "line", "out", "by", "putting", "a", "comment", "sign", "in", "front", "of", "the", "line", "." ]
theno/utlz
python
https://github.com/theno/utlz/blob/bf7d2b53f3e0d35c6f8ded81f3f774a74fcd3389/utlz/__init__.py#L358-L366
[ "def", "comment_out_line", "(", "filename", ",", "line", ",", "comment", "=", "'#'", ",", "update_or_append_line", "=", "update_or_append_line", ")", ":", "update_or_append_line", "(", "filename", ",", "prefix", "=", "line", ",", "new_line", "=", "comment", "+",...
bf7d2b53f3e0d35c6f8ded81f3f774a74fcd3389
train
uncomment_or_update_or_append_line
Remove the comment of an commented out line and make the line "active". If such an commented out line not exists it would be appended.
utlz/__init__.py
def uncomment_or_update_or_append_line(filename, prefix, new_line, comment='#', keep_backup=True, update_or_append_line=update_or_append_line): '''Remove the comment of an commented out line and make the line "active". If such an com...
def uncomment_or_update_or_append_line(filename, prefix, new_line, comment='#', keep_backup=True, update_or_append_line=update_or_append_line): '''Remove the comment of an commented out line and make the line "active". If such an com...
[ "Remove", "the", "comment", "of", "an", "commented", "out", "line", "and", "make", "the", "line", "active", "." ]
theno/utlz
python
https://github.com/theno/utlz/blob/bf7d2b53f3e0d35c6f8ded81f3f774a74fcd3389/utlz/__init__.py#L370-L382
[ "def", "uncomment_or_update_or_append_line", "(", "filename", ",", "prefix", ",", "new_line", ",", "comment", "=", "'#'", ",", "keep_backup", "=", "True", ",", "update_or_append_line", "=", "update_or_append_line", ")", ":", "uncommented", "=", "update_or_append_line"...
bf7d2b53f3e0d35c6f8ded81f3f774a74fcd3389
train
convert_unicode_2_utf8
Return a copy of `input` with every str component encoded from unicode to utf-8.
utlz/__init__.py
def convert_unicode_2_utf8(input): '''Return a copy of `input` with every str component encoded from unicode to utf-8. ''' if isinstance(input, dict): try: # python-2.6 return dict((convert_unicode_2_utf8(key), convert_unicode_2_utf8(value)) for ke...
def convert_unicode_2_utf8(input): '''Return a copy of `input` with every str component encoded from unicode to utf-8. ''' if isinstance(input, dict): try: # python-2.6 return dict((convert_unicode_2_utf8(key), convert_unicode_2_utf8(value)) for ke...
[ "Return", "a", "copy", "of", "input", "with", "every", "str", "component", "encoded", "from", "unicode", "to", "utf", "-", "8", "." ]
theno/utlz
python
https://github.com/theno/utlz/blob/bf7d2b53f3e0d35c6f8ded81f3f774a74fcd3389/utlz/__init__.py#L387-L417
[ "def", "convert_unicode_2_utf8", "(", "input", ")", ":", "if", "isinstance", "(", "input", ",", "dict", ")", ":", "try", ":", "# python-2.6", "return", "dict", "(", "(", "convert_unicode_2_utf8", "(", "key", ")", ",", "convert_unicode_2_utf8", "(", "value", ...
bf7d2b53f3e0d35c6f8ded81f3f774a74fcd3389
train
load_json
Return the json-file data, with all strings utf-8 encoded.
utlz/__init__.py
def load_json(filename, gzip_mode=False): '''Return the json-file data, with all strings utf-8 encoded.''' open_file = open if gzip_mode: open_file = gzip.open try: with open_file(filename, 'rt') as fh: data = json.load(fh) data = convert_unicode_2_utf8(data) ...
def load_json(filename, gzip_mode=False): '''Return the json-file data, with all strings utf-8 encoded.''' open_file = open if gzip_mode: open_file = gzip.open try: with open_file(filename, 'rt') as fh: data = json.load(fh) data = convert_unicode_2_utf8(data) ...
[ "Return", "the", "json", "-", "file", "data", "with", "all", "strings", "utf", "-", "8", "encoded", "." ]
theno/utlz
python
https://github.com/theno/utlz/blob/bf7d2b53f3e0d35c6f8ded81f3f774a74fcd3389/utlz/__init__.py#L420-L438
[ "def", "load_json", "(", "filename", ",", "gzip_mode", "=", "False", ")", ":", "open_file", "=", "open", "if", "gzip_mode", ":", "open_file", "=", "gzip", ".", "open", "try", ":", "with", "open_file", "(", "filename", ",", "'rt'", ")", "as", "fh", ":",...
bf7d2b53f3e0d35c6f8ded81f3f774a74fcd3389
train
write_json
Write the python data structure as a json-Object to filename.
utlz/__init__.py
def write_json(data, filename, gzip_mode=False): '''Write the python data structure as a json-Object to filename.''' open_file = open if gzip_mode: open_file = gzip.open try: with open_file(filename, 'wt') as fh: json.dump(obj=data, fp=fh, sort_keys=True) except Attribu...
def write_json(data, filename, gzip_mode=False): '''Write the python data structure as a json-Object to filename.''' open_file = open if gzip_mode: open_file = gzip.open try: with open_file(filename, 'wt') as fh: json.dump(obj=data, fp=fh, sort_keys=True) except Attribu...
[ "Write", "the", "python", "data", "structure", "as", "a", "json", "-", "Object", "to", "filename", "." ]
theno/utlz
python
https://github.com/theno/utlz/blob/bf7d2b53f3e0d35c6f8ded81f3f774a74fcd3389/utlz/__init__.py#L441-L455
[ "def", "write_json", "(", "data", ",", "filename", ",", "gzip_mode", "=", "False", ")", ":", "open_file", "=", "open", "if", "gzip_mode", ":", "open_file", "=", "gzip", ".", "open", "try", ":", "with", "open_file", "(", "filename", ",", "'wt'", ")", "a...
bf7d2b53f3e0d35c6f8ded81f3f774a74fcd3389
train
text_with_newlines
Return text with a `newline` inserted after each `line_length` char. Return `text` unchanged if line_length == 0.
utlz/__init__.py
def text_with_newlines(text, line_length=78, newline='\n'): '''Return text with a `newline` inserted after each `line_length` char. Return `text` unchanged if line_length == 0. ''' if line_length > 0: if len(text) <= line_length: return text else: return newline....
def text_with_newlines(text, line_length=78, newline='\n'): '''Return text with a `newline` inserted after each `line_length` char. Return `text` unchanged if line_length == 0. ''' if line_length > 0: if len(text) <= line_length: return text else: return newline....
[ "Return", "text", "with", "a", "newline", "inserted", "after", "each", "line_length", "char", "." ]
theno/utlz
python
https://github.com/theno/utlz/blob/bf7d2b53f3e0d35c6f8ded81f3f774a74fcd3389/utlz/__init__.py#L468-L481
[ "def", "text_with_newlines", "(", "text", ",", "line_length", "=", "78", ",", "newline", "=", "'\\n'", ")", ":", "if", "line_length", ">", "0", ":", "if", "len", "(", "text", ")", "<=", "line_length", ":", "return", "text", "else", ":", "return", "newl...
bf7d2b53f3e0d35c6f8ded81f3f774a74fcd3389
train
lazy_val
A memoize decorator for class properties. Return a cached property that is calculated by function `func` on first access.
utlz/__init__.py
def lazy_val(func, with_del_hook=False): '''A memoize decorator for class properties. Return a cached property that is calculated by function `func` on first access. ''' def hook_for(that): try: orig_del = that.__del__ except AttributeError: orig_del = None ...
def lazy_val(func, with_del_hook=False): '''A memoize decorator for class properties. Return a cached property that is calculated by function `func` on first access. ''' def hook_for(that): try: orig_del = that.__del__ except AttributeError: orig_del = None ...
[ "A", "memoize", "decorator", "for", "class", "properties", "." ]
theno/utlz
python
https://github.com/theno/utlz/blob/bf7d2b53f3e0d35c6f8ded81f3f774a74fcd3389/utlz/__init__.py#L492-L544
[ "def", "lazy_val", "(", "func", ",", "with_del_hook", "=", "False", ")", ":", "def", "hook_for", "(", "that", ")", ":", "try", ":", "orig_del", "=", "that", ".", "__del__", "except", "AttributeError", ":", "orig_del", "=", "None", "def", "del_hook", "(",...
bf7d2b53f3e0d35c6f8ded81f3f774a74fcd3389
train
_readlines
Read all lines from file.
pmisc/compat3.py
def _readlines(fname, fpointer1=open, fpointer2=open): # pragma: no cover """Read all lines from file.""" # fpointer1, fpointer2 arguments to ease testing try: with fpointer1(fname, "r") as fobj: return fobj.readlines() except UnicodeDecodeError: # pragma: no cover with fpo...
def _readlines(fname, fpointer1=open, fpointer2=open): # pragma: no cover """Read all lines from file.""" # fpointer1, fpointer2 arguments to ease testing try: with fpointer1(fname, "r") as fobj: return fobj.readlines() except UnicodeDecodeError: # pragma: no cover with fpo...
[ "Read", "all", "lines", "from", "file", "." ]
pmacosta/pmisc
python
https://github.com/pmacosta/pmisc/blob/dd2bb32e59eee872f1ef2db2d9921a396ab9f50b/pmisc/compat3.py#L30-L38
[ "def", "_readlines", "(", "fname", ",", "fpointer1", "=", "open", ",", "fpointer2", "=", "open", ")", ":", "# pragma: no cover", "# fpointer1, fpointer2 arguments to ease testing", "try", ":", "with", "fpointer1", "(", "fname", ",", "\"r\"", ")", "as", "fobj", "...
dd2bb32e59eee872f1ef2db2d9921a396ab9f50b
train
Req.call
Generic interface to REST apiGeneric interface to REST api :param callname: query name :param data: dictionary of inputs :param args: keyword arguments added to the payload :return:
bors/api/requestor.py
def call(self, callname, data=None, **args): """ Generic interface to REST apiGeneric interface to REST api :param callname: query name :param data: dictionary of inputs :param args: keyword arguments added to the payload :return: """ url = f"{self.u...
def call(self, callname, data=None, **args): """ Generic interface to REST apiGeneric interface to REST api :param callname: query name :param data: dictionary of inputs :param args: keyword arguments added to the payload :return: """ url = f"{self.u...
[ "Generic", "interface", "to", "REST", "apiGeneric", "interface", "to", "REST", "api", ":", "param", "callname", ":", "query", "name", ":", "param", "data", ":", "dictionary", "of", "inputs", ":", "param", "args", ":", "keyword", "arguments", "added", "to", ...
RobotStudio/bors
python
https://github.com/RobotStudio/bors/blob/38bf338fc6905d90819faa56bd832140116720f0/bors/api/requestor.py#L20-L47
[ "def", "call", "(", "self", ",", "callname", ",", "data", "=", "None", ",", "*", "*", "args", ")", ":", "url", "=", "f\"{self.url_base}/{callname}\"", "payload", "=", "self", ".", "payload", ".", "copy", "(", ")", "payload", ".", "update", "(", "*", ...
38bf338fc6905d90819faa56bd832140116720f0
train
NagiosPlugins.launch_plugin
launch nagios_plugin command
monitoring_agent/inputs/nagios_plugins.py
def launch_plugin(self): ''' launch nagios_plugin command ''' # nagios_plugins probes for plugin in self.plugins: # Construct the nagios_plugin command command = ('%s%s' % (self.plugins[plugin]['path'], self.plugins[plugin]['command'])) try: ...
def launch_plugin(self): ''' launch nagios_plugin command ''' # nagios_plugins probes for plugin in self.plugins: # Construct the nagios_plugin command command = ('%s%s' % (self.plugins[plugin]['path'], self.plugins[plugin]['command'])) try: ...
[ "launch", "nagios_plugin", "command" ]
Eyepea/tanto
python
https://github.com/Eyepea/tanto/blob/ad8fd32e0fd3b7bc3dee5dabb984a2567ae46fe9/monitoring_agent/inputs/nagios_plugins.py#L31-L64
[ "def", "launch_plugin", "(", "self", ")", ":", "# nagios_plugins probes", "for", "plugin", "in", "self", ".", "plugins", ":", "# Construct the nagios_plugin command", "command", "=", "(", "'%s%s'", "%", "(", "self", ".", "plugins", "[", "plugin", "]", "[", "'p...
ad8fd32e0fd3b7bc3dee5dabb984a2567ae46fe9
train
File.match
for a given path and regexp pattern, return the files that match
bl/file.py
def match(Class, path, pattern, flags=re.I, sortkey=None, ext=None): """for a given path and regexp pattern, return the files that match""" return sorted( [ Class(fn=fn) for fn in rglob(path, f"*{ext or ''}") if re.search(pattern, os.path.basen...
def match(Class, path, pattern, flags=re.I, sortkey=None, ext=None): """for a given path and regexp pattern, return the files that match""" return sorted( [ Class(fn=fn) for fn in rglob(path, f"*{ext or ''}") if re.search(pattern, os.path.basen...
[ "for", "a", "given", "path", "and", "regexp", "pattern", "return", "the", "files", "that", "match" ]
BlackEarth/bl
python
https://github.com/BlackEarth/bl/blob/edf6f37dac718987260b90ad0e7f7fe084a7c1a3/bl/file.py#L57-L67
[ "def", "match", "(", "Class", ",", "path", ",", "pattern", ",", "flags", "=", "re", ".", "I", ",", "sortkey", "=", "None", ",", "ext", "=", "None", ")", ":", "return", "sorted", "(", "[", "Class", "(", "fn", "=", "fn", ")", "for", "fn", "in", ...
edf6f37dac718987260b90ad0e7f7fe084a7c1a3
train
File.copy
copy the file to the new_fn, preserving atime and mtime
bl/file.py
def copy(self, new_fn): """copy the file to the new_fn, preserving atime and mtime""" new_file = self.__class__(fn=str(new_fn)) new_file.write(data=self.read()) new_file.utime(self.atime, self.mtime) return new_file
def copy(self, new_fn): """copy the file to the new_fn, preserving atime and mtime""" new_file = self.__class__(fn=str(new_fn)) new_file.write(data=self.read()) new_file.utime(self.atime, self.mtime) return new_file
[ "copy", "the", "file", "to", "the", "new_fn", "preserving", "atime", "and", "mtime" ]
BlackEarth/bl
python
https://github.com/BlackEarth/bl/blob/edf6f37dac718987260b90ad0e7f7fe084a7c1a3/bl/file.py#L124-L129
[ "def", "copy", "(", "self", ",", "new_fn", ")", ":", "new_file", "=", "self", ".", "__class__", "(", "fn", "=", "str", "(", "new_fn", ")", ")", "new_file", ".", "write", "(", "data", "=", "self", ".", "read", "(", ")", ")", "new_file", ".", "utim...
edf6f37dac718987260b90ad0e7f7fe084a7c1a3
train
File.make_basename
make a filesystem-compliant basename for this file
bl/file.py
def make_basename(self, fn=None, ext=None): """make a filesystem-compliant basename for this file""" fb, oldext = os.path.splitext(os.path.basename(fn or self.fn)) ext = ext or oldext.lower() fb = String(fb).hyphenify(ascii=True) return ''.join([fb, ext])
def make_basename(self, fn=None, ext=None): """make a filesystem-compliant basename for this file""" fb, oldext = os.path.splitext(os.path.basename(fn or self.fn)) ext = ext or oldext.lower() fb = String(fb).hyphenify(ascii=True) return ''.join([fb, ext])
[ "make", "a", "filesystem", "-", "compliant", "basename", "for", "this", "file" ]
BlackEarth/bl
python
https://github.com/BlackEarth/bl/blob/edf6f37dac718987260b90ad0e7f7fe084a7c1a3/bl/file.py#L140-L145
[ "def", "make_basename", "(", "self", ",", "fn", "=", "None", ",", "ext", "=", "None", ")", ":", "fb", ",", "oldext", "=", "os", ".", "path", ".", "splitext", "(", "os", ".", "path", ".", "basename", "(", "fn", "or", "self", ".", "fn", ")", ")",...
edf6f37dac718987260b90ad0e7f7fe084a7c1a3
train
File.tempfile
write the contents of the file to a tempfile and return the tempfile filename
bl/file.py
def tempfile(self, mode='wb', **args): "write the contents of the file to a tempfile and return the tempfile filename" tf = tempfile.NamedTemporaryFile(mode=mode) self.write(tf.name, mode=mode, **args) return tfn
def tempfile(self, mode='wb', **args): "write the contents of the file to a tempfile and return the tempfile filename" tf = tempfile.NamedTemporaryFile(mode=mode) self.write(tf.name, mode=mode, **args) return tfn
[ "write", "the", "contents", "of", "the", "file", "to", "a", "tempfile", "and", "return", "the", "tempfile", "filename" ]
BlackEarth/bl
python
https://github.com/BlackEarth/bl/blob/edf6f37dac718987260b90ad0e7f7fe084a7c1a3/bl/file.py#L195-L199
[ "def", "tempfile", "(", "self", ",", "mode", "=", "'wb'", ",", "*", "*", "args", ")", ":", "tf", "=", "tempfile", ".", "NamedTemporaryFile", "(", "mode", "=", "mode", ")", "self", ".", "write", "(", "tf", ".", "name", ",", "mode", "=", "mode", ",...
edf6f37dac718987260b90ad0e7f7fe084a7c1a3
train
File.delete
delete the file from the filesystem.
bl/file.py
def delete(self): """delete the file from the filesystem.""" if self.isfile: os.remove(self.fn) elif self.isdir: shutil.rmtree(self.fn)
def delete(self): """delete the file from the filesystem.""" if self.isfile: os.remove(self.fn) elif self.isdir: shutil.rmtree(self.fn)
[ "delete", "the", "file", "from", "the", "filesystem", "." ]
BlackEarth/bl
python
https://github.com/BlackEarth/bl/blob/edf6f37dac718987260b90ad0e7f7fe084a7c1a3/bl/file.py#L230-L235
[ "def", "delete", "(", "self", ")", ":", "if", "self", ".", "isfile", ":", "os", ".", "remove", "(", "self", ".", "fn", ")", "elif", "self", ".", "isdir", ":", "shutil", ".", "rmtree", "(", "self", ".", "fn", ")" ]
edf6f37dac718987260b90ad0e7f7fe084a7c1a3
train
File.readable_size
given a number of bytes, return the file size in readable units
bl/file.py
def readable_size(C, bytes, suffix='B', decimals=1, sep='\u00a0'): """given a number of bytes, return the file size in readable units""" if bytes is None: return size = float(bytes) for unit in C.SIZE_UNITS: if abs(size) < 1024 or unit == C.SIZE_UNITS[-1]: ...
def readable_size(C, bytes, suffix='B', decimals=1, sep='\u00a0'): """given a number of bytes, return the file size in readable units""" if bytes is None: return size = float(bytes) for unit in C.SIZE_UNITS: if abs(size) < 1024 or unit == C.SIZE_UNITS[-1]: ...
[ "given", "a", "number", "of", "bytes", "return", "the", "file", "size", "in", "readable", "units" ]
BlackEarth/bl
python
https://github.com/BlackEarth/bl/blob/edf6f37dac718987260b90ad0e7f7fe084a7c1a3/bl/file.py#L240-L254
[ "def", "readable_size", "(", "C", ",", "bytes", ",", "suffix", "=", "'B'", ",", "decimals", "=", "1", ",", "sep", "=", "'\\u00a0'", ")", ":", "if", "bytes", "is", "None", ":", "return", "size", "=", "float", "(", "bytes", ")", "for", "unit", "in", ...
edf6f37dac718987260b90ad0e7f7fe084a7c1a3
train
File.bytes_from_readable_size
given a readable_size (as produced by File.readable_size()), return the number of bytes.
bl/file.py
def bytes_from_readable_size(C, size, suffix='B'): """given a readable_size (as produced by File.readable_size()), return the number of bytes.""" s = re.split("^([0-9\.]+)\s*([%s]?)%s?" % (''.join(C.SIZE_UNITS), suffix), size, flags=re.I) bytes, unit = round(float(s[1])), s[2].upper() wh...
def bytes_from_readable_size(C, size, suffix='B'): """given a readable_size (as produced by File.readable_size()), return the number of bytes.""" s = re.split("^([0-9\.]+)\s*([%s]?)%s?" % (''.join(C.SIZE_UNITS), suffix), size, flags=re.I) bytes, unit = round(float(s[1])), s[2].upper() wh...
[ "given", "a", "readable_size", "(", "as", "produced", "by", "File", ".", "readable_size", "()", ")", "return", "the", "number", "of", "bytes", "." ]
BlackEarth/bl
python
https://github.com/BlackEarth/bl/blob/edf6f37dac718987260b90ad0e7f7fe084a7c1a3/bl/file.py#L257-L264
[ "def", "bytes_from_readable_size", "(", "C", ",", "size", ",", "suffix", "=", "'B'", ")", ":", "s", "=", "re", ".", "split", "(", "\"^([0-9\\.]+)\\s*([%s]?)%s?\"", "%", "(", "''", ".", "join", "(", "C", ".", "SIZE_UNITS", ")", ",", "suffix", ")", ",", ...
edf6f37dac718987260b90ad0e7f7fe084a7c1a3
train
ApiMetaAdapter.run
Executed on startup of application
bors/app/api_factory.py
def run(self): """Executed on startup of application""" for wsock in self.wsocks: wsock.run() for api in self.apis: api.run()
def run(self): """Executed on startup of application""" for wsock in self.wsocks: wsock.run() for api in self.apis: api.run()
[ "Executed", "on", "startup", "of", "application" ]
RobotStudio/bors
python
https://github.com/RobotStudio/bors/blob/38bf338fc6905d90819faa56bd832140116720f0/bors/app/api_factory.py#L28-L33
[ "def", "run", "(", "self", ")", ":", "for", "wsock", "in", "self", ".", "wsocks", ":", "wsock", ".", "run", "(", ")", "for", "api", "in", "self", ".", "apis", ":", "api", ".", "run", "(", ")" ]
38bf338fc6905d90819faa56bd832140116720f0
train
ApiMetaAdapter.shutdown
Executed on shutdown of application
bors/app/api_factory.py
def shutdown(self): """Executed on shutdown of application""" for wsock in self.wsocks: wsock.shutdown() for api in self.apis: api.shutdown()
def shutdown(self): """Executed on shutdown of application""" for wsock in self.wsocks: wsock.shutdown() for api in self.apis: api.shutdown()
[ "Executed", "on", "shutdown", "of", "application" ]
RobotStudio/bors
python
https://github.com/RobotStudio/bors/blob/38bf338fc6905d90819faa56bd832140116720f0/bors/app/api_factory.py#L35-L40
[ "def", "shutdown", "(", "self", ")", ":", "for", "wsock", "in", "self", ".", "wsocks", ":", "wsock", ".", "shutdown", "(", ")", "for", "api", "in", "self", ".", "apis", ":", "api", ".", "shutdown", "(", ")" ]
38bf338fc6905d90819faa56bd832140116720f0
train
PagarmeApi.request
Makes a HTTP call, formats response and does error handling.
pagarme/api.py
def request(self, url, method, data=None, headers=None): """Makes a HTTP call, formats response and does error handling. """ http_headers = merge_dict(self.default_headers, headers or {}) request_data = merge_dict({'api_key': self.apikey}, data or {}) logger.info('HTTP %s REQUES...
def request(self, url, method, data=None, headers=None): """Makes a HTTP call, formats response and does error handling. """ http_headers = merge_dict(self.default_headers, headers or {}) request_data = merge_dict({'api_key': self.apikey}, data or {}) logger.info('HTTP %s REQUES...
[ "Makes", "a", "HTTP", "call", "formats", "response", "and", "does", "error", "handling", "." ]
michaeltcoelho/pagarme.py
python
https://github.com/michaeltcoelho/pagarme.py/blob/469fdd6e61e7c24a9eaf23d474d25316c3b5450b/pagarme/api.py#L50-L71
[ "def", "request", "(", "self", ",", "url", ",", "method", ",", "data", "=", "None", ",", "headers", "=", "None", ")", ":", "http_headers", "=", "merge_dict", "(", "self", ".", "default_headers", ",", "headers", "or", "{", "}", ")", "request_data", "=",...
469fdd6e61e7c24a9eaf23d474d25316c3b5450b
train
PagarmeApi.get
Makes a GET request
pagarme/api.py
def get(self, action, params=None, headers=None): """Makes a GET request """ return self.request(make_url(self.endpoint, action), method='GET', data=params, headers=headers)
def get(self, action, params=None, headers=None): """Makes a GET request """ return self.request(make_url(self.endpoint, action), method='GET', data=params, headers=headers)
[ "Makes", "a", "GET", "request" ]
michaeltcoelho/pagarme.py
python
https://github.com/michaeltcoelho/pagarme.py/blob/469fdd6e61e7c24a9eaf23d474d25316c3b5450b/pagarme/api.py#L73-L77
[ "def", "get", "(", "self", ",", "action", ",", "params", "=", "None", ",", "headers", "=", "None", ")", ":", "return", "self", ".", "request", "(", "make_url", "(", "self", ".", "endpoint", ",", "action", ")", ",", "method", "=", "'GET'", ",", "dat...
469fdd6e61e7c24a9eaf23d474d25316c3b5450b
train
PagarmeApi.post
Makes a GET request
pagarme/api.py
def post(self, action, data=None, headers=None): """Makes a GET request """ return self.request(make_url(self.endpoint, action), method='POST', data=data, headers=headers)
def post(self, action, data=None, headers=None): """Makes a GET request """ return self.request(make_url(self.endpoint, action), method='POST', data=data, headers=headers)
[ "Makes", "a", "GET", "request" ]
michaeltcoelho/pagarme.py
python
https://github.com/michaeltcoelho/pagarme.py/blob/469fdd6e61e7c24a9eaf23d474d25316c3b5450b/pagarme/api.py#L79-L83
[ "def", "post", "(", "self", ",", "action", ",", "data", "=", "None", ",", "headers", "=", "None", ")", ":", "return", "self", ".", "request", "(", "make_url", "(", "self", ".", "endpoint", ",", "action", ")", ",", "method", "=", "'POST'", ",", "dat...
469fdd6e61e7c24a9eaf23d474d25316c3b5450b
train
PagarmeApi.delete
Makes a GET request
pagarme/api.py
def delete(self, action, headers=None): """Makes a GET request """ return self.request(make_url(self.endpoint, action), method='DELETE', headers=headers)
def delete(self, action, headers=None): """Makes a GET request """ return self.request(make_url(self.endpoint, action), method='DELETE', headers=headers)
[ "Makes", "a", "GET", "request" ]
michaeltcoelho/pagarme.py
python
https://github.com/michaeltcoelho/pagarme.py/blob/469fdd6e61e7c24a9eaf23d474d25316c3b5450b/pagarme/api.py#L91-L95
[ "def", "delete", "(", "self", ",", "action", ",", "headers", "=", "None", ")", ":", "return", "self", ".", "request", "(", "make_url", "(", "self", ".", "endpoint", ",", "action", ")", ",", "method", "=", "'DELETE'", ",", "headers", "=", "headers", "...
469fdd6e61e7c24a9eaf23d474d25316c3b5450b
train
calc_piece_size
Calculates a good piece size for a size
thomas/piece.py
def calc_piece_size(size, min_piece_size=20, max_piece_size=29, max_piece_count=1000): """ Calculates a good piece size for a size """ logger.debug('Calculating piece size for %i' % size) for i in range(min_piece_size, max_piece_size): # 20 = 1MB if size / (2**i) < max_piece_count: ...
def calc_piece_size(size, min_piece_size=20, max_piece_size=29, max_piece_count=1000): """ Calculates a good piece size for a size """ logger.debug('Calculating piece size for %i' % size) for i in range(min_piece_size, max_piece_size): # 20 = 1MB if size / (2**i) < max_piece_count: ...
[ "Calculates", "a", "good", "piece", "size", "for", "a", "size" ]
JohnDoee/thomas
python
https://github.com/JohnDoee/thomas/blob/51916dd110098b189a1c2fbcb71794fd9ec94832/thomas/piece.py#L18-L27
[ "def", "calc_piece_size", "(", "size", ",", "min_piece_size", "=", "20", ",", "max_piece_size", "=", "29", ",", "max_piece_count", "=", "1000", ")", ":", "logger", ".", "debug", "(", "'Calculating piece size for %i'", "%", "size", ")", "for", "i", "in", "ran...
51916dd110098b189a1c2fbcb71794fd9ec94832
train
split_pieces
Prepare a list of all pieces grouped together
thomas/piece.py
def split_pieces(piece_list, segments, num): """ Prepare a list of all pieces grouped together """ piece_groups = [] pieces = list(piece_list) while pieces: for i in range(segments): p = pieces[i::segments][:num] if not p: break piece_g...
def split_pieces(piece_list, segments, num): """ Prepare a list of all pieces grouped together """ piece_groups = [] pieces = list(piece_list) while pieces: for i in range(segments): p = pieces[i::segments][:num] if not p: break piece_g...
[ "Prepare", "a", "list", "of", "all", "pieces", "grouped", "together" ]
JohnDoee/thomas
python
https://github.com/JohnDoee/thomas/blob/51916dd110098b189a1c2fbcb71794fd9ec94832/thomas/piece.py#L30-L44
[ "def", "split_pieces", "(", "piece_list", ",", "segments", ",", "num", ")", ":", "piece_groups", "=", "[", "]", "pieces", "=", "list", "(", "piece_list", ")", "while", "pieces", ":", "for", "i", "in", "range", "(", "segments", ")", ":", "p", "=", "pi...
51916dd110098b189a1c2fbcb71794fd9ec94832
train
rglob
recursive glob, gets all files that match the pattern within the directory tree
bl/rglob.py
def rglob(dirname, pattern, dirs=False, sort=True): """recursive glob, gets all files that match the pattern within the directory tree""" fns = [] path = str(dirname) if os.path.isdir(path): fns = glob(os.path.join(escape(path), pattern)) dns = [fn for fn in [os.p...
def rglob(dirname, pattern, dirs=False, sort=True): """recursive glob, gets all files that match the pattern within the directory tree""" fns = [] path = str(dirname) if os.path.isdir(path): fns = glob(os.path.join(escape(path), pattern)) dns = [fn for fn in [os.p...
[ "recursive", "glob", "gets", "all", "files", "that", "match", "the", "pattern", "within", "the", "directory", "tree" ]
BlackEarth/bl
python
https://github.com/BlackEarth/bl/blob/edf6f37dac718987260b90ad0e7f7fe084a7c1a3/bl/rglob.py#L17-L35
[ "def", "rglob", "(", "dirname", ",", "pattern", ",", "dirs", "=", "False", ",", "sort", "=", "True", ")", ":", "fns", "=", "[", "]", "path", "=", "str", "(", "dirname", ")", "if", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "fns", ...
edf6f37dac718987260b90ad0e7f7fe084a7c1a3
train
after
Create a new Future whose completion depends on parent futures The new future will have a function that it calls once all its parents have completed, the return value of which will be its final value. There is a special case, however, in which the dependent future's callback returns a future or list of...
junction/futures.py
def after(parents, func=None): '''Create a new Future whose completion depends on parent futures The new future will have a function that it calls once all its parents have completed, the return value of which will be its final value. There is a special case, however, in which the dependent future's ...
def after(parents, func=None): '''Create a new Future whose completion depends on parent futures The new future will have a function that it calls once all its parents have completed, the return value of which will be its final value. There is a special case, however, in which the dependent future's ...
[ "Create", "a", "new", "Future", "whose", "completion", "depends", "on", "parent", "futures" ]
teepark/junction
python
https://github.com/teepark/junction/blob/481d135d9e53acb55c72686e2eb4483432f35fa6/junction/futures.py#L339-L372
[ "def", "after", "(", "parents", ",", "func", "=", "None", ")", ":", "if", "func", "is", "None", ":", "return", "lambda", "f", ":", "after", "(", "parents", ",", "f", ")", "dep", "=", "Dependent", "(", "parents", ",", "func", ")", "for", "parent", ...
481d135d9e53acb55c72686e2eb4483432f35fa6
train
wait_any
Wait for the completion of any (the first) one of multiple futures :param list futures: A list of :class:`Future`\s :param timeout: The maximum time to wait. With ``None``, will block indefinitely. :type timeout: float or None :returns: One of the futures from the provided list -- the ...
junction/futures.py
def wait_any(futures, timeout=None): '''Wait for the completion of any (the first) one of multiple futures :param list futures: A list of :class:`Future`\s :param timeout: The maximum time to wait. With ``None``, will block indefinitely. :type timeout: float or None :returns: One o...
def wait_any(futures, timeout=None): '''Wait for the completion of any (the first) one of multiple futures :param list futures: A list of :class:`Future`\s :param timeout: The maximum time to wait. With ``None``, will block indefinitely. :type timeout: float or None :returns: One o...
[ "Wait", "for", "the", "completion", "of", "any", "(", "the", "first", ")", "one", "of", "multiple", "futures" ]
teepark/junction
python
https://github.com/teepark/junction/blob/481d135d9e53acb55c72686e2eb4483432f35fa6/junction/futures.py#L375-L401
[ "def", "wait_any", "(", "futures", ",", "timeout", "=", "None", ")", ":", "for", "fut", "in", "futures", ":", "if", "fut", ".", "complete", ":", "return", "fut", "wait", "=", "_Wait", "(", "futures", ")", "for", "fut", "in", "futures", ":", "fut", ...
481d135d9e53acb55c72686e2eb4483432f35fa6
train
wait_all
Wait for the completion of all futures in a list :param list future: a list of :class:`Future`\s :param timeout: The maximum time to wait. With ``None``, can block indefinitely. :type timeout: float or None :raises WaitTimeout: if a timeout is provided and hit
junction/futures.py
def wait_all(futures, timeout=None): '''Wait for the completion of all futures in a list :param list future: a list of :class:`Future`\s :param timeout: The maximum time to wait. With ``None``, can block indefinitely. :type timeout: float or None :raises WaitTimeout: if a timeout is provid...
def wait_all(futures, timeout=None): '''Wait for the completion of all futures in a list :param list future: a list of :class:`Future`\s :param timeout: The maximum time to wait. With ``None``, can block indefinitely. :type timeout: float or None :raises WaitTimeout: if a timeout is provid...
[ "Wait", "for", "the", "completion", "of", "all", "futures", "in", "a", "list" ]
teepark/junction
python
https://github.com/teepark/junction/blob/481d135d9e53acb55c72686e2eb4483432f35fa6/junction/futures.py#L404-L420
[ "def", "wait_all", "(", "futures", ",", "timeout", "=", "None", ")", ":", "if", "timeout", "is", "not", "None", ":", "deadline", "=", "time", ".", "time", "(", ")", "+", "timeout", "for", "fut", "in", "futures", ":", "fut", ".", "wait", "(", "deadl...
481d135d9e53acb55c72686e2eb4483432f35fa6
train
Future.value
The final value, if it has arrived :raises: AttributeError, if not yet complete :raises: an exception if the Future was :meth:`abort`\ed
junction/futures.py
def value(self): '''The final value, if it has arrived :raises: AttributeError, if not yet complete :raises: an exception if the Future was :meth:`abort`\ed ''' if not self._done.is_set(): raise AttributeError("value") if self._failure: raise self...
def value(self): '''The final value, if it has arrived :raises: AttributeError, if not yet complete :raises: an exception if the Future was :meth:`abort`\ed ''' if not self._done.is_set(): raise AttributeError("value") if self._failure: raise self...
[ "The", "final", "value", "if", "it", "has", "arrived" ]
teepark/junction
python
https://github.com/teepark/junction/blob/481d135d9e53acb55c72686e2eb4483432f35fa6/junction/futures.py#L38-L48
[ "def", "value", "(", "self", ")", ":", "if", "not", "self", ".", "_done", ".", "is_set", "(", ")", ":", "raise", "AttributeError", "(", "\"value\"", ")", "if", "self", ".", "_failure", ":", "raise", "self", ".", "_failure", "[", "0", "]", ",", "sel...
481d135d9e53acb55c72686e2eb4483432f35fa6
train
Future.finish
Give the future it's value and trigger any associated callbacks :param value: the new value for the future :raises: :class:`AlreadyComplete <junction.errors.AlreadyComplete>` if already complete
junction/futures.py
def finish(self, value): '''Give the future it's value and trigger any associated callbacks :param value: the new value for the future :raises: :class:`AlreadyComplete <junction.errors.AlreadyComplete>` if already complete ''' if self._done.is_set(): ...
def finish(self, value): '''Give the future it's value and trigger any associated callbacks :param value: the new value for the future :raises: :class:`AlreadyComplete <junction.errors.AlreadyComplete>` if already complete ''' if self._done.is_set(): ...
[ "Give", "the", "future", "it", "s", "value", "and", "trigger", "any", "associated", "callbacks" ]
teepark/junction
python
https://github.com/teepark/junction/blob/481d135d9e53acb55c72686e2eb4483432f35fa6/junction/futures.py#L50-L78
[ "def", "finish", "(", "self", ",", "value", ")", ":", "if", "self", ".", "_done", ".", "is_set", "(", ")", ":", "raise", "errors", ".", "AlreadyComplete", "(", ")", "self", ".", "_value", "=", "value", "for", "cb", "in", "self", ".", "_cbacks", ":"...
481d135d9e53acb55c72686e2eb4483432f35fa6
train
Future.abort
Finish this future (maybe early) in an error state Takes a standard exception triple as arguments (like returned by ``sys.exc_info``) and will re-raise them as the value. Any :class:`Dependents` that are children of this one will also be aborted. :param class klass: the class ...
junction/futures.py
def abort(self, klass, exc, tb=None): '''Finish this future (maybe early) in an error state Takes a standard exception triple as arguments (like returned by ``sys.exc_info``) and will re-raise them as the value. Any :class:`Dependents` that are children of this one will also be ...
def abort(self, klass, exc, tb=None): '''Finish this future (maybe early) in an error state Takes a standard exception triple as arguments (like returned by ``sys.exc_info``) and will re-raise them as the value. Any :class:`Dependents` that are children of this one will also be ...
[ "Finish", "this", "future", "(", "maybe", "early", ")", "in", "an", "error", "state" ]
teepark/junction
python
https://github.com/teepark/junction/blob/481d135d9e53acb55c72686e2eb4483432f35fa6/junction/futures.py#L80-L117
[ "def", "abort", "(", "self", ",", "klass", ",", "exc", ",", "tb", "=", "None", ")", ":", "if", "self", ".", "_done", ".", "is_set", "(", ")", ":", "raise", "errors", ".", "AlreadyComplete", "(", ")", "self", ".", "_failure", "=", "(", "klass", ",...
481d135d9e53acb55c72686e2eb4483432f35fa6
train
Future.on_finish
Assign a callback function to be run when successfully complete :param function func: A callback to run when complete. It will be given one argument (the value that has arrived), and it's return value is ignored.
junction/futures.py
def on_finish(self, func): '''Assign a callback function to be run when successfully complete :param function func: A callback to run when complete. It will be given one argument (the value that has arrived), and it's return value is ignored. ''' if self._done.is...
def on_finish(self, func): '''Assign a callback function to be run when successfully complete :param function func: A callback to run when complete. It will be given one argument (the value that has arrived), and it's return value is ignored. ''' if self._done.is...
[ "Assign", "a", "callback", "function", "to", "be", "run", "when", "successfully", "complete" ]
teepark/junction
python
https://github.com/teepark/junction/blob/481d135d9e53acb55c72686e2eb4483432f35fa6/junction/futures.py#L119-L130
[ "def", "on_finish", "(", "self", ",", "func", ")", ":", "if", "self", ".", "_done", ".", "is_set", "(", ")", ":", "if", "self", ".", "_failure", "is", "None", ":", "backend", ".", "schedule", "(", "func", ",", "args", "=", "(", "self", ".", "_val...
481d135d9e53acb55c72686e2eb4483432f35fa6
train
Future.on_abort
Assign a callback function to be run when :meth:`abort`\ed :param function func: A callback to run when aborted. It will be given three arguments: - ``klass``: the exception class - ``exc``: the exception instance - ``tb``: the traceback object assoc...
junction/futures.py
def on_abort(self, func): '''Assign a callback function to be run when :meth:`abort`\ed :param function func: A callback to run when aborted. It will be given three arguments: - ``klass``: the exception class - ``exc``: the exception instance ...
def on_abort(self, func): '''Assign a callback function to be run when :meth:`abort`\ed :param function func: A callback to run when aborted. It will be given three arguments: - ``klass``: the exception class - ``exc``: the exception instance ...
[ "Assign", "a", "callback", "function", "to", "be", "run", "when", ":", "meth", ":", "abort", "\\", "ed" ]
teepark/junction
python
https://github.com/teepark/junction/blob/481d135d9e53acb55c72686e2eb4483432f35fa6/junction/futures.py#L132-L146
[ "def", "on_abort", "(", "self", ",", "func", ")", ":", "if", "self", ".", "_done", ".", "is_set", "(", ")", ":", "if", "self", ".", "_failure", "is", "not", "None", ":", "backend", ".", "schedule", "(", "func", ",", "args", "=", "self", ".", "_fa...
481d135d9e53acb55c72686e2eb4483432f35fa6
train
Future.after
Create a new Future whose completion depends on this one The new future will have a function that it calls once all its parents have completed, the return value of which will be its final value. There is a special case, however, in which the dependent future's callback returns a future ...
junction/futures.py
def after(self, func=None, other_parents=None): '''Create a new Future whose completion depends on this one The new future will have a function that it calls once all its parents have completed, the return value of which will be its final value. There is a special case, however, in whic...
def after(self, func=None, other_parents=None): '''Create a new Future whose completion depends on this one The new future will have a function that it calls once all its parents have completed, the return value of which will be its final value. There is a special case, however, in whic...
[ "Create", "a", "new", "Future", "whose", "completion", "depends", "on", "this", "one" ]
teepark/junction
python
https://github.com/teepark/junction/blob/481d135d9e53acb55c72686e2eb4483432f35fa6/junction/futures.py#L161-L188
[ "def", "after", "(", "self", ",", "func", "=", "None", ",", "other_parents", "=", "None", ")", ":", "parents", "=", "[", "self", "]", "if", "other_parents", "is", "not", "None", ":", "parents", "+=", "other_parents", "return", "after", "(", "parents", ...
481d135d9e53acb55c72686e2eb4483432f35fa6
train
RPC.partial_results
The results that the RPC has received *so far* This may also be the complete results if :attr:`complete` is ``True``.
junction/futures.py
def partial_results(self): '''The results that the RPC has received *so far* This may also be the complete results if :attr:`complete` is ``True``. ''' results = [] for r in self._results: if isinstance(r, Exception): results.append(type(r)(*deepcopy(...
def partial_results(self): '''The results that the RPC has received *so far* This may also be the complete results if :attr:`complete` is ``True``. ''' results = [] for r in self._results: if isinstance(r, Exception): results.append(type(r)(*deepcopy(...
[ "The", "results", "that", "the", "RPC", "has", "received", "*", "so", "far", "*" ]
teepark/junction
python
https://github.com/teepark/junction/blob/481d135d9e53acb55c72686e2eb4483432f35fa6/junction/futures.py#L236-L250
[ "def", "partial_results", "(", "self", ")", ":", "results", "=", "[", "]", "for", "r", "in", "self", ".", "_results", ":", "if", "isinstance", "(", "r", ",", "Exception", ")", ":", "results", ".", "append", "(", "type", "(", "r", ")", "(", "*", "...
481d135d9e53acb55c72686e2eb4483432f35fa6
train
Install.os_path_transform
transforms any os path into unix style
facsimile/install.py
def os_path_transform(self, s, sep=os.path.sep): """ transforms any os path into unix style """ if sep == '/': return s else: return s.replace(sep, '/')
def os_path_transform(self, s, sep=os.path.sep): """ transforms any os path into unix style """ if sep == '/': return s else: return s.replace(sep, '/')
[ "transforms", "any", "os", "path", "into", "unix", "style" ]
20c/facsimile
python
https://github.com/20c/facsimile/blob/570e28568475d5be1b1a2c95b8e941fbfbc167eb/facsimile/install.py#L96-L101
[ "def", "os_path_transform", "(", "self", ",", "s", ",", "sep", "=", "os", ".", "path", ".", "sep", ")", ":", "if", "sep", "==", "'/'", ":", "return", "s", "else", ":", "return", "s", ".", "replace", "(", "sep", ",", "'/'", ")" ]
570e28568475d5be1b1a2c95b8e941fbfbc167eb
train
Install.transform
replaces $tokens$ with values will be replaced with config rendering
facsimile/install.py
def transform(self, tr_list, files): """ replaces $tokens$ with values will be replaced with config rendering """ singular = False if not isinstance(files, list) and not isinstance(files, tuple): singular = True files = [files] for _find, ...
def transform(self, tr_list, files): """ replaces $tokens$ with values will be replaced with config rendering """ singular = False if not isinstance(files, list) and not isinstance(files, tuple): singular = True files = [files] for _find, ...
[ "replaces", "$tokens$", "with", "values", "will", "be", "replaced", "with", "config", "rendering" ]
20c/facsimile
python
https://github.com/20c/facsimile/blob/570e28568475d5be1b1a2c95b8e941fbfbc167eb/facsimile/install.py#L103-L119
[ "def", "transform", "(", "self", ",", "tr_list", ",", "files", ")", ":", "singular", "=", "False", "if", "not", "isinstance", "(", "files", ",", "list", ")", "and", "not", "isinstance", "(", "files", ",", "tuple", ")", ":", "singular", "=", "True", "...
570e28568475d5be1b1a2c95b8e941fbfbc167eb
train
Install.resolve_dst
finds the destination based on source if source is an absolute path, and there's no pattern, it copies the file to base dst_dir
facsimile/install.py
def resolve_dst(self, dst_dir, src): """ finds the destination based on source if source is an absolute path, and there's no pattern, it copies the file to base dst_dir """ if os.path.isabs(src): return os.path.join(dst_dir, os.path.basename(src)) return os.pa...
def resolve_dst(self, dst_dir, src): """ finds the destination based on source if source is an absolute path, and there's no pattern, it copies the file to base dst_dir """ if os.path.isabs(src): return os.path.join(dst_dir, os.path.basename(src)) return os.pa...
[ "finds", "the", "destination", "based", "on", "source", "if", "source", "is", "an", "absolute", "path", "and", "there", "s", "no", "pattern", "it", "copies", "the", "file", "to", "base", "dst_dir" ]
20c/facsimile
python
https://github.com/20c/facsimile/blob/570e28568475d5be1b1a2c95b8e941fbfbc167eb/facsimile/install.py#L133-L140
[ "def", "resolve_dst", "(", "self", ",", "dst_dir", ",", "src", ")", ":", "if", "os", ".", "path", ".", "isabs", "(", "src", ")", ":", "return", "os", ".", "path", ".", "join", "(", "dst_dir", ",", "os", ".", "path", ".", "basename", "(", "src", ...
570e28568475d5be1b1a2c95b8e941fbfbc167eb
train
ZIP.write
copy the zip file from its filename to the given filename.
bl/zip.py
def write(self, fn=None): """copy the zip file from its filename to the given filename.""" fn = fn or self.fn if not os.path.exists(os.path.dirname(fn)): os.makedirs(os.path.dirname(fn)) f = open(self.fn, 'rb') b = f.read() f.close() f = open(fn, 'wb')...
def write(self, fn=None): """copy the zip file from its filename to the given filename.""" fn = fn or self.fn if not os.path.exists(os.path.dirname(fn)): os.makedirs(os.path.dirname(fn)) f = open(self.fn, 'rb') b = f.read() f.close() f = open(fn, 'wb')...
[ "copy", "the", "zip", "file", "from", "its", "filename", "to", "the", "given", "filename", "." ]
BlackEarth/bl
python
https://github.com/BlackEarth/bl/blob/edf6f37dac718987260b90ad0e7f7fe084a7c1a3/bl/zip.py#L20-L30
[ "def", "write", "(", "self", ",", "fn", "=", "None", ")", ":", "fn", "=", "fn", "or", "self", ".", "fn", "if", "not", "os", ".", "path", ".", "exists", "(", "os", ".", "path", ".", "dirname", "(", "fn", ")", ")", ":", "os", ".", "makedirs", ...
edf6f37dac718987260b90ad0e7f7fe084a7c1a3
train
Resource.assign
Merge new attributes
pagarme/resources/resource.py
def assign(self, attrs): """Merge new attributes """ for k, v in attrs.items(): setattr(self, k, v)
def assign(self, attrs): """Merge new attributes """ for k, v in attrs.items(): setattr(self, k, v)
[ "Merge", "new", "attributes" ]
michaeltcoelho/pagarme.py
python
https://github.com/michaeltcoelho/pagarme.py/blob/469fdd6e61e7c24a9eaf23d474d25316c3b5450b/pagarme/resources/resource.py#L25-L29
[ "def", "assign", "(", "self", ",", "attrs", ")", ":", "for", "k", ",", "v", "in", "attrs", ".", "items", "(", ")", ":", "setattr", "(", "self", ",", "k", ",", "v", ")" ]
469fdd6e61e7c24a9eaf23d474d25316c3b5450b
train
CSignatureTool.normalize_rust_function
Normalizes a single rust frame with a function
siggen/rules.py
def normalize_rust_function(self, function, line): """Normalizes a single rust frame with a function""" # Drop the prefix and return type if there is any function = drop_prefix_and_return_type(function) # Collapse types function = collapse( function, open...
def normalize_rust_function(self, function, line): """Normalizes a single rust frame with a function""" # Drop the prefix and return type if there is any function = drop_prefix_and_return_type(function) # Collapse types function = collapse( function, open...
[ "Normalizes", "a", "single", "rust", "frame", "with", "a", "function" ]
willkg/socorro-siggen
python
https://github.com/willkg/socorro-siggen/blob/db7e3233e665a458a961c48da22e93a69b1d08d6/siggen/rules.py#L121-L156
[ "def", "normalize_rust_function", "(", "self", ",", "function", ",", "line", ")", ":", "# Drop the prefix and return type if there is any", "function", "=", "drop_prefix_and_return_type", "(", "function", ")", "# Collapse types", "function", "=", "collapse", "(", "functio...
db7e3233e665a458a961c48da22e93a69b1d08d6
train
CSignatureTool.normalize_cpp_function
Normalizes a single cpp frame with a function
siggen/rules.py
def normalize_cpp_function(self, function, line): """Normalizes a single cpp frame with a function""" # Drop member function cv/ref qualifiers like const, const&, &, and && for ref in ('const', 'const&', '&&', '&'): if function.endswith(ref): function = function[:-len...
def normalize_cpp_function(self, function, line): """Normalizes a single cpp frame with a function""" # Drop member function cv/ref qualifiers like const, const&, &, and && for ref in ('const', 'const&', '&&', '&'): if function.endswith(ref): function = function[:-len...
[ "Normalizes", "a", "single", "cpp", "frame", "with", "a", "function" ]
willkg/socorro-siggen
python
https://github.com/willkg/socorro-siggen/blob/db7e3233e665a458a961c48da22e93a69b1d08d6/siggen/rules.py#L158-L208
[ "def", "normalize_cpp_function", "(", "self", ",", "function", ",", "line", ")", ":", "# Drop member function cv/ref qualifiers like const, const&, &, and &&", "for", "ref", "in", "(", "'const'", ",", "'const&'", ",", "'&&'", ",", "'&'", ")", ":", "if", "function", ...
db7e3233e665a458a961c48da22e93a69b1d08d6
train
CSignatureTool.normalize_frame
Normalizes a single frame Returns a structured conglomeration of the input parameters to serve as a signature. The parameter names of this function reflect the exact names of the fields from the jsonMDSW frame output. This allows this function to be invoked by passing a frame as ``**a_f...
siggen/rules.py
def normalize_frame( self, module=None, function=None, file=None, line=None, module_offset=None, offset=None, normalized=None, **kwargs # eat any extra kwargs passed in ): """Normalizes a single frame Returns a structured cong...
def normalize_frame( self, module=None, function=None, file=None, line=None, module_offset=None, offset=None, normalized=None, **kwargs # eat any extra kwargs passed in ): """Normalizes a single frame Returns a structured cong...
[ "Normalizes", "a", "single", "frame" ]
willkg/socorro-siggen
python
https://github.com/willkg/socorro-siggen/blob/db7e3233e665a458a961c48da22e93a69b1d08d6/siggen/rules.py#L210-L266
[ "def", "normalize_frame", "(", "self", ",", "module", "=", "None", ",", "function", "=", "None", ",", "file", "=", "None", ",", "line", "=", "None", ",", "module_offset", "=", "None", ",", "offset", "=", "None", ",", "normalized", "=", "None", ",", "...
db7e3233e665a458a961c48da22e93a69b1d08d6
train
CSignatureTool._do_generate
each element of signatureList names a frame in the crash stack; and is: - a prefix of a relevant frame: Append this element to the signature - a relevant frame: Append this element and stop looking - irrelevant: Append this element only after seeing a prefix frame The signature is ...
siggen/rules.py
def _do_generate(self, source_list, hang_type, crashed_thread, delimiter=' | '): """ each element of signatureList names a frame in the crash stack; and is: - a prefix of a relevant frame: Append this element to the signature - a relevant frame: Append this element and stop looking ...
def _do_generate(self, source_list, hang_type, crashed_thread, delimiter=' | '): """ each element of signatureList names a frame in the crash stack; and is: - a prefix of a relevant frame: Append this element to the signature - a relevant frame: Append this element and stop looking ...
[ "each", "element", "of", "signatureList", "names", "a", "frame", "in", "the", "crash", "stack", ";", "and", "is", ":", "-", "a", "prefix", "of", "a", "relevant", "frame", ":", "Append", "this", "element", "to", "the", "signature", "-", "a", "relevant", ...
willkg/socorro-siggen
python
https://github.com/willkg/socorro-siggen/blob/db7e3233e665a458a961c48da22e93a69b1d08d6/siggen/rules.py#L268-L351
[ "def", "_do_generate", "(", "self", ",", "source_list", ",", "hang_type", ",", "crashed_thread", ",", "delimiter", "=", "' | '", ")", ":", "notes", "=", "[", "]", "debug_notes", "=", "[", "]", "# shorten source_list to the first signatureSentinel", "sentinel_locatio...
db7e3233e665a458a961c48da22e93a69b1d08d6
train
_clean_tag
Fix up some garbage errors.
islex/tokens.py
def _clean_tag(t): """Fix up some garbage errors.""" # TODO: when score present, include info. t = _scored_patt.sub(string=t, repl='') if t == '_country_' or t.startswith('_country:'): t = 'nnp_country' elif t == 'vpb': t = 'vb' # "carjack" is listed with vpb tag. elif t == 'nnd...
def _clean_tag(t): """Fix up some garbage errors.""" # TODO: when score present, include info. t = _scored_patt.sub(string=t, repl='') if t == '_country_' or t.startswith('_country:'): t = 'nnp_country' elif t == 'vpb': t = 'vb' # "carjack" is listed with vpb tag. elif t == 'nnd...
[ "Fix", "up", "some", "garbage", "errors", "." ]
jkahn/islex
python
https://github.com/jkahn/islex/blob/c60fee062e9ebe34a3bef338539749463e47faf0/islex/tokens.py#L91-L113
[ "def", "_clean_tag", "(", "t", ")", ":", "# TODO: when score present, include info.", "t", "=", "_scored_patt", ".", "sub", "(", "string", "=", "t", ",", "repl", "=", "''", ")", "if", "t", "==", "'_country_'", "or", "t", ".", "startswith", "(", "'_country:...
c60fee062e9ebe34a3bef338539749463e47faf0
train
local_settings
Localizes the settings for the dotted prefix. For example, if the prefix where 'xyz':: {'xyz.foo': 'bar', 'other': 'something'} Would become:: {'foo': 'bar'} Note, that non-prefixed items are left out and the prefix is dropped.
pyramid_sawing/utils.py
def local_settings(settings, prefix): """Localizes the settings for the dotted prefix. For example, if the prefix where 'xyz':: {'xyz.foo': 'bar', 'other': 'something'} Would become:: {'foo': 'bar'} Note, that non-prefixed items are left out and the prefix is dropped. """ pre...
def local_settings(settings, prefix): """Localizes the settings for the dotted prefix. For example, if the prefix where 'xyz':: {'xyz.foo': 'bar', 'other': 'something'} Would become:: {'foo': 'bar'} Note, that non-prefixed items are left out and the prefix is dropped. """ pre...
[ "Localizes", "the", "settings", "for", "the", "dotted", "prefix", ".", "For", "example", "if", "the", "prefix", "where", "xyz", "::" ]
openstax/pyramid_sawing
python
https://github.com/openstax/pyramid_sawing/blob/d2ac7faf30c1517ed4621b8e62b7848e926078b9/pyramid_sawing/utils.py#L13-L28
[ "def", "local_settings", "(", "settings", ",", "prefix", ")", ":", "prefix", "=", "\"{}.\"", ".", "format", "(", "prefix", ")", "new_settings", "=", "{", "k", "[", "len", "(", "prefix", ")", ":", "]", ":", "v", "for", "k", ",", "v", "in", "settings...
d2ac7faf30c1517ed4621b8e62b7848e926078b9
train
humanize_bytes
Return a humanized string representation of a number of bytes. Assumes `from __future__ import division`. >>> humanize_bytes(1) '1 byte' >>> humanize_bytes(1024) '1.0 kB' >>> humanize_bytes(1024*123) '123.0 kB' >>> humanize_bytes(1024*12342) '12.1 MB' >>> humanize_bytes(1024*12...
thomas/humanize.py
def humanize_bytes(bytes, precision=1): """Return a humanized string representation of a number of bytes. Assumes `from __future__ import division`. >>> humanize_bytes(1) '1 byte' >>> humanize_bytes(1024) '1.0 kB' >>> humanize_bytes(1024*123) '123.0 kB' >>> humanize_bytes(1024*1234...
def humanize_bytes(bytes, precision=1): """Return a humanized string representation of a number of bytes. Assumes `from __future__ import division`. >>> humanize_bytes(1) '1 byte' >>> humanize_bytes(1024) '1.0 kB' >>> humanize_bytes(1024*123) '123.0 kB' >>> humanize_bytes(1024*1234...
[ "Return", "a", "humanized", "string", "representation", "of", "a", "number", "of", "bytes", "." ]
JohnDoee/thomas
python
https://github.com/JohnDoee/thomas/blob/51916dd110098b189a1c2fbcb71794fd9ec94832/thomas/humanize.py#L7-L42
[ "def", "humanize_bytes", "(", "bytes", ",", "precision", "=", "1", ")", ":", "abbrevs", "=", "(", "(", "1", "<<", "50", ",", "'PB'", ")", ",", "(", "1", "<<", "40", ",", "'TB'", ")", ",", "(", "1", "<<", "30", ",", "'GB'", ")", ",", "(", "1...
51916dd110098b189a1c2fbcb71794fd9ec94832
train
URL.parent
return the parent URL, with params, query, and fragment in place
bl/url.py
def parent(self): """return the parent URL, with params, query, and fragment in place""" path = '/'.join(self.path.split('/')[:-1]) s = path.strip('/').split(':') if len(s)==2 and s[1]=='': return None else: return self.__class__(self, path=path)
def parent(self): """return the parent URL, with params, query, and fragment in place""" path = '/'.join(self.path.split('/')[:-1]) s = path.strip('/').split(':') if len(s)==2 and s[1]=='': return None else: return self.__class__(self, path=path)
[ "return", "the", "parent", "URL", "with", "params", "query", "and", "fragment", "in", "place" ]
BlackEarth/bl
python
https://github.com/BlackEarth/bl/blob/edf6f37dac718987260b90ad0e7f7fe084a7c1a3/bl/url.py#L100-L107
[ "def", "parent", "(", "self", ")", ":", "path", "=", "'/'", ".", "join", "(", "self", ".", "path", ".", "split", "(", "'/'", ")", "[", ":", "-", "1", "]", ")", "s", "=", "path", ".", "strip", "(", "'/'", ")", ".", "split", "(", "':'", ")", ...
edf6f37dac718987260b90ad0e7f7fe084a7c1a3
train
URL.join
join a list of url elements, and include any keyword arguments, as a new URL
bl/url.py
def join(C, *args, **kwargs): """join a list of url elements, and include any keyword arguments, as a new URL""" u = C('/'.join([str(arg).strip('/') for arg in args]), **kwargs) return u
def join(C, *args, **kwargs): """join a list of url elements, and include any keyword arguments, as a new URL""" u = C('/'.join([str(arg).strip('/') for arg in args]), **kwargs) return u
[ "join", "a", "list", "of", "url", "elements", "and", "include", "any", "keyword", "arguments", "as", "a", "new", "URL" ]
BlackEarth/bl
python
https://github.com/BlackEarth/bl/blob/edf6f37dac718987260b90ad0e7f7fe084a7c1a3/bl/url.py#L150-L153
[ "def", "join", "(", "C", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "u", "=", "C", "(", "'/'", ".", "join", "(", "[", "str", "(", "arg", ")", ".", "strip", "(", "'/'", ")", "for", "arg", "in", "args", "]", ")", ",", "*", "*", ...
edf6f37dac718987260b90ad0e7f7fe084a7c1a3
train
select_peer
Choose a target from the available peers for a singular message :param peer_addrs: the ``(host, port)``s of the peers eligible to handle the RPC, and possibly a ``None`` entry if this hub can handle it locally :type peer_addrs: list :param service: the service of the message :type servi...
junction/hooks.py
def select_peer(peer_addrs, service, routing_id, method): '''Choose a target from the available peers for a singular message :param peer_addrs: the ``(host, port)``s of the peers eligible to handle the RPC, and possibly a ``None`` entry if this hub can handle it locally :type peer_addrs: li...
def select_peer(peer_addrs, service, routing_id, method): '''Choose a target from the available peers for a singular message :param peer_addrs: the ``(host, port)``s of the peers eligible to handle the RPC, and possibly a ``None`` entry if this hub can handle it locally :type peer_addrs: li...
[ "Choose", "a", "target", "from", "the", "available", "peers", "for", "a", "singular", "message" ]
teepark/junction
python
https://github.com/teepark/junction/blob/481d135d9e53acb55c72686e2eb4483432f35fa6/junction/hooks.py#L8-L32
[ "def", "select_peer", "(", "peer_addrs", ",", "service", ",", "routing_id", ",", "method", ")", ":", "if", "any", "(", "p", "is", "None", "for", "p", "in", "peer_addrs", ")", ":", "return", "None", "return", "random", ".", "choice", "(", "peer_addrs", ...
481d135d9e53acb55c72686e2eb4483432f35fa6
train
setup
Setup the sphinx extension This will setup autodoc and autosummary. Add the :class:`ext.ModDocstringDocumenter`. Add the config values. Connect builder-inited event to :func:`gendoc.main`. :param app: the sphinx app :type app: :class:`sphinx.application.Sphinx` :returns: None ...
src/jinjaapidoc/__init__.py
def setup(app): """Setup the sphinx extension This will setup autodoc and autosummary. Add the :class:`ext.ModDocstringDocumenter`. Add the config values. Connect builder-inited event to :func:`gendoc.main`. :param app: the sphinx app :type app: :class:`sphinx.application.Sphinx` ...
def setup(app): """Setup the sphinx extension This will setup autodoc and autosummary. Add the :class:`ext.ModDocstringDocumenter`. Add the config values. Connect builder-inited event to :func:`gendoc.main`. :param app: the sphinx app :type app: :class:`sphinx.application.Sphinx` ...
[ "Setup", "the", "sphinx", "extension", "This", "will", "setup", "autodoc", "and", "autosummary", ".", "Add", "the", ":", "class", ":", "ext", ".", "ModDocstringDocumenter", ".", "Add", "the", "config", "values", ".", "Connect", "builder", "-", "inited", "eve...
storax/jinjaapidoc
python
https://github.com/storax/jinjaapidoc/blob/f1eeb6ab5bd1a96c4130306718c6423f37c76856/src/jinjaapidoc/__init__.py#L9-L42
[ "def", "setup", "(", "app", ")", ":", "# Connect before autosummary\r", "app", ".", "connect", "(", "'builder-inited'", ",", "gendoc", ".", "main", ")", "app", ".", "setup_extension", "(", "'sphinx.ext.autodoc'", ")", "app", ".", "setup_extension", "(", "'sphinx...
f1eeb6ab5bd1a96c4130306718c6423f37c76856
train
Progress.start
initialize process timing for the current stack
bl/progress.py
def start(self, key=None, **params): """initialize process timing for the current stack""" self.params.update(**params) key = key or self.stack_key if key is not None: self.current_times[key] = time()
def start(self, key=None, **params): """initialize process timing for the current stack""" self.params.update(**params) key = key or self.stack_key if key is not None: self.current_times[key] = time()
[ "initialize", "process", "timing", "for", "the", "current", "stack" ]
BlackEarth/bl
python
https://github.com/BlackEarth/bl/blob/edf6f37dac718987260b90ad0e7f7fe084a7c1a3/bl/progress.py#L19-L24
[ "def", "start", "(", "self", ",", "key", "=", "None", ",", "*", "*", "params", ")", ":", "self", ".", "params", ".", "update", "(", "*", "*", "params", ")", "key", "=", "key", "or", "self", ".", "stack_key", "if", "key", "is", "not", "None", ":...
edf6f37dac718987260b90ad0e7f7fe084a7c1a3
train
Progress.report
report the total progress for the current stack, optionally given the local fraction completed. fraction=None: if given, used as the fraction of the local method so far completed. runtimes=None: if given, used as the expected runtimes for the current stack.
bl/progress.py
def report(self, fraction=None): """report the total progress for the current stack, optionally given the local fraction completed. fraction=None: if given, used as the fraction of the local method so far completed. runtimes=None: if given, used as the expected runtimes for the current stack. """ r = Dict() ...
def report(self, fraction=None): """report the total progress for the current stack, optionally given the local fraction completed. fraction=None: if given, used as the fraction of the local method so far completed. runtimes=None: if given, used as the expected runtimes for the current stack. """ r = Dict() ...
[ "report", "the", "total", "progress", "for", "the", "current", "stack", "optionally", "given", "the", "local", "fraction", "completed", ".", "fraction", "=", "None", ":", "if", "given", "used", "as", "the", "fraction", "of", "the", "local", "method", "so", ...
BlackEarth/bl
python
https://github.com/BlackEarth/bl/blob/edf6f37dac718987260b90ad0e7f7fe084a7c1a3/bl/progress.py#L34-L51
[ "def", "report", "(", "self", ",", "fraction", "=", "None", ")", ":", "r", "=", "Dict", "(", ")", "local_key", "=", "self", ".", "stack_key", "if", "local_key", "is", "None", ":", "return", "{", "}", "runtimes", "=", "self", ".", "runtimes", "(", "...
edf6f37dac718987260b90ad0e7f7fe084a7c1a3
train
Progress.finish
record the current stack process as finished
bl/progress.py
def finish(self): """record the current stack process as finished""" self.report(fraction=1.0) key = self.stack_key if key is not None: if self.data.get(key) is None: self.data[key] = [] start_time = self.current_times.get(key) or time() self.data[key].append(Dict(runtime=time()-start_time, **self....
def finish(self): """record the current stack process as finished""" self.report(fraction=1.0) key = self.stack_key if key is not None: if self.data.get(key) is None: self.data[key] = [] start_time = self.current_times.get(key) or time() self.data[key].append(Dict(runtime=time()-start_time, **self....
[ "record", "the", "current", "stack", "process", "as", "finished" ]
BlackEarth/bl
python
https://github.com/BlackEarth/bl/blob/edf6f37dac718987260b90ad0e7f7fe084a7c1a3/bl/progress.py#L53-L61
[ "def", "finish", "(", "self", ")", ":", "self", ".", "report", "(", "fraction", "=", "1.0", ")", "key", "=", "self", ".", "stack_key", "if", "key", "is", "not", "None", ":", "if", "self", ".", "data", ".", "get", "(", "key", ")", "is", "None", ...
edf6f37dac718987260b90ad0e7f7fe084a7c1a3
train
ModDocstringDocumenter.add_directive_header
Add the directive header and options to the generated content.
src/jinjaapidoc/ext.py
def add_directive_header(self, sig): """Add the directive header and options to the generated content.""" domain = getattr(self, 'domain', 'py') directive = getattr(self, 'directivetype', "module") name = self.format_name() self.add_line(u'.. %s:%s:: %s%s' % (domain, directive, n...
def add_directive_header(self, sig): """Add the directive header and options to the generated content.""" domain = getattr(self, 'domain', 'py') directive = getattr(self, 'directivetype', "module") name = self.format_name() self.add_line(u'.. %s:%s:: %s%s' % (domain, directive, n...
[ "Add", "the", "directive", "header", "and", "options", "to", "the", "generated", "content", "." ]
storax/jinjaapidoc
python
https://github.com/storax/jinjaapidoc/blob/f1eeb6ab5bd1a96c4130306718c6423f37c76856/src/jinjaapidoc/ext.py#L13-L25
[ "def", "add_directive_header", "(", "self", ",", "sig", ")", ":", "domain", "=", "getattr", "(", "self", ",", "'domain'", ",", "'py'", ")", "directive", "=", "getattr", "(", "self", ",", "'directivetype'", ",", "\"module\"", ")", "name", "=", "self", "."...
f1eeb6ab5bd1a96c4130306718c6423f37c76856
train
Client.connect
Initiate the connection to a proxying hub
junction/client.py
def connect(self): "Initiate the connection to a proxying hub" log.info("connecting") # don't have the connection attempt reconnects, because when it goes # down we are going to cycle to the next potential peer from the Client self._peer = connection.Peer( None, ...
def connect(self): "Initiate the connection to a proxying hub" log.info("connecting") # don't have the connection attempt reconnects, because when it goes # down we are going to cycle to the next potential peer from the Client self._peer = connection.Peer( None, ...
[ "Initiate", "the", "connection", "to", "a", "proxying", "hub" ]
teepark/junction
python
https://github.com/teepark/junction/blob/481d135d9e53acb55c72686e2eb4483432f35fa6/junction/client.py#L29-L38
[ "def", "connect", "(", "self", ")", ":", "log", ".", "info", "(", "\"connecting\"", ")", "# don't have the connection attempt reconnects, because when it goes", "# down we are going to cycle to the next potential peer from the Client", "self", ".", "_peer", "=", "connection", "...
481d135d9e53acb55c72686e2eb4483432f35fa6
train
Client.wait_connected
Wait for connections to be made and their handshakes to finish :param timeout: maximum time to wait in seconds. with None, there is no timeout. :type timeout: float or None :returns: ``True`` if all connections were made, ``False`` if one or more failed.
junction/client.py
def wait_connected(self, timeout=None): '''Wait for connections to be made and their handshakes to finish :param timeout: maximum time to wait in seconds. with None, there is no timeout. :type timeout: float or None :returns: ``True`` if all connections were mad...
def wait_connected(self, timeout=None): '''Wait for connections to be made and their handshakes to finish :param timeout: maximum time to wait in seconds. with None, there is no timeout. :type timeout: float or None :returns: ``True`` if all connections were mad...
[ "Wait", "for", "connections", "to", "be", "made", "and", "their", "handshakes", "to", "finish" ]
teepark/junction
python
https://github.com/teepark/junction/blob/481d135d9e53acb55c72686e2eb4483432f35fa6/junction/client.py#L40-L55
[ "def", "wait_connected", "(", "self", ",", "timeout", "=", "None", ")", ":", "result", "=", "self", ".", "_peer", ".", "wait_connected", "(", "timeout", ")", "if", "not", "result", ":", "if", "timeout", "is", "not", "None", ":", "log", ".", "warn", "...
481d135d9e53acb55c72686e2eb4483432f35fa6
train
Client.reset
Close the current failed connection and prepare for a new one
junction/client.py
def reset(self): "Close the current failed connection and prepare for a new one" log.info("resetting client") rpc_client = self._rpc_client self._addrs.append(self._peer.addr) self.__init__(self._addrs) self._rpc_client = rpc_client self._dispatcher.rpc_client = r...
def reset(self): "Close the current failed connection and prepare for a new one" log.info("resetting client") rpc_client = self._rpc_client self._addrs.append(self._peer.addr) self.__init__(self._addrs) self._rpc_client = rpc_client self._dispatcher.rpc_client = r...
[ "Close", "the", "current", "failed", "connection", "and", "prepare", "for", "a", "new", "one" ]
teepark/junction
python
https://github.com/teepark/junction/blob/481d135d9e53acb55c72686e2eb4483432f35fa6/junction/client.py#L57-L65
[ "def", "reset", "(", "self", ")", ":", "log", ".", "info", "(", "\"resetting client\"", ")", "rpc_client", "=", "self", ".", "_rpc_client", "self", ".", "_addrs", ".", "append", "(", "self", ".", "_peer", ".", "addr", ")", "self", ".", "__init__", "(",...
481d135d9e53acb55c72686e2eb4483432f35fa6
train
Client.shutdown
Close the hub connection
junction/client.py
def shutdown(self): 'Close the hub connection' log.info("shutting down") self._peer.go_down(reconnect=False, expected=True)
def shutdown(self): 'Close the hub connection' log.info("shutting down") self._peer.go_down(reconnect=False, expected=True)
[ "Close", "the", "hub", "connection" ]
teepark/junction
python
https://github.com/teepark/junction/blob/481d135d9e53acb55c72686e2eb4483432f35fa6/junction/client.py#L67-L70
[ "def", "shutdown", "(", "self", ")", ":", "log", ".", "info", "(", "\"shutting down\"", ")", "self", ".", "_peer", ".", "go_down", "(", "reconnect", "=", "False", ",", "expected", "=", "True", ")" ]
481d135d9e53acb55c72686e2eb4483432f35fa6
train
Client.publish
Send a 1-way message :param service: the service name (the routing top level) :type service: anything hash-able :param routing_id: The id used for routing within the registered handlers of the service. :type routing_id: int :param method: the method name ...
junction/client.py
def publish(self, service, routing_id, method, args=None, kwargs=None, broadcast=False): '''Send a 1-way message :param service: the service name (the routing top level) :type service: anything hash-able :param routing_id: The id used for routing within the regis...
def publish(self, service, routing_id, method, args=None, kwargs=None, broadcast=False): '''Send a 1-way message :param service: the service name (the routing top level) :type service: anything hash-able :param routing_id: The id used for routing within the regis...
[ "Send", "a", "1", "-", "way", "message" ]
teepark/junction
python
https://github.com/teepark/junction/blob/481d135d9e53acb55c72686e2eb4483432f35fa6/junction/client.py#L72-L102
[ "def", "publish", "(", "self", ",", "service", ",", "routing_id", ",", "method", ",", "args", "=", "None", ",", "kwargs", "=", "None", ",", "broadcast", "=", "False", ")", ":", "if", "not", "self", ".", "_peer", ".", "up", ":", "raise", "errors", "...
481d135d9e53acb55c72686e2eb4483432f35fa6
train
Client.publish_receiver_count
Get the number of peers that would handle a particular publish This method will block until a response arrives :param service: the service name :type service: anything hash-able :param routing_id: the id used for narrowing within the service handlers :type routing_i...
junction/client.py
def publish_receiver_count( self, service, routing_id, method, timeout=None): '''Get the number of peers that would handle a particular publish This method will block until a response arrives :param service: the service name :type service: anything hash-able :param ...
def publish_receiver_count( self, service, routing_id, method, timeout=None): '''Get the number of peers that would handle a particular publish This method will block until a response arrives :param service: the service name :type service: anything hash-able :param ...
[ "Get", "the", "number", "of", "peers", "that", "would", "handle", "a", "particular", "publish" ]
teepark/junction
python
https://github.com/teepark/junction/blob/481d135d9e53acb55c72686e2eb4483432f35fa6/junction/client.py#L104-L131
[ "def", "publish_receiver_count", "(", "self", ",", "service", ",", "routing_id", ",", "method", ",", "timeout", "=", "None", ")", ":", "if", "not", "self", ".", "_peer", ".", "up", ":", "raise", "errors", ".", "Unroutable", "(", ")", "return", "self", ...
481d135d9e53acb55c72686e2eb4483432f35fa6
train
Client.send_rpc
Send out an RPC request :param service: the service name (the routing top level) :type service: anything hash-able :param routing_id: The id used for routing within the registered handlers of the service. :type routing_id: int :param method: the method na...
junction/client.py
def send_rpc(self, service, routing_id, method, args=None, kwargs=None, broadcast=False): '''Send out an RPC request :param service: the service name (the routing top level) :type service: anything hash-able :param routing_id: The id used for routing within the r...
def send_rpc(self, service, routing_id, method, args=None, kwargs=None, broadcast=False): '''Send out an RPC request :param service: the service name (the routing top level) :type service: anything hash-able :param routing_id: The id used for routing within the r...
[ "Send", "out", "an", "RPC", "request" ]
teepark/junction
python
https://github.com/teepark/junction/blob/481d135d9e53acb55c72686e2eb4483432f35fa6/junction/client.py#L133-L165
[ "def", "send_rpc", "(", "self", ",", "service", ",", "routing_id", ",", "method", ",", "args", "=", "None", ",", "kwargs", "=", "None", ",", "broadcast", "=", "False", ")", ":", "if", "not", "self", ".", "_peer", ".", "up", ":", "raise", "errors", ...
481d135d9e53acb55c72686e2eb4483432f35fa6
train
Client.rpc_receiver_count
Get the number of peers that would handle a particular RPC This method will block until a response arrives :param service: the service name :type service: anything hash-able :param routing_id: the id used for narrowing within the service handlers :type routing_id: i...
junction/client.py
def rpc_receiver_count(self, service, routing_id, method, timeout=None): '''Get the number of peers that would handle a particular RPC This method will block until a response arrives :param service: the service name :type service: anything hash-able :param routing_id: ...
def rpc_receiver_count(self, service, routing_id, method, timeout=None): '''Get the number of peers that would handle a particular RPC This method will block until a response arrives :param service: the service name :type service: anything hash-able :param routing_id: ...
[ "Get", "the", "number", "of", "peers", "that", "would", "handle", "a", "particular", "RPC" ]
teepark/junction
python
https://github.com/teepark/junction/blob/481d135d9e53acb55c72686e2eb4483432f35fa6/junction/client.py#L207-L234
[ "def", "rpc_receiver_count", "(", "self", ",", "service", ",", "routing_id", ",", "method", ",", "timeout", "=", "None", ")", ":", "if", "not", "self", ".", "_peer", ".", "up", ":", "raise", "errors", ".", "Unroutable", "(", ")", "return", "self", ".",...
481d135d9e53acb55c72686e2eb4483432f35fa6
train
Endpoint._headers
Return the default headers and others as necessary
restapi/__init__.py
def _headers(self, others={}): """Return the default headers and others as necessary""" headers = { 'Content-Type': 'application/json' } for p in others.keys(): headers[p] = others[p] return headers
def _headers(self, others={}): """Return the default headers and others as necessary""" headers = { 'Content-Type': 'application/json' } for p in others.keys(): headers[p] = others[p] return headers
[ "Return", "the", "default", "headers", "and", "others", "as", "necessary" ]
berlotto/restapi-client
python
https://github.com/berlotto/restapi-client/blob/c35406c3fa8163fadb2e25ef5c2604d03569a6a1/restapi/__init__.py#L64-L72
[ "def", "_headers", "(", "self", ",", "others", "=", "{", "}", ")", ":", "headers", "=", "{", "'Content-Type'", ":", "'application/json'", "}", "for", "p", "in", "others", ".", "keys", "(", ")", ":", "headers", "[", "p", "]", "=", "others", "[", "p"...
c35406c3fa8163fadb2e25ef5c2604d03569a6a1
train
read
Read the config file with spec validation
monitoring_agent/configurator.py
def read(config_file, configspec, server_mode=False, default_section='default_settings', list_values=True): ''' Read the config file with spec validation ''' # configspec = ConfigObj(path.join(path.abspath(path.dirname(__file__)), configspec), # encoding='UTF8', # ...
def read(config_file, configspec, server_mode=False, default_section='default_settings', list_values=True): ''' Read the config file with spec validation ''' # configspec = ConfigObj(path.join(path.abspath(path.dirname(__file__)), configspec), # encoding='UTF8', # ...
[ "Read", "the", "config", "file", "with", "spec", "validation" ]
Eyepea/tanto
python
https://github.com/Eyepea/tanto/blob/ad8fd32e0fd3b7bc3dee5dabb984a2567ae46fe9/monitoring_agent/configurator.py#L21-L52
[ "def", "read", "(", "config_file", ",", "configspec", ",", "server_mode", "=", "False", ",", "default_section", "=", "'default_settings'", ",", "list_values", "=", "True", ")", ":", "# configspec = ConfigObj(path.join(path.abspath(path.dirname(__file__)), configspec),", ...
ad8fd32e0fd3b7bc3dee5dabb984a2567ae46fe9
train
elapsed_time_string
r""" Return a formatted string with the elapsed time between two time points. The string includes years (365 days), months (30 days), days (24 hours), hours (60 minutes), minutes (60 seconds) and seconds. If both arguments are equal, the string returned is :code:`'None'`; otherwise, the string retu...
pmisc/strings.py
def elapsed_time_string(start_time, stop_time): r""" Return a formatted string with the elapsed time between two time points. The string includes years (365 days), months (30 days), days (24 hours), hours (60 minutes), minutes (60 seconds) and seconds. If both arguments are equal, the string return...
def elapsed_time_string(start_time, stop_time): r""" Return a formatted string with the elapsed time between two time points. The string includes years (365 days), months (30 days), days (24 hours), hours (60 minutes), minutes (60 seconds) and seconds. If both arguments are equal, the string return...
[ "r", "Return", "a", "formatted", "string", "with", "the", "elapsed", "time", "between", "two", "time", "points", "." ]
pmacosta/pmisc
python
https://github.com/pmacosta/pmisc/blob/dd2bb32e59eee872f1ef2db2d9921a396ab9f50b/pmisc/strings.py#L95-L158
[ "def", "elapsed_time_string", "(", "start_time", ",", "stop_time", ")", ":", "if", "start_time", ">", "stop_time", ":", "raise", "RuntimeError", "(", "\"Invalid time delta specification\"", ")", "delta_time", "=", "stop_time", "-", "start_time", "# Python 2.6 datetime o...
dd2bb32e59eee872f1ef2db2d9921a396ab9f50b