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 | _parse_status_code | Return error string code if the response is an error, otherwise ``"OK"`` | loopialib/client.py | def _parse_status_code(response):
"""
Return error string code if the response is an error, otherwise ``"OK"``
"""
# This happens when a status response is expected
if isinstance(response, string_types):
return response
# This happens when a list of structs are expected
is_single_l... | def _parse_status_code(response):
"""
Return error string code if the response is an error, otherwise ``"OK"``
"""
# This happens when a status response is expected
if isinstance(response, string_types):
return response
# This happens when a list of structs are expected
is_single_l... | [
"Return",
"error",
"string",
"code",
"if",
"the",
"response",
"is",
"an",
"error",
"otherwise",
"OK"
] | runfalk/loopialib | python | https://github.com/runfalk/loopialib/blob/58d99c56b0e9eb62f40d76b7b4ad5fdd4b079155/loopialib/client.py#L6-L21 | [
"def",
"_parse_status_code",
"(",
"response",
")",
":",
"# This happens when a status response is expected",
"if",
"isinstance",
"(",
"response",
",",
"string_types",
")",
":",
"return",
"response",
"# This happens when a list of structs are expected",
"is_single_list",
"=",
... | 58d99c56b0e9eb62f40d76b7b4ad5fdd4b079155 |
train | Loopia.remove_zone_record | Remove the zone record with the given ID that belongs to the given
domain and sub domain. If no sub domain is given the wildcard sub-domain
is assumed. | loopialib/client.py | def remove_zone_record(self, id, domain, subdomain=None):
"""
Remove the zone record with the given ID that belongs to the given
domain and sub domain. If no sub domain is given the wildcard sub-domain
is assumed.
"""
if subdomain is None:
subdomain = "@"
... | def remove_zone_record(self, id, domain, subdomain=None):
"""
Remove the zone record with the given ID that belongs to the given
domain and sub domain. If no sub domain is given the wildcard sub-domain
is assumed.
"""
if subdomain is None:
subdomain = "@"
... | [
"Remove",
"the",
"zone",
"record",
"with",
"the",
"given",
"ID",
"that",
"belongs",
"to",
"the",
"given",
"domain",
"and",
"sub",
"domain",
".",
"If",
"no",
"sub",
"domain",
"is",
"given",
"the",
"wildcard",
"sub",
"-",
"domain",
"is",
"assumed",
"."
] | runfalk/loopialib | python | https://github.com/runfalk/loopialib/blob/58d99c56b0e9eb62f40d76b7b4ad5fdd4b079155/loopialib/client.py#L100-L112 | [
"def",
"remove_zone_record",
"(",
"self",
",",
"id",
",",
"domain",
",",
"subdomain",
"=",
"None",
")",
":",
"if",
"subdomain",
"is",
"None",
":",
"subdomain",
"=",
"\"@\"",
"_validate_int",
"(",
"\"id\"",
",",
"id",
")",
"self",
".",
"_call",
"(",
"\"... | 58d99c56b0e9eb62f40d76b7b4ad5fdd4b079155 |
train | ClassImporter.parse_module_class | Parse the module and class name part of the fully qualifed class name. | src/python/zensols/actioncli/factory.py | def parse_module_class(self):
"""Parse the module and class name part of the fully qualifed class name.
"""
cname = self.class_name
match = re.match(self.CLASS_REGEX, cname)
if not match:
raise ValueError(f'not a fully qualified class name: {cname}')
return m... | def parse_module_class(self):
"""Parse the module and class name part of the fully qualifed class name.
"""
cname = self.class_name
match = re.match(self.CLASS_REGEX, cname)
if not match:
raise ValueError(f'not a fully qualified class name: {cname}')
return m... | [
"Parse",
"the",
"module",
"and",
"class",
"name",
"part",
"of",
"the",
"fully",
"qualifed",
"class",
"name",
"."
] | plandes/actioncli | python | https://github.com/plandes/actioncli/blob/d1c4ea27e6f3394b30a1652ddd4b916160662773/src/python/zensols/actioncli/factory.py#L33-L41 | [
"def",
"parse_module_class",
"(",
"self",
")",
":",
"cname",
"=",
"self",
".",
"class_name",
"match",
"=",
"re",
".",
"match",
"(",
"self",
".",
"CLASS_REGEX",
",",
"cname",
")",
"if",
"not",
"match",
":",
"raise",
"ValueError",
"(",
"f'not a fully qualifi... | d1c4ea27e6f3394b30a1652ddd4b916160662773 |
train | ClassImporter.get_module_class | Return the module and class as a tuple of the given class in the
initializer.
:param reload: if ``True`` then reload the module before returning the
class | src/python/zensols/actioncli/factory.py | def get_module_class(self):
"""Return the module and class as a tuple of the given class in the
initializer.
:param reload: if ``True`` then reload the module before returning the
class
"""
pkg, cname = self.parse_module_class()
logger.debug(f'pkg: {pkg}, class:... | def get_module_class(self):
"""Return the module and class as a tuple of the given class in the
initializer.
:param reload: if ``True`` then reload the module before returning the
class
"""
pkg, cname = self.parse_module_class()
logger.debug(f'pkg: {pkg}, class:... | [
"Return",
"the",
"module",
"and",
"class",
"as",
"a",
"tuple",
"of",
"the",
"given",
"class",
"in",
"the",
"initializer",
"."
] | plandes/actioncli | python | https://github.com/plandes/actioncli/blob/d1c4ea27e6f3394b30a1652ddd4b916160662773/src/python/zensols/actioncli/factory.py#L43-L60 | [
"def",
"get_module_class",
"(",
"self",
")",
":",
"pkg",
",",
"cname",
"=",
"self",
".",
"parse_module_class",
"(",
")",
"logger",
".",
"debug",
"(",
"f'pkg: {pkg}, class: {cname}'",
")",
"pkg",
"=",
"pkg",
".",
"split",
"(",
"'.'",
")",
"mod",
"=",
"red... | d1c4ea27e6f3394b30a1652ddd4b916160662773 |
train | ClassImporter.instance | Create an instance of the specified class in the initializer.
:param args: the arguments given to the initializer of the new class
:param kwargs: the keyword arguments given to the initializer of the
new class | src/python/zensols/actioncli/factory.py | def instance(self, *args, **kwargs):
"""Create an instance of the specified class in the initializer.
:param args: the arguments given to the initializer of the new class
:param kwargs: the keyword arguments given to the initializer of the
new class
"""
mod... | def instance(self, *args, **kwargs):
"""Create an instance of the specified class in the initializer.
:param args: the arguments given to the initializer of the new class
:param kwargs: the keyword arguments given to the initializer of the
new class
"""
mod... | [
"Create",
"an",
"instance",
"of",
"the",
"specified",
"class",
"in",
"the",
"initializer",
"."
] | plandes/actioncli | python | https://github.com/plandes/actioncli/blob/d1c4ea27e6f3394b30a1652ddd4b916160662773/src/python/zensols/actioncli/factory.py#L62-L73 | [
"def",
"instance",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"mod",
",",
"cls",
"=",
"self",
".",
"get_module_class",
"(",
")",
"inst",
"=",
"cls",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"logger",
".",
"debug",
... | d1c4ea27e6f3394b30a1652ddd4b916160662773 |
train | ClassImporter.set_log_level | Convenciene method to set the log level of the module given in the
initializer of this class.
:param level: and instance of ``logging.<level>`` | src/python/zensols/actioncli/factory.py | def set_log_level(self, level=logging.INFO):
"""Convenciene method to set the log level of the module given in the
initializer of this class.
:param level: and instance of ``logging.<level>``
"""
mod, cls = self.parse_module_class()
logging.getLogger(mod).setLevel(level) | def set_log_level(self, level=logging.INFO):
"""Convenciene method to set the log level of the module given in the
initializer of this class.
:param level: and instance of ``logging.<level>``
"""
mod, cls = self.parse_module_class()
logging.getLogger(mod).setLevel(level) | [
"Convenciene",
"method",
"to",
"set",
"the",
"log",
"level",
"of",
"the",
"module",
"given",
"in",
"the",
"initializer",
"of",
"this",
"class",
"."
] | plandes/actioncli | python | https://github.com/plandes/actioncli/blob/d1c4ea27e6f3394b30a1652ddd4b916160662773/src/python/zensols/actioncli/factory.py#L75-L82 | [
"def",
"set_log_level",
"(",
"self",
",",
"level",
"=",
"logging",
".",
"INFO",
")",
":",
"mod",
",",
"cls",
"=",
"self",
".",
"parse_module_class",
"(",
")",
"logging",
".",
"getLogger",
"(",
"mod",
")",
".",
"setLevel",
"(",
"level",
")"
] | d1c4ea27e6f3394b30a1652ddd4b916160662773 |
train | ConfigFactory.register | Register a class with the factory.
:param instance_class: the class to register with the factory (not a
string)
:param name: the name to use as the key for instance class lookups;
defaults to the name of the class | src/python/zensols/actioncli/factory.py | def register(cls, instance_class, name=None):
"""Register a class with the factory.
:param instance_class: the class to register with the factory (not a
string)
:param name: the name to use as the key for instance class lookups;
defaults to the name of the class
... | def register(cls, instance_class, name=None):
"""Register a class with the factory.
:param instance_class: the class to register with the factory (not a
string)
:param name: the name to use as the key for instance class lookups;
defaults to the name of the class
... | [
"Register",
"a",
"class",
"with",
"the",
"factory",
"."
] | plandes/actioncli | python | https://github.com/plandes/actioncli/blob/d1c4ea27e6f3394b30a1652ddd4b916160662773/src/python/zensols/actioncli/factory.py#L120-L131 | [
"def",
"register",
"(",
"cls",
",",
"instance_class",
",",
"name",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
":",
"name",
"=",
"instance_class",
".",
"__name__",
"cls",
".",
"INSTANCE_CLASSES",
"[",
"name",
"]",
"=",
"instance_class"
] | d1c4ea27e6f3394b30a1652ddd4b916160662773 |
train | ConfigFactory._find_class | Resolve the class from the name. | src/python/zensols/actioncli/factory.py | def _find_class(self, class_name):
"Resolve the class from the name."
classes = {}
classes.update(globals())
classes.update(self.INSTANCE_CLASSES)
logger.debug(f'looking up class: {class_name}')
cls = classes[class_name]
logger.debug(f'found class: {cls}')
... | def _find_class(self, class_name):
"Resolve the class from the name."
classes = {}
classes.update(globals())
classes.update(self.INSTANCE_CLASSES)
logger.debug(f'looking up class: {class_name}')
cls = classes[class_name]
logger.debug(f'found class: {cls}')
... | [
"Resolve",
"the",
"class",
"from",
"the",
"name",
"."
] | plandes/actioncli | python | https://github.com/plandes/actioncli/blob/d1c4ea27e6f3394b30a1652ddd4b916160662773/src/python/zensols/actioncli/factory.py#L133-L141 | [
"def",
"_find_class",
"(",
"self",
",",
"class_name",
")",
":",
"classes",
"=",
"{",
"}",
"classes",
".",
"update",
"(",
"globals",
"(",
")",
")",
"classes",
".",
"update",
"(",
"self",
".",
"INSTANCE_CLASSES",
")",
"logger",
".",
"debug",
"(",
"f'look... | d1c4ea27e6f3394b30a1652ddd4b916160662773 |
train | ConfigFactory._class_name_params | Get the class name and parameters to use for ``__init__``. | src/python/zensols/actioncli/factory.py | def _class_name_params(self, name):
"Get the class name and parameters to use for ``__init__``."
sec = self.pattern.format(**{'name': name})
logger.debug(f'section: {sec}')
params = {}
params.update(self.config.populate({}, section=sec))
class_name = params['class_name']
... | def _class_name_params(self, name):
"Get the class name and parameters to use for ``__init__``."
sec = self.pattern.format(**{'name': name})
logger.debug(f'section: {sec}')
params = {}
params.update(self.config.populate({}, section=sec))
class_name = params['class_name']
... | [
"Get",
"the",
"class",
"name",
"and",
"parameters",
"to",
"use",
"for",
"__init__",
"."
] | plandes/actioncli | python | https://github.com/plandes/actioncli/blob/d1c4ea27e6f3394b30a1652ddd4b916160662773/src/python/zensols/actioncli/factory.py#L143-L151 | [
"def",
"_class_name_params",
"(",
"self",
",",
"name",
")",
":",
"sec",
"=",
"self",
".",
"pattern",
".",
"format",
"(",
"*",
"*",
"{",
"'name'",
":",
"name",
"}",
")",
"logger",
".",
"debug",
"(",
"f'section: {sec}'",
")",
"params",
"=",
"{",
"}",
... | d1c4ea27e6f3394b30a1652ddd4b916160662773 |
train | ConfigFactory._has_init_config | Return whether the class has a ``config`` parameter in the ``__init__``
method. | src/python/zensols/actioncli/factory.py | def _has_init_config(self, cls):
"""Return whether the class has a ``config`` parameter in the ``__init__``
method.
"""
args = inspect.signature(cls.__init__)
return self.config_param_name in args.parameters | def _has_init_config(self, cls):
"""Return whether the class has a ``config`` parameter in the ``__init__``
method.
"""
args = inspect.signature(cls.__init__)
return self.config_param_name in args.parameters | [
"Return",
"whether",
"the",
"class",
"has",
"a",
"config",
"parameter",
"in",
"the",
"__init__",
"method",
"."
] | plandes/actioncli | python | https://github.com/plandes/actioncli/blob/d1c4ea27e6f3394b30a1652ddd4b916160662773/src/python/zensols/actioncli/factory.py#L153-L159 | [
"def",
"_has_init_config",
"(",
"self",
",",
"cls",
")",
":",
"args",
"=",
"inspect",
".",
"signature",
"(",
"cls",
".",
"__init__",
")",
"return",
"self",
".",
"config_param_name",
"in",
"args",
".",
"parameters"
] | d1c4ea27e6f3394b30a1652ddd4b916160662773 |
train | ConfigFactory._has_init_name | Return whether the class has a ``name`` parameter in the ``__init__``
method. | src/python/zensols/actioncli/factory.py | def _has_init_name(self, cls):
"""Return whether the class has a ``name`` parameter in the ``__init__``
method.
"""
args = inspect.signature(cls.__init__)
return self.name_param_name in args.parameters | def _has_init_name(self, cls):
"""Return whether the class has a ``name`` parameter in the ``__init__``
method.
"""
args = inspect.signature(cls.__init__)
return self.name_param_name in args.parameters | [
"Return",
"whether",
"the",
"class",
"has",
"a",
"name",
"parameter",
"in",
"the",
"__init__",
"method",
"."
] | plandes/actioncli | python | https://github.com/plandes/actioncli/blob/d1c4ea27e6f3394b30a1652ddd4b916160662773/src/python/zensols/actioncli/factory.py#L161-L167 | [
"def",
"_has_init_name",
"(",
"self",
",",
"cls",
")",
":",
"args",
"=",
"inspect",
".",
"signature",
"(",
"cls",
".",
"__init__",
")",
"return",
"self",
".",
"name_param_name",
"in",
"args",
".",
"parameters"
] | d1c4ea27e6f3394b30a1652ddd4b916160662773 |
train | ConfigFactory._instance | Return the instance.
:param cls: the class to create the instance from
:param args: given to the ``__init__`` method
:param kwargs: given to the ``__init__`` method | src/python/zensols/actioncli/factory.py | def _instance(self, cls, *args, **kwargs):
"""Return the instance.
:param cls: the class to create the instance from
:param args: given to the ``__init__`` method
:param kwargs: given to the ``__init__`` method
"""
logger.debug(f'args: {args}, kwargs: {kwargs}')
... | def _instance(self, cls, *args, **kwargs):
"""Return the instance.
:param cls: the class to create the instance from
:param args: given to the ``__init__`` method
:param kwargs: given to the ``__init__`` method
"""
logger.debug(f'args: {args}, kwargs: {kwargs}')
... | [
"Return",
"the",
"instance",
"."
] | plandes/actioncli | python | https://github.com/plandes/actioncli/blob/d1c4ea27e6f3394b30a1652ddd4b916160662773/src/python/zensols/actioncli/factory.py#L169-L177 | [
"def",
"_instance",
"(",
"self",
",",
"cls",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"logger",
".",
"debug",
"(",
"f'args: {args}, kwargs: {kwargs}'",
")",
"return",
"cls",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | d1c4ea27e6f3394b30a1652ddd4b916160662773 |
train | ConfigFactory.instance | Create a new instance using key ``name``.
:param name: the name of the class (by default) or the key name of the
class used to find the class
:param args: given to the ``__init__`` method
:param kwargs: given to the ``__init__`` method | src/python/zensols/actioncli/factory.py | def instance(self, name=None, *args, **kwargs):
"""Create a new instance using key ``name``.
:param name: the name of the class (by default) or the key name of the
class used to find the class
:param args: given to the ``__init__`` method
:param kwargs: given to the ``__init... | def instance(self, name=None, *args, **kwargs):
"""Create a new instance using key ``name``.
:param name: the name of the class (by default) or the key name of the
class used to find the class
:param args: given to the ``__init__`` method
:param kwargs: given to the ``__init... | [
"Create",
"a",
"new",
"instance",
"using",
"key",
"name",
"."
] | plandes/actioncli | python | https://github.com/plandes/actioncli/blob/d1c4ea27e6f3394b30a1652ddd4b916160662773/src/python/zensols/actioncli/factory.py#L179-L207 | [
"def",
"instance",
"(",
"self",
",",
"name",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"logger",
".",
"info",
"(",
"f'new instance of {name}'",
")",
"t0",
"=",
"time",
"(",
")",
"name",
"=",
"self",
".",
"default_name",
"if",
... | d1c4ea27e6f3394b30a1652ddd4b916160662773 |
train | ConfigManager.load | Load the instance of the object from the stash. | src/python/zensols/actioncli/factory.py | def load(self, name=None, *args, **kwargs):
"Load the instance of the object from the stash."
inst = self.stash.load(name)
if inst is None:
inst = self.instance(name, *args, **kwargs)
logger.debug(f'loaded (conf mng) instance: {inst}')
return inst | def load(self, name=None, *args, **kwargs):
"Load the instance of the object from the stash."
inst = self.stash.load(name)
if inst is None:
inst = self.instance(name, *args, **kwargs)
logger.debug(f'loaded (conf mng) instance: {inst}')
return inst | [
"Load",
"the",
"instance",
"of",
"the",
"object",
"from",
"the",
"stash",
"."
] | plandes/actioncli | python | https://github.com/plandes/actioncli/blob/d1c4ea27e6f3394b30a1652ddd4b916160662773/src/python/zensols/actioncli/factory.py#L225-L231 | [
"def",
"load",
"(",
"self",
",",
"name",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"inst",
"=",
"self",
".",
"stash",
".",
"load",
"(",
"name",
")",
"if",
"inst",
"is",
"None",
":",
"inst",
"=",
"self",
".",
"instance",
... | d1c4ea27e6f3394b30a1652ddd4b916160662773 |
train | ConfigManager.dump | Save the object instance to the stash. | src/python/zensols/actioncli/factory.py | def dump(self, name: str, inst):
"Save the object instance to the stash."
self.stash.dump(name, inst) | def dump(self, name: str, inst):
"Save the object instance to the stash."
self.stash.dump(name, inst) | [
"Save",
"the",
"object",
"instance",
"to",
"the",
"stash",
"."
] | plandes/actioncli | python | https://github.com/plandes/actioncli/blob/d1c4ea27e6f3394b30a1652ddd4b916160662773/src/python/zensols/actioncli/factory.py#L241-L243 | [
"def",
"dump",
"(",
"self",
",",
"name",
":",
"str",
",",
"inst",
")",
":",
"self",
".",
"stash",
".",
"dump",
"(",
"name",
",",
"inst",
")"
] | d1c4ea27e6f3394b30a1652ddd4b916160662773 |
train | Client.from_env | Return a client configured from environment variables.
Essentially copying this:
https://github.com/docker/docker-py/blob/master/docker/client.py#L43.
The environment variables looked for are the following:
.. envvar:: SALTANT_API_URL
The URL of the saltant API. For examp... | saltant/client.py | def from_env(cls, default_timeout=DEFAULT_TIMEOUT_SECONDS):
"""Return a client configured from environment variables.
Essentially copying this:
https://github.com/docker/docker-py/blob/master/docker/client.py#L43.
The environment variables looked for are the following:
.. envv... | def from_env(cls, default_timeout=DEFAULT_TIMEOUT_SECONDS):
"""Return a client configured from environment variables.
Essentially copying this:
https://github.com/docker/docker-py/blob/master/docker/client.py#L43.
The environment variables looked for are the following:
.. envv... | [
"Return",
"a",
"client",
"configured",
"from",
"environment",
"variables",
"."
] | saltant-org/saltant-py | python | https://github.com/saltant-org/saltant-py/blob/bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be/saltant/client.py#L127-L178 | [
"def",
"from_env",
"(",
"cls",
",",
"default_timeout",
"=",
"DEFAULT_TIMEOUT_SECONDS",
")",
":",
"# Get variables from environment",
"try",
":",
"base_api_url",
"=",
"os",
".",
"environ",
"[",
"\"SALTANT_API_URL\"",
"]",
"except",
"KeyError",
":",
"raise",
"BadEnvir... | bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be |
train | PersistedWork.clear_global | Clear only any cached global data. | src/python/zensols/actioncli/persist.py | def clear_global(self):
"""Clear only any cached global data.
"""
vname = self.varname
logger.debug(f'global clearning {vname}')
if vname in globals():
logger.debug('removing global instance var: {}'.format(vname))
del globals()[vname] | def clear_global(self):
"""Clear only any cached global data.
"""
vname = self.varname
logger.debug(f'global clearning {vname}')
if vname in globals():
logger.debug('removing global instance var: {}'.format(vname))
del globals()[vname] | [
"Clear",
"only",
"any",
"cached",
"global",
"data",
"."
] | plandes/actioncli | python | https://github.com/plandes/actioncli/blob/d1c4ea27e6f3394b30a1652ddd4b916160662773/src/python/zensols/actioncli/persist.py#L64-L72 | [
"def",
"clear_global",
"(",
"self",
")",
":",
"vname",
"=",
"self",
".",
"varname",
"logger",
".",
"debug",
"(",
"f'global clearning {vname}'",
")",
"if",
"vname",
"in",
"globals",
"(",
")",
":",
"logger",
".",
"debug",
"(",
"'removing global instance var: {}'... | d1c4ea27e6f3394b30a1652ddd4b916160662773 |
train | PersistedWork.clear | Clear the data, and thus, force it to be created on the next fetch. This is
done by removing the attribute from ``owner``, deleting it from globals
and removing the file from the disk. | src/python/zensols/actioncli/persist.py | def clear(self):
"""Clear the data, and thus, force it to be created on the next fetch. This is
done by removing the attribute from ``owner``, deleting it from globals
and removing the file from the disk.
"""
vname = self.varname
if self.path.exists():
logge... | def clear(self):
"""Clear the data, and thus, force it to be created on the next fetch. This is
done by removing the attribute from ``owner``, deleting it from globals
and removing the file from the disk.
"""
vname = self.varname
if self.path.exists():
logge... | [
"Clear",
"the",
"data",
"and",
"thus",
"force",
"it",
"to",
"be",
"created",
"on",
"the",
"next",
"fetch",
".",
"This",
"is",
"done",
"by",
"removing",
"the",
"attribute",
"from",
"owner",
"deleting",
"it",
"from",
"globals",
"and",
"removing",
"the",
"f... | plandes/actioncli | python | https://github.com/plandes/actioncli/blob/d1c4ea27e6f3394b30a1652ddd4b916160662773/src/python/zensols/actioncli/persist.py#L74-L87 | [
"def",
"clear",
"(",
"self",
")",
":",
"vname",
"=",
"self",
".",
"varname",
"if",
"self",
".",
"path",
".",
"exists",
"(",
")",
":",
"logger",
".",
"debug",
"(",
"'deleting cached work: {}'",
".",
"format",
"(",
"self",
".",
"path",
")",
")",
"self"... | d1c4ea27e6f3394b30a1652ddd4b916160662773 |
train | PersistedWork._load_or_create | Invoke the file system operations to get the data, or create work.
If the file does not exist, calling ``__do_work__`` and save it. | src/python/zensols/actioncli/persist.py | def _load_or_create(self, *argv, **kwargs):
"""Invoke the file system operations to get the data, or create work.
If the file does not exist, calling ``__do_work__`` and save it.
"""
if self.path.exists():
self._info('loading work from {}'.format(self.path))
with... | def _load_or_create(self, *argv, **kwargs):
"""Invoke the file system operations to get the data, or create work.
If the file does not exist, calling ``__do_work__`` and save it.
"""
if self.path.exists():
self._info('loading work from {}'.format(self.path))
with... | [
"Invoke",
"the",
"file",
"system",
"operations",
"to",
"get",
"the",
"data",
"or",
"create",
"work",
"."
] | plandes/actioncli | python | https://github.com/plandes/actioncli/blob/d1c4ea27e6f3394b30a1652ddd4b916160662773/src/python/zensols/actioncli/persist.py#L96-L110 | [
"def",
"_load_or_create",
"(",
"self",
",",
"*",
"argv",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"path",
".",
"exists",
"(",
")",
":",
"self",
".",
"_info",
"(",
"'loading work from {}'",
".",
"format",
"(",
"self",
".",
"path",
")",
... | d1c4ea27e6f3394b30a1652ddd4b916160662773 |
train | PreemptiveStash.has_data | Return whether or not the stash has any data available or not. | src/python/zensols/actioncli/persist.py | def has_data(self):
"""Return whether or not the stash has any data available or not."""
if not hasattr(self, '_has_data'):
try:
next(iter(self.delegate.keys()))
self._has_data = True
except StopIteration:
self._has_data = False
... | def has_data(self):
"""Return whether or not the stash has any data available or not."""
if not hasattr(self, '_has_data'):
try:
next(iter(self.delegate.keys()))
self._has_data = True
except StopIteration:
self._has_data = False
... | [
"Return",
"whether",
"or",
"not",
"the",
"stash",
"has",
"any",
"data",
"available",
"or",
"not",
"."
] | plandes/actioncli | python | https://github.com/plandes/actioncli/blob/d1c4ea27e6f3394b30a1652ddd4b916160662773/src/python/zensols/actioncli/persist.py#L393-L401 | [
"def",
"has_data",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_has_data'",
")",
":",
"try",
":",
"next",
"(",
"iter",
"(",
"self",
".",
"delegate",
".",
"keys",
"(",
")",
")",
")",
"self",
".",
"_has_data",
"=",
"True",
"e... | d1c4ea27e6f3394b30a1652ddd4b916160662773 |
train | DirectoryStash._get_instance_path | Return a path to the pickled data with key ``name``. | src/python/zensols/actioncli/persist.py | def _get_instance_path(self, name):
"Return a path to the pickled data with key ``name``."
fname = self.pattern.format(**{'name': name})
logger.debug(f'path {self.create_path}: {self.create_path.exists()}')
self._create_path_dir()
return Path(self.create_path, fname) | def _get_instance_path(self, name):
"Return a path to the pickled data with key ``name``."
fname = self.pattern.format(**{'name': name})
logger.debug(f'path {self.create_path}: {self.create_path.exists()}')
self._create_path_dir()
return Path(self.create_path, fname) | [
"Return",
"a",
"path",
"to",
"the",
"pickled",
"data",
"with",
"key",
"name",
"."
] | plandes/actioncli | python | https://github.com/plandes/actioncli/blob/d1c4ea27e6f3394b30a1652ddd4b916160662773/src/python/zensols/actioncli/persist.py#L533-L538 | [
"def",
"_get_instance_path",
"(",
"self",
",",
"name",
")",
":",
"fname",
"=",
"self",
".",
"pattern",
".",
"format",
"(",
"*",
"*",
"{",
"'name'",
":",
"name",
"}",
")",
"logger",
".",
"debug",
"(",
"f'path {self.create_path}: {self.create_path.exists()}'",
... | d1c4ea27e6f3394b30a1652ddd4b916160662773 |
train | ShelveStash.shelve | Return an opened shelve object. | src/python/zensols/actioncli/persist.py | def shelve(self):
"""Return an opened shelve object.
"""
logger.info('creating shelve data')
fname = str(self.create_path.absolute())
inst = sh.open(fname, writeback=self.writeback)
self.is_open = True
return inst | def shelve(self):
"""Return an opened shelve object.
"""
logger.info('creating shelve data')
fname = str(self.create_path.absolute())
inst = sh.open(fname, writeback=self.writeback)
self.is_open = True
return inst | [
"Return",
"an",
"opened",
"shelve",
"object",
"."
] | plandes/actioncli | python | https://github.com/plandes/actioncli/blob/d1c4ea27e6f3394b30a1652ddd4b916160662773/src/python/zensols/actioncli/persist.py#L602-L610 | [
"def",
"shelve",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"'creating shelve data'",
")",
"fname",
"=",
"str",
"(",
"self",
".",
"create_path",
".",
"absolute",
"(",
")",
")",
"inst",
"=",
"sh",
".",
"open",
"(",
"fname",
",",
"writeback",
"... | d1c4ea27e6f3394b30a1652ddd4b916160662773 |
train | ShelveStash.delete | Delete the shelve data file. | src/python/zensols/actioncli/persist.py | def delete(self, name=None):
"Delete the shelve data file."
logger.info('clearing shelve data')
self.close()
for path in Path(self.create_path.parent, self.create_path.name), \
Path(self.create_path.parent, self.create_path.name + '.db'):
logger.debug(f'clearing {... | def delete(self, name=None):
"Delete the shelve data file."
logger.info('clearing shelve data')
self.close()
for path in Path(self.create_path.parent, self.create_path.name), \
Path(self.create_path.parent, self.create_path.name + '.db'):
logger.debug(f'clearing {... | [
"Delete",
"the",
"shelve",
"data",
"file",
"."
] | plandes/actioncli | python | https://github.com/plandes/actioncli/blob/d1c4ea27e6f3394b30a1652ddd4b916160662773/src/python/zensols/actioncli/persist.py#L625-L634 | [
"def",
"delete",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"logger",
".",
"info",
"(",
"'clearing shelve data'",
")",
"self",
".",
"close",
"(",
")",
"for",
"path",
"in",
"Path",
"(",
"self",
".",
"create_path",
".",
"parent",
",",
"self",
"."... | d1c4ea27e6f3394b30a1652ddd4b916160662773 |
train | ShelveStash.close | Close the shelve object, which is needed for data consistency. | src/python/zensols/actioncli/persist.py | def close(self):
"Close the shelve object, which is needed for data consistency."
if self.is_open:
logger.info('closing shelve data')
try:
self.shelve.close()
self._shelve.clear()
except Exception:
self.is_open = False | def close(self):
"Close the shelve object, which is needed for data consistency."
if self.is_open:
logger.info('closing shelve data')
try:
self.shelve.close()
self._shelve.clear()
except Exception:
self.is_open = False | [
"Close",
"the",
"shelve",
"object",
"which",
"is",
"needed",
"for",
"data",
"consistency",
"."
] | plandes/actioncli | python | https://github.com/plandes/actioncli/blob/d1c4ea27e6f3394b30a1652ddd4b916160662773/src/python/zensols/actioncli/persist.py#L636-L644 | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_open",
":",
"logger",
".",
"info",
"(",
"'closing shelve data'",
")",
"try",
":",
"self",
".",
"shelve",
".",
"close",
"(",
")",
"self",
".",
"_shelve",
".",
"clear",
"(",
")",
"except",
... | d1c4ea27e6f3394b30a1652ddd4b916160662773 |
train | MultiThreadedPoolStash._map | Map ``data_item`` separately in each thread. | src/python/zensols/actioncli/persist.py | def _map(self, data_item):
"Map ``data_item`` separately in each thread."
delegate = self.delegate
logger.debug(f'mapping: {data_item}')
if self.clobber or not self.exists(data_item.id):
logger.debug(f'exist: {data_item.id}: {self.exists(data_item.id)}')
delegate.... | def _map(self, data_item):
"Map ``data_item`` separately in each thread."
delegate = self.delegate
logger.debug(f'mapping: {data_item}')
if self.clobber or not self.exists(data_item.id):
logger.debug(f'exist: {data_item.id}: {self.exists(data_item.id)}')
delegate.... | [
"Map",
"data_item",
"separately",
"in",
"each",
"thread",
"."
] | plandes/actioncli | python | https://github.com/plandes/actioncli/blob/d1c4ea27e6f3394b30a1652ddd4b916160662773/src/python/zensols/actioncli/persist.py#L685-L691 | [
"def",
"_map",
"(",
"self",
",",
"data_item",
")",
":",
"delegate",
"=",
"self",
".",
"delegate",
"logger",
".",
"debug",
"(",
"f'mapping: {data_item}'",
")",
"if",
"self",
".",
"clobber",
"or",
"not",
"self",
".",
"exists",
"(",
"data_item",
".",
"id",
... | d1c4ea27e6f3394b30a1652ddd4b916160662773 |
train | MultiThreadedPoolStash.load_all | Load all instances witih multiple threads.
:param workers: number of workers to use to load instances, which
defaults to what was given in the class initializer
:param limit: return a maximum, which defaults to no limit
:param n_expected: rerun the iteration on the data... | src/python/zensols/actioncli/persist.py | def load_all(self, workers=None, limit=None, n_expected=None):
"""Load all instances witih multiple threads.
:param workers: number of workers to use to load instances, which
defaults to what was given in the class initializer
:param limit: return a maximum, which defaul... | def load_all(self, workers=None, limit=None, n_expected=None):
"""Load all instances witih multiple threads.
:param workers: number of workers to use to load instances, which
defaults to what was given in the class initializer
:param limit: return a maximum, which defaul... | [
"Load",
"all",
"instances",
"witih",
"multiple",
"threads",
"."
] | plandes/actioncli | python | https://github.com/plandes/actioncli/blob/d1c4ea27e6f3394b30a1652ddd4b916160662773/src/python/zensols/actioncli/persist.py#L714-L741 | [
"def",
"load_all",
"(",
"self",
",",
"workers",
"=",
"None",
",",
"limit",
"=",
"None",
",",
"n_expected",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"has_data",
":",
"self",
".",
"_preempt",
"(",
"True",
")",
"# we did the best we could (avoid repea... | d1c4ea27e6f3394b30a1652ddd4b916160662773 |
train | API._make_persistent | Monkey-patch object persistence (ex: to/from database) into a
bravado-core model class | pymacaron_core/swagger/api.py | def _make_persistent(self, model_name, pkg_name):
"""Monkey-patch object persistence (ex: to/from database) into a
bravado-core model class"""
#
# WARNING: ugly piece of monkey-patching below. Hopefully will replace
# with native bravado-core code in the future...
#
... | def _make_persistent(self, model_name, pkg_name):
"""Monkey-patch object persistence (ex: to/from database) into a
bravado-core model class"""
#
# WARNING: ugly piece of monkey-patching below. Hopefully will replace
# with native bravado-core code in the future...
#
... | [
"Monkey",
"-",
"patch",
"object",
"persistence",
"(",
"ex",
":",
"to",
"/",
"from",
"database",
")",
"into",
"a",
"bravado",
"-",
"core",
"model",
"class"
] | pymacaron/pymacaron-core | python | https://github.com/pymacaron/pymacaron-core/blob/95070a39ed7065a84244ff5601fea4d54cc72b66/pymacaron_core/swagger/api.py#L121-L145 | [
"def",
"_make_persistent",
"(",
"self",
",",
"model_name",
",",
"pkg_name",
")",
":",
"#",
"# WARNING: ugly piece of monkey-patching below. Hopefully will replace",
"# with native bravado-core code in the future...",
"#",
"# Load class at path pkg_name",
"c",
"=",
"get_function",
... | 95070a39ed7065a84244ff5601fea4d54cc72b66 |
train | API.spawn_api | Auto-generate server endpoints implementing the API into this Flask app | pymacaron_core/swagger/api.py | def spawn_api(self, app, decorator=None):
"""Auto-generate server endpoints implementing the API into this Flask app"""
if decorator:
assert type(decorator).__name__ == 'function'
self.is_server = True
self.app = app
if self.local:
# Re-generate client ca... | def spawn_api(self, app, decorator=None):
"""Auto-generate server endpoints implementing the API into this Flask app"""
if decorator:
assert type(decorator).__name__ == 'function'
self.is_server = True
self.app = app
if self.local:
# Re-generate client ca... | [
"Auto",
"-",
"generate",
"server",
"endpoints",
"implementing",
"the",
"API",
"into",
"this",
"Flask",
"app"
] | pymacaron/pymacaron-core | python | https://github.com/pymacaron/pymacaron-core/blob/95070a39ed7065a84244ff5601fea4d54cc72b66/pymacaron_core/swagger/api.py#L161-L172 | [
"def",
"spawn_api",
"(",
"self",
",",
"app",
",",
"decorator",
"=",
"None",
")",
":",
"if",
"decorator",
":",
"assert",
"type",
"(",
"decorator",
")",
".",
"__name__",
"==",
"'function'",
"self",
".",
"is_server",
"=",
"True",
"self",
".",
"app",
"=",
... | 95070a39ed7065a84244ff5601fea4d54cc72b66 |
train | API.json_to_model | Take a json strust and a model name, and return a model instance | pymacaron_core/swagger/api.py | def json_to_model(self, model_name, j, validate=False):
"""Take a json strust and a model name, and return a model instance"""
if validate:
self.api_spec.validate(model_name, j)
return self.api_spec.json_to_model(model_name, j) | def json_to_model(self, model_name, j, validate=False):
"""Take a json strust and a model name, and return a model instance"""
if validate:
self.api_spec.validate(model_name, j)
return self.api_spec.json_to_model(model_name, j) | [
"Take",
"a",
"json",
"strust",
"and",
"a",
"model",
"name",
"and",
"return",
"a",
"model",
"instance"
] | pymacaron/pymacaron-core | python | https://github.com/pymacaron/pymacaron-core/blob/95070a39ed7065a84244ff5601fea4d54cc72b66/pymacaron_core/swagger/api.py#L185-L189 | [
"def",
"json_to_model",
"(",
"self",
",",
"model_name",
",",
"j",
",",
"validate",
"=",
"False",
")",
":",
"if",
"validate",
":",
"self",
".",
"api_spec",
".",
"validate",
"(",
"model_name",
",",
"j",
")",
"return",
"self",
".",
"api_spec",
".",
"json_... | 95070a39ed7065a84244ff5601fea4d54cc72b66 |
train | assemble | Assemble items in *iterable* into discreet collections.
*patterns* may be specified as a list of regular expressions to limit
the returned collection possibilities. Use this when interested in
collections that only match specific patterns. Each pattern must contain
the expression from :py:data:`DIGITS_... | source/clique/__init__.py | def assemble(
iterable, patterns=None, minimum_items=2, case_sensitive=True,
assume_padded_when_ambiguous=False
):
'''Assemble items in *iterable* into discreet collections.
*patterns* may be specified as a list of regular expressions to limit
the returned collection possibilities. Use this when in... | def assemble(
iterable, patterns=None, minimum_items=2, case_sensitive=True,
assume_padded_when_ambiguous=False
):
'''Assemble items in *iterable* into discreet collections.
*patterns* may be specified as a list of regular expressions to limit
the returned collection possibilities. Use this when in... | [
"Assemble",
"items",
"in",
"*",
"iterable",
"*",
"into",
"discreet",
"collections",
"."
] | 4degrees/clique | python | https://github.com/4degrees/clique/blob/af1d4fef1d60c30a870257199a4d98597d15417d/source/clique/__init__.py#L23-L206 | [
"def",
"assemble",
"(",
"iterable",
",",
"patterns",
"=",
"None",
",",
"minimum_items",
"=",
"2",
",",
"case_sensitive",
"=",
"True",
",",
"assume_padded_when_ambiguous",
"=",
"False",
")",
":",
"collection_map",
"=",
"defaultdict",
"(",
"set",
")",
"collectio... | af1d4fef1d60c30a870257199a4d98597d15417d |
train | parse | Parse *value* into a :py:class:`~clique.collection.Collection`.
Use *pattern* to extract information from *value*. It may make use of the
following keys:
* *head* - Common leading part of the collection.
* *tail* - Common trailing part of the collection.
* *padding* - Padding value in ... | source/clique/__init__.py | def parse(value, pattern='{head}{padding}{tail} [{ranges}]'):
'''Parse *value* into a :py:class:`~clique.collection.Collection`.
Use *pattern* to extract information from *value*. It may make use of the
following keys:
* *head* - Common leading part of the collection.
* *tail* - Common tra... | def parse(value, pattern='{head}{padding}{tail} [{ranges}]'):
'''Parse *value* into a :py:class:`~clique.collection.Collection`.
Use *pattern* to extract information from *value*. It may make use of the
following keys:
* *head* - Common leading part of the collection.
* *tail* - Common tra... | [
"Parse",
"*",
"value",
"*",
"into",
"a",
":",
"py",
":",
"class",
":",
"~clique",
".",
"collection",
".",
"Collection",
"."
] | 4degrees/clique | python | https://github.com/4degrees/clique/blob/af1d4fef1d60c30a870257199a4d98597d15417d/source/clique/__init__.py#L209-L293 | [
"def",
"parse",
"(",
"value",
",",
"pattern",
"=",
"'{head}{padding}{tail} [{ranges}]'",
")",
":",
"# Construct regular expression for given pattern.",
"expressions",
"=",
"{",
"'head'",
":",
"'(?P<head>.*)'",
",",
"'tail'",
":",
"'(?P<tail>.*)'",
",",
"'padding'",
":",... | af1d4fef1d60c30a870257199a4d98597d15417d |
train | SortedSet.add | Add *item*. | source/clique/sorted_set.py | def add(self, item):
'''Add *item*.'''
if not item in self:
index = bisect.bisect_right(self._members, item)
self._members.insert(index, item) | def add(self, item):
'''Add *item*.'''
if not item in self:
index = bisect.bisect_right(self._members, item)
self._members.insert(index, item) | [
"Add",
"*",
"item",
"*",
"."
] | 4degrees/clique | python | https://github.com/4degrees/clique/blob/af1d4fef1d60c30a870257199a4d98597d15417d/source/clique/sorted_set.py#L39-L43 | [
"def",
"add",
"(",
"self",
",",
"item",
")",
":",
"if",
"not",
"item",
"in",
"self",
":",
"index",
"=",
"bisect",
".",
"bisect_right",
"(",
"self",
".",
"_members",
",",
"item",
")",
"self",
".",
"_members",
".",
"insert",
"(",
"index",
",",
"item"... | af1d4fef1d60c30a870257199a4d98597d15417d |
train | SortedSet.discard | Remove *item*. | source/clique/sorted_set.py | def discard(self, item):
'''Remove *item*.'''
index = self._index(item)
if index >= 0:
del self._members[index] | def discard(self, item):
'''Remove *item*.'''
index = self._index(item)
if index >= 0:
del self._members[index] | [
"Remove",
"*",
"item",
"*",
"."
] | 4degrees/clique | python | https://github.com/4degrees/clique/blob/af1d4fef1d60c30a870257199a4d98597d15417d/source/clique/sorted_set.py#L45-L49 | [
"def",
"discard",
"(",
"self",
",",
"item",
")",
":",
"index",
"=",
"self",
".",
"_index",
"(",
"item",
")",
"if",
"index",
">=",
"0",
":",
"del",
"self",
".",
"_members",
"[",
"index",
"]"
] | af1d4fef1d60c30a870257199a4d98597d15417d |
train | SortedSet._index | Return index of *item* in member list or -1 if not present. | source/clique/sorted_set.py | def _index(self, item):
'''Return index of *item* in member list or -1 if not present.'''
index = bisect.bisect_left(self._members, item)
if index != len(self) and self._members[index] == item:
return index
return -1 | def _index(self, item):
'''Return index of *item* in member list or -1 if not present.'''
index = bisect.bisect_left(self._members, item)
if index != len(self) and self._members[index] == item:
return index
return -1 | [
"Return",
"index",
"of",
"*",
"item",
"*",
"in",
"member",
"list",
"or",
"-",
"1",
"if",
"not",
"present",
"."
] | 4degrees/clique | python | https://github.com/4degrees/clique/blob/af1d4fef1d60c30a870257199a4d98597d15417d/source/clique/sorted_set.py#L56-L62 | [
"def",
"_index",
"(",
"self",
",",
"item",
")",
":",
"index",
"=",
"bisect",
".",
"bisect_left",
"(",
"self",
".",
"_members",
",",
"item",
")",
"if",
"index",
"!=",
"len",
"(",
"self",
")",
"and",
"self",
".",
"_members",
"[",
"index",
"]",
"==",
... | af1d4fef1d60c30a870257199a4d98597d15417d |
train | Collection._update_expression | Update internal expression. | source/clique/collection.py | def _update_expression(self):
'''Update internal expression.'''
self._expression = re.compile(
'^{0}(?P<index>(?P<padding>0*)\d+?){1}$'
.format(re.escape(self.head), re.escape(self.tail))
) | def _update_expression(self):
'''Update internal expression.'''
self._expression = re.compile(
'^{0}(?P<index>(?P<padding>0*)\d+?){1}$'
.format(re.escape(self.head), re.escape(self.tail))
) | [
"Update",
"internal",
"expression",
"."
] | 4degrees/clique | python | https://github.com/4degrees/clique/blob/af1d4fef1d60c30a870257199a4d98597d15417d/source/clique/collection.py#L77-L82 | [
"def",
"_update_expression",
"(",
"self",
")",
":",
"self",
".",
"_expression",
"=",
"re",
".",
"compile",
"(",
"'^{0}(?P<index>(?P<padding>0*)\\d+?){1}$'",
".",
"format",
"(",
"re",
".",
"escape",
"(",
"self",
".",
"head",
")",
",",
"re",
".",
"escape",
"... | af1d4fef1d60c30a870257199a4d98597d15417d |
train | Collection.match | Return whether *item* matches this collection expression.
If a match is successful return data about the match otherwise return
None. | source/clique/collection.py | def match(self, item):
'''Return whether *item* matches this collection expression.
If a match is successful return data about the match otherwise return
None.
'''
match = self._expression.match(item)
if not match:
return None
index = match.group('i... | def match(self, item):
'''Return whether *item* matches this collection expression.
If a match is successful return data about the match otherwise return
None.
'''
match = self._expression.match(item)
if not match:
return None
index = match.group('i... | [
"Return",
"whether",
"*",
"item",
"*",
"matches",
"this",
"collection",
"expression",
"."
] | 4degrees/clique | python | https://github.com/4degrees/clique/blob/af1d4fef1d60c30a870257199a4d98597d15417d/source/clique/collection.py#L170-L193 | [
"def",
"match",
"(",
"self",
",",
"item",
")",
":",
"match",
"=",
"self",
".",
"_expression",
".",
"match",
"(",
"item",
")",
"if",
"not",
"match",
":",
"return",
"None",
"index",
"=",
"match",
".",
"group",
"(",
"'index'",
")",
"padded",
"=",
"Fal... | af1d4fef1d60c30a870257199a4d98597d15417d |
train | Collection.add | Add *item* to collection.
raise :py:class:`~clique.error.CollectionError` if *item* cannot be
added to the collection. | source/clique/collection.py | def add(self, item):
'''Add *item* to collection.
raise :py:class:`~clique.error.CollectionError` if *item* cannot be
added to the collection.
'''
match = self.match(item)
if match is None:
raise clique.error.CollectionError(
'Item does not m... | def add(self, item):
'''Add *item* to collection.
raise :py:class:`~clique.error.CollectionError` if *item* cannot be
added to the collection.
'''
match = self.match(item)
if match is None:
raise clique.error.CollectionError(
'Item does not m... | [
"Add",
"*",
"item",
"*",
"to",
"collection",
"."
] | 4degrees/clique | python | https://github.com/4degrees/clique/blob/af1d4fef1d60c30a870257199a4d98597d15417d/source/clique/collection.py#L195-L208 | [
"def",
"add",
"(",
"self",
",",
"item",
")",
":",
"match",
"=",
"self",
".",
"match",
"(",
"item",
")",
"if",
"match",
"is",
"None",
":",
"raise",
"clique",
".",
"error",
".",
"CollectionError",
"(",
"'Item does not match collection expression.'",
")",
"se... | af1d4fef1d60c30a870257199a4d98597d15417d |
train | Collection.remove | Remove *item* from collection.
raise :py:class:`~clique.error.CollectionError` if *item* cannot be
removed from the collection. | source/clique/collection.py | def remove(self, item):
'''Remove *item* from collection.
raise :py:class:`~clique.error.CollectionError` if *item* cannot be
removed from the collection.
'''
match = self.match(item)
if match is None:
raise clique.error.CollectionError(
'Ite... | def remove(self, item):
'''Remove *item* from collection.
raise :py:class:`~clique.error.CollectionError` if *item* cannot be
removed from the collection.
'''
match = self.match(item)
if match is None:
raise clique.error.CollectionError(
'Ite... | [
"Remove",
"*",
"item",
"*",
"from",
"collection",
"."
] | 4degrees/clique | python | https://github.com/4degrees/clique/blob/af1d4fef1d60c30a870257199a4d98597d15417d/source/clique/collection.py#L210-L229 | [
"def",
"remove",
"(",
"self",
",",
"item",
")",
":",
"match",
"=",
"self",
".",
"match",
"(",
"item",
")",
"if",
"match",
"is",
"None",
":",
"raise",
"clique",
".",
"error",
".",
"CollectionError",
"(",
"'Item not present in collection.'",
")",
"index",
... | af1d4fef1d60c30a870257199a4d98597d15417d |
train | Collection.format | Return string representation as specified by *pattern*.
Pattern can be any format accepted by Python's standard format function
and will receive the following keyword arguments as context:
* *head* - Common leading part of the collection.
* *tail* - Common trailing part of the ... | source/clique/collection.py | def format(self, pattern='{head}{padding}{tail} [{ranges}]'):
'''Return string representation as specified by *pattern*.
Pattern can be any format accepted by Python's standard format function
and will receive the following keyword arguments as context:
* *head* - Common leading pa... | def format(self, pattern='{head}{padding}{tail} [{ranges}]'):
'''Return string representation as specified by *pattern*.
Pattern can be any format accepted by Python's standard format function
and will receive the following keyword arguments as context:
* *head* - Common leading pa... | [
"Return",
"string",
"representation",
"as",
"specified",
"by",
"*",
"pattern",
"*",
"."
] | 4degrees/clique | python | https://github.com/4degrees/clique/blob/af1d4fef1d60c30a870257199a4d98597d15417d/source/clique/collection.py#L231-L283 | [
"def",
"format",
"(",
"self",
",",
"pattern",
"=",
"'{head}{padding}{tail} [{ranges}]'",
")",
":",
"data",
"=",
"{",
"}",
"data",
"[",
"'head'",
"]",
"=",
"self",
".",
"head",
"data",
"[",
"'tail'",
"]",
"=",
"self",
".",
"tail",
"if",
"self",
".",
"... | af1d4fef1d60c30a870257199a4d98597d15417d |
train | Collection.is_contiguous | Return whether entire collection is contiguous. | source/clique/collection.py | def is_contiguous(self):
'''Return whether entire collection is contiguous.'''
previous = None
for index in self.indexes:
if previous is None:
previous = index
continue
if index != (previous + 1):
return False
... | def is_contiguous(self):
'''Return whether entire collection is contiguous.'''
previous = None
for index in self.indexes:
if previous is None:
previous = index
continue
if index != (previous + 1):
return False
... | [
"Return",
"whether",
"entire",
"collection",
"is",
"contiguous",
"."
] | 4degrees/clique | python | https://github.com/4degrees/clique/blob/af1d4fef1d60c30a870257199a4d98597d15417d/source/clique/collection.py#L285-L298 | [
"def",
"is_contiguous",
"(",
"self",
")",
":",
"previous",
"=",
"None",
"for",
"index",
"in",
"self",
".",
"indexes",
":",
"if",
"previous",
"is",
"None",
":",
"previous",
"=",
"index",
"continue",
"if",
"index",
"!=",
"(",
"previous",
"+",
"1",
")",
... | af1d4fef1d60c30a870257199a4d98597d15417d |
train | Collection.holes | Return holes in collection.
Return :py:class:`~clique.collection.Collection` of missing indexes. | source/clique/collection.py | def holes(self):
'''Return holes in collection.
Return :py:class:`~clique.collection.Collection` of missing indexes.
'''
missing = set([])
previous = None
for index in self.indexes:
if previous is None:
previous = index
contin... | def holes(self):
'''Return holes in collection.
Return :py:class:`~clique.collection.Collection` of missing indexes.
'''
missing = set([])
previous = None
for index in self.indexes:
if previous is None:
previous = index
contin... | [
"Return",
"holes",
"in",
"collection",
"."
] | 4degrees/clique | python | https://github.com/4degrees/clique/blob/af1d4fef1d60c30a870257199a4d98597d15417d/source/clique/collection.py#L300-L318 | [
"def",
"holes",
"(",
"self",
")",
":",
"missing",
"=",
"set",
"(",
"[",
"]",
")",
"previous",
"=",
"None",
"for",
"index",
"in",
"self",
".",
"indexes",
":",
"if",
"previous",
"is",
"None",
":",
"previous",
"=",
"index",
"continue",
"if",
"index",
... | af1d4fef1d60c30a870257199a4d98597d15417d |
train | Collection.is_compatible | Return whether *collection* is compatible with this collection.
To be compatible *collection* must have the same head, tail and padding
properties as this collection. | source/clique/collection.py | def is_compatible(self, collection):
'''Return whether *collection* is compatible with this collection.
To be compatible *collection* must have the same head, tail and padding
properties as this collection.
'''
return all([
isinstance(collection, Collection),
... | def is_compatible(self, collection):
'''Return whether *collection* is compatible with this collection.
To be compatible *collection* must have the same head, tail and padding
properties as this collection.
'''
return all([
isinstance(collection, Collection),
... | [
"Return",
"whether",
"*",
"collection",
"*",
"is",
"compatible",
"with",
"this",
"collection",
"."
] | 4degrees/clique | python | https://github.com/4degrees/clique/blob/af1d4fef1d60c30a870257199a4d98597d15417d/source/clique/collection.py#L320-L332 | [
"def",
"is_compatible",
"(",
"self",
",",
"collection",
")",
":",
"return",
"all",
"(",
"[",
"isinstance",
"(",
"collection",
",",
"Collection",
")",
",",
"collection",
".",
"head",
"==",
"self",
".",
"head",
",",
"collection",
".",
"tail",
"==",
"self",... | af1d4fef1d60c30a870257199a4d98597d15417d |
train | Collection.merge | Merge *collection* into this collection.
If the *collection* is compatible with this collection then update
indexes with all indexes in *collection*.
raise :py:class:`~clique.error.CollectionError` if *collection* is not
compatible with this collection. | source/clique/collection.py | def merge(self, collection):
'''Merge *collection* into this collection.
If the *collection* is compatible with this collection then update
indexes with all indexes in *collection*.
raise :py:class:`~clique.error.CollectionError` if *collection* is not
compatible with this coll... | def merge(self, collection):
'''Merge *collection* into this collection.
If the *collection* is compatible with this collection then update
indexes with all indexes in *collection*.
raise :py:class:`~clique.error.CollectionError` if *collection* is not
compatible with this coll... | [
"Merge",
"*",
"collection",
"*",
"into",
"this",
"collection",
"."
] | 4degrees/clique | python | https://github.com/4degrees/clique/blob/af1d4fef1d60c30a870257199a4d98597d15417d/source/clique/collection.py#L334-L348 | [
"def",
"merge",
"(",
"self",
",",
"collection",
")",
":",
"if",
"not",
"self",
".",
"is_compatible",
"(",
"collection",
")",
":",
"raise",
"clique",
".",
"error",
".",
"CollectionError",
"(",
"'Collection is not compatible '",
"'with this collection.'",
")",
"se... | af1d4fef1d60c30a870257199a4d98597d15417d |
train | Collection.separate | Return contiguous parts of collection as separate collections.
Return as list of :py:class:`~clique.collection.Collection` instances. | source/clique/collection.py | def separate(self):
'''Return contiguous parts of collection as separate collections.
Return as list of :py:class:`~clique.collection.Collection` instances.
'''
collections = []
start = None
end = None
for index in self.indexes:
if start is None:
... | def separate(self):
'''Return contiguous parts of collection as separate collections.
Return as list of :py:class:`~clique.collection.Collection` instances.
'''
collections = []
start = None
end = None
for index in self.indexes:
if start is None:
... | [
"Return",
"contiguous",
"parts",
"of",
"collection",
"as",
"separate",
"collections",
"."
] | 4degrees/clique | python | https://github.com/4degrees/clique/blob/af1d4fef1d60c30a870257199a4d98597d15417d/source/clique/collection.py#L350-L385 | [
"def",
"separate",
"(",
"self",
")",
":",
"collections",
"=",
"[",
"]",
"start",
"=",
"None",
"end",
"=",
"None",
"for",
"index",
"in",
"self",
".",
"indexes",
":",
"if",
"start",
"is",
"None",
":",
"start",
"=",
"index",
"end",
"=",
"start",
"cont... | af1d4fef1d60c30a870257199a4d98597d15417d |
train | format_check | Check the format of a osmnet_config object.
Parameters
----------
settings : dict
osmnet_config as a dictionary
Returns
-------
Nothing | osmnet/config.py | def format_check(settings):
"""
Check the format of a osmnet_config object.
Parameters
----------
settings : dict
osmnet_config as a dictionary
Returns
-------
Nothing
"""
valid_keys = ['logs_folder', 'log_file', 'log_console', 'log_name',
'log_filenam... | def format_check(settings):
"""
Check the format of a osmnet_config object.
Parameters
----------
settings : dict
osmnet_config as a dictionary
Returns
-------
Nothing
"""
valid_keys = ['logs_folder', 'log_file', 'log_console', 'log_name',
'log_filenam... | [
"Check",
"the",
"format",
"of",
"a",
"osmnet_config",
"object",
"."
] | UDST/osmnet | python | https://github.com/UDST/osmnet/blob/155110a8e38d3646b9dbc3ec729063930cab3d5f/osmnet/config.py#L2-L30 | [
"def",
"format_check",
"(",
"settings",
")",
":",
"valid_keys",
"=",
"[",
"'logs_folder'",
",",
"'log_file'",
",",
"'log_console'",
",",
"'log_name'",
",",
"'log_filename'",
",",
"'keep_osm_tags'",
"]",
"for",
"key",
"in",
"list",
"(",
"settings",
".",
"keys",... | 155110a8e38d3646b9dbc3ec729063930cab3d5f |
train | osmnet_config.to_dict | Return a dict representation of an osmnet osmnet_config instance. | osmnet/config.py | def to_dict(self):
"""
Return a dict representation of an osmnet osmnet_config instance.
"""
return {'logs_folder': self.logs_folder,
'log_file': self.log_file,
'log_console': self.log_console,
'log_name': self.log_name,
'lo... | def to_dict(self):
"""
Return a dict representation of an osmnet osmnet_config instance.
"""
return {'logs_folder': self.logs_folder,
'log_file': self.log_file,
'log_console': self.log_console,
'log_name': self.log_name,
'lo... | [
"Return",
"a",
"dict",
"representation",
"of",
"an",
"osmnet",
"osmnet_config",
"instance",
"."
] | UDST/osmnet | python | https://github.com/UDST/osmnet/blob/155110a8e38d3646b9dbc3ec729063930cab3d5f/osmnet/config.py#L73-L83 | [
"def",
"to_dict",
"(",
"self",
")",
":",
"return",
"{",
"'logs_folder'",
":",
"self",
".",
"logs_folder",
",",
"'log_file'",
":",
"self",
".",
"log_file",
",",
"'log_console'",
":",
"self",
".",
"log_console",
",",
"'log_name'",
":",
"self",
".",
"log_name... | 155110a8e38d3646b9dbc3ec729063930cab3d5f |
train | great_circle_dist | Get the distance (in meters) between two lat/lon points
via the Haversine formula.
Parameters
----------
lat1, lon1, lat2, lon2 : float
Latitude and longitude in degrees.
Returns
-------
dist : float
Distance in meters. | osmnet/utils.py | def great_circle_dist(lat1, lon1, lat2, lon2):
"""
Get the distance (in meters) between two lat/lon points
via the Haversine formula.
Parameters
----------
lat1, lon1, lat2, lon2 : float
Latitude and longitude in degrees.
Returns
-------
dist : float
Distance in met... | def great_circle_dist(lat1, lon1, lat2, lon2):
"""
Get the distance (in meters) between two lat/lon points
via the Haversine formula.
Parameters
----------
lat1, lon1, lat2, lon2 : float
Latitude and longitude in degrees.
Returns
-------
dist : float
Distance in met... | [
"Get",
"the",
"distance",
"(",
"in",
"meters",
")",
"between",
"two",
"lat",
"/",
"lon",
"points",
"via",
"the",
"Haversine",
"formula",
"."
] | UDST/osmnet | python | https://github.com/UDST/osmnet/blob/155110a8e38d3646b9dbc3ec729063930cab3d5f/osmnet/utils.py#L17-L49 | [
"def",
"great_circle_dist",
"(",
"lat1",
",",
"lon1",
",",
"lat2",
",",
"lon2",
")",
":",
"radius",
"=",
"6372795",
"# meters",
"lat1",
"=",
"math",
".",
"radians",
"(",
"lat1",
")",
"lon1",
"=",
"math",
".",
"radians",
"(",
"lon1",
")",
"lat2",
"=",... | 155110a8e38d3646b9dbc3ec729063930cab3d5f |
train | osm_filter | Create a filter to query Overpass API for the specified OSM network type.
Parameters
----------
network_type : string, {'walk', 'drive'} denoting the type of street
network to extract
Returns
-------
osm_filter : string | osmnet/load.py | def osm_filter(network_type):
"""
Create a filter to query Overpass API for the specified OSM network type.
Parameters
----------
network_type : string, {'walk', 'drive'} denoting the type of street
network to extract
Returns
-------
osm_filter : string
"""
filters = {}
... | def osm_filter(network_type):
"""
Create a filter to query Overpass API for the specified OSM network type.
Parameters
----------
network_type : string, {'walk', 'drive'} denoting the type of street
network to extract
Returns
-------
osm_filter : string
"""
filters = {}
... | [
"Create",
"a",
"filter",
"to",
"query",
"Overpass",
"API",
"for",
"the",
"specified",
"OSM",
"network",
"type",
"."
] | UDST/osmnet | python | https://github.com/UDST/osmnet/blob/155110a8e38d3646b9dbc3ec729063930cab3d5f/osmnet/load.py#L29-L67 | [
"def",
"osm_filter",
"(",
"network_type",
")",
":",
"filters",
"=",
"{",
"}",
"# drive: select only roads that are drivable by normal 2 wheel drive",
"# passenger vehicles both private and public",
"# roads. Filter out un-drivable roads and service roads tagged as parking,",
"# driveway, o... | 155110a8e38d3646b9dbc3ec729063930cab3d5f |
train | osm_net_download | Download OSM ways and nodes within a bounding box from the Overpass API.
Parameters
----------
lat_min : float
southern latitude of bounding box
lng_min : float
eastern longitude of bounding box
lat_max : float
northern latitude of bounding box
lng_max : float
we... | osmnet/load.py | def osm_net_download(lat_min=None, lng_min=None, lat_max=None, lng_max=None,
network_type='walk', timeout=180, memory=None,
max_query_area_size=50*1000*50*1000,
custom_osm_filter=None):
"""
Download OSM ways and nodes within a bounding box from the ... | def osm_net_download(lat_min=None, lng_min=None, lat_max=None, lng_max=None,
network_type='walk', timeout=180, memory=None,
max_query_area_size=50*1000*50*1000,
custom_osm_filter=None):
"""
Download OSM ways and nodes within a bounding box from the ... | [
"Download",
"OSM",
"ways",
"and",
"nodes",
"within",
"a",
"bounding",
"box",
"from",
"the",
"Overpass",
"API",
"."
] | UDST/osmnet | python | https://github.com/UDST/osmnet/blob/155110a8e38d3646b9dbc3ec729063930cab3d5f/osmnet/load.py#L70-L200 | [
"def",
"osm_net_download",
"(",
"lat_min",
"=",
"None",
",",
"lng_min",
"=",
"None",
",",
"lat_max",
"=",
"None",
",",
"lng_max",
"=",
"None",
",",
"network_type",
"=",
"'walk'",
",",
"timeout",
"=",
"180",
",",
"memory",
"=",
"None",
",",
"max_query_are... | 155110a8e38d3646b9dbc3ec729063930cab3d5f |
train | overpass_request | Send a request to the Overpass API via HTTP POST and return the
JSON response
Parameters
----------
data : dict or OrderedDict
key-value pairs of parameters to post to Overpass API
pause_duration : int
how long to pause in seconds before requests, if None, will query
Overpas... | osmnet/load.py | def overpass_request(data, pause_duration=None, timeout=180,
error_pause_duration=None):
"""
Send a request to the Overpass API via HTTP POST and return the
JSON response
Parameters
----------
data : dict or OrderedDict
key-value pairs of parameters to post to Overp... | def overpass_request(data, pause_duration=None, timeout=180,
error_pause_duration=None):
"""
Send a request to the Overpass API via HTTP POST and return the
JSON response
Parameters
----------
data : dict or OrderedDict
key-value pairs of parameters to post to Overp... | [
"Send",
"a",
"request",
"to",
"the",
"Overpass",
"API",
"via",
"HTTP",
"POST",
"and",
"return",
"the",
"JSON",
"response"
] | UDST/osmnet | python | https://github.com/UDST/osmnet/blob/155110a8e38d3646b9dbc3ec729063930cab3d5f/osmnet/load.py#L203-L270 | [
"def",
"overpass_request",
"(",
"data",
",",
"pause_duration",
"=",
"None",
",",
"timeout",
"=",
"180",
",",
"error_pause_duration",
"=",
"None",
")",
":",
"# define the Overpass API URL, then construct a GET-style URL",
"url",
"=",
"'http://www.overpass-api.de/api/interpre... | 155110a8e38d3646b9dbc3ec729063930cab3d5f |
train | get_pause_duration | Check the Overpass API status endpoint to determine how long to wait until
next slot is available.
Parameters
----------
recursive_delay : int
how long to wait between recursive calls if server is currently
running a query
default_duration : int
if fatal error, function fall... | osmnet/load.py | def get_pause_duration(recursive_delay=5, default_duration=10):
"""
Check the Overpass API status endpoint to determine how long to wait until
next slot is available.
Parameters
----------
recursive_delay : int
how long to wait between recursive calls if server is currently
runn... | def get_pause_duration(recursive_delay=5, default_duration=10):
"""
Check the Overpass API status endpoint to determine how long to wait until
next slot is available.
Parameters
----------
recursive_delay : int
how long to wait between recursive calls if server is currently
runn... | [
"Check",
"the",
"Overpass",
"API",
"status",
"endpoint",
"to",
"determine",
"how",
"long",
"to",
"wait",
"until",
"next",
"slot",
"is",
"available",
"."
] | UDST/osmnet | python | https://github.com/UDST/osmnet/blob/155110a8e38d3646b9dbc3ec729063930cab3d5f/osmnet/load.py#L273-L328 | [
"def",
"get_pause_duration",
"(",
"recursive_delay",
"=",
"5",
",",
"default_duration",
"=",
"10",
")",
":",
"try",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"'http://overpass-api.de/api/status'",
")",
"status",
"=",
"response",
".",
"text",
".",
"spl... | 155110a8e38d3646b9dbc3ec729063930cab3d5f |
train | consolidate_subdivide_geometry | Consolidate a geometry into a convex hull, then subdivide it into
smaller sub-polygons if its area exceeds max size (in geometry's units).
Parameters
----------
geometry : shapely Polygon or MultiPolygon
the geometry to consolidate and subdivide
max_query_area_size : float
max area ... | osmnet/load.py | def consolidate_subdivide_geometry(geometry, max_query_area_size):
"""
Consolidate a geometry into a convex hull, then subdivide it into
smaller sub-polygons if its area exceeds max size (in geometry's units).
Parameters
----------
geometry : shapely Polygon or MultiPolygon
the geometry... | def consolidate_subdivide_geometry(geometry, max_query_area_size):
"""
Consolidate a geometry into a convex hull, then subdivide it into
smaller sub-polygons if its area exceeds max size (in geometry's units).
Parameters
----------
geometry : shapely Polygon or MultiPolygon
the geometry... | [
"Consolidate",
"a",
"geometry",
"into",
"a",
"convex",
"hull",
"then",
"subdivide",
"it",
"into",
"smaller",
"sub",
"-",
"polygons",
"if",
"its",
"area",
"exceeds",
"max",
"size",
"(",
"in",
"geometry",
"s",
"units",
")",
"."
] | UDST/osmnet | python | https://github.com/UDST/osmnet/blob/155110a8e38d3646b9dbc3ec729063930cab3d5f/osmnet/load.py#L331-L373 | [
"def",
"consolidate_subdivide_geometry",
"(",
"geometry",
",",
"max_query_area_size",
")",
":",
"# let the linear length of the quadrats (with which to subdivide the",
"# geometry) be the square root of max area size",
"quadrat_width",
"=",
"math",
".",
"sqrt",
"(",
"max_query_area_s... | 155110a8e38d3646b9dbc3ec729063930cab3d5f |
train | quadrat_cut_geometry | Split a Polygon or MultiPolygon up into sub-polygons of a specified size,
using quadrats.
Parameters
----------
geometry : shapely Polygon or MultiPolygon
the geometry to split up into smaller sub-polygons
quadrat_width : float
the linear width of the quadrats with which to cut up t... | osmnet/load.py | def quadrat_cut_geometry(geometry, quadrat_width, min_num=3,
buffer_amount=1e-9):
"""
Split a Polygon or MultiPolygon up into sub-polygons of a specified size,
using quadrats.
Parameters
----------
geometry : shapely Polygon or MultiPolygon
the geometry to split... | def quadrat_cut_geometry(geometry, quadrat_width, min_num=3,
buffer_amount=1e-9):
"""
Split a Polygon or MultiPolygon up into sub-polygons of a specified size,
using quadrats.
Parameters
----------
geometry : shapely Polygon or MultiPolygon
the geometry to split... | [
"Split",
"a",
"Polygon",
"or",
"MultiPolygon",
"up",
"into",
"sub",
"-",
"polygons",
"of",
"a",
"specified",
"size",
"using",
"quadrats",
"."
] | UDST/osmnet | python | https://github.com/UDST/osmnet/blob/155110a8e38d3646b9dbc3ec729063930cab3d5f/osmnet/load.py#L376-L421 | [
"def",
"quadrat_cut_geometry",
"(",
"geometry",
",",
"quadrat_width",
",",
"min_num",
"=",
"3",
",",
"buffer_amount",
"=",
"1e-9",
")",
":",
"# create n evenly spaced points between the min and max x and y bounds",
"lng_max",
",",
"lat_min",
",",
"lng_min",
",",
"lat_ma... | 155110a8e38d3646b9dbc3ec729063930cab3d5f |
train | project_geometry | Project a shapely Polygon or MultiPolygon from WGS84 to UTM, or vice-versa
Parameters
----------
geometry : shapely Polygon or MultiPolygon
the geometry to project
crs : int
the starting coordinate reference system of the passed-in geometry
to_latlong : bool
if True, project... | osmnet/load.py | def project_geometry(geometry, crs, to_latlong=False):
"""
Project a shapely Polygon or MultiPolygon from WGS84 to UTM, or vice-versa
Parameters
----------
geometry : shapely Polygon or MultiPolygon
the geometry to project
crs : int
the starting coordinate reference system of th... | def project_geometry(geometry, crs, to_latlong=False):
"""
Project a shapely Polygon or MultiPolygon from WGS84 to UTM, or vice-versa
Parameters
----------
geometry : shapely Polygon or MultiPolygon
the geometry to project
crs : int
the starting coordinate reference system of th... | [
"Project",
"a",
"shapely",
"Polygon",
"or",
"MultiPolygon",
"from",
"WGS84",
"to",
"UTM",
"or",
"vice",
"-",
"versa"
] | UDST/osmnet | python | https://github.com/UDST/osmnet/blob/155110a8e38d3646b9dbc3ec729063930cab3d5f/osmnet/load.py#L424-L450 | [
"def",
"project_geometry",
"(",
"geometry",
",",
"crs",
",",
"to_latlong",
"=",
"False",
")",
":",
"gdf",
"=",
"gpd",
".",
"GeoDataFrame",
"(",
")",
"gdf",
".",
"crs",
"=",
"crs",
"gdf",
".",
"name",
"=",
"'geometry to project'",
"gdf",
"[",
"'geometry'"... | 155110a8e38d3646b9dbc3ec729063930cab3d5f |
train | process_node | Process a node element entry into a dict suitable for going into a
Pandas DataFrame.
Parameters
----------
e : dict
individual node element in downloaded OSM json
Returns
-------
node : dict | osmnet/load.py | def process_node(e):
"""
Process a node element entry into a dict suitable for going into a
Pandas DataFrame.
Parameters
----------
e : dict
individual node element in downloaded OSM json
Returns
-------
node : dict
"""
node = {'id': e['id'],
'lat': e['... | def process_node(e):
"""
Process a node element entry into a dict suitable for going into a
Pandas DataFrame.
Parameters
----------
e : dict
individual node element in downloaded OSM json
Returns
-------
node : dict
"""
node = {'id': e['id'],
'lat': e['... | [
"Process",
"a",
"node",
"element",
"entry",
"into",
"a",
"dict",
"suitable",
"for",
"going",
"into",
"a",
"Pandas",
"DataFrame",
"."
] | UDST/osmnet | python | https://github.com/UDST/osmnet/blob/155110a8e38d3646b9dbc3ec729063930cab3d5f/osmnet/load.py#L514-L539 | [
"def",
"process_node",
"(",
"e",
")",
":",
"node",
"=",
"{",
"'id'",
":",
"e",
"[",
"'id'",
"]",
",",
"'lat'",
":",
"e",
"[",
"'lat'",
"]",
",",
"'lon'",
":",
"e",
"[",
"'lon'",
"]",
"}",
"if",
"'tags'",
"in",
"e",
":",
"if",
"e",
"[",
"'ta... | 155110a8e38d3646b9dbc3ec729063930cab3d5f |
train | process_way | Process a way element entry into a list of dicts suitable for going into
a Pandas DataFrame.
Parameters
----------
e : dict
individual way element in downloaded OSM json
Returns
-------
way : dict
waynodes : list of dict | osmnet/load.py | def process_way(e):
"""
Process a way element entry into a list of dicts suitable for going into
a Pandas DataFrame.
Parameters
----------
e : dict
individual way element in downloaded OSM json
Returns
-------
way : dict
waynodes : list of dict
"""
way = {'id':... | def process_way(e):
"""
Process a way element entry into a list of dicts suitable for going into
a Pandas DataFrame.
Parameters
----------
e : dict
individual way element in downloaded OSM json
Returns
-------
way : dict
waynodes : list of dict
"""
way = {'id':... | [
"Process",
"a",
"way",
"element",
"entry",
"into",
"a",
"list",
"of",
"dicts",
"suitable",
"for",
"going",
"into",
"a",
"Pandas",
"DataFrame",
"."
] | UDST/osmnet | python | https://github.com/UDST/osmnet/blob/155110a8e38d3646b9dbc3ec729063930cab3d5f/osmnet/load.py#L542-L572 | [
"def",
"process_way",
"(",
"e",
")",
":",
"way",
"=",
"{",
"'id'",
":",
"e",
"[",
"'id'",
"]",
"}",
"if",
"'tags'",
"in",
"e",
":",
"if",
"e",
"[",
"'tags'",
"]",
"is",
"not",
"np",
".",
"nan",
":",
"for",
"t",
",",
"v",
"in",
"list",
"(",
... | 155110a8e38d3646b9dbc3ec729063930cab3d5f |
train | parse_network_osm_query | Convert OSM query data to DataFrames of ways and way-nodes.
Parameters
----------
data : dict
Result of an OSM query.
Returns
-------
nodes, ways, waynodes : pandas.DataFrame | osmnet/load.py | def parse_network_osm_query(data):
"""
Convert OSM query data to DataFrames of ways and way-nodes.
Parameters
----------
data : dict
Result of an OSM query.
Returns
-------
nodes, ways, waynodes : pandas.DataFrame
"""
if len(data['elements']) == 0:
raise Runtim... | def parse_network_osm_query(data):
"""
Convert OSM query data to DataFrames of ways and way-nodes.
Parameters
----------
data : dict
Result of an OSM query.
Returns
-------
nodes, ways, waynodes : pandas.DataFrame
"""
if len(data['elements']) == 0:
raise Runtim... | [
"Convert",
"OSM",
"query",
"data",
"to",
"DataFrames",
"of",
"ways",
"and",
"way",
"-",
"nodes",
"."
] | UDST/osmnet | python | https://github.com/UDST/osmnet/blob/155110a8e38d3646b9dbc3ec729063930cab3d5f/osmnet/load.py#L575-L608 | [
"def",
"parse_network_osm_query",
"(",
"data",
")",
":",
"if",
"len",
"(",
"data",
"[",
"'elements'",
"]",
")",
"==",
"0",
":",
"raise",
"RuntimeError",
"(",
"'OSM query results contain no data.'",
")",
"nodes",
"=",
"[",
"]",
"ways",
"=",
"[",
"]",
"wayno... | 155110a8e38d3646b9dbc3ec729063930cab3d5f |
train | ways_in_bbox | Get DataFrames of OSM data in a bounding box.
Parameters
----------
lat_min : float
southern latitude of bounding box
lng_min : float
eastern longitude of bounding box
lat_max : float
northern latitude of bounding box
lng_max : float
western longitude of bounding... | osmnet/load.py | def ways_in_bbox(lat_min, lng_min, lat_max, lng_max, network_type,
timeout=180, memory=None,
max_query_area_size=50*1000*50*1000,
custom_osm_filter=None):
"""
Get DataFrames of OSM data in a bounding box.
Parameters
----------
lat_min : float
... | def ways_in_bbox(lat_min, lng_min, lat_max, lng_max, network_type,
timeout=180, memory=None,
max_query_area_size=50*1000*50*1000,
custom_osm_filter=None):
"""
Get DataFrames of OSM data in a bounding box.
Parameters
----------
lat_min : float
... | [
"Get",
"DataFrames",
"of",
"OSM",
"data",
"in",
"a",
"bounding",
"box",
"."
] | UDST/osmnet | python | https://github.com/UDST/osmnet/blob/155110a8e38d3646b9dbc3ec729063930cab3d5f/osmnet/load.py#L611-L658 | [
"def",
"ways_in_bbox",
"(",
"lat_min",
",",
"lng_min",
",",
"lat_max",
",",
"lng_max",
",",
"network_type",
",",
"timeout",
"=",
"180",
",",
"memory",
"=",
"None",
",",
"max_query_area_size",
"=",
"50",
"*",
"1000",
"*",
"50",
"*",
"1000",
",",
"custom_o... | 155110a8e38d3646b9dbc3ec729063930cab3d5f |
train | intersection_nodes | Returns a set of all the nodes that appear in 2 or more ways.
Parameters
----------
waynodes : pandas.DataFrame
Mapping of way IDs to node IDs as returned by `ways_in_bbox`.
Returns
-------
intersections : set
Node IDs that appear in 2 or more ways. | osmnet/load.py | def intersection_nodes(waynodes):
"""
Returns a set of all the nodes that appear in 2 or more ways.
Parameters
----------
waynodes : pandas.DataFrame
Mapping of way IDs to node IDs as returned by `ways_in_bbox`.
Returns
-------
intersections : set
Node IDs that appear i... | def intersection_nodes(waynodes):
"""
Returns a set of all the nodes that appear in 2 or more ways.
Parameters
----------
waynodes : pandas.DataFrame
Mapping of way IDs to node IDs as returned by `ways_in_bbox`.
Returns
-------
intersections : set
Node IDs that appear i... | [
"Returns",
"a",
"set",
"of",
"all",
"the",
"nodes",
"that",
"appear",
"in",
"2",
"or",
"more",
"ways",
"."
] | UDST/osmnet | python | https://github.com/UDST/osmnet/blob/155110a8e38d3646b9dbc3ec729063930cab3d5f/osmnet/load.py#L661-L677 | [
"def",
"intersection_nodes",
"(",
"waynodes",
")",
":",
"counts",
"=",
"waynodes",
".",
"node_id",
".",
"value_counts",
"(",
")",
"return",
"set",
"(",
"counts",
"[",
"counts",
">",
"1",
"]",
".",
"index",
".",
"values",
")"
] | 155110a8e38d3646b9dbc3ec729063930cab3d5f |
train | node_pairs | Create a table of node pairs with the distances between them.
Parameters
----------
nodes : pandas.DataFrame
Must have 'lat' and 'lon' columns.
ways : pandas.DataFrame
Table of way metadata.
waynodes : pandas.DataFrame
Table linking way IDs to node IDs. Way IDs should be in ... | osmnet/load.py | def node_pairs(nodes, ways, waynodes, two_way=True):
"""
Create a table of node pairs with the distances between them.
Parameters
----------
nodes : pandas.DataFrame
Must have 'lat' and 'lon' columns.
ways : pandas.DataFrame
Table of way metadata.
waynodes : pandas.DataFrame... | def node_pairs(nodes, ways, waynodes, two_way=True):
"""
Create a table of node pairs with the distances between them.
Parameters
----------
nodes : pandas.DataFrame
Must have 'lat' and 'lon' columns.
ways : pandas.DataFrame
Table of way metadata.
waynodes : pandas.DataFrame... | [
"Create",
"a",
"table",
"of",
"node",
"pairs",
"with",
"the",
"distances",
"between",
"them",
"."
] | UDST/osmnet | python | https://github.com/UDST/osmnet/blob/155110a8e38d3646b9dbc3ec729063930cab3d5f/osmnet/load.py#L680-L764 | [
"def",
"node_pairs",
"(",
"nodes",
",",
"ways",
",",
"waynodes",
",",
"two_way",
"=",
"True",
")",
":",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"def",
"pairwise",
"(",
"l",
")",
":",
"return",
"zip",
"(",
"islice",
"(",
"l",
",",
"0",
"... | 155110a8e38d3646b9dbc3ec729063930cab3d5f |
train | network_from_bbox | Make a graph network from a bounding lat/lon box composed of nodes and
edges for use in Pandana street network accessibility calculations.
You may either enter a lat/long box via the four lat_min,
lng_min, lat_max, lng_max parameters or the bbox parameter as a tuple.
Parameters
----------
lat_m... | osmnet/load.py | def network_from_bbox(lat_min=None, lng_min=None, lat_max=None, lng_max=None,
bbox=None, network_type='walk', two_way=True,
timeout=180, memory=None,
max_query_area_size=50*1000*50*1000,
custom_osm_filter=None):
"""
Make a g... | def network_from_bbox(lat_min=None, lng_min=None, lat_max=None, lng_max=None,
bbox=None, network_type='walk', two_way=True,
timeout=180, memory=None,
max_query_area_size=50*1000*50*1000,
custom_osm_filter=None):
"""
Make a g... | [
"Make",
"a",
"graph",
"network",
"from",
"a",
"bounding",
"lat",
"/",
"lon",
"box",
"composed",
"of",
"nodes",
"and",
"edges",
"for",
"use",
"in",
"Pandana",
"street",
"network",
"accessibility",
"calculations",
".",
"You",
"may",
"either",
"enter",
"a",
"... | UDST/osmnet | python | https://github.com/UDST/osmnet/blob/155110a8e38d3646b9dbc3ec729063930cab3d5f/osmnet/load.py#L767-L873 | [
"def",
"network_from_bbox",
"(",
"lat_min",
"=",
"None",
",",
"lng_min",
"=",
"None",
",",
"lat_max",
"=",
"None",
",",
"lng_max",
"=",
"None",
",",
"bbox",
"=",
"None",
",",
"network_type",
"=",
"'walk'",
",",
"two_way",
"=",
"True",
",",
"timeout",
"... | 155110a8e38d3646b9dbc3ec729063930cab3d5f |
train | read_lines | Returns a list of lines from a input markdown file. | markdown_toclify/markdown_toclify.py | def read_lines(in_file):
"""Returns a list of lines from a input markdown file."""
with open(in_file, 'r') as inf:
in_contents = inf.read().split('\n')
return in_contents | def read_lines(in_file):
"""Returns a list of lines from a input markdown file."""
with open(in_file, 'r') as inf:
in_contents = inf.read().split('\n')
return in_contents | [
"Returns",
"a",
"list",
"of",
"lines",
"from",
"a",
"input",
"markdown",
"file",
"."
] | rasbt/markdown-toclify | python | https://github.com/rasbt/markdown-toclify/blob/517cde672bebda5371130b87c1fcb7184d141a02/markdown_toclify/markdown_toclify.py#L33-L38 | [
"def",
"read_lines",
"(",
"in_file",
")",
":",
"with",
"open",
"(",
"in_file",
",",
"'r'",
")",
"as",
"inf",
":",
"in_contents",
"=",
"inf",
".",
"read",
"(",
")",
".",
"split",
"(",
"'\\n'",
")",
"return",
"in_contents"
] | 517cde672bebda5371130b87c1fcb7184d141a02 |
train | remove_lines | Removes existing [back to top] links and <a id> tags. | markdown_toclify/markdown_toclify.py | def remove_lines(lines, remove=('[[back to top]', '<a class="mk-toclify"')):
"""Removes existing [back to top] links and <a id> tags."""
if not remove:
return lines[:]
out = []
for l in lines:
if l.startswith(remove):
continue
out.append(l)
return out | def remove_lines(lines, remove=('[[back to top]', '<a class="mk-toclify"')):
"""Removes existing [back to top] links and <a id> tags."""
if not remove:
return lines[:]
out = []
for l in lines:
if l.startswith(remove):
continue
out.append(l)
return out | [
"Removes",
"existing",
"[",
"back",
"to",
"top",
"]",
"links",
"and",
"<a",
"id",
">",
"tags",
"."
] | rasbt/markdown-toclify | python | https://github.com/rasbt/markdown-toclify/blob/517cde672bebda5371130b87c1fcb7184d141a02/markdown_toclify/markdown_toclify.py#L41-L52 | [
"def",
"remove_lines",
"(",
"lines",
",",
"remove",
"=",
"(",
"'[[back to top]'",
",",
"'<a class=\"mk-toclify\"'",
")",
")",
":",
"if",
"not",
"remove",
":",
"return",
"lines",
"[",
":",
"]",
"out",
"=",
"[",
"]",
"for",
"l",
"in",
"lines",
":",
"if",... | 517cde672bebda5371130b87c1fcb7184d141a02 |
train | slugify_headline | Takes a header line from a Markdown document and
returns a tuple of the
'#'-stripped version of the head line,
a string version for <a id=''></a> anchor tags,
and the level of the headline as integer.
E.g.,
>>> dashify_headline('### some header lvl3')
('Some header lvl3', 'some-h... | markdown_toclify/markdown_toclify.py | def slugify_headline(line, remove_dashes=False):
"""
Takes a header line from a Markdown document and
returns a tuple of the
'#'-stripped version of the head line,
a string version for <a id=''></a> anchor tags,
and the level of the headline as integer.
E.g.,
>>> dashify_head... | def slugify_headline(line, remove_dashes=False):
"""
Takes a header line from a Markdown document and
returns a tuple of the
'#'-stripped version of the head line,
a string version for <a id=''></a> anchor tags,
and the level of the headline as integer.
E.g.,
>>> dashify_head... | [
"Takes",
"a",
"header",
"line",
"from",
"a",
"Markdown",
"document",
"and",
"returns",
"a",
"tuple",
"of",
"the",
"#",
"-",
"stripped",
"version",
"of",
"the",
"head",
"line",
"a",
"string",
"version",
"for",
"<a",
"id",
"=",
">",
"<",
"/",
"a",
">",... | rasbt/markdown-toclify | python | https://github.com/rasbt/markdown-toclify/blob/517cde672bebda5371130b87c1fcb7184d141a02/markdown_toclify/markdown_toclify.py#L55-L88 | [
"def",
"slugify_headline",
"(",
"line",
",",
"remove_dashes",
"=",
"False",
")",
":",
"stripped_right",
"=",
"line",
".",
"rstrip",
"(",
"'#'",
")",
"stripped_both",
"=",
"stripped_right",
".",
"lstrip",
"(",
"'#'",
")",
"level",
"=",
"len",
"(",
"stripped... | 517cde672bebda5371130b87c1fcb7184d141a02 |
train | tag_and_collect | Gets headlines from the markdown document and creates anchor tags.
Keyword arguments:
lines: a list of sublists where every sublist
represents a line from a Markdown document.
id_tag: if true, creates inserts a the <a id> tags (not req. by GitHub)
back_links: if true, adds "back... | markdown_toclify/markdown_toclify.py | def tag_and_collect(lines, id_tag=True, back_links=False, exclude_h=None, remove_dashes=False):
"""
Gets headlines from the markdown document and creates anchor tags.
Keyword arguments:
lines: a list of sublists where every sublist
represents a line from a Markdown document.
id_... | def tag_and_collect(lines, id_tag=True, back_links=False, exclude_h=None, remove_dashes=False):
"""
Gets headlines from the markdown document and creates anchor tags.
Keyword arguments:
lines: a list of sublists where every sublist
represents a line from a Markdown document.
id_... | [
"Gets",
"headlines",
"from",
"the",
"markdown",
"document",
"and",
"creates",
"anchor",
"tags",
"."
] | rasbt/markdown-toclify | python | https://github.com/rasbt/markdown-toclify/blob/517cde672bebda5371130b87c1fcb7184d141a02/markdown_toclify/markdown_toclify.py#L91-L157 | [
"def",
"tag_and_collect",
"(",
"lines",
",",
"id_tag",
"=",
"True",
",",
"back_links",
"=",
"False",
",",
"exclude_h",
"=",
"None",
",",
"remove_dashes",
"=",
"False",
")",
":",
"out_contents",
"=",
"[",
"]",
"headlines",
"=",
"[",
"]",
"for",
"l",
"in... | 517cde672bebda5371130b87c1fcb7184d141a02 |
train | positioning_headlines | Strips unnecessary whitespaces/tabs if first header is not left-aligned | markdown_toclify/markdown_toclify.py | def positioning_headlines(headlines):
"""
Strips unnecessary whitespaces/tabs if first header is not left-aligned
"""
left_just = False
for row in headlines:
if row[-1] == 1:
left_just = True
break
if not left_just:
for row in headlines:
row[-1... | def positioning_headlines(headlines):
"""
Strips unnecessary whitespaces/tabs if first header is not left-aligned
"""
left_just = False
for row in headlines:
if row[-1] == 1:
left_just = True
break
if not left_just:
for row in headlines:
row[-1... | [
"Strips",
"unnecessary",
"whitespaces",
"/",
"tabs",
"if",
"first",
"header",
"is",
"not",
"left",
"-",
"aligned"
] | rasbt/markdown-toclify | python | https://github.com/rasbt/markdown-toclify/blob/517cde672bebda5371130b87c1fcb7184d141a02/markdown_toclify/markdown_toclify.py#L160-L172 | [
"def",
"positioning_headlines",
"(",
"headlines",
")",
":",
"left_just",
"=",
"False",
"for",
"row",
"in",
"headlines",
":",
"if",
"row",
"[",
"-",
"1",
"]",
"==",
"1",
":",
"left_just",
"=",
"True",
"break",
"if",
"not",
"left_just",
":",
"for",
"row"... | 517cde672bebda5371130b87c1fcb7184d141a02 |
train | create_toc | Creates the table of contents from the headline list
that was returned by the tag_and_collect function.
Keyword Arguments:
headlines: list of lists
e.g., ['Some header lvl3', 'some-header-lvl3', 3]
hyperlink: Creates hyperlinks in Markdown format if True,
e.g., '- [Some ... | markdown_toclify/markdown_toclify.py | def create_toc(headlines, hyperlink=True, top_link=False, no_toc_header=False):
"""
Creates the table of contents from the headline list
that was returned by the tag_and_collect function.
Keyword Arguments:
headlines: list of lists
e.g., ['Some header lvl3', 'some-header-lvl3', 3]
... | def create_toc(headlines, hyperlink=True, top_link=False, no_toc_header=False):
"""
Creates the table of contents from the headline list
that was returned by the tag_and_collect function.
Keyword Arguments:
headlines: list of lists
e.g., ['Some header lvl3', 'some-header-lvl3', 3]
... | [
"Creates",
"the",
"table",
"of",
"contents",
"from",
"the",
"headline",
"list",
"that",
"was",
"returned",
"by",
"the",
"tag_and_collect",
"function",
"."
] | rasbt/markdown-toclify | python | https://github.com/rasbt/markdown-toclify/blob/517cde672bebda5371130b87c1fcb7184d141a02/markdown_toclify/markdown_toclify.py#L175-L207 | [
"def",
"create_toc",
"(",
"headlines",
",",
"hyperlink",
"=",
"True",
",",
"top_link",
"=",
"False",
",",
"no_toc_header",
"=",
"False",
")",
":",
"processed",
"=",
"[",
"]",
"if",
"not",
"no_toc_header",
":",
"if",
"top_link",
":",
"processed",
".",
"ap... | 517cde672bebda5371130b87c1fcb7184d141a02 |
train | build_markdown | Returns a string with the Markdown output contents incl.
the table of contents.
Keyword arguments:
toc_headlines: lines for the table of contents
as created by the create_toc function.
body: contents of the Markdown file including
ID-anchor tags as returned by the
... | markdown_toclify/markdown_toclify.py | def build_markdown(toc_headlines, body, spacer=0, placeholder=None):
"""
Returns a string with the Markdown output contents incl.
the table of contents.
Keyword arguments:
toc_headlines: lines for the table of contents
as created by the create_toc function.
body: contents of... | def build_markdown(toc_headlines, body, spacer=0, placeholder=None):
"""
Returns a string with the Markdown output contents incl.
the table of contents.
Keyword arguments:
toc_headlines: lines for the table of contents
as created by the create_toc function.
body: contents of... | [
"Returns",
"a",
"string",
"with",
"the",
"Markdown",
"output",
"contents",
"incl",
".",
"the",
"table",
"of",
"contents",
"."
] | rasbt/markdown-toclify | python | https://github.com/rasbt/markdown-toclify/blob/517cde672bebda5371130b87c1fcb7184d141a02/markdown_toclify/markdown_toclify.py#L210-L241 | [
"def",
"build_markdown",
"(",
"toc_headlines",
",",
"body",
",",
"spacer",
"=",
"0",
",",
"placeholder",
"=",
"None",
")",
":",
"if",
"spacer",
":",
"spacer_line",
"=",
"[",
"'\\n<div style=\"height:%spx;\"></div>\\n'",
"%",
"(",
"spacer",
")",
"]",
"toc_markd... | 517cde672bebda5371130b87c1fcb7184d141a02 |
train | output_markdown | Writes to an output file if `outfile` is a valid path. | markdown_toclify/markdown_toclify.py | def output_markdown(markdown_cont, output_file):
"""
Writes to an output file if `outfile` is a valid path.
"""
if output_file:
with open(output_file, 'w') as out:
out.write(markdown_cont) | def output_markdown(markdown_cont, output_file):
"""
Writes to an output file if `outfile` is a valid path.
"""
if output_file:
with open(output_file, 'w') as out:
out.write(markdown_cont) | [
"Writes",
"to",
"an",
"output",
"file",
"if",
"outfile",
"is",
"a",
"valid",
"path",
"."
] | rasbt/markdown-toclify | python | https://github.com/rasbt/markdown-toclify/blob/517cde672bebda5371130b87c1fcb7184d141a02/markdown_toclify/markdown_toclify.py#L244-L251 | [
"def",
"output_markdown",
"(",
"markdown_cont",
",",
"output_file",
")",
":",
"if",
"output_file",
":",
"with",
"open",
"(",
"output_file",
",",
"'w'",
")",
"as",
"out",
":",
"out",
".",
"write",
"(",
"markdown_cont",
")"
] | 517cde672bebda5371130b87c1fcb7184d141a02 |
train | markdown_toclify | Function to add table of contents to markdown files.
Parameters
-----------
input_file: str
Path to the markdown input file.
output_file: str (defaul: None)
Path to the markdown output file.
github: bool (default: False)
Uses GitHub TOC syntax if True.
back_to... | markdown_toclify/markdown_toclify.py | def markdown_toclify(input_file, output_file=None, github=False,
back_to_top=False, nolink=False,
no_toc_header=False, spacer=0, placeholder=None,
exclude_h=None, remove_dashes=False):
""" Function to add table of contents to markdown files.
Parame... | def markdown_toclify(input_file, output_file=None, github=False,
back_to_top=False, nolink=False,
no_toc_header=False, spacer=0, placeholder=None,
exclude_h=None, remove_dashes=False):
""" Function to add table of contents to markdown files.
Parame... | [
"Function",
"to",
"add",
"table",
"of",
"contents",
"to",
"markdown",
"files",
"."
] | rasbt/markdown-toclify | python | https://github.com/rasbt/markdown-toclify/blob/517cde672bebda5371130b87c1fcb7184d141a02/markdown_toclify/markdown_toclify.py#L254-L326 | [
"def",
"markdown_toclify",
"(",
"input_file",
",",
"output_file",
"=",
"None",
",",
"github",
"=",
"False",
",",
"back_to_top",
"=",
"False",
",",
"nolink",
"=",
"False",
",",
"no_toc_header",
"=",
"False",
",",
"spacer",
"=",
"0",
",",
"placeholder",
"=",... | 517cde672bebda5371130b87c1fcb7184d141a02 |
train | url_parse | parse urls with different prefixes | cli_github/utils.py | def url_parse(name):
"""parse urls with different prefixes"""
position = name.find("github.com")
if position >= 0:
if position != 0:
position_1 = name.find("www.github.com")
position_2 = name.find("http://github.com")
position_3 = name.find("https://github.com")
... | def url_parse(name):
"""parse urls with different prefixes"""
position = name.find("github.com")
if position >= 0:
if position != 0:
position_1 = name.find("www.github.com")
position_2 = name.find("http://github.com")
position_3 = name.find("https://github.com")
... | [
"parse",
"urls",
"with",
"different",
"prefixes"
] | harshasrinivas/cli-github | python | https://github.com/harshasrinivas/cli-github/blob/33e08d0325b48f908506ca76e501cfb890a9a2cd/cli_github/utils.py#L30-L48 | [
"def",
"url_parse",
"(",
"name",
")",
":",
"position",
"=",
"name",
".",
"find",
"(",
"\"github.com\"",
")",
"if",
"position",
">=",
"0",
":",
"if",
"position",
"!=",
"0",
":",
"position_1",
"=",
"name",
".",
"find",
"(",
"\"www.github.com\"",
")",
"po... | 33e08d0325b48f908506ca76e501cfb890a9a2cd |
train | get_req | simple get request | cli_github/utils.py | def get_req(url):
"""simple get request"""
request = urllib.request.Request(url)
request.add_header('Authorization', 'token %s' % API_TOKEN)
try:
response = urllib.request.urlopen(request).read().decode('utf-8')
return response
except urllib.error.HTTPError:
exception()
... | def get_req(url):
"""simple get request"""
request = urllib.request.Request(url)
request.add_header('Authorization', 'token %s' % API_TOKEN)
try:
response = urllib.request.urlopen(request).read().decode('utf-8')
return response
except urllib.error.HTTPError:
exception()
... | [
"simple",
"get",
"request"
] | harshasrinivas/cli-github | python | https://github.com/harshasrinivas/cli-github/blob/33e08d0325b48f908506ca76e501cfb890a9a2cd/cli_github/utils.py#L53-L62 | [
"def",
"get_req",
"(",
"url",
")",
":",
"request",
"=",
"urllib",
".",
"request",
".",
"Request",
"(",
"url",
")",
"request",
".",
"add_header",
"(",
"'Authorization'",
",",
"'token %s'",
"%",
"API_TOKEN",
")",
"try",
":",
"response",
"=",
"urllib",
".",... | 33e08d0325b48f908506ca76e501cfb890a9a2cd |
train | geturl_req | get request that returns 302 | cli_github/utils.py | def geturl_req(url):
"""get request that returns 302"""
request = urllib.request.Request(url)
request.add_header('Authorization', 'token %s' % API_TOKEN)
try:
response_url = urllib.request.urlopen(request).geturl()
return response_url
except urllib.error.HTTPError:
exception(... | def geturl_req(url):
"""get request that returns 302"""
request = urllib.request.Request(url)
request.add_header('Authorization', 'token %s' % API_TOKEN)
try:
response_url = urllib.request.urlopen(request).geturl()
return response_url
except urllib.error.HTTPError:
exception(... | [
"get",
"request",
"that",
"returns",
"302"
] | harshasrinivas/cli-github | python | https://github.com/harshasrinivas/cli-github/blob/33e08d0325b48f908506ca76e501cfb890a9a2cd/cli_github/utils.py#L67-L76 | [
"def",
"geturl_req",
"(",
"url",
")",
":",
"request",
"=",
"urllib",
".",
"request",
".",
"Request",
"(",
"url",
")",
"request",
".",
"add_header",
"(",
"'Authorization'",
",",
"'token %s'",
"%",
"API_TOKEN",
")",
"try",
":",
"response_url",
"=",
"urllib",... | 33e08d0325b48f908506ca76e501cfb890a9a2cd |
train | main | main function | cli_github/mains.py | def main():
"""main function"""
parser = argparse.ArgumentParser(
description='Github within the Command Line')
group = parser.add_mutually_exclusive_group()
group.add_argument('-n', '--url', type=str,
help="Get repos from the user profile's URL")
group.add_argument('-... | def main():
"""main function"""
parser = argparse.ArgumentParser(
description='Github within the Command Line')
group = parser.add_mutually_exclusive_group()
group.add_argument('-n', '--url', type=str,
help="Get repos from the user profile's URL")
group.add_argument('-... | [
"main",
"function"
] | harshasrinivas/cli-github | python | https://github.com/harshasrinivas/cli-github/blob/33e08d0325b48f908506ca76e501cfb890a9a2cd/cli_github/mains.py#L25-L223 | [
"def",
"main",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'Github within the Command Line'",
")",
"group",
"=",
"parser",
".",
"add_mutually_exclusive_group",
"(",
")",
"group",
".",
"add_argument",
"(",
"'-n'",
",... | 33e08d0325b48f908506ca76e501cfb890a9a2cd |
train | do_capture | Capture the contents of a tag output.
Usage:
.. code-block:: html+django
{% capture %}..{% endcapture %} # output in {{ capture }}
{% capture silent %}..{% endcapture %} # output in {{ capture }} only
{% capture as varname %}..{% endcapture %} # o... | capture_tag/templatetags/capture_tags.py | def do_capture(parser, token):
"""
Capture the contents of a tag output.
Usage:
.. code-block:: html+django
{% capture %}..{% endcapture %} # output in {{ capture }}
{% capture silent %}..{% endcapture %} # output in {{ capture }} only
{% capture ... | def do_capture(parser, token):
"""
Capture the contents of a tag output.
Usage:
.. code-block:: html+django
{% capture %}..{% endcapture %} # output in {{ capture }}
{% capture silent %}..{% endcapture %} # output in {{ capture }} only
{% capture ... | [
"Capture",
"the",
"contents",
"of",
"a",
"tag",
"output",
".",
"Usage",
":"
] | edoburu/django-capture-tag | python | https://github.com/edoburu/django-capture-tag/blob/68b2c635f14dca0d90857d09bde9c4c68e249476/capture_tag/templatetags/capture_tags.py#L7-L59 | [
"def",
"do_capture",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"split_contents",
"(",
")",
"# tokens",
"t_as",
"=",
"'as'",
"t_silent",
"=",
"'silent'",
"var",
"=",
"'capture'",
"silent",
"=",
"False",
"num_bits",
"=",
"len",
"(",... | 68b2c635f14dca0d90857d09bde9c4c68e249476 |
train | MonzoTransaction._parse_special_fields | Helper method that parses special fields to Python objects
:param data: response from Monzo API request
:type data: dict | src/pymonzo/api_objects.py | def _parse_special_fields(self, data):
"""
Helper method that parses special fields to Python objects
:param data: response from Monzo API request
:type data: dict
"""
self.created = parse_date(data.pop('created'))
if data.get('settled'): # Not always returned
... | def _parse_special_fields(self, data):
"""
Helper method that parses special fields to Python objects
:param data: response from Monzo API request
:type data: dict
"""
self.created = parse_date(data.pop('created'))
if data.get('settled'): # Not always returned
... | [
"Helper",
"method",
"that",
"parses",
"special",
"fields",
"to",
"Python",
"objects"
] | pawelad/pymonzo | python | https://github.com/pawelad/pymonzo/blob/b5c8d4f46dcb3a2f475797a8b8ef1c15f6493fb9/src/pymonzo/api_objects.py#L102-L117 | [
"def",
"_parse_special_fields",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"created",
"=",
"parse_date",
"(",
"data",
".",
"pop",
"(",
"'created'",
")",
")",
"if",
"data",
".",
"get",
"(",
"'settled'",
")",
":",
"# Not always returned",
"self",
"."... | b5c8d4f46dcb3a2f475797a8b8ef1c15f6493fb9 |
train | MonzoAPI._save_token_on_disk | Helper function that saves the token on disk | src/pymonzo/monzo_api.py | def _save_token_on_disk(self):
"""Helper function that saves the token on disk"""
token = self._token.copy()
# Client secret is needed for token refreshing and isn't returned
# as a pared of OAuth token by default
token.update(client_secret=self._client_secret)
with cod... | def _save_token_on_disk(self):
"""Helper function that saves the token on disk"""
token = self._token.copy()
# Client secret is needed for token refreshing and isn't returned
# as a pared of OAuth token by default
token.update(client_secret=self._client_secret)
with cod... | [
"Helper",
"function",
"that",
"saves",
"the",
"token",
"on",
"disk"
] | pawelad/pymonzo | python | https://github.com/pawelad/pymonzo/blob/b5c8d4f46dcb3a2f475797a8b8ef1c15f6493fb9/src/pymonzo/monzo_api.py#L119-L133 | [
"def",
"_save_token_on_disk",
"(",
"self",
")",
":",
"token",
"=",
"self",
".",
"_token",
".",
"copy",
"(",
")",
"# Client secret is needed for token refreshing and isn't returned",
"# as a pared of OAuth token by default",
"token",
".",
"update",
"(",
"client_secret",
"=... | b5c8d4f46dcb3a2f475797a8b8ef1c15f6493fb9 |
train | MonzoAPI._get_oauth_token | Get Monzo access token via OAuth2 `authorization code` grant type.
Official docs:
https://monzo.com/docs/#acquire-an-access-token
:returns: OAuth 2 access token
:rtype: dict | src/pymonzo/monzo_api.py | def _get_oauth_token(self):
"""
Get Monzo access token via OAuth2 `authorization code` grant type.
Official docs:
https://monzo.com/docs/#acquire-an-access-token
:returns: OAuth 2 access token
:rtype: dict
"""
url = urljoin(self.api_url, '/oauth2/tok... | def _get_oauth_token(self):
"""
Get Monzo access token via OAuth2 `authorization code` grant type.
Official docs:
https://monzo.com/docs/#acquire-an-access-token
:returns: OAuth 2 access token
:rtype: dict
"""
url = urljoin(self.api_url, '/oauth2/tok... | [
"Get",
"Monzo",
"access",
"token",
"via",
"OAuth2",
"authorization",
"code",
"grant",
"type",
"."
] | pawelad/pymonzo | python | https://github.com/pawelad/pymonzo/blob/b5c8d4f46dcb3a2f475797a8b8ef1c15f6493fb9/src/pymonzo/monzo_api.py#L135-L158 | [
"def",
"_get_oauth_token",
"(",
"self",
")",
":",
"url",
"=",
"urljoin",
"(",
"self",
".",
"api_url",
",",
"'/oauth2/token'",
")",
"oauth",
"=",
"OAuth2Session",
"(",
"client_id",
"=",
"self",
".",
"_client_id",
",",
"redirect_uri",
"=",
"config",
".",
"RE... | b5c8d4f46dcb3a2f475797a8b8ef1c15f6493fb9 |
train | MonzoAPI._refresh_oath_token | Refresh Monzo OAuth 2 token.
Official docs:
https://monzo.com/docs/#refreshing-access
:raises UnableToRefreshTokenException: when token couldn't be refreshed | src/pymonzo/monzo_api.py | def _refresh_oath_token(self):
"""
Refresh Monzo OAuth 2 token.
Official docs:
https://monzo.com/docs/#refreshing-access
:raises UnableToRefreshTokenException: when token couldn't be refreshed
"""
url = urljoin(self.api_url, '/oauth2/token')
data = {... | def _refresh_oath_token(self):
"""
Refresh Monzo OAuth 2 token.
Official docs:
https://monzo.com/docs/#refreshing-access
:raises UnableToRefreshTokenException: when token couldn't be refreshed
"""
url = urljoin(self.api_url, '/oauth2/token')
data = {... | [
"Refresh",
"Monzo",
"OAuth",
"2",
"token",
"."
] | pawelad/pymonzo | python | https://github.com/pawelad/pymonzo/blob/b5c8d4f46dcb3a2f475797a8b8ef1c15f6493fb9/src/pymonzo/monzo_api.py#L160-L187 | [
"def",
"_refresh_oath_token",
"(",
"self",
")",
":",
"url",
"=",
"urljoin",
"(",
"self",
".",
"api_url",
",",
"'/oauth2/token'",
")",
"data",
"=",
"{",
"'grant_type'",
":",
"'refresh_token'",
",",
"'client_id'",
":",
"self",
".",
"_client_id",
",",
"'client_... | b5c8d4f46dcb3a2f475797a8b8ef1c15f6493fb9 |
train | MonzoAPI._get_response | Helper method to handle HTTP requests and catch API errors
:param method: valid HTTP method
:type method: str
:param endpoint: API endpoint
:type endpoint: str
:param params: extra parameters passed with the request
:type params: dict
:returns: API response
... | src/pymonzo/monzo_api.py | def _get_response(self, method, endpoint, params=None):
"""
Helper method to handle HTTP requests and catch API errors
:param method: valid HTTP method
:type method: str
:param endpoint: API endpoint
:type endpoint: str
:param params: extra parameters passed with... | def _get_response(self, method, endpoint, params=None):
"""
Helper method to handle HTTP requests and catch API errors
:param method: valid HTTP method
:type method: str
:param endpoint: API endpoint
:type endpoint: str
:param params: extra parameters passed with... | [
"Helper",
"method",
"to",
"handle",
"HTTP",
"requests",
"and",
"catch",
"API",
"errors"
] | pawelad/pymonzo | python | https://github.com/pawelad/pymonzo/blob/b5c8d4f46dcb3a2f475797a8b8ef1c15f6493fb9/src/pymonzo/monzo_api.py#L189-L229 | [
"def",
"_get_response",
"(",
"self",
",",
"method",
",",
"endpoint",
",",
"params",
"=",
"None",
")",
":",
"url",
"=",
"urljoin",
"(",
"self",
".",
"api_url",
",",
"endpoint",
")",
"try",
":",
"response",
"=",
"getattr",
"(",
"self",
".",
"_session",
... | b5c8d4f46dcb3a2f475797a8b8ef1c15f6493fb9 |
train | MonzoAPI.whoami | Get information about the access token.
Official docs:
https://monzo.com/docs/#authenticating-requests
:returns: access token details
:rtype: dict | src/pymonzo/monzo_api.py | def whoami(self):
"""
Get information about the access token.
Official docs:
https://monzo.com/docs/#authenticating-requests
:returns: access token details
:rtype: dict
"""
endpoint = '/ping/whoami'
response = self._get_response(
... | def whoami(self):
"""
Get information about the access token.
Official docs:
https://monzo.com/docs/#authenticating-requests
:returns: access token details
:rtype: dict
"""
endpoint = '/ping/whoami'
response = self._get_response(
... | [
"Get",
"information",
"about",
"the",
"access",
"token",
"."
] | pawelad/pymonzo | python | https://github.com/pawelad/pymonzo/blob/b5c8d4f46dcb3a2f475797a8b8ef1c15f6493fb9/src/pymonzo/monzo_api.py#L231-L246 | [
"def",
"whoami",
"(",
"self",
")",
":",
"endpoint",
"=",
"'/ping/whoami'",
"response",
"=",
"self",
".",
"_get_response",
"(",
"method",
"=",
"'get'",
",",
"endpoint",
"=",
"endpoint",
",",
")",
"return",
"response",
".",
"json",
"(",
")"
] | b5c8d4f46dcb3a2f475797a8b8ef1c15f6493fb9 |
train | MonzoAPI.accounts | Returns a list of accounts owned by the currently authorised user.
It's often used when deciding whether to require explicit account ID
or use the only available one, so we cache the response by default.
Official docs:
https://monzo.com/docs/#list-accounts
:param refresh: d... | src/pymonzo/monzo_api.py | def accounts(self, refresh=False):
"""
Returns a list of accounts owned by the currently authorised user.
It's often used when deciding whether to require explicit account ID
or use the only available one, so we cache the response by default.
Official docs:
https://m... | def accounts(self, refresh=False):
"""
Returns a list of accounts owned by the currently authorised user.
It's often used when deciding whether to require explicit account ID
or use the only available one, so we cache the response by default.
Official docs:
https://m... | [
"Returns",
"a",
"list",
"of",
"accounts",
"owned",
"by",
"the",
"currently",
"authorised",
"user",
".",
"It",
"s",
"often",
"used",
"when",
"deciding",
"whether",
"to",
"require",
"explicit",
"account",
"ID",
"or",
"use",
"the",
"only",
"available",
"one",
... | pawelad/pymonzo | python | https://github.com/pawelad/pymonzo/blob/b5c8d4f46dcb3a2f475797a8b8ef1c15f6493fb9/src/pymonzo/monzo_api.py#L248-L274 | [
"def",
"accounts",
"(",
"self",
",",
"refresh",
"=",
"False",
")",
":",
"if",
"not",
"refresh",
"and",
"self",
".",
"_cached_accounts",
":",
"return",
"self",
".",
"_cached_accounts",
"endpoint",
"=",
"'/accounts'",
"response",
"=",
"self",
".",
"_get_respon... | b5c8d4f46dcb3a2f475797a8b8ef1c15f6493fb9 |
train | MonzoAPI.balance | Returns balance information for a specific account.
Official docs:
https://monzo.com/docs/#read-balance
:param account_id: Monzo account ID
:type account_id: str
:raises: ValueError
:returns: Monzo balance instance
:rtype: MonzoBalance | src/pymonzo/monzo_api.py | def balance(self, account_id=None):
"""
Returns balance information for a specific account.
Official docs:
https://monzo.com/docs/#read-balance
:param account_id: Monzo account ID
:type account_id: str
:raises: ValueError
:returns: Monzo balance inst... | def balance(self, account_id=None):
"""
Returns balance information for a specific account.
Official docs:
https://monzo.com/docs/#read-balance
:param account_id: Monzo account ID
:type account_id: str
:raises: ValueError
:returns: Monzo balance inst... | [
"Returns",
"balance",
"information",
"for",
"a",
"specific",
"account",
"."
] | pawelad/pymonzo | python | https://github.com/pawelad/pymonzo/blob/b5c8d4f46dcb3a2f475797a8b8ef1c15f6493fb9/src/pymonzo/monzo_api.py#L276-L303 | [
"def",
"balance",
"(",
"self",
",",
"account_id",
"=",
"None",
")",
":",
"if",
"not",
"account_id",
":",
"if",
"len",
"(",
"self",
".",
"accounts",
"(",
")",
")",
"==",
"1",
":",
"account_id",
"=",
"self",
".",
"accounts",
"(",
")",
"[",
"0",
"]"... | b5c8d4f46dcb3a2f475797a8b8ef1c15f6493fb9 |
train | MonzoAPI.pots | Returns a list of pots owned by the currently authorised user.
Official docs:
https://monzo.com/docs/#pots
:param refresh: decides if the pots information should be refreshed.
:type refresh: bool
:returns: list of Monzo pots
:rtype: list of MonzoPot | src/pymonzo/monzo_api.py | def pots(self, refresh=False):
"""
Returns a list of pots owned by the currently authorised user.
Official docs:
https://monzo.com/docs/#pots
:param refresh: decides if the pots information should be refreshed.
:type refresh: bool
:returns: list of Monzo pot... | def pots(self, refresh=False):
"""
Returns a list of pots owned by the currently authorised user.
Official docs:
https://monzo.com/docs/#pots
:param refresh: decides if the pots information should be refreshed.
:type refresh: bool
:returns: list of Monzo pot... | [
"Returns",
"a",
"list",
"of",
"pots",
"owned",
"by",
"the",
"currently",
"authorised",
"user",
"."
] | pawelad/pymonzo | python | https://github.com/pawelad/pymonzo/blob/b5c8d4f46dcb3a2f475797a8b8ef1c15f6493fb9/src/pymonzo/monzo_api.py#L305-L329 | [
"def",
"pots",
"(",
"self",
",",
"refresh",
"=",
"False",
")",
":",
"if",
"not",
"refresh",
"and",
"self",
".",
"_cached_pots",
":",
"return",
"self",
".",
"_cached_pots",
"endpoint",
"=",
"'/pots/listV1'",
"response",
"=",
"self",
".",
"_get_response",
"(... | b5c8d4f46dcb3a2f475797a8b8ef1c15f6493fb9 |
train | MonzoAPI.transactions | Returns a list of transactions on the user's account.
Official docs:
https://monzo.com/docs/#list-transactions
:param account_id: Monzo account ID
:type account_id: str
:param reverse: whether transactions should be in in descending order
:type reverse: bool
... | src/pymonzo/monzo_api.py | def transactions(self, account_id=None, reverse=True, limit=None):
"""
Returns a list of transactions on the user's account.
Official docs:
https://monzo.com/docs/#list-transactions
:param account_id: Monzo account ID
:type account_id: str
:param reverse: wh... | def transactions(self, account_id=None, reverse=True, limit=None):
"""
Returns a list of transactions on the user's account.
Official docs:
https://monzo.com/docs/#list-transactions
:param account_id: Monzo account ID
:type account_id: str
:param reverse: wh... | [
"Returns",
"a",
"list",
"of",
"transactions",
"on",
"the",
"user",
"s",
"account",
"."
] | pawelad/pymonzo | python | https://github.com/pawelad/pymonzo/blob/b5c8d4f46dcb3a2f475797a8b8ef1c15f6493fb9/src/pymonzo/monzo_api.py#L331-L372 | [
"def",
"transactions",
"(",
"self",
",",
"account_id",
"=",
"None",
",",
"reverse",
"=",
"True",
",",
"limit",
"=",
"None",
")",
":",
"if",
"not",
"account_id",
":",
"if",
"len",
"(",
"self",
".",
"accounts",
"(",
")",
")",
"==",
"1",
":",
"account... | b5c8d4f46dcb3a2f475797a8b8ef1c15f6493fb9 |
train | MonzoAPI.transaction | Returns an individual transaction, fetched by its id.
Official docs:
https://monzo.com/docs/#retrieve-transaction
:param transaction_id: Monzo transaction ID
:type transaction_id: str
:param expand_merchant: whether merchant data should be included
:type expand_merc... | src/pymonzo/monzo_api.py | def transaction(self, transaction_id, expand_merchant=False):
"""
Returns an individual transaction, fetched by its id.
Official docs:
https://monzo.com/docs/#retrieve-transaction
:param transaction_id: Monzo transaction ID
:type transaction_id: str
:param e... | def transaction(self, transaction_id, expand_merchant=False):
"""
Returns an individual transaction, fetched by its id.
Official docs:
https://monzo.com/docs/#retrieve-transaction
:param transaction_id: Monzo transaction ID
:type transaction_id: str
:param e... | [
"Returns",
"an",
"individual",
"transaction",
"fetched",
"by",
"its",
"id",
"."
] | pawelad/pymonzo | python | https://github.com/pawelad/pymonzo/blob/b5c8d4f46dcb3a2f475797a8b8ef1c15f6493fb9/src/pymonzo/monzo_api.py#L374-L398 | [
"def",
"transaction",
"(",
"self",
",",
"transaction_id",
",",
"expand_merchant",
"=",
"False",
")",
":",
"endpoint",
"=",
"'/transactions/{}'",
".",
"format",
"(",
"transaction_id",
")",
"data",
"=",
"dict",
"(",
")",
"if",
"expand_merchant",
":",
"data",
"... | b5c8d4f46dcb3a2f475797a8b8ef1c15f6493fb9 |
train | launcher | Launch it. | snmposter/scripts.py | def launcher():
"""Launch it."""
parser = OptionParser()
parser.add_option(
'-f',
'--file',
dest='filename',
default='agents.csv',
help='snmposter configuration file'
)
options, args = parser.parse_args()
factory = SNMPosterFactory()
snmpd_status = s... | def launcher():
"""Launch it."""
parser = OptionParser()
parser.add_option(
'-f',
'--file',
dest='filename',
default='agents.csv',
help='snmposter configuration file'
)
options, args = parser.parse_args()
factory = SNMPosterFactory()
snmpd_status = s... | [
"Launch",
"it",
"."
] | cluther/snmposter | python | https://github.com/cluther/snmposter/blob/3d9fb122368893cc71374442da6d49cde19aac75/snmposter/scripts.py#L22-L52 | [
"def",
"launcher",
"(",
")",
":",
"parser",
"=",
"OptionParser",
"(",
")",
"parser",
".",
"add_option",
"(",
"'-f'",
",",
"'--file'",
",",
"dest",
"=",
"'filename'",
",",
"default",
"=",
"'agents.csv'",
",",
"help",
"=",
"'snmposter configuration file'",
")"... | 3d9fb122368893cc71374442da6d49cde19aac75 |
train | SauceClient.get_auth_string | Create auth string from credentials. | sauceclient.py | def get_auth_string(self):
"""Create auth string from credentials."""
auth_info = '{}:{}'.format(self.sauce_username, self.sauce_access_key)
return base64.b64encode(auth_info.encode('utf-8')).decode('utf-8') | def get_auth_string(self):
"""Create auth string from credentials."""
auth_info = '{}:{}'.format(self.sauce_username, self.sauce_access_key)
return base64.b64encode(auth_info.encode('utf-8')).decode('utf-8') | [
"Create",
"auth",
"string",
"from",
"credentials",
"."
] | cgoldberg/sauceclient | python | https://github.com/cgoldberg/sauceclient/blob/aa27b7da8eb2e483adc2754c694fe5082e1fa8f7/sauceclient.py#L59-L62 | [
"def",
"get_auth_string",
"(",
"self",
")",
":",
"auth_info",
"=",
"'{}:{}'",
".",
"format",
"(",
"self",
".",
"sauce_username",
",",
"self",
".",
"sauce_access_key",
")",
"return",
"base64",
".",
"b64encode",
"(",
"auth_info",
".",
"encode",
"(",
"'utf-8'",... | aa27b7da8eb2e483adc2754c694fe5082e1fa8f7 |
train | SauceClient.make_auth_headers | Add authorization header. | sauceclient.py | def make_auth_headers(self, content_type):
"""Add authorization header."""
headers = self.make_headers(content_type)
headers['Authorization'] = 'Basic {}'.format(self.get_auth_string())
return headers | def make_auth_headers(self, content_type):
"""Add authorization header."""
headers = self.make_headers(content_type)
headers['Authorization'] = 'Basic {}'.format(self.get_auth_string())
return headers | [
"Add",
"authorization",
"header",
"."
] | cgoldberg/sauceclient | python | https://github.com/cgoldberg/sauceclient/blob/aa27b7da8eb2e483adc2754c694fe5082e1fa8f7/sauceclient.py#L70-L74 | [
"def",
"make_auth_headers",
"(",
"self",
",",
"content_type",
")",
":",
"headers",
"=",
"self",
".",
"make_headers",
"(",
"content_type",
")",
"headers",
"[",
"'Authorization'",
"]",
"=",
"'Basic {}'",
".",
"format",
"(",
"self",
".",
"get_auth_string",
"(",
... | aa27b7da8eb2e483adc2754c694fe5082e1fa8f7 |
train | SauceClient.request | Send http request. | sauceclient.py | def request(self, method, url, body=None, content_type='application/json'):
"""Send http request."""
headers = self.make_auth_headers(content_type)
connection = http_client.HTTPSConnection(self.apibase)
connection.request(method, url, body, headers=headers)
response = connection.... | def request(self, method, url, body=None, content_type='application/json'):
"""Send http request."""
headers = self.make_auth_headers(content_type)
connection = http_client.HTTPSConnection(self.apibase)
connection.request(method, url, body, headers=headers)
response = connection.... | [
"Send",
"http",
"request",
"."
] | cgoldberg/sauceclient | python | https://github.com/cgoldberg/sauceclient/blob/aa27b7da8eb2e483adc2754c694fe5082e1fa8f7/sauceclient.py#L76-L87 | [
"def",
"request",
"(",
"self",
",",
"method",
",",
"url",
",",
"body",
"=",
"None",
",",
"content_type",
"=",
"'application/json'",
")",
":",
"headers",
"=",
"self",
".",
"make_auth_headers",
"(",
"content_type",
")",
"connection",
"=",
"http_client",
".",
... | aa27b7da8eb2e483adc2754c694fe5082e1fa8f7 |
train | Account.get_user | Access basic account information. | sauceclient.py | def get_user(self):
"""Access basic account information."""
method = 'GET'
endpoint = '/rest/v1/users/{}'.format(self.client.sauce_username)
return self.client.request(method, endpoint) | def get_user(self):
"""Access basic account information."""
method = 'GET'
endpoint = '/rest/v1/users/{}'.format(self.client.sauce_username)
return self.client.request(method, endpoint) | [
"Access",
"basic",
"account",
"information",
"."
] | cgoldberg/sauceclient | python | https://github.com/cgoldberg/sauceclient/blob/aa27b7da8eb2e483adc2754c694fe5082e1fa8f7/sauceclient.py#L100-L104 | [
"def",
"get_user",
"(",
"self",
")",
":",
"method",
"=",
"'GET'",
"endpoint",
"=",
"'/rest/v1/users/{}'",
".",
"format",
"(",
"self",
".",
"client",
".",
"sauce_username",
")",
"return",
"self",
".",
"client",
".",
"request",
"(",
"method",
",",
"endpoint"... | aa27b7da8eb2e483adc2754c694fe5082e1fa8f7 |
train | Account.create_user | Create a sub account. | sauceclient.py | def create_user(self, username, password, name, email):
"""Create a sub account."""
method = 'POST'
endpoint = '/rest/v1/users/{}'.format(self.client.sauce_username)
body = json.dumps({'username': username, 'password': password,
'name': name, 'email': email, })... | def create_user(self, username, password, name, email):
"""Create a sub account."""
method = 'POST'
endpoint = '/rest/v1/users/{}'.format(self.client.sauce_username)
body = json.dumps({'username': username, 'password': password,
'name': name, 'email': email, })... | [
"Create",
"a",
"sub",
"account",
"."
] | cgoldberg/sauceclient | python | https://github.com/cgoldberg/sauceclient/blob/aa27b7da8eb2e483adc2754c694fe5082e1fa8f7/sauceclient.py#L106-L112 | [
"def",
"create_user",
"(",
"self",
",",
"username",
",",
"password",
",",
"name",
",",
"email",
")",
":",
"method",
"=",
"'POST'",
"endpoint",
"=",
"'/rest/v1/users/{}'",
".",
"format",
"(",
"self",
".",
"client",
".",
"sauce_username",
")",
"body",
"=",
... | aa27b7da8eb2e483adc2754c694fe5082e1fa8f7 |
train | Account.get_concurrency | Check account concurrency limits. | sauceclient.py | def get_concurrency(self):
"""Check account concurrency limits."""
method = 'GET'
endpoint = '/rest/v1.1/users/{}/concurrency'.format(
self.client.sauce_username)
return self.client.request(method, endpoint) | def get_concurrency(self):
"""Check account concurrency limits."""
method = 'GET'
endpoint = '/rest/v1.1/users/{}/concurrency'.format(
self.client.sauce_username)
return self.client.request(method, endpoint) | [
"Check",
"account",
"concurrency",
"limits",
"."
] | cgoldberg/sauceclient | python | https://github.com/cgoldberg/sauceclient/blob/aa27b7da8eb2e483adc2754c694fe5082e1fa8f7/sauceclient.py#L114-L119 | [
"def",
"get_concurrency",
"(",
"self",
")",
":",
"method",
"=",
"'GET'",
"endpoint",
"=",
"'/rest/v1.1/users/{}/concurrency'",
".",
"format",
"(",
"self",
".",
"client",
".",
"sauce_username",
")",
"return",
"self",
".",
"client",
".",
"request",
"(",
"method"... | aa27b7da8eb2e483adc2754c694fe5082e1fa8f7 |
train | Account.get_subaccounts | Get a list of sub accounts associated with a parent account. | sauceclient.py | def get_subaccounts(self):
"""Get a list of sub accounts associated with a parent account."""
method = 'GET'
endpoint = '/rest/v1/users/{}/list-subaccounts'.format(
self.client.sauce_username)
return self.client.request(method, endpoint) | def get_subaccounts(self):
"""Get a list of sub accounts associated with a parent account."""
method = 'GET'
endpoint = '/rest/v1/users/{}/list-subaccounts'.format(
self.client.sauce_username)
return self.client.request(method, endpoint) | [
"Get",
"a",
"list",
"of",
"sub",
"accounts",
"associated",
"with",
"a",
"parent",
"account",
"."
] | cgoldberg/sauceclient | python | https://github.com/cgoldberg/sauceclient/blob/aa27b7da8eb2e483adc2754c694fe5082e1fa8f7/sauceclient.py#L121-L126 | [
"def",
"get_subaccounts",
"(",
"self",
")",
":",
"method",
"=",
"'GET'",
"endpoint",
"=",
"'/rest/v1/users/{}/list-subaccounts'",
".",
"format",
"(",
"self",
".",
"client",
".",
"sauce_username",
")",
"return",
"self",
".",
"client",
".",
"request",
"(",
"meth... | aa27b7da8eb2e483adc2754c694fe5082e1fa8f7 |
train | Account.get_siblings | Get a list of sibling accounts associated with provided account. | sauceclient.py | def get_siblings(self):
"""Get a list of sibling accounts associated with provided account."""
method = 'GET'
endpoint = '/rest/v1.1/users/{}/siblings'.format(
self.client.sauce_username)
return self.client.request(method, endpoint) | def get_siblings(self):
"""Get a list of sibling accounts associated with provided account."""
method = 'GET'
endpoint = '/rest/v1.1/users/{}/siblings'.format(
self.client.sauce_username)
return self.client.request(method, endpoint) | [
"Get",
"a",
"list",
"of",
"sibling",
"accounts",
"associated",
"with",
"provided",
"account",
"."
] | cgoldberg/sauceclient | python | https://github.com/cgoldberg/sauceclient/blob/aa27b7da8eb2e483adc2754c694fe5082e1fa8f7/sauceclient.py#L128-L133 | [
"def",
"get_siblings",
"(",
"self",
")",
":",
"method",
"=",
"'GET'",
"endpoint",
"=",
"'/rest/v1.1/users/{}/siblings'",
".",
"format",
"(",
"self",
".",
"client",
".",
"sauce_username",
")",
"return",
"self",
".",
"client",
".",
"request",
"(",
"method",
",... | aa27b7da8eb2e483adc2754c694fe5082e1fa8f7 |
train | Account.get_subaccount_info | Get information about a sub account. | sauceclient.py | def get_subaccount_info(self):
"""Get information about a sub account."""
method = 'GET'
endpoint = '/rest/v1/users/{}/subaccounts'.format(
self.client.sauce_username)
return self.client.request(method, endpoint) | def get_subaccount_info(self):
"""Get information about a sub account."""
method = 'GET'
endpoint = '/rest/v1/users/{}/subaccounts'.format(
self.client.sauce_username)
return self.client.request(method, endpoint) | [
"Get",
"information",
"about",
"a",
"sub",
"account",
"."
] | cgoldberg/sauceclient | python | https://github.com/cgoldberg/sauceclient/blob/aa27b7da8eb2e483adc2754c694fe5082e1fa8f7/sauceclient.py#L135-L140 | [
"def",
"get_subaccount_info",
"(",
"self",
")",
":",
"method",
"=",
"'GET'",
"endpoint",
"=",
"'/rest/v1/users/{}/subaccounts'",
".",
"format",
"(",
"self",
".",
"client",
".",
"sauce_username",
")",
"return",
"self",
".",
"client",
".",
"request",
"(",
"metho... | aa27b7da8eb2e483adc2754c694fe5082e1fa8f7 |
train | Account.change_access_key | Change access key of your account. | sauceclient.py | def change_access_key(self):
"""Change access key of your account."""
method = 'POST'
endpoint = '/rest/v1/users/{}/accesskey/change'.format(
self.client.sauce_username)
return self.client.request(method, endpoint) | def change_access_key(self):
"""Change access key of your account."""
method = 'POST'
endpoint = '/rest/v1/users/{}/accesskey/change'.format(
self.client.sauce_username)
return self.client.request(method, endpoint) | [
"Change",
"access",
"key",
"of",
"your",
"account",
"."
] | cgoldberg/sauceclient | python | https://github.com/cgoldberg/sauceclient/blob/aa27b7da8eb2e483adc2754c694fe5082e1fa8f7/sauceclient.py#L142-L147 | [
"def",
"change_access_key",
"(",
"self",
")",
":",
"method",
"=",
"'POST'",
"endpoint",
"=",
"'/rest/v1/users/{}/accesskey/change'",
".",
"format",
"(",
"self",
".",
"client",
".",
"sauce_username",
")",
"return",
"self",
".",
"client",
".",
"request",
"(",
"m... | aa27b7da8eb2e483adc2754c694fe5082e1fa8f7 |
train | Account.get_activity | Check account concurrency limits. | sauceclient.py | def get_activity(self):
"""Check account concurrency limits."""
method = 'GET'
endpoint = '/rest/v1/{}/activity'.format(self.client.sauce_username)
return self.client.request(method, endpoint) | def get_activity(self):
"""Check account concurrency limits."""
method = 'GET'
endpoint = '/rest/v1/{}/activity'.format(self.client.sauce_username)
return self.client.request(method, endpoint) | [
"Check",
"account",
"concurrency",
"limits",
"."
] | cgoldberg/sauceclient | python | https://github.com/cgoldberg/sauceclient/blob/aa27b7da8eb2e483adc2754c694fe5082e1fa8f7/sauceclient.py#L149-L153 | [
"def",
"get_activity",
"(",
"self",
")",
":",
"method",
"=",
"'GET'",
"endpoint",
"=",
"'/rest/v1/{}/activity'",
".",
"format",
"(",
"self",
".",
"client",
".",
"sauce_username",
")",
"return",
"self",
".",
"client",
".",
"request",
"(",
"method",
",",
"en... | aa27b7da8eb2e483adc2754c694fe5082e1fa8f7 |
train | Account.get_usage | Access historical account usage data. | sauceclient.py | def get_usage(self, start=None, end=None):
"""Access historical account usage data."""
method = 'GET'
endpoint = '/rest/v1/users/{}/usage'.format(self.client.sauce_username)
data = {}
if start:
data['start'] = start
if end:
data['end'] = end
... | def get_usage(self, start=None, end=None):
"""Access historical account usage data."""
method = 'GET'
endpoint = '/rest/v1/users/{}/usage'.format(self.client.sauce_username)
data = {}
if start:
data['start'] = start
if end:
data['end'] = end
... | [
"Access",
"historical",
"account",
"usage",
"data",
"."
] | cgoldberg/sauceclient | python | https://github.com/cgoldberg/sauceclient/blob/aa27b7da8eb2e483adc2754c694fe5082e1fa8f7/sauceclient.py#L155-L166 | [
"def",
"get_usage",
"(",
"self",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
")",
":",
"method",
"=",
"'GET'",
"endpoint",
"=",
"'/rest/v1/users/{}/usage'",
".",
"format",
"(",
"self",
".",
"client",
".",
"sauce_username",
")",
"data",
"=",
"{",
... | aa27b7da8eb2e483adc2754c694fe5082e1fa8f7 |
train | Information.get_platforms | Get a list of objects describing all the OS and browser platforms
currently supported on Sauce Labs. | sauceclient.py | def get_platforms(self, automation_api='all'):
"""Get a list of objects describing all the OS and browser platforms
currently supported on Sauce Labs."""
method = 'GET'
endpoint = '/rest/v1/info/platforms/{}'.format(automation_api)
return self.client.request(method, endpoint) | def get_platforms(self, automation_api='all'):
"""Get a list of objects describing all the OS and browser platforms
currently supported on Sauce Labs."""
method = 'GET'
endpoint = '/rest/v1/info/platforms/{}'.format(automation_api)
return self.client.request(method, endpoint) | [
"Get",
"a",
"list",
"of",
"objects",
"describing",
"all",
"the",
"OS",
"and",
"browser",
"platforms",
"currently",
"supported",
"on",
"Sauce",
"Labs",
"."
] | cgoldberg/sauceclient | python | https://github.com/cgoldberg/sauceclient/blob/aa27b7da8eb2e483adc2754c694fe5082e1fa8f7/sauceclient.py#L351-L356 | [
"def",
"get_platforms",
"(",
"self",
",",
"automation_api",
"=",
"'all'",
")",
":",
"method",
"=",
"'GET'",
"endpoint",
"=",
"'/rest/v1/info/platforms/{}'",
".",
"format",
"(",
"automation_api",
")",
"return",
"self",
".",
"client",
".",
"request",
"(",
"metho... | aa27b7da8eb2e483adc2754c694fe5082e1fa8f7 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.