repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
hubo1016/vlcp | vlcp/server/module.py | ModuleAPIHandler.unregisterAPI | def unregisterAPI(self, name):
"""
Remove an API from this handler
"""
if name.startswith('public/'):
target = 'public'
name = name[len('public/'):]
else:
target = self.servicename
name = name
removes = [m for m in self.hand... | python | def unregisterAPI(self, name):
"""
Remove an API from this handler
"""
if name.startswith('public/'):
target = 'public'
name = name[len('public/'):]
else:
target = self.servicename
name = name
removes = [m for m in self.hand... | [
"def",
"unregisterAPI",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
".",
"startswith",
"(",
"'public/'",
")",
":",
"target",
"=",
"'public'",
"name",
"=",
"name",
"[",
"len",
"(",
"'public/'",
")",
":",
"]",
"else",
":",
"target",
"=",
"self",
... | Remove an API from this handler | [
"Remove",
"an",
"API",
"from",
"this",
"handler"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/server/module.py#L229-L241 |
hubo1016/vlcp | vlcp/server/module.py | ModuleAPIHandler.discover | def discover(self, details = False):
'Discover API definitions. Set details=true to show details'
if details and not (isinstance(details, str) and details.lower() == 'false'):
return copy.deepcopy(self.discoverinfo)
else:
return dict((k,v.get('description', '')) for k,v i... | python | def discover(self, details = False):
'Discover API definitions. Set details=true to show details'
if details and not (isinstance(details, str) and details.lower() == 'false'):
return copy.deepcopy(self.discoverinfo)
else:
return dict((k,v.get('description', '')) for k,v i... | [
"def",
"discover",
"(",
"self",
",",
"details",
"=",
"False",
")",
":",
"if",
"details",
"and",
"not",
"(",
"isinstance",
"(",
"details",
",",
"str",
")",
"and",
"details",
".",
"lower",
"(",
")",
"==",
"'false'",
")",
":",
"return",
"copy",
".",
"... | Discover API definitions. Set details=true to show details | [
"Discover",
"API",
"definitions",
".",
"Set",
"details",
"=",
"true",
"to",
"show",
"details"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/server/module.py#L242-L247 |
hubo1016/vlcp | vlcp/server/module.py | ModuleLoader.loadmodule | async def loadmodule(self, module):
'''
Load a module class
'''
self._logger.debug('Try to load module %r', module)
if hasattr(module, '_instance'):
self._logger.debug('Module is already initialized, module state is: %r', module._instance.state)
if module.... | python | async def loadmodule(self, module):
'''
Load a module class
'''
self._logger.debug('Try to load module %r', module)
if hasattr(module, '_instance'):
self._logger.debug('Module is already initialized, module state is: %r', module._instance.state)
if module.... | [
"async",
"def",
"loadmodule",
"(",
"self",
",",
"module",
")",
":",
"self",
".",
"_logger",
".",
"debug",
"(",
"'Try to load module %r'",
",",
"module",
")",
"if",
"hasattr",
"(",
"module",
",",
"'_instance'",
")",
":",
"self",
".",
"_logger",
".",
"debu... | Load a module class | [
"Load",
"a",
"module",
"class"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/server/module.py#L502-L577 |
hubo1016/vlcp | vlcp/server/module.py | ModuleLoader.unloadmodule | async def unloadmodule(self, module, ignoreDependencies = False):
'''
Unload a module class
'''
self._logger.debug('Try to unload module %r', module)
if hasattr(module, '_instance'):
self._logger.debug('Module %r is loaded, module state is %r', module, module._instanc... | python | async def unloadmodule(self, module, ignoreDependencies = False):
'''
Unload a module class
'''
self._logger.debug('Try to unload module %r', module)
if hasattr(module, '_instance'):
self._logger.debug('Module %r is loaded, module state is %r', module, module._instanc... | [
"async",
"def",
"unloadmodule",
"(",
"self",
",",
"module",
",",
"ignoreDependencies",
"=",
"False",
")",
":",
"self",
".",
"_logger",
".",
"debug",
"(",
"'Try to unload module %r'",
",",
"module",
")",
"if",
"hasattr",
"(",
"module",
",",
"'_instance'",
")"... | Unload a module class | [
"Unload",
"a",
"module",
"class"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/server/module.py#L578-L613 |
hubo1016/vlcp | vlcp/server/module.py | ModuleLoader.load_by_path | async def load_by_path(self, path):
"""
Load a module by full path. If there are dependencies, they are also loaded.
"""
try:
p, module = findModule(path, True)
except KeyError as exc:
raise ModuleLoadException('Cannot load module ' + repr(path) + ': ' + s... | python | async def load_by_path(self, path):
"""
Load a module by full path. If there are dependencies, they are also loaded.
"""
try:
p, module = findModule(path, True)
except KeyError as exc:
raise ModuleLoadException('Cannot load module ' + repr(path) + ': ' + s... | [
"async",
"def",
"load_by_path",
"(",
"self",
",",
"path",
")",
":",
"try",
":",
"p",
",",
"module",
"=",
"findModule",
"(",
"path",
",",
"True",
")",
"except",
"KeyError",
"as",
"exc",
":",
"raise",
"ModuleLoadException",
"(",
"'Cannot load module '",
"+",... | Load a module by full path. If there are dependencies, they are also loaded. | [
"Load",
"a",
"module",
"by",
"full",
"path",
".",
"If",
"there",
"are",
"dependencies",
"they",
"are",
"also",
"loaded",
"."
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/server/module.py#L614-L626 |
hubo1016/vlcp | vlcp/server/module.py | ModuleLoader.unload_by_path | async def unload_by_path(self, path):
"""
Unload a module by full path. Dependencies are automatically unloaded if they are marked to be
services.
"""
p, module = findModule(path, False)
if module is None:
raise ModuleLoadException('Cannot find module: ' + rep... | python | async def unload_by_path(self, path):
"""
Unload a module by full path. Dependencies are automatically unloaded if they are marked to be
services.
"""
p, module = findModule(path, False)
if module is None:
raise ModuleLoadException('Cannot find module: ' + rep... | [
"async",
"def",
"unload_by_path",
"(",
"self",
",",
"path",
")",
":",
"p",
",",
"module",
"=",
"findModule",
"(",
"path",
",",
"False",
")",
"if",
"module",
"is",
"None",
":",
"raise",
"ModuleLoadException",
"(",
"'Cannot find module: '",
"+",
"repr",
"(",... | Unload a module by full path. Dependencies are automatically unloaded if they are marked to be
services. | [
"Unload",
"a",
"module",
"by",
"full",
"path",
".",
"Dependencies",
"are",
"automatically",
"unloaded",
"if",
"they",
"are",
"marked",
"to",
"be",
"services",
"."
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/server/module.py#L630-L638 |
hubo1016/vlcp | vlcp/server/module.py | ModuleLoader.reload_modules | async def reload_modules(self, pathlist):
"""
Reload modules with a full path in the pathlist
"""
loadedModules = []
failures = []
for path in pathlist:
p, module = findModule(path, False)
if module is not None and hasattr(module, '_instance') and ... | python | async def reload_modules(self, pathlist):
"""
Reload modules with a full path in the pathlist
"""
loadedModules = []
failures = []
for path in pathlist:
p, module = findModule(path, False)
if module is not None and hasattr(module, '_instance') and ... | [
"async",
"def",
"reload_modules",
"(",
"self",
",",
"pathlist",
")",
":",
"loadedModules",
"=",
"[",
"]",
"failures",
"=",
"[",
"]",
"for",
"path",
"in",
"pathlist",
":",
"p",
",",
"module",
"=",
"findModule",
"(",
"path",
",",
"False",
")",
"if",
"m... | Reload modules with a full path in the pathlist | [
"Reload",
"modules",
"with",
"a",
"full",
"path",
"in",
"the",
"pathlist"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/server/module.py#L642-L723 |
hubo1016/vlcp | vlcp/server/module.py | ModuleLoader.get_module_by_name | def get_module_by_name(self, targetname):
"""
Return the module instance for a target name.
"""
if targetname == 'public':
target = None
elif not targetname not in self.activeModules:
raise KeyError('Module %r not exists or is not loaded' % (targetname,))
... | python | def get_module_by_name(self, targetname):
"""
Return the module instance for a target name.
"""
if targetname == 'public':
target = None
elif not targetname not in self.activeModules:
raise KeyError('Module %r not exists or is not loaded' % (targetname,))
... | [
"def",
"get_module_by_name",
"(",
"self",
",",
"targetname",
")",
":",
"if",
"targetname",
"==",
"'public'",
":",
"target",
"=",
"None",
"elif",
"not",
"targetname",
"not",
"in",
"self",
".",
"activeModules",
":",
"raise",
"KeyError",
"(",
"'Module %r not exis... | Return the module instance for a target name. | [
"Return",
"the",
"module",
"instance",
"for",
"a",
"target",
"name",
"."
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/server/module.py#L727-L737 |
hubo1016/vlcp | vlcp/config/config.py | configbase | def configbase(key):
"""
Decorator to set this class to configuration base class. A configuration base class
uses `<parentbase>.key.` for its configuration base, and uses `<parentbase>.key.default` for configuration mapping.
"""
def decorator(cls):
parent = cls.getConfigurableParent()
... | python | def configbase(key):
"""
Decorator to set this class to configuration base class. A configuration base class
uses `<parentbase>.key.` for its configuration base, and uses `<parentbase>.key.default` for configuration mapping.
"""
def decorator(cls):
parent = cls.getConfigurableParent()
... | [
"def",
"configbase",
"(",
"key",
")",
":",
"def",
"decorator",
"(",
"cls",
")",
":",
"parent",
"=",
"cls",
".",
"getConfigurableParent",
"(",
")",
"if",
"parent",
"is",
"None",
":",
"parentbase",
"=",
"None",
"else",
":",
"parentbase",
"=",
"getattr",
... | Decorator to set this class to configuration base class. A configuration base class
uses `<parentbase>.key.` for its configuration base, and uses `<parentbase>.key.default` for configuration mapping. | [
"Decorator",
"to",
"set",
"this",
"class",
"to",
"configuration",
"base",
"class",
".",
"A",
"configuration",
"base",
"class",
"uses",
"<parentbase",
">",
".",
"key",
".",
"for",
"its",
"configuration",
"base",
"and",
"uses",
"<parentbase",
">",
".",
"key",
... | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/config/config.py#L391-L409 |
hubo1016/vlcp | vlcp/config/config.py | config | def config(key):
"""
Decorator to map this class directly to a configuration node. It uses `<parentbase>.key` for configuration
base and configuration mapping.
"""
def decorator(cls):
parent = cls.getConfigurableParent()
if parent is None:
parentbase = None
else:
... | python | def config(key):
"""
Decorator to map this class directly to a configuration node. It uses `<parentbase>.key` for configuration
base and configuration mapping.
"""
def decorator(cls):
parent = cls.getConfigurableParent()
if parent is None:
parentbase = None
else:
... | [
"def",
"config",
"(",
"key",
")",
":",
"def",
"decorator",
"(",
"cls",
")",
":",
"parent",
"=",
"cls",
".",
"getConfigurableParent",
"(",
")",
"if",
"parent",
"is",
"None",
":",
"parentbase",
"=",
"None",
"else",
":",
"parentbase",
"=",
"getattr",
"(",... | Decorator to map this class directly to a configuration node. It uses `<parentbase>.key` for configuration
base and configuration mapping. | [
"Decorator",
"to",
"map",
"this",
"class",
"directly",
"to",
"a",
"configuration",
"node",
".",
"It",
"uses",
"<parentbase",
">",
".",
"key",
"for",
"configuration",
"base",
"and",
"configuration",
"mapping",
"."
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/config/config.py#L411-L427 |
hubo1016/vlcp | vlcp/config/config.py | defaultconfig | def defaultconfig(cls):
"""
Generate a default configuration mapping bases on the class name. If this class does not have a
parent with `configbase` defined, it is set to a configuration base with
`configbase=<lowercase-name>` and `configkey=<lowercase-name>.default`; otherwise it inherits
`configba... | python | def defaultconfig(cls):
"""
Generate a default configuration mapping bases on the class name. If this class does not have a
parent with `configbase` defined, it is set to a configuration base with
`configbase=<lowercase-name>` and `configkey=<lowercase-name>.default`; otherwise it inherits
`configba... | [
"def",
"defaultconfig",
"(",
"cls",
")",
":",
"parentbase",
"=",
"None",
"for",
"p",
"in",
"cls",
".",
"__bases__",
":",
"if",
"issubclass",
"(",
"p",
",",
"Configurable",
")",
":",
"parentbase",
"=",
"getattr",
"(",
"p",
",",
"'configbase'",
",",
"Non... | Generate a default configuration mapping bases on the class name. If this class does not have a
parent with `configbase` defined, it is set to a configuration base with
`configbase=<lowercase-name>` and `configkey=<lowercase-name>.default`; otherwise it inherits
`configbase` of its parent and set `configkey... | [
"Generate",
"a",
"default",
"configuration",
"mapping",
"bases",
"on",
"the",
"class",
"name",
".",
"If",
"this",
"class",
"does",
"not",
"have",
"a",
"parent",
"with",
"configbase",
"defined",
"it",
"is",
"set",
"to",
"a",
"configuration",
"base",
"with",
... | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/config/config.py#L429-L458 |
hubo1016/vlcp | vlcp/config/config.py | ConfigTree.config_keys | def config_keys(self, sortkey = False):
"""
Return all configuration keys in this node, including configurations on children nodes.
"""
if sortkey:
items = sorted(self.items())
else:
items = self.items()
for k,v in items:
if isinstance(... | python | def config_keys(self, sortkey = False):
"""
Return all configuration keys in this node, including configurations on children nodes.
"""
if sortkey:
items = sorted(self.items())
else:
items = self.items()
for k,v in items:
if isinstance(... | [
"def",
"config_keys",
"(",
"self",
",",
"sortkey",
"=",
"False",
")",
":",
"if",
"sortkey",
":",
"items",
"=",
"sorted",
"(",
"self",
".",
"items",
"(",
")",
")",
"else",
":",
"items",
"=",
"self",
".",
"items",
"(",
")",
"for",
"k",
",",
"v",
... | Return all configuration keys in this node, including configurations on children nodes. | [
"Return",
"all",
"configuration",
"keys",
"in",
"this",
"node",
"including",
"configurations",
"on",
"children",
"nodes",
"."
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/config/config.py#L36-L49 |
hubo1016/vlcp | vlcp/config/config.py | ConfigTree.config_items | def config_items(self, sortkey = False):
"""
Return all `(key, value)` tuples for configurations in this node, including configurations on children nodes.
"""
if sortkey:
items = sorted(self.items())
else:
items = self.items()
for k,v in items:
... | python | def config_items(self, sortkey = False):
"""
Return all `(key, value)` tuples for configurations in this node, including configurations on children nodes.
"""
if sortkey:
items = sorted(self.items())
else:
items = self.items()
for k,v in items:
... | [
"def",
"config_items",
"(",
"self",
",",
"sortkey",
"=",
"False",
")",
":",
"if",
"sortkey",
":",
"items",
"=",
"sorted",
"(",
"self",
".",
"items",
"(",
")",
")",
"else",
":",
"items",
"=",
"self",
".",
"items",
"(",
")",
"for",
"k",
",",
"v",
... | Return all `(key, value)` tuples for configurations in this node, including configurations on children nodes. | [
"Return",
"all",
"(",
"key",
"value",
")",
"tuples",
"for",
"configurations",
"in",
"this",
"node",
"including",
"configurations",
"on",
"children",
"nodes",
"."
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/config/config.py#L50-L63 |
hubo1016/vlcp | vlcp/config/config.py | ConfigTree.config_value_keys | def config_value_keys(self, sortkey = False):
"""
Return configuration keys directly stored in this node. Configurations in child nodes are not included.
"""
if sortkey:
items = sorted(self.items())
else:
items = self.items()
return (k for k,v in i... | python | def config_value_keys(self, sortkey = False):
"""
Return configuration keys directly stored in this node. Configurations in child nodes are not included.
"""
if sortkey:
items = sorted(self.items())
else:
items = self.items()
return (k for k,v in i... | [
"def",
"config_value_keys",
"(",
"self",
",",
"sortkey",
"=",
"False",
")",
":",
"if",
"sortkey",
":",
"items",
"=",
"sorted",
"(",
"self",
".",
"items",
"(",
")",
")",
"else",
":",
"items",
"=",
"self",
".",
"items",
"(",
")",
"return",
"(",
"k",
... | Return configuration keys directly stored in this node. Configurations in child nodes are not included. | [
"Return",
"configuration",
"keys",
"directly",
"stored",
"in",
"this",
"node",
".",
"Configurations",
"in",
"child",
"nodes",
"are",
"not",
"included",
"."
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/config/config.py#L64-L72 |
hubo1016/vlcp | vlcp/config/config.py | ConfigTree.loadconfig | def loadconfig(self, keysuffix, obj):
"""
Copy all configurations from this node into obj
"""
subtree = self.get(keysuffix)
if subtree is not None and isinstance(subtree, ConfigTree):
for k,v in subtree.items():
if isinstance(v, ConfigTree):
... | python | def loadconfig(self, keysuffix, obj):
"""
Copy all configurations from this node into obj
"""
subtree = self.get(keysuffix)
if subtree is not None and isinstance(subtree, ConfigTree):
for k,v in subtree.items():
if isinstance(v, ConfigTree):
... | [
"def",
"loadconfig",
"(",
"self",
",",
"keysuffix",
",",
"obj",
")",
":",
"subtree",
"=",
"self",
".",
"get",
"(",
"keysuffix",
")",
"if",
"subtree",
"is",
"not",
"None",
"and",
"isinstance",
"(",
"subtree",
",",
"ConfigTree",
")",
":",
"for",
"k",
"... | Copy all configurations from this node into obj | [
"Copy",
"all",
"configurations",
"from",
"this",
"node",
"into",
"obj"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/config/config.py#L82-L95 |
hubo1016/vlcp | vlcp/config/config.py | ConfigTree.withconfig | def withconfig(self, keysuffix):
"""
Load configurations with this decorator
"""
def decorator(cls):
return self.loadconfig(keysuffix, cls)
return decorator | python | def withconfig(self, keysuffix):
"""
Load configurations with this decorator
"""
def decorator(cls):
return self.loadconfig(keysuffix, cls)
return decorator | [
"def",
"withconfig",
"(",
"self",
",",
"keysuffix",
")",
":",
"def",
"decorator",
"(",
"cls",
")",
":",
"return",
"self",
".",
"loadconfig",
"(",
"keysuffix",
",",
"cls",
")",
"return",
"decorator"
] | Load configurations with this decorator | [
"Load",
"configurations",
"with",
"this",
"decorator"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/config/config.py#L96-L102 |
hubo1016/vlcp | vlcp/config/config.py | ConfigTree.gettree | def gettree(self, key, create = False):
"""
Get a subtree node from the key (path relative to this node)
"""
tree, _ = self._getsubitem(key + '.tmp', create)
return tree | python | def gettree(self, key, create = False):
"""
Get a subtree node from the key (path relative to this node)
"""
tree, _ = self._getsubitem(key + '.tmp', create)
return tree | [
"def",
"gettree",
"(",
"self",
",",
"key",
",",
"create",
"=",
"False",
")",
":",
"tree",
",",
"_",
"=",
"self",
".",
"_getsubitem",
"(",
"key",
"+",
"'.tmp'",
",",
"create",
")",
"return",
"tree"
] | Get a subtree node from the key (path relative to this node) | [
"Get",
"a",
"subtree",
"node",
"from",
"the",
"key",
"(",
"path",
"relative",
"to",
"this",
"node",
")"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/config/config.py#L108-L113 |
hubo1016/vlcp | vlcp/config/config.py | ConfigTree.get | def get(self, key, defaultvalue = None):
"""
Support dict-like get (return a default value if not found)
"""
(t, k) = self._getsubitem(key, False)
if t is None:
return defaultvalue
else:
return t.__dict__.get(k, defaultvalue) | python | def get(self, key, defaultvalue = None):
"""
Support dict-like get (return a default value if not found)
"""
(t, k) = self._getsubitem(key, False)
if t is None:
return defaultvalue
else:
return t.__dict__.get(k, defaultvalue) | [
"def",
"get",
"(",
"self",
",",
"key",
",",
"defaultvalue",
"=",
"None",
")",
":",
"(",
"t",
",",
"k",
")",
"=",
"self",
".",
"_getsubitem",
"(",
"key",
",",
"False",
")",
"if",
"t",
"is",
"None",
":",
"return",
"defaultvalue",
"else",
":",
"retu... | Support dict-like get (return a default value if not found) | [
"Support",
"dict",
"-",
"like",
"get",
"(",
"return",
"a",
"default",
"value",
"if",
"not",
"found",
")"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/config/config.py#L163-L171 |
hubo1016/vlcp | vlcp/config/config.py | ConfigTree.setdefault | def setdefault(self, key, defaultvalue = None):
"""
Support dict-like setdefault (create if not existed)
"""
(t, k) = self._getsubitem(key, True)
return t.__dict__.setdefault(k, defaultvalue) | python | def setdefault(self, key, defaultvalue = None):
"""
Support dict-like setdefault (create if not existed)
"""
(t, k) = self._getsubitem(key, True)
return t.__dict__.setdefault(k, defaultvalue) | [
"def",
"setdefault",
"(",
"self",
",",
"key",
",",
"defaultvalue",
"=",
"None",
")",
":",
"(",
"t",
",",
"k",
")",
"=",
"self",
".",
"_getsubitem",
"(",
"key",
",",
"True",
")",
"return",
"t",
".",
"__dict__",
".",
"setdefault",
"(",
"k",
",",
"d... | Support dict-like setdefault (create if not existed) | [
"Support",
"dict",
"-",
"like",
"setdefault",
"(",
"create",
"if",
"not",
"existed",
")"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/config/config.py#L172-L177 |
hubo1016/vlcp | vlcp/config/config.py | ConfigTree.todict | def todict(self):
"""
Convert this node to a dictionary tree.
"""
dict_entry = []
for k,v in self.items():
if isinstance(v, ConfigTree):
dict_entry.append((k, v.todict()))
else:
dict_entry.append((k, v))
return dict(... | python | def todict(self):
"""
Convert this node to a dictionary tree.
"""
dict_entry = []
for k,v in self.items():
if isinstance(v, ConfigTree):
dict_entry.append((k, v.todict()))
else:
dict_entry.append((k, v))
return dict(... | [
"def",
"todict",
"(",
"self",
")",
":",
"dict_entry",
"=",
"[",
"]",
"for",
"k",
",",
"v",
"in",
"self",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"v",
",",
"ConfigTree",
")",
":",
"dict_entry",
".",
"append",
"(",
"(",
"k",
",",
"v... | Convert this node to a dictionary tree. | [
"Convert",
"this",
"node",
"to",
"a",
"dictionary",
"tree",
"."
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/config/config.py#L192-L202 |
hubo1016/vlcp | vlcp/config/config.py | Manager.loadfromfile | def loadfromfile(self, filelike):
"""
Read configurations from a file-like object, or a sequence of strings. Old values are not
cleared, if you want to reload the configurations completely, you should call `clear()`
before using `load*` methods.
"""
line_format = re.compi... | python | def loadfromfile(self, filelike):
"""
Read configurations from a file-like object, or a sequence of strings. Old values are not
cleared, if you want to reload the configurations completely, you should call `clear()`
before using `load*` methods.
"""
line_format = re.compi... | [
"def",
"loadfromfile",
"(",
"self",
",",
"filelike",
")",
":",
"line_format",
"=",
"re",
".",
"compile",
"(",
"r'((?:[a-zA-Z][a-zA-Z0-9_]*\\.)*[a-zA-Z][a-zA-Z0-9_]*)\\s*=\\s*'",
")",
"space",
"=",
"re",
".",
"compile",
"(",
"r'\\s'",
")",
"line_no",
"=",
"0",
"#... | Read configurations from a file-like object, or a sequence of strings. Old values are not
cleared, if you want to reload the configurations completely, you should call `clear()`
before using `load*` methods. | [
"Read",
"configurations",
"from",
"a",
"file",
"-",
"like",
"object",
"or",
"a",
"sequence",
"of",
"strings",
".",
"Old",
"values",
"are",
"not",
"cleared",
"if",
"you",
"want",
"to",
"reload",
"the",
"configurations",
"completely",
"you",
"should",
"call",
... | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/config/config.py#L210-L259 |
hubo1016/vlcp | vlcp/config/config.py | Manager.save | def save(self, sortkey = True):
"""
Save configurations to a list of strings
"""
return [k + '=' + repr(v) for k,v in self.config_items(sortkey)] | python | def save(self, sortkey = True):
"""
Save configurations to a list of strings
"""
return [k + '=' + repr(v) for k,v in self.config_items(sortkey)] | [
"def",
"save",
"(",
"self",
",",
"sortkey",
"=",
"True",
")",
":",
"return",
"[",
"k",
"+",
"'='",
"+",
"repr",
"(",
"v",
")",
"for",
"k",
",",
"v",
"in",
"self",
".",
"config_items",
"(",
"sortkey",
")",
"]"
] | Save configurations to a list of strings | [
"Save",
"configurations",
"to",
"a",
"list",
"of",
"strings"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/config/config.py#L271-L275 |
hubo1016/vlcp | vlcp/config/config.py | Manager.savetostr | def savetostr(self, sortkey = True):
"""
Save configurations to a single string
"""
return ''.join(k + '=' + repr(v) + '\n' for k,v in self.config_items(sortkey)) | python | def savetostr(self, sortkey = True):
"""
Save configurations to a single string
"""
return ''.join(k + '=' + repr(v) + '\n' for k,v in self.config_items(sortkey)) | [
"def",
"savetostr",
"(",
"self",
",",
"sortkey",
"=",
"True",
")",
":",
"return",
"''",
".",
"join",
"(",
"k",
"+",
"'='",
"+",
"repr",
"(",
"v",
")",
"+",
"'\\n'",
"for",
"k",
",",
"v",
"in",
"self",
".",
"config_items",
"(",
"sortkey",
")",
"... | Save configurations to a single string | [
"Save",
"configurations",
"to",
"a",
"single",
"string"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/config/config.py#L276-L280 |
hubo1016/vlcp | vlcp/config/config.py | Manager.savetofile | def savetofile(self, filelike, sortkey = True):
"""
Save configurations to a file-like object which supports `writelines`
"""
filelike.writelines(k + '=' + repr(v) + '\n' for k,v in self.config_items(sortkey)) | python | def savetofile(self, filelike, sortkey = True):
"""
Save configurations to a file-like object which supports `writelines`
"""
filelike.writelines(k + '=' + repr(v) + '\n' for k,v in self.config_items(sortkey)) | [
"def",
"savetofile",
"(",
"self",
",",
"filelike",
",",
"sortkey",
"=",
"True",
")",
":",
"filelike",
".",
"writelines",
"(",
"k",
"+",
"'='",
"+",
"repr",
"(",
"v",
")",
"+",
"'\\n'",
"for",
"k",
",",
"v",
"in",
"self",
".",
"config_items",
"(",
... | Save configurations to a file-like object which supports `writelines` | [
"Save",
"configurations",
"to",
"a",
"file",
"-",
"like",
"object",
"which",
"supports",
"writelines"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/config/config.py#L281-L285 |
hubo1016/vlcp | vlcp/config/config.py | Manager.saveto | def saveto(self, path, sortkey = True):
"""
Save configurations to path
"""
with open(path, 'w') as f:
self.savetofile(f, sortkey) | python | def saveto(self, path, sortkey = True):
"""
Save configurations to path
"""
with open(path, 'w') as f:
self.savetofile(f, sortkey) | [
"def",
"saveto",
"(",
"self",
",",
"path",
",",
"sortkey",
"=",
"True",
")",
":",
"with",
"open",
"(",
"path",
",",
"'w'",
")",
"as",
"f",
":",
"self",
".",
"savetofile",
"(",
"f",
",",
"sortkey",
")"
] | Save configurations to path | [
"Save",
"configurations",
"to",
"path"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/config/config.py#L286-L291 |
hubo1016/vlcp | vlcp/config/config.py | Configurable.getConfigurableParent | def getConfigurableParent(cls):
"""
Return the parent from which this class inherits configurations
"""
for p in cls.__bases__:
if isinstance(p, Configurable) and p is not Configurable:
return p
return None | python | def getConfigurableParent(cls):
"""
Return the parent from which this class inherits configurations
"""
for p in cls.__bases__:
if isinstance(p, Configurable) and p is not Configurable:
return p
return None | [
"def",
"getConfigurableParent",
"(",
"cls",
")",
":",
"for",
"p",
"in",
"cls",
".",
"__bases__",
":",
"if",
"isinstance",
"(",
"p",
",",
"Configurable",
")",
"and",
"p",
"is",
"not",
"Configurable",
":",
"return",
"p",
"return",
"None"
] | Return the parent from which this class inherits configurations | [
"Return",
"the",
"parent",
"from",
"which",
"this",
"class",
"inherits",
"configurations"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/config/config.py#L346-L353 |
hubo1016/vlcp | vlcp/config/config.py | Configurable.getConfigRoot | def getConfigRoot(cls, create = False):
"""
Return the mapped configuration root node
"""
try:
return manager.gettree(getattr(cls, 'configkey'), create)
except AttributeError:
return None | python | def getConfigRoot(cls, create = False):
"""
Return the mapped configuration root node
"""
try:
return manager.gettree(getattr(cls, 'configkey'), create)
except AttributeError:
return None | [
"def",
"getConfigRoot",
"(",
"cls",
",",
"create",
"=",
"False",
")",
":",
"try",
":",
"return",
"manager",
".",
"gettree",
"(",
"getattr",
"(",
"cls",
",",
"'configkey'",
")",
",",
"create",
")",
"except",
"AttributeError",
":",
"return",
"None"
] | Return the mapped configuration root node | [
"Return",
"the",
"mapped",
"configuration",
"root",
"node"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/config/config.py#L355-L362 |
hubo1016/vlcp | vlcp/config/config.py | Configurable.config_value_keys | def config_value_keys(self, sortkey = False):
"""
Return all mapped configuration keys for this object
"""
ret = set()
cls = type(self)
while True:
root = cls.getConfigRoot()
if root:
ret = ret.union(set(root.config_value_keys()))
... | python | def config_value_keys(self, sortkey = False):
"""
Return all mapped configuration keys for this object
"""
ret = set()
cls = type(self)
while True:
root = cls.getConfigRoot()
if root:
ret = ret.union(set(root.config_value_keys()))
... | [
"def",
"config_value_keys",
"(",
"self",
",",
"sortkey",
"=",
"False",
")",
":",
"ret",
"=",
"set",
"(",
")",
"cls",
"=",
"type",
"(",
"self",
")",
"while",
"True",
":",
"root",
"=",
"cls",
".",
"getConfigRoot",
"(",
")",
"if",
"root",
":",
"ret",
... | Return all mapped configuration keys for this object | [
"Return",
"all",
"mapped",
"configuration",
"keys",
"for",
"this",
"object"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/config/config.py#L363-L383 |
hubo1016/vlcp | vlcp/config/config.py | Configurable.config_value_items | def config_value_items(self, sortkey = False):
"""
Return `(key, value)` tuples for all mapped configurations for this object
"""
return ((k, getattr(self, k)) for k in self.config_value_keys(sortkey)) | python | def config_value_items(self, sortkey = False):
"""
Return `(key, value)` tuples for all mapped configurations for this object
"""
return ((k, getattr(self, k)) for k in self.config_value_keys(sortkey)) | [
"def",
"config_value_items",
"(",
"self",
",",
"sortkey",
"=",
"False",
")",
":",
"return",
"(",
"(",
"k",
",",
"getattr",
"(",
"self",
",",
"k",
")",
")",
"for",
"k",
"in",
"self",
".",
"config_value_keys",
"(",
"sortkey",
")",
")"
] | Return `(key, value)` tuples for all mapped configurations for this object | [
"Return",
"(",
"key",
"value",
")",
"tuples",
"for",
"all",
"mapped",
"configurations",
"for",
"this",
"object"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/config/config.py#L385-L389 |
hubo1016/vlcp | vlcp/server/server.py | main | def main(configpath = None, startup = None, daemon = False, pidfile = None, fork = None):
"""
The most simple way to start the VLCP framework
:param configpath: path of a configuration file to be loaded
:param startup: startup modules list. If None, `server.startup` in the configuration files
... | python | def main(configpath = None, startup = None, daemon = False, pidfile = None, fork = None):
"""
The most simple way to start the VLCP framework
:param configpath: path of a configuration file to be loaded
:param startup: startup modules list. If None, `server.startup` in the configuration files
... | [
"def",
"main",
"(",
"configpath",
"=",
"None",
",",
"startup",
"=",
"None",
",",
"daemon",
"=",
"False",
",",
"pidfile",
"=",
"None",
",",
"fork",
"=",
"None",
")",
":",
"if",
"configpath",
"is",
"not",
"None",
":",
"manager",
".",
"loadfrom",
"(",
... | The most simple way to start the VLCP framework
:param configpath: path of a configuration file to be loaded
:param startup: startup modules list. If None, `server.startup` in the configuration files
is used; if `server.startup` is not configured, any module defined or imported
... | [
"The",
"most",
"simple",
"way",
"to",
"start",
"the",
"VLCP",
"framework",
":",
"param",
"configpath",
":",
"path",
"of",
"a",
"configuration",
"file",
"to",
"be",
"loaded",
":",
"param",
"startup",
":",
"startup",
"modules",
"list",
".",
"If",
"None",
"... | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/server/server.py#L174-L312 |
hubo1016/vlcp | vlcp/service/sdn/vxlancast.py | VXLANUpdater.wait_for_group | async def wait_for_group(self, container, networkid, timeout = 120):
"""
Wait for a VXLAN group to be created
"""
if networkid in self._current_groups:
return self._current_groups[networkid]
else:
if not self._connection.connected:
raise Co... | python | async def wait_for_group(self, container, networkid, timeout = 120):
"""
Wait for a VXLAN group to be created
"""
if networkid in self._current_groups:
return self._current_groups[networkid]
else:
if not self._connection.connected:
raise Co... | [
"async",
"def",
"wait_for_group",
"(",
"self",
",",
"container",
",",
"networkid",
",",
"timeout",
"=",
"120",
")",
":",
"if",
"networkid",
"in",
"self",
".",
"_current_groups",
":",
"return",
"self",
".",
"_current_groups",
"[",
"networkid",
"]",
"else",
... | Wait for a VXLAN group to be created | [
"Wait",
"for",
"a",
"VXLAN",
"group",
"to",
"be",
"created"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/service/sdn/vxlancast.py#L80-L97 |
hubo1016/vlcp | vlcp/event/stream.py | BaseStream.read | async def read(self, container = None, size = None):
"""
Coroutine method to read from the stream and return the data. Raises EOFError
when the stream end has been reached; raises IOError if there are other errors.
:param container: A routine container
:param si... | python | async def read(self, container = None, size = None):
"""
Coroutine method to read from the stream and return the data. Raises EOFError
when the stream end has been reached; raises IOError if there are other errors.
:param container: A routine container
:param si... | [
"async",
"def",
"read",
"(",
"self",
",",
"container",
"=",
"None",
",",
"size",
"=",
"None",
")",
":",
"ret",
"=",
"[",
"]",
"retsize",
"=",
"0",
"if",
"self",
".",
"eof",
":",
"raise",
"EOFError",
"if",
"self",
".",
"errored",
":",
"raise",
"IO... | Coroutine method to read from the stream and return the data. Raises EOFError
when the stream end has been reached; raises IOError if there are other errors.
:param container: A routine container
:param size: maximum read size, or unlimited if is None | [
"Coroutine",
"method",
"to",
"read",
"from",
"the",
"stream",
"and",
"return",
"the",
"data",
".",
"Raises",
"EOFError",
"when",
"the",
"stream",
"end",
"has",
"been",
"reached",
";",
"raises",
"IOError",
"if",
"there",
"are",
"other",
"errors",
".",
":",
... | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/stream.py#L58-L97 |
hubo1016/vlcp | vlcp/event/stream.py | BaseStream.readonce | def readonce(self, size = None):
"""
Read from current buffer. If current buffer is empty, returns an empty string. You can use `prepareRead`
to read the next chunk of data.
This is not a coroutine method.
"""
if self.eof:
raise EOFError
if se... | python | def readonce(self, size = None):
"""
Read from current buffer. If current buffer is empty, returns an empty string. You can use `prepareRead`
to read the next chunk of data.
This is not a coroutine method.
"""
if self.eof:
raise EOFError
if se... | [
"def",
"readonce",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"if",
"self",
".",
"eof",
":",
"raise",
"EOFError",
"if",
"self",
".",
"errored",
":",
"raise",
"IOError",
"(",
"'Stream is broken before EOF'",
")",
"if",
"size",
"is",
"not",
"None",
... | Read from current buffer. If current buffer is empty, returns an empty string. You can use `prepareRead`
to read the next chunk of data.
This is not a coroutine method. | [
"Read",
"from",
"current",
"buffer",
".",
"If",
"current",
"buffer",
"is",
"empty",
"returns",
"an",
"empty",
"string",
".",
"You",
"can",
"use",
"prepareRead",
"to",
"read",
"the",
"next",
"chunk",
"of",
"data",
".",
"This",
"is",
"not",
"a",
"coroutine... | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/stream.py#L98-L118 |
hubo1016/vlcp | vlcp/event/stream.py | BaseStream.readline | async def readline(self, container = None, size = None):
"""
Coroutine method which reads the next line or until EOF or size exceeds
"""
ret = []
retsize = 0
if self.eof:
raise EOFError
if self.errored:
raise IOError('Stream is broken befor... | python | async def readline(self, container = None, size = None):
"""
Coroutine method which reads the next line or until EOF or size exceeds
"""
ret = []
retsize = 0
if self.eof:
raise EOFError
if self.errored:
raise IOError('Stream is broken befor... | [
"async",
"def",
"readline",
"(",
"self",
",",
"container",
"=",
"None",
",",
"size",
"=",
"None",
")",
":",
"ret",
"=",
"[",
"]",
"retsize",
"=",
"0",
"if",
"self",
".",
"eof",
":",
"raise",
"EOFError",
"if",
"self",
".",
"errored",
":",
"raise",
... | Coroutine method which reads the next line or until EOF or size exceeds | [
"Coroutine",
"method",
"which",
"reads",
"the",
"next",
"line",
"or",
"until",
"EOF",
"or",
"size",
"exceeds"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/stream.py#L125-L177 |
hubo1016/vlcp | vlcp/event/stream.py | BaseStream.copy_to | async def copy_to(self, dest, container, buffering = True):
"""
Coroutine method to copy content from this stream to another stream.
"""
if self.eof:
await dest.write(u'' if self.isunicode else b'', True)
elif self.errored:
await dest.error(container)
... | python | async def copy_to(self, dest, container, buffering = True):
"""
Coroutine method to copy content from this stream to another stream.
"""
if self.eof:
await dest.write(u'' if self.isunicode else b'', True)
elif self.errored:
await dest.error(container)
... | [
"async",
"def",
"copy_to",
"(",
"self",
",",
"dest",
",",
"container",
",",
"buffering",
"=",
"True",
")",
":",
"if",
"self",
".",
"eof",
":",
"await",
"dest",
".",
"write",
"(",
"u''",
"if",
"self",
".",
"isunicode",
"else",
"b''",
",",
"True",
")... | Coroutine method to copy content from this stream to another stream. | [
"Coroutine",
"method",
"to",
"copy",
"content",
"from",
"this",
"stream",
"to",
"another",
"stream",
"."
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/stream.py#L178-L204 |
hubo1016/vlcp | vlcp/event/stream.py | BaseStream.write | async def write(self, data, container, eof = False, ignoreexception = False, buffering = True, split = True):
"""
Coroutine method to write data to this stream.
:param data: data to write
:param container: the routine container
:param eof: if True, this... | python | async def write(self, data, container, eof = False, ignoreexception = False, buffering = True, split = True):
"""
Coroutine method to write data to this stream.
:param data: data to write
:param container: the routine container
:param eof: if True, this... | [
"async",
"def",
"write",
"(",
"self",
",",
"data",
",",
"container",
",",
"eof",
"=",
"False",
",",
"ignoreexception",
"=",
"False",
",",
"buffering",
"=",
"True",
",",
"split",
"=",
"True",
")",
":",
"if",
"not",
"ignoreexception",
":",
"raise",
"IOEr... | Coroutine method to write data to this stream.
:param data: data to write
:param container: the routine container
:param eof: if True, this is the last chunk of this stream. The other end will receive an EOF after reading
this chunk.
... | [
"Coroutine",
"method",
"to",
"write",
"data",
"to",
"this",
"stream",
".",
":",
"param",
"data",
":",
"data",
"to",
"write",
":",
"param",
"container",
":",
"the",
"routine",
"container",
":",
"param",
"eof",
":",
"if",
"True",
"this",
"is",
"the",
"la... | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/stream.py#L208-L228 |
hubo1016/vlcp | vlcp/event/matchtree.py | MatchTree.subtree | def subtree(self, matcher, create = False):
'''
Find a subtree from a matcher
:param matcher: the matcher to locate the subtree. If None, return the root of the tree.
:param create: if True, the subtree is created if not exists; otherwise return None if not exists
... | python | def subtree(self, matcher, create = False):
'''
Find a subtree from a matcher
:param matcher: the matcher to locate the subtree. If None, return the root of the tree.
:param create: if True, the subtree is created if not exists; otherwise return None if not exists
... | [
"def",
"subtree",
"(",
"self",
",",
"matcher",
",",
"create",
"=",
"False",
")",
":",
"if",
"matcher",
"is",
"None",
":",
"return",
"self",
"current",
"=",
"self",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"depth",
",",
"len",
"(",
"matcher",
".... | Find a subtree from a matcher
:param matcher: the matcher to locate the subtree. If None, return the root of the tree.
:param create: if True, the subtree is created if not exists; otherwise return None if not exists | [
"Find",
"a",
"subtree",
"from",
"a",
"matcher",
":",
"param",
"matcher",
":",
"the",
"matcher",
"to",
"locate",
"the",
"subtree",
".",
"If",
"None",
"return",
"the",
"root",
"of",
"the",
"tree",
".",
":",
"param",
"create",
":",
"if",
"True",
"the",
... | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/matchtree.py#L29-L66 |
hubo1016/vlcp | vlcp/event/matchtree.py | MatchTree.insert | def insert(self, matcher, obj):
'''
Insert a new matcher
:param matcher: an EventMatcher
:param obj: object to return
'''
current = self.subtree(matcher, True)
#current.matchers[(obj, matcher)] = None
if current._use_dict:
cur... | python | def insert(self, matcher, obj):
'''
Insert a new matcher
:param matcher: an EventMatcher
:param obj: object to return
'''
current = self.subtree(matcher, True)
#current.matchers[(obj, matcher)] = None
if current._use_dict:
cur... | [
"def",
"insert",
"(",
"self",
",",
"matcher",
",",
"obj",
")",
":",
"current",
"=",
"self",
".",
"subtree",
"(",
"matcher",
",",
"True",
")",
"#current.matchers[(obj, matcher)] = None",
"if",
"current",
".",
"_use_dict",
":",
"current",
".",
"matchers_dict",
... | Insert a new matcher
:param matcher: an EventMatcher
:param obj: object to return | [
"Insert",
"a",
"new",
"matcher",
":",
"param",
"matcher",
":",
"an",
"EventMatcher",
":",
"param",
"obj",
":",
"object",
"to",
"return"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/matchtree.py#L67-L81 |
hubo1016/vlcp | vlcp/event/matchtree.py | MatchTree.remove | def remove(self, matcher, obj):
'''
Remove the matcher
:param matcher: an EventMatcher
:param obj: the object to remove
'''
current = self.subtree(matcher, False)
if current is None:
return
# Assume that this pair only appears... | python | def remove(self, matcher, obj):
'''
Remove the matcher
:param matcher: an EventMatcher
:param obj: the object to remove
'''
current = self.subtree(matcher, False)
if current is None:
return
# Assume that this pair only appears... | [
"def",
"remove",
"(",
"self",
",",
"matcher",
",",
"obj",
")",
":",
"current",
"=",
"self",
".",
"subtree",
"(",
"matcher",
",",
"False",
")",
"if",
"current",
"is",
"None",
":",
"return",
"# Assume that this pair only appears once",
"if",
"current",
".",
... | Remove the matcher
:param matcher: an EventMatcher
:param obj: the object to remove | [
"Remove",
"the",
"matcher",
":",
"param",
"matcher",
":",
"an",
"EventMatcher",
":",
"param",
"obj",
":",
"the",
"object",
"to",
"remove"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/matchtree.py#L82-L124 |
hubo1016/vlcp | vlcp/event/matchtree.py | MatchTree.matchesWithMatchers | def matchesWithMatchers(self, event):
'''
Return all matches for this event. The first matcher is also returned for each matched object.
:param event: an input event
'''
ret = []
self._matches(event, set(), ret)
return tuple(ret) | python | def matchesWithMatchers(self, event):
'''
Return all matches for this event. The first matcher is also returned for each matched object.
:param event: an input event
'''
ret = []
self._matches(event, set(), ret)
return tuple(ret) | [
"def",
"matchesWithMatchers",
"(",
"self",
",",
"event",
")",
":",
"ret",
"=",
"[",
"]",
"self",
".",
"_matches",
"(",
"event",
",",
"set",
"(",
")",
",",
"ret",
")",
"return",
"tuple",
"(",
"ret",
")"
] | Return all matches for this event. The first matcher is also returned for each matched object.
:param event: an input event | [
"Return",
"all",
"matches",
"for",
"this",
"event",
".",
"The",
"first",
"matcher",
"is",
"also",
"returned",
"for",
"each",
"matched",
"object",
".",
":",
"param",
"event",
":",
"an",
"input",
"event"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/matchtree.py#L125-L133 |
hubo1016/vlcp | vlcp/event/matchtree.py | MatchTree.matches | def matches(self, event):
'''
Return all matches for this event. The first matcher is also returned for each matched object.
:param event: an input event
'''
ret = []
self._matches(event, set(), ret)
return tuple(r[0] for r in ret) | python | def matches(self, event):
'''
Return all matches for this event. The first matcher is also returned for each matched object.
:param event: an input event
'''
ret = []
self._matches(event, set(), ret)
return tuple(r[0] for r in ret) | [
"def",
"matches",
"(",
"self",
",",
"event",
")",
":",
"ret",
"=",
"[",
"]",
"self",
".",
"_matches",
"(",
"event",
",",
"set",
"(",
")",
",",
"ret",
")",
"return",
"tuple",
"(",
"r",
"[",
"0",
"]",
"for",
"r",
"in",
"ret",
")"
] | Return all matches for this event. The first matcher is also returned for each matched object.
:param event: an input event | [
"Return",
"all",
"matches",
"for",
"this",
"event",
".",
"The",
"first",
"matcher",
"is",
"also",
"returned",
"for",
"each",
"matched",
"object",
".",
":",
"param",
"event",
":",
"an",
"input",
"event"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/matchtree.py#L134-L142 |
hubo1016/vlcp | vlcp/event/matchtree.py | MatchTree.matchfirst | def matchfirst(self, event):
'''
Return first match for this event
:param event: an input event
'''
# 1. matches(self.index[ind], event)
# 2. matches(self.any, event)
# 3. self.matches
if self.depth < len(event.indices):
ind = event.in... | python | def matchfirst(self, event):
'''
Return first match for this event
:param event: an input event
'''
# 1. matches(self.index[ind], event)
# 2. matches(self.any, event)
# 3. self.matches
if self.depth < len(event.indices):
ind = event.in... | [
"def",
"matchfirst",
"(",
"self",
",",
"event",
")",
":",
"# 1. matches(self.index[ind], event)",
"# 2. matches(self.any, event)",
"# 3. self.matches",
"if",
"self",
".",
"depth",
"<",
"len",
"(",
"event",
".",
"indices",
")",
":",
"ind",
"=",
"event",
".",
"ind... | Return first match for this event
:param event: an input event | [
"Return",
"first",
"match",
"for",
"this",
"event",
":",
"param",
"event",
":",
"an",
"input",
"event"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/matchtree.py#L166-L192 |
hubo1016/vlcp | vlcp/event/matchtree.py | EventTree.subtree | def subtree(self, event, create = False):
'''
Find a subtree from an event
'''
current = self
for i in range(self.depth, len(event.indices)):
if not hasattr(current, 'index'):
return current
ind = event.indices[i]
if create:
... | python | def subtree(self, event, create = False):
'''
Find a subtree from an event
'''
current = self
for i in range(self.depth, len(event.indices)):
if not hasattr(current, 'index'):
return current
ind = event.indices[i]
if create:
... | [
"def",
"subtree",
"(",
"self",
",",
"event",
",",
"create",
"=",
"False",
")",
":",
"current",
"=",
"self",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"depth",
",",
"len",
"(",
"event",
".",
"indices",
")",
")",
":",
"if",
"not",
"hasattr",
"("... | Find a subtree from an event | [
"Find",
"a",
"subtree",
"from",
"an",
"event"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/matchtree.py#L242-L258 |
hubo1016/vlcp | vlcp/utils/vxlandiscover.py | lognet_vxlan_walker | def lognet_vxlan_walker(prepush = True):
"""
Return a walker function to retrieve necessary information from ObjectDB
"""
def _walk_lognet(key, value, walk, save):
save(key)
if value is None:
return
try:
phynet = walk(value.physicalnetwork.getkey())
... | python | def lognet_vxlan_walker(prepush = True):
"""
Return a walker function to retrieve necessary information from ObjectDB
"""
def _walk_lognet(key, value, walk, save):
save(key)
if value is None:
return
try:
phynet = walk(value.physicalnetwork.getkey())
... | [
"def",
"lognet_vxlan_walker",
"(",
"prepush",
"=",
"True",
")",
":",
"def",
"_walk_lognet",
"(",
"key",
",",
"value",
",",
"walk",
",",
"save",
")",
":",
"save",
"(",
"key",
")",
"if",
"value",
"is",
"None",
":",
"return",
"try",
":",
"phynet",
"=",
... | Return a walker function to retrieve necessary information from ObjectDB | [
"Return",
"a",
"walker",
"function",
"to",
"retrieve",
"necessary",
"information",
"from",
"ObjectDB"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/vxlandiscover.py#L15-L59 |
hubo1016/vlcp | vlcp/utils/vxlandiscover.py | update_vxlaninfo | async def update_vxlaninfo(container, network_ip_dict, created_ports, removed_ports,
ovsdb_vhost, system_id, bridge,
allowedmigrationtime, refreshinterval):
'''
Do an ObjectDB transact to update all VXLAN informations
:param container: Routine container
:param n... | python | async def update_vxlaninfo(container, network_ip_dict, created_ports, removed_ports,
ovsdb_vhost, system_id, bridge,
allowedmigrationtime, refreshinterval):
'''
Do an ObjectDB transact to update all VXLAN informations
:param container: Routine container
:param n... | [
"async",
"def",
"update_vxlaninfo",
"(",
"container",
",",
"network_ip_dict",
",",
"created_ports",
",",
"removed_ports",
",",
"ovsdb_vhost",
",",
"system_id",
",",
"bridge",
",",
"allowedmigrationtime",
",",
"refreshinterval",
")",
":",
"network_list",
"=",
"list",... | Do an ObjectDB transact to update all VXLAN informations
:param container: Routine container
:param network_ip_dict: a {logicalnetwork_id: tunnel_ip} dictionary
:param created_ports: logical ports to be added, a {logicalport_id: tunnel_ip} dictionary
:param removed_ports: logical por... | [
"Do",
"an",
"ObjectDB",
"transact",
"to",
"update",
"all",
"VXLAN",
"informations",
":",
"param",
"container",
":",
"Routine",
"container",
":",
"param",
"network_ip_dict",
":",
"a",
"{",
"logicalnetwork_id",
":",
"tunnel_ip",
"}",
"dictionary",
":",
"param",
... | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/vxlandiscover.py#L61-L148 |
hubo1016/vlcp | vlcp/utils/vxlandiscover.py | get_broadcast_ips | def get_broadcast_ips(vxlan_endpointset, local_ip, ovsdb_vhost, system_id, bridge):
'''
Get all IP addresses that are not local
:param vxlan_endpointset: a VXLANEndpointSet object
:param local_ips: list of local IP address to exclude with
:param ovsdb_vhost: identifier, vhost
... | python | def get_broadcast_ips(vxlan_endpointset, local_ip, ovsdb_vhost, system_id, bridge):
'''
Get all IP addresses that are not local
:param vxlan_endpointset: a VXLANEndpointSet object
:param local_ips: list of local IP address to exclude with
:param ovsdb_vhost: identifier, vhost
... | [
"def",
"get_broadcast_ips",
"(",
"vxlan_endpointset",
",",
"local_ip",
",",
"ovsdb_vhost",
",",
"system_id",
",",
"bridge",
")",
":",
"localip_addr",
"=",
"_get_ip",
"(",
"local_ip",
")",
"allips",
"=",
"[",
"(",
"ip",
",",
"ipnum",
")",
"for",
"ip",
",",
... | Get all IP addresses that are not local
:param vxlan_endpointset: a VXLANEndpointSet object
:param local_ips: list of local IP address to exclude with
:param ovsdb_vhost: identifier, vhost
:param system_id: identifier, system-id
:param bridge: identifier, bridge name
... | [
"Get",
"all",
"IP",
"addresses",
"that",
"are",
"not",
"local",
":",
"param",
"vxlan_endpointset",
":",
"a",
"VXLANEndpointSet",
"object",
":",
"param",
"local_ips",
":",
"list",
"of",
"local",
"IP",
"address",
"to",
"exclude",
"with",
":",
"param",
"ovsdb_v... | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/vxlandiscover.py#L157-L178 |
hubo1016/vlcp | vlcp/event/future.py | Future.result | def result(self):
'''
:return: None if the result is not ready, the result from set_result, or raise the exception
from set_exception. If the result can be None, it is not possible to tell if the result is
available; use done() to determine that.
'''
try... | python | def result(self):
'''
:return: None if the result is not ready, the result from set_result, or raise the exception
from set_exception. If the result can be None, it is not possible to tell if the result is
available; use done() to determine that.
'''
try... | [
"def",
"result",
"(",
"self",
")",
":",
"try",
":",
"r",
"=",
"getattr",
"(",
"self",
",",
"'_result'",
")",
"except",
"AttributeError",
":",
"return",
"None",
"else",
":",
"if",
"hasattr",
"(",
"self",
",",
"'_exception'",
")",
":",
"raise",
"self",
... | :return: None if the result is not ready, the result from set_result, or raise the exception
from set_exception. If the result can be None, it is not possible to tell if the result is
available; use done() to determine that. | [
":",
"return",
":",
"None",
"if",
"the",
"result",
"is",
"not",
"ready",
"the",
"result",
"from",
"set_result",
"or",
"raise",
"the",
"exception",
"from",
"set_exception",
".",
"If",
"the",
"result",
"can",
"be",
"None",
"it",
"is",
"not",
"possible",
"t... | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/future.py#L57-L71 |
hubo1016/vlcp | vlcp/event/future.py | Future.wait | async def wait(self, container = None):
'''
:param container: DEPRECATED container of current routine
:return: The result, or raise the exception from set_exception.
'''
if hasattr(self, '_result'):
if hasattr(self, '_exception'):
raise self._... | python | async def wait(self, container = None):
'''
:param container: DEPRECATED container of current routine
:return: The result, or raise the exception from set_exception.
'''
if hasattr(self, '_result'):
if hasattr(self, '_exception'):
raise self._... | [
"async",
"def",
"wait",
"(",
"self",
",",
"container",
"=",
"None",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'_result'",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'_exception'",
")",
":",
"raise",
"self",
".",
"_exception",
"else",
":",
"ret... | :param container: DEPRECATED container of current routine
:return: The result, or raise the exception from set_exception. | [
":",
"param",
"container",
":",
"DEPRECATED",
"container",
"of",
"current",
"routine",
":",
"return",
":",
"The",
"result",
"or",
"raise",
"the",
"exception",
"from",
"set_exception",
"."
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/future.py#L72-L88 |
hubo1016/vlcp | vlcp/event/future.py | Future.set_result | def set_result(self, result):
'''
Set the result to Future object, wake up all the waiters
:param result: result to set
'''
if hasattr(self, '_result'):
raise ValueError('Cannot set the result twice')
self._result = result
self._scheduler.emer... | python | def set_result(self, result):
'''
Set the result to Future object, wake up all the waiters
:param result: result to set
'''
if hasattr(self, '_result'):
raise ValueError('Cannot set the result twice')
self._result = result
self._scheduler.emer... | [
"def",
"set_result",
"(",
"self",
",",
"result",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'_result'",
")",
":",
"raise",
"ValueError",
"(",
"'Cannot set the result twice'",
")",
"self",
".",
"_result",
"=",
"result",
"self",
".",
"_scheduler",
".",
"e... | Set the result to Future object, wake up all the waiters
:param result: result to set | [
"Set",
"the",
"result",
"to",
"Future",
"object",
"wake",
"up",
"all",
"the",
"waiters",
":",
"param",
"result",
":",
"result",
"to",
"set"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/future.py#L89-L98 |
hubo1016/vlcp | vlcp/event/future.py | Future.set_exception | def set_exception(self, exception):
'''
Set an exception to Future object, wake up all the waiters
:param exception: exception to set
'''
if hasattr(self, '_result'):
raise ValueError('Cannot set the result twice')
self._result = None
self._ex... | python | def set_exception(self, exception):
'''
Set an exception to Future object, wake up all the waiters
:param exception: exception to set
'''
if hasattr(self, '_result'):
raise ValueError('Cannot set the result twice')
self._result = None
self._ex... | [
"def",
"set_exception",
"(",
"self",
",",
"exception",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'_result'",
")",
":",
"raise",
"ValueError",
"(",
"'Cannot set the result twice'",
")",
"self",
".",
"_result",
"=",
"None",
"self",
".",
"_exception",
"=",
... | Set an exception to Future object, wake up all the waiters
:param exception: exception to set | [
"Set",
"an",
"exception",
"to",
"Future",
"object",
"wake",
"up",
"all",
"the",
"waiters",
":",
"param",
"exception",
":",
"exception",
"to",
"set"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/future.py#L99-L109 |
hubo1016/vlcp | vlcp/event/future.py | Future.ensure_result | def ensure_result(self, supress_exception = False, defaultresult = None):
'''
Context manager to ensure returning the result
'''
try:
yield self
except Exception as exc:
if not self.done():
self.set_exception(exc)
if not supress... | python | def ensure_result(self, supress_exception = False, defaultresult = None):
'''
Context manager to ensure returning the result
'''
try:
yield self
except Exception as exc:
if not self.done():
self.set_exception(exc)
if not supress... | [
"def",
"ensure_result",
"(",
"self",
",",
"supress_exception",
"=",
"False",
",",
"defaultresult",
"=",
"None",
")",
":",
"try",
":",
"yield",
"self",
"except",
"Exception",
"as",
"exc",
":",
"if",
"not",
"self",
".",
"done",
"(",
")",
":",
"self",
"."... | Context manager to ensure returning the result | [
"Context",
"manager",
"to",
"ensure",
"returning",
"the",
"result"
] | train | https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/future.py#L111-L128 |
pudo/datafreeze | datafreeze/app.py | freeze | def freeze(result, format='csv', filename='freeze.csv', fileobj=None,
prefix='.', mode='list', **kw):
"""
Perform a data export of a given result set. This is a very
flexible exporter, allowing for various output formats, metadata
assignment, and file name templating to dump each record (or a... | python | def freeze(result, format='csv', filename='freeze.csv', fileobj=None,
prefix='.', mode='list', **kw):
"""
Perform a data export of a given result set. This is a very
flexible exporter, allowing for various output formats, metadata
assignment, and file name templating to dump each record (or a... | [
"def",
"freeze",
"(",
"result",
",",
"format",
"=",
"'csv'",
",",
"filename",
"=",
"'freeze.csv'",
",",
"fileobj",
"=",
"None",
",",
"prefix",
"=",
"'.'",
",",
"mode",
"=",
"'list'",
",",
"*",
"*",
"kw",
")",
":",
"kw",
".",
"update",
"(",
"{",
"... | Perform a data export of a given result set. This is a very
flexible exporter, allowing for various output formats, metadata
assignment, and file name templating to dump each record (or a set
of records) into individual files.
::
result = db['person'].all()
dataset.freeze(result, forma... | [
"Perform",
"a",
"data",
"export",
"of",
"a",
"given",
"result",
"set",
".",
"This",
"is",
"a",
"very",
"flexible",
"exporter",
"allowing",
"for",
"various",
"output",
"formats",
"metadata",
"assignment",
"and",
"file",
"name",
"templating",
"to",
"dump",
"ea... | train | https://github.com/pudo/datafreeze/blob/adbb19ad71a9a6cec1fbec650ee1e784c33eae8e/datafreeze/app.py#L26-L124 |
rbit/pydtls | dtls/x509.py | decode_cert | def decode_cert(cert):
"""Convert an X509 certificate into a Python dictionary
This function converts the given X509 certificate into a Python dictionary
in the manner established by the Python standard library's ssl module.
"""
ret_dict = {}
subject_xname = X509_get_subject_name(cert.value)
... | python | def decode_cert(cert):
"""Convert an X509 certificate into a Python dictionary
This function converts the given X509 certificate into a Python dictionary
in the manner established by the Python standard library's ssl module.
"""
ret_dict = {}
subject_xname = X509_get_subject_name(cert.value)
... | [
"def",
"decode_cert",
"(",
"cert",
")",
":",
"ret_dict",
"=",
"{",
"}",
"subject_xname",
"=",
"X509_get_subject_name",
"(",
"cert",
".",
"value",
")",
"ret_dict",
"[",
"\"subject\"",
"]",
"=",
"_create_tuple_for_X509_NAME",
"(",
"subject_xname",
")",
"notAfter",... | Convert an X509 certificate into a Python dictionary
This function converts the given X509 certificate into a Python dictionary
in the manner established by the Python standard library's ssl module. | [
"Convert",
"an",
"X509",
"certificate",
"into",
"a",
"Python",
"dictionary"
] | train | https://github.com/rbit/pydtls/blob/41a71fccd990347d0de5f42418fea1e4e733359c/dtls/x509.py#L61-L79 |
rbit/pydtls | dtls/patch.py | _get_server_certificate | def _get_server_certificate(addr, ssl_version=PROTOCOL_SSLv23, ca_certs=None):
"""Retrieve a server certificate
Retrieve the certificate from the server at the specified address,
and return it as a PEM-encoded string.
If 'ca_certs' is specified, validate the server cert against it.
If 'ssl_version'... | python | def _get_server_certificate(addr, ssl_version=PROTOCOL_SSLv23, ca_certs=None):
"""Retrieve a server certificate
Retrieve the certificate from the server at the specified address,
and return it as a PEM-encoded string.
If 'ca_certs' is specified, validate the server cert against it.
If 'ssl_version'... | [
"def",
"_get_server_certificate",
"(",
"addr",
",",
"ssl_version",
"=",
"PROTOCOL_SSLv23",
",",
"ca_certs",
"=",
"None",
")",
":",
"if",
"ssl_version",
"not",
"in",
"(",
"PROTOCOL_DTLS",
",",
"PROTOCOL_DTLSv1",
",",
"PROTOCOL_DTLSv1_2",
")",
":",
"return",
"_ori... | Retrieve a server certificate
Retrieve the certificate from the server at the specified address,
and return it as a PEM-encoded string.
If 'ca_certs' is specified, validate the server cert against it.
If 'ssl_version' is specified, use it in the connection attempt. | [
"Retrieve",
"a",
"server",
"certificate"
] | train | https://github.com/rbit/pydtls/blob/41a71fccd990347d0de5f42418fea1e4e733359c/dtls/patch.py#L100-L123 |
rbit/pydtls | dtls/sslconnection.py | SSLContext.set_curves | def set_curves(self, curves):
u''' Set supported curves by name, nid or nist.
:param str | tuple(int) curves: Example "secp384r1:secp256k1", (715, 714), "P-384", "K-409:B-409:K-571", ...
:return: 1 for success and 0 for failure
'''
retVal = None
if isinstance(curves, str... | python | def set_curves(self, curves):
u''' Set supported curves by name, nid or nist.
:param str | tuple(int) curves: Example "secp384r1:secp256k1", (715, 714), "P-384", "K-409:B-409:K-571", ...
:return: 1 for success and 0 for failure
'''
retVal = None
if isinstance(curves, str... | [
"def",
"set_curves",
"(",
"self",
",",
"curves",
")",
":",
"retVal",
"=",
"None",
"if",
"isinstance",
"(",
"curves",
",",
"str",
")",
":",
"retVal",
"=",
"SSL_CTX_set1_curves_list",
"(",
"self",
".",
"_ctx",
",",
"curves",
")",
"elif",
"isinstance",
"(",... | u''' Set supported curves by name, nid or nist.
:param str | tuple(int) curves: Example "secp384r1:secp256k1", (715, 714), "P-384", "K-409:B-409:K-571", ...
:return: 1 for success and 0 for failure | [
"u",
"Set",
"supported",
"curves",
"by",
"name",
"nid",
"or",
"nist",
"."
] | train | https://github.com/rbit/pydtls/blob/41a71fccd990347d0de5f42418fea1e4e733359c/dtls/sslconnection.py#L206-L217 |
rbit/pydtls | dtls/sslconnection.py | SSLContext.set_ecdh_curve | def set_ecdh_curve(self, curve_name=None):
u''' Select a curve to use for ECDH(E) key exchange or set it to auto mode
Used for server only!
s.a. openssl.exe ecparam -list_curves
:param None | str curve_name: None = Auto-mode, "secp256k1", "secp384r1", ...
:return: 1 for succes... | python | def set_ecdh_curve(self, curve_name=None):
u''' Select a curve to use for ECDH(E) key exchange or set it to auto mode
Used for server only!
s.a. openssl.exe ecparam -list_curves
:param None | str curve_name: None = Auto-mode, "secp256k1", "secp384r1", ...
:return: 1 for succes... | [
"def",
"set_ecdh_curve",
"(",
"self",
",",
"curve_name",
"=",
"None",
")",
":",
"if",
"curve_name",
":",
"retVal",
"=",
"SSL_CTX_set_ecdh_auto",
"(",
"self",
".",
"_ctx",
",",
"0",
")",
"avail_curves",
"=",
"get_elliptic_curves",
"(",
")",
"key",
"=",
"[",... | u''' Select a curve to use for ECDH(E) key exchange or set it to auto mode
Used for server only!
s.a. openssl.exe ecparam -list_curves
:param None | str curve_name: None = Auto-mode, "secp256k1", "secp384r1", ...
:return: 1 for success and 0 for failure | [
"u",
"Select",
"a",
"curve",
"to",
"use",
"for",
"ECDH",
"(",
"E",
")",
"key",
"exchange",
"or",
"set",
"it",
"to",
"auto",
"mode"
] | train | https://github.com/rbit/pydtls/blob/41a71fccd990347d0de5f42418fea1e4e733359c/dtls/sslconnection.py#L238-L255 |
rbit/pydtls | dtls/sslconnection.py | SSLContext.build_cert_chain | def build_cert_chain(self, flags=SSL_BUILD_CHAIN_FLAG_NONE):
u'''
Used for server side only!
:param flags:
:return: 1 for success and 0 for failure
'''
retVal = SSL_CTX_build_cert_chain(self._ctx, flags)
return retVal | python | def build_cert_chain(self, flags=SSL_BUILD_CHAIN_FLAG_NONE):
u'''
Used for server side only!
:param flags:
:return: 1 for success and 0 for failure
'''
retVal = SSL_CTX_build_cert_chain(self._ctx, flags)
return retVal | [
"def",
"build_cert_chain",
"(",
"self",
",",
"flags",
"=",
"SSL_BUILD_CHAIN_FLAG_NONE",
")",
":",
"retVal",
"=",
"SSL_CTX_build_cert_chain",
"(",
"self",
".",
"_ctx",
",",
"flags",
")",
"return",
"retVal"
] | u'''
Used for server side only!
:param flags:
:return: 1 for success and 0 for failure | [
"u",
"Used",
"for",
"server",
"side",
"only!"
] | train | https://github.com/rbit/pydtls/blob/41a71fccd990347d0de5f42418fea1e4e733359c/dtls/sslconnection.py#L257-L265 |
rbit/pydtls | dtls/sslconnection.py | SSLContext.set_ssl_logging | def set_ssl_logging(self, enable=False, func=_ssl_logging_cb):
u''' Enable or disable SSL logging
:param True | False enable: Enable or disable SSL logging
:param func: Callback function for logging
'''
if enable:
SSL_CTX_set_info_callback(self._ctx, func)
el... | python | def set_ssl_logging(self, enable=False, func=_ssl_logging_cb):
u''' Enable or disable SSL logging
:param True | False enable: Enable or disable SSL logging
:param func: Callback function for logging
'''
if enable:
SSL_CTX_set_info_callback(self._ctx, func)
el... | [
"def",
"set_ssl_logging",
"(",
"self",
",",
"enable",
"=",
"False",
",",
"func",
"=",
"_ssl_logging_cb",
")",
":",
"if",
"enable",
":",
"SSL_CTX_set_info_callback",
"(",
"self",
".",
"_ctx",
",",
"func",
")",
"else",
":",
"SSL_CTX_set_info_callback",
"(",
"s... | u''' Enable or disable SSL logging
:param True | False enable: Enable or disable SSL logging
:param func: Callback function for logging | [
"u",
"Enable",
"or",
"disable",
"SSL",
"logging"
] | train | https://github.com/rbit/pydtls/blob/41a71fccd990347d0de5f42418fea1e4e733359c/dtls/sslconnection.py#L267-L276 |
rbit/pydtls | dtls/sslconnection.py | SSLConnection.get_socket | def get_socket(self, inbound):
"""Retrieve a socket used by this connection
When inbound is True, then the socket from which this connection reads
data is retrieved. Otherwise the socket to which this connection writes
data is retrieved.
Read and write sockets differ depending ... | python | def get_socket(self, inbound):
"""Retrieve a socket used by this connection
When inbound is True, then the socket from which this connection reads
data is retrieved. Otherwise the socket to which this connection writes
data is retrieved.
Read and write sockets differ depending ... | [
"def",
"get_socket",
"(",
"self",
",",
"inbound",
")",
":",
"if",
"inbound",
"and",
"hasattr",
"(",
"self",
",",
"\"_rsock\"",
")",
":",
"return",
"self",
".",
"_rsock",
"return",
"self",
".",
"_sock"
] | Retrieve a socket used by this connection
When inbound is True, then the socket from which this connection reads
data is retrieved. Otherwise the socket to which this connection writes
data is retrieved.
Read and write sockets differ depending on whether this is a server- or
a ... | [
"Retrieve",
"a",
"socket",
"used",
"by",
"this",
"connection"
] | train | https://github.com/rbit/pydtls/blob/41a71fccd990347d0de5f42418fea1e4e733359c/dtls/sslconnection.py#L575-L588 |
rbit/pydtls | dtls/sslconnection.py | SSLConnection.listen | def listen(self):
"""Server-side cookie exchange
This method reads datagrams from the socket and initiates cookie
exchange, upon whose successful conclusion one can then proceed to
the accept method. Alternatively, accept can be called directly, in
which case it will call this m... | python | def listen(self):
"""Server-side cookie exchange
This method reads datagrams from the socket and initiates cookie
exchange, upon whose successful conclusion one can then proceed to
the accept method. Alternatively, accept can be called directly, in
which case it will call this m... | [
"def",
"listen",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"\"_listening\"",
")",
":",
"raise",
"InvalidSocketError",
"(",
"\"listen called on non-listening socket\"",
")",
"self",
".",
"_pending_peer_address",
"=",
"None",
"try",
":",
"pe... | Server-side cookie exchange
This method reads datagrams from the socket and initiates cookie
exchange, upon whose successful conclusion one can then proceed to
the accept method. Alternatively, accept can be called directly, in
which case it will call this method. In order to prevent de... | [
"Server",
"-",
"side",
"cookie",
"exchange"
] | train | https://github.com/rbit/pydtls/blob/41a71fccd990347d0de5f42418fea1e4e733359c/dtls/sslconnection.py#L590-L664 |
rbit/pydtls | dtls/sslconnection.py | SSLConnection.accept | def accept(self):
"""Server-side UDP connection establishment
This method returns a server-side SSLConnection object, connected to
that peer most recently returned from the listen method and not yet
connected. If there is no such peer, then the listen method is invoked.
Return ... | python | def accept(self):
"""Server-side UDP connection establishment
This method returns a server-side SSLConnection object, connected to
that peer most recently returned from the listen method and not yet
connected. If there is no such peer, then the listen method is invoked.
Return ... | [
"def",
"accept",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_pending_peer_address",
":",
"if",
"not",
"self",
".",
"listen",
"(",
")",
":",
"_logger",
".",
"debug",
"(",
"\"Accept returning without connection\"",
")",
"return",
"new_conn",
"=",
"SSLCo... | Server-side UDP connection establishment
This method returns a server-side SSLConnection object, connected to
that peer most recently returned from the listen method and not yet
connected. If there is no such peer, then the listen method is invoked.
Return value: SSLConnection connecte... | [
"Server",
"-",
"side",
"UDP",
"connection",
"establishment"
] | train | https://github.com/rbit/pydtls/blob/41a71fccd990347d0de5f42418fea1e4e733359c/dtls/sslconnection.py#L666-L697 |
rbit/pydtls | dtls/sslconnection.py | SSLConnection.connect | def connect(self, peer_address):
"""Client-side UDP connection establishment
This method connects this object's underlying socket. It subsequently
performs a handshake if do_handshake_on_connect was set during
initialization.
Arguments:
peer_address - address tuple of s... | python | def connect(self, peer_address):
"""Client-side UDP connection establishment
This method connects this object's underlying socket. It subsequently
performs a handshake if do_handshake_on_connect was set during
initialization.
Arguments:
peer_address - address tuple of s... | [
"def",
"connect",
"(",
"self",
",",
"peer_address",
")",
":",
"self",
".",
"_sock",
".",
"connect",
"(",
"peer_address",
")",
"peer_address",
"=",
"self",
".",
"_sock",
".",
"getpeername",
"(",
")",
"# substituted host addrinfo",
"BIO_dgram_set_connected",
"(",
... | Client-side UDP connection establishment
This method connects this object's underlying socket. It subsequently
performs a handshake if do_handshake_on_connect was set during
initialization.
Arguments:
peer_address - address tuple of server peer | [
"Client",
"-",
"side",
"UDP",
"connection",
"establishment"
] | train | https://github.com/rbit/pydtls/blob/41a71fccd990347d0de5f42418fea1e4e733359c/dtls/sslconnection.py#L699-L715 |
rbit/pydtls | dtls/sslconnection.py | SSLConnection.do_handshake | def do_handshake(self):
"""Perform a handshake with the peer
This method forces an explicit handshake to be performed with either
the client or server peer.
"""
_logger.debug("Initiating handshake...")
try:
self._wrap_socket_library_call(
lam... | python | def do_handshake(self):
"""Perform a handshake with the peer
This method forces an explicit handshake to be performed with either
the client or server peer.
"""
_logger.debug("Initiating handshake...")
try:
self._wrap_socket_library_call(
lam... | [
"def",
"do_handshake",
"(",
"self",
")",
":",
"_logger",
".",
"debug",
"(",
"\"Initiating handshake...\"",
")",
"try",
":",
"self",
".",
"_wrap_socket_library_call",
"(",
"lambda",
":",
"SSL_do_handshake",
"(",
"self",
".",
"_ssl",
".",
"value",
")",
",",
"E... | Perform a handshake with the peer
This method forces an explicit handshake to be performed with either
the client or server peer. | [
"Perform",
"a",
"handshake",
"with",
"the",
"peer"
] | train | https://github.com/rbit/pydtls/blob/41a71fccd990347d0de5f42418fea1e4e733359c/dtls/sslconnection.py#L717-L734 |
rbit/pydtls | dtls/sslconnection.py | SSLConnection.read | def read(self, len=1024, buffer=None):
"""Read data from connection
Read up to len bytes and return them.
Arguments:
len -- maximum number of bytes to read
Return value:
string containing read bytes
"""
try:
return self._wrap_socket_library_... | python | def read(self, len=1024, buffer=None):
"""Read data from connection
Read up to len bytes and return them.
Arguments:
len -- maximum number of bytes to read
Return value:
string containing read bytes
"""
try:
return self._wrap_socket_library_... | [
"def",
"read",
"(",
"self",
",",
"len",
"=",
"1024",
",",
"buffer",
"=",
"None",
")",
":",
"try",
":",
"return",
"self",
".",
"_wrap_socket_library_call",
"(",
"lambda",
":",
"SSL_read",
"(",
"self",
".",
"_ssl",
".",
"value",
",",
"len",
",",
"buffe... | Read data from connection
Read up to len bytes and return them.
Arguments:
len -- maximum number of bytes to read
Return value:
string containing read bytes | [
"Read",
"data",
"from",
"connection"
] | train | https://github.com/rbit/pydtls/blob/41a71fccd990347d0de5f42418fea1e4e733359c/dtls/sslconnection.py#L736-L753 |
rbit/pydtls | dtls/sslconnection.py | SSLConnection.write | def write(self, data):
"""Write data to connection
Write data as string of bytes.
Arguments:
data -- buffer containing data to be written
Return value:
number of bytes actually transmitted
"""
try:
ret = self._wrap_socket_library_call(
... | python | def write(self, data):
"""Write data to connection
Write data as string of bytes.
Arguments:
data -- buffer containing data to be written
Return value:
number of bytes actually transmitted
"""
try:
ret = self._wrap_socket_library_call(
... | [
"def",
"write",
"(",
"self",
",",
"data",
")",
":",
"try",
":",
"ret",
"=",
"self",
".",
"_wrap_socket_library_call",
"(",
"lambda",
":",
"SSL_write",
"(",
"self",
".",
"_ssl",
".",
"value",
",",
"data",
")",
",",
"ERR_WRITE_TIMEOUT",
")",
"except",
"o... | Write data to connection
Write data as string of bytes.
Arguments:
data -- buffer containing data to be written
Return value:
number of bytes actually transmitted | [
"Write",
"data",
"to",
"connection"
] | train | https://github.com/rbit/pydtls/blob/41a71fccd990347d0de5f42418fea1e4e733359c/dtls/sslconnection.py#L755-L776 |
rbit/pydtls | dtls/sslconnection.py | SSLConnection.shutdown | def shutdown(self):
"""Shut down the DTLS connection
This method attemps to complete a bidirectional shutdown between
peers. For non-blocking sockets, it should be called repeatedly until
it no longer raises continuation request exceptions.
"""
if hasattr(self, "_listen... | python | def shutdown(self):
"""Shut down the DTLS connection
This method attemps to complete a bidirectional shutdown between
peers. For non-blocking sockets, it should be called repeatedly until
it no longer raises continuation request exceptions.
"""
if hasattr(self, "_listen... | [
"def",
"shutdown",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"\"_listening\"",
")",
":",
"# Listening server-side sockets cannot be shut down",
"return",
"try",
":",
"self",
".",
"_wrap_socket_library_call",
"(",
"lambda",
":",
"SSL_shutdown",
"(",
... | Shut down the DTLS connection
This method attemps to complete a bidirectional shutdown between
peers. For non-blocking sockets, it should be called repeatedly until
it no longer raises continuation request exceptions. | [
"Shut",
"down",
"the",
"DTLS",
"connection"
] | train | https://github.com/rbit/pydtls/blob/41a71fccd990347d0de5f42418fea1e4e733359c/dtls/sslconnection.py#L778-L811 |
rbit/pydtls | dtls/sslconnection.py | SSLConnection.getpeercert | def getpeercert(self, binary_form=False):
"""Retrieve the peer's certificate
When binary form is requested, the peer's DER-encoded certficate is
returned if it was transmitted during the handshake.
When binary form is not requested, and the peer's certificate has been
validated... | python | def getpeercert(self, binary_form=False):
"""Retrieve the peer's certificate
When binary form is requested, the peer's DER-encoded certficate is
returned if it was transmitted during the handshake.
When binary form is not requested, and the peer's certificate has been
validated... | [
"def",
"getpeercert",
"(",
"self",
",",
"binary_form",
"=",
"False",
")",
":",
"try",
":",
"peer_cert",
"=",
"_X509",
"(",
"SSL_get_peer_certificate",
"(",
"self",
".",
"_ssl",
".",
"value",
")",
")",
"except",
"openssl_error",
"(",
")",
":",
"return",
"... | Retrieve the peer's certificate
When binary form is requested, the peer's DER-encoded certficate is
returned if it was transmitted during the handshake.
When binary form is not requested, and the peer's certificate has been
validated, then a certificate dictionary is returned. If the c... | [
"Retrieve",
"the",
"peer",
"s",
"certificate"
] | train | https://github.com/rbit/pydtls/blob/41a71fccd990347d0de5f42418fea1e4e733359c/dtls/sslconnection.py#L813-L836 |
rbit/pydtls | dtls/sslconnection.py | SSLConnection.cipher | def cipher(self):
"""Retrieve information about the current cipher
Return a triple consisting of cipher name, SSL protocol version defining
its use, and the number of secret bits. Return None if handshaking
has not been completed.
"""
if not self._handshake_done:
... | python | def cipher(self):
"""Retrieve information about the current cipher
Return a triple consisting of cipher name, SSL protocol version defining
its use, and the number of secret bits. Return None if handshaking
has not been completed.
"""
if not self._handshake_done:
... | [
"def",
"cipher",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_handshake_done",
":",
"return",
"current_cipher",
"=",
"SSL_get_current_cipher",
"(",
"self",
".",
"_ssl",
".",
"value",
")",
"cipher_name",
"=",
"SSL_CIPHER_get_name",
"(",
"current_cipher",
... | Retrieve information about the current cipher
Return a triple consisting of cipher name, SSL protocol version defining
its use, and the number of secret bits. Return None if handshaking
has not been completed. | [
"Retrieve",
"information",
"about",
"the",
"current",
"cipher"
] | train | https://github.com/rbit/pydtls/blob/41a71fccd990347d0de5f42418fea1e4e733359c/dtls/sslconnection.py#L855-L870 |
rbit/pydtls | dtls/__init__.py | _prep_bins | def _prep_bins():
"""
Support for running straight out of a cloned source directory instead
of an installed distribution
"""
from os import path
from sys import platform, maxsize
from shutil import copy
bit_suffix = "-x86_64" if maxsize > 2**32 else "-x86"
package_root = path.abspat... | python | def _prep_bins():
"""
Support for running straight out of a cloned source directory instead
of an installed distribution
"""
from os import path
from sys import platform, maxsize
from shutil import copy
bit_suffix = "-x86_64" if maxsize > 2**32 else "-x86"
package_root = path.abspat... | [
"def",
"_prep_bins",
"(",
")",
":",
"from",
"os",
"import",
"path",
"from",
"sys",
"import",
"platform",
",",
"maxsize",
"from",
"shutil",
"import",
"copy",
"bit_suffix",
"=",
"\"-x86_64\"",
"if",
"maxsize",
">",
"2",
"**",
"32",
"else",
"\"-x86\"",
"packa... | Support for running straight out of a cloned source directory instead
of an installed distribution | [
"Support",
"for",
"running",
"straight",
"out",
"of",
"a",
"cloned",
"source",
"directory",
"instead",
"of",
"an",
"installed",
"distribution"
] | train | https://github.com/rbit/pydtls/blob/41a71fccd990347d0de5f42418fea1e4e733359c/dtls/__init__.py#L37-L59 |
rbit/pydtls | dtls/demux/osnet.py | UDPDemux.get_connection | def get_connection(self, address):
"""Create or retrieve a muxed connection
Arguments:
address -- a peer endpoint in IPv4/v6 address format; None refers
to the connection for unknown peers
Return:
a bound, connected datagram socket instance, or the root socke... | python | def get_connection(self, address):
"""Create or retrieve a muxed connection
Arguments:
address -- a peer endpoint in IPv4/v6 address format; None refers
to the connection for unknown peers
Return:
a bound, connected datagram socket instance, or the root socke... | [
"def",
"get_connection",
"(",
"self",
",",
"address",
")",
":",
"if",
"not",
"address",
":",
"return",
"self",
".",
"_datagram_socket",
"# Create a new datagram socket bound to the same interface and port as",
"# the root socket, but connected to the given peer",
"conn",
"=",
... | Create or retrieve a muxed connection
Arguments:
address -- a peer endpoint in IPv4/v6 address format; None refers
to the connection for unknown peers
Return:
a bound, connected datagram socket instance, or the root socket
in case address was None | [
"Create",
"or",
"retrieve",
"a",
"muxed",
"connection"
] | train | https://github.com/rbit/pydtls/blob/41a71fccd990347d0de5f42418fea1e4e733359c/dtls/demux/osnet.py#L86-L110 |
rbit/pydtls | dtls/openssl.py | SSL_CTX_set_info_callback | def SSL_CTX_set_info_callback(ctx, app_info_cb):
"""
Set the info callback
:param callback: The Python callback to use
:return: None
"""
def py_info_callback(ssl, where, ret):
try:
app_info_cb(SSL(ssl), where, ret)
except:
pass
return
global ... | python | def SSL_CTX_set_info_callback(ctx, app_info_cb):
"""
Set the info callback
:param callback: The Python callback to use
:return: None
"""
def py_info_callback(ssl, where, ret):
try:
app_info_cb(SSL(ssl), where, ret)
except:
pass
return
global ... | [
"def",
"SSL_CTX_set_info_callback",
"(",
"ctx",
",",
"app_info_cb",
")",
":",
"def",
"py_info_callback",
"(",
"ssl",
",",
"where",
",",
"ret",
")",
":",
"try",
":",
"app_info_cb",
"(",
"SSL",
"(",
"ssl",
")",
",",
"where",
",",
"ret",
")",
"except",
":... | Set the info callback
:param callback: The Python callback to use
:return: None | [
"Set",
"the",
"info",
"callback"
] | train | https://github.com/rbit/pydtls/blob/41a71fccd990347d0de5f42418fea1e4e733359c/dtls/openssl.py#L876-L892 |
rbit/pydtls | dtls/err.py | raise_ssl_error | def raise_ssl_error(code, nested=None):
"""Raise an SSL error with the given error code"""
err_string = str(code) + ": " + _ssl_errors[code]
if nested:
raise SSLError(code, err_string + str(nested))
raise SSLError(code, err_string) | python | def raise_ssl_error(code, nested=None):
"""Raise an SSL error with the given error code"""
err_string = str(code) + ": " + _ssl_errors[code]
if nested:
raise SSLError(code, err_string + str(nested))
raise SSLError(code, err_string) | [
"def",
"raise_ssl_error",
"(",
"code",
",",
"nested",
"=",
"None",
")",
":",
"err_string",
"=",
"str",
"(",
"code",
")",
"+",
"\": \"",
"+",
"_ssl_errors",
"[",
"code",
"]",
"if",
"nested",
":",
"raise",
"SSLError",
"(",
"code",
",",
"err_string",
"+",... | Raise an SSL error with the given error code | [
"Raise",
"an",
"SSL",
"error",
"with",
"the",
"given",
"error",
"code"
] | train | https://github.com/rbit/pydtls/blob/41a71fccd990347d0de5f42418fea1e4e733359c/dtls/err.py#L108-L113 |
rbit/pydtls | dtls/demux/router.py | UDPDemux.get_connection | def get_connection(self, address):
"""Create or retrieve a muxed connection
Arguments:
address -- a peer endpoint in IPv4/v6 address format; None refers
to the connection for unknown peers
Return:
a bound, connected datagram socket instance
"""
... | python | def get_connection(self, address):
"""Create or retrieve a muxed connection
Arguments:
address -- a peer endpoint in IPv4/v6 address format; None refers
to the connection for unknown peers
Return:
a bound, connected datagram socket instance
"""
... | [
"def",
"get_connection",
"(",
"self",
",",
"address",
")",
":",
"if",
"self",
".",
"connections",
".",
"has_key",
"(",
"address",
")",
":",
"return",
"self",
".",
"connections",
"[",
"address",
"]",
"# We need a new datagram socket on a dynamically assigned ephemera... | Create or retrieve a muxed connection
Arguments:
address -- a peer endpoint in IPv4/v6 address format; None refers
to the connection for unknown peers
Return:
a bound, connected datagram socket instance | [
"Create",
"or",
"retrieve",
"a",
"muxed",
"connection"
] | train | https://github.com/rbit/pydtls/blob/41a71fccd990347d0de5f42418fea1e4e733359c/dtls/demux/router.py#L94-L118 |
rbit/pydtls | dtls/demux/router.py | UDPDemux.service | def service(self):
"""Service the root socket
Read from the root socket and forward one datagram to a
connection. The call will return without forwarding data
if any of the following occurs:
* An error is encountered while reading from the root socket
* Reading from... | python | def service(self):
"""Service the root socket
Read from the root socket and forward one datagram to a
connection. The call will return without forwarding data
if any of the following occurs:
* An error is encountered while reading from the root socket
* Reading from... | [
"def",
"service",
"(",
"self",
")",
":",
"self",
".",
"payload",
",",
"self",
".",
"payload_peer_address",
"=",
"self",
".",
"datagram_socket",
".",
"recvfrom",
"(",
"UDP_MAX_DGRAM_LENGTH",
")",
"_logger",
".",
"debug",
"(",
"\"Received datagram from peer: %s\"",
... | Service the root socket
Read from the root socket and forward one datagram to a
connection. The call will return without forwarding data
if any of the following occurs:
* An error is encountered while reading from the root socket
* Reading from the root socket times out
... | [
"Service",
"the",
"root",
"socket"
] | train | https://github.com/rbit/pydtls/blob/41a71fccd990347d0de5f42418fea1e4e733359c/dtls/demux/router.py#L133-L164 |
rbit/pydtls | dtls/demux/router.py | UDPDemux.forward | def forward(self):
"""Forward a stored datagram
When the service method returns the address of a new peer, it holds
the datagram from that peer in this instance. In this case, this
method will perform the forwarding step. The target connection is the
one associated with address ... | python | def forward(self):
"""Forward a stored datagram
When the service method returns the address of a new peer, it holds
the datagram from that peer in this instance. In this case, this
method will perform the forwarding step. The target connection is the
one associated with address ... | [
"def",
"forward",
"(",
"self",
")",
":",
"assert",
"self",
".",
"payload",
"assert",
"self",
".",
"payload_peer_address",
"if",
"self",
".",
"connections",
".",
"has_key",
"(",
"self",
".",
"payload_peer_address",
")",
":",
"conn",
"=",
"self",
".",
"conne... | Forward a stored datagram
When the service method returns the address of a new peer, it holds
the datagram from that peer in this instance. In this case, this
method will perform the forwarding step. The target connection is the
one associated with address None if get_connection has not... | [
"Forward",
"a",
"stored",
"datagram"
] | train | https://github.com/rbit/pydtls/blob/41a71fccd990347d0de5f42418fea1e4e733359c/dtls/demux/router.py#L166-L189 |
glasnt/emojificate | emojificate/templatetags/emojificate.py | emojificate_filter | def emojificate_filter(content, autoescape=True):
"Convert any emoji in a string into accessible content."
# return mark_safe(emojificate(content))
if autoescape:
esc = conditional_escape
else:
esc = lambda x: x
return mark_safe(emojificate(esc(content))) | python | def emojificate_filter(content, autoescape=True):
"Convert any emoji in a string into accessible content."
# return mark_safe(emojificate(content))
if autoescape:
esc = conditional_escape
else:
esc = lambda x: x
return mark_safe(emojificate(esc(content))) | [
"def",
"emojificate_filter",
"(",
"content",
",",
"autoescape",
"=",
"True",
")",
":",
"# return mark_safe(emojificate(content))",
"if",
"autoescape",
":",
"esc",
"=",
"conditional_escape",
"else",
":",
"esc",
"=",
"lambda",
"x",
":",
"x",
"return",
"mark_safe",
... | Convert any emoji in a string into accessible content. | [
"Convert",
"any",
"emoji",
"in",
"a",
"string",
"into",
"accessible",
"content",
"."
] | train | https://github.com/glasnt/emojificate/blob/701baad443022043870389c0e0030ed6b7127448/emojificate/templatetags/emojificate.py#L12-L19 |
xeroc/stakemachine | stakemachine/strategies/walls.py | Walls.updateorders | def updateorders(self):
""" Update the orders
"""
log.info("Replacing orders")
# Canceling orders
self.cancelall()
# Target
target = self.bot.get("target", {})
price = self.getprice()
# prices
buy_price = price * (1 - target["offsets"]["... | python | def updateorders(self):
""" Update the orders
"""
log.info("Replacing orders")
# Canceling orders
self.cancelall()
# Target
target = self.bot.get("target", {})
price = self.getprice()
# prices
buy_price = price * (1 - target["offsets"]["... | [
"def",
"updateorders",
"(",
"self",
")",
":",
"log",
".",
"info",
"(",
"\"Replacing orders\"",
")",
"# Canceling orders",
"self",
".",
"cancelall",
"(",
")",
"# Target",
"target",
"=",
"self",
".",
"bot",
".",
"get",
"(",
"\"target\"",
",",
"{",
"}",
")"... | Update the orders | [
"Update",
"the",
"orders"
] | train | https://github.com/xeroc/stakemachine/blob/c2d5bcfe7c013a93c8c7293bec44ef5690883b16/stakemachine/strategies/walls.py#L35-L78 |
xeroc/stakemachine | stakemachine/strategies/walls.py | Walls.getprice | def getprice(self):
""" Here we obtain the price for the quote and make sure it has
a feed price
"""
target = self.bot.get("target", {})
if target.get("reference") == "feed":
assert self.market == self.market.core_quote_market(), "Wrong market for 'feed' reference... | python | def getprice(self):
""" Here we obtain the price for the quote and make sure it has
a feed price
"""
target = self.bot.get("target", {})
if target.get("reference") == "feed":
assert self.market == self.market.core_quote_market(), "Wrong market for 'feed' reference... | [
"def",
"getprice",
"(",
"self",
")",
":",
"target",
"=",
"self",
".",
"bot",
".",
"get",
"(",
"\"target\"",
",",
"{",
"}",
")",
"if",
"target",
".",
"get",
"(",
"\"reference\"",
")",
"==",
"\"feed\"",
":",
"assert",
"self",
".",
"market",
"==",
"se... | Here we obtain the price for the quote and make sure it has
a feed price | [
"Here",
"we",
"obtain",
"the",
"price",
"for",
"the",
"quote",
"and",
"make",
"sure",
"it",
"has",
"a",
"feed",
"price"
] | train | https://github.com/xeroc/stakemachine/blob/c2d5bcfe7c013a93c8c7293bec44ef5690883b16/stakemachine/strategies/walls.py#L80-L90 |
xeroc/stakemachine | stakemachine/strategies/walls.py | Walls.tick | def tick(self, d):
""" ticks come in on every block
"""
if self.test_blocks:
if not (self.counter["blocks"] or 0) % self.test_blocks:
self.test()
self.counter["blocks"] += 1 | python | def tick(self, d):
""" ticks come in on every block
"""
if self.test_blocks:
if not (self.counter["blocks"] or 0) % self.test_blocks:
self.test()
self.counter["blocks"] += 1 | [
"def",
"tick",
"(",
"self",
",",
"d",
")",
":",
"if",
"self",
".",
"test_blocks",
":",
"if",
"not",
"(",
"self",
".",
"counter",
"[",
"\"blocks\"",
"]",
"or",
"0",
")",
"%",
"self",
".",
"test_blocks",
":",
"self",
".",
"test",
"(",
")",
"self",
... | ticks come in on every block | [
"ticks",
"come",
"in",
"on",
"every",
"block"
] | train | https://github.com/xeroc/stakemachine/blob/c2d5bcfe7c013a93c8c7293bec44ef5690883b16/stakemachine/strategies/walls.py#L92-L98 |
xeroc/stakemachine | stakemachine/basestrategy.py | BaseStrategy.orders | def orders(self):
""" Return the bot's open accounts in the current market
"""
self.account.refresh()
return [o for o in self.account.openorders if self.bot["market"] == o.market and self.account.openorders] | python | def orders(self):
""" Return the bot's open accounts in the current market
"""
self.account.refresh()
return [o for o in self.account.openorders if self.bot["market"] == o.market and self.account.openorders] | [
"def",
"orders",
"(",
"self",
")",
":",
"self",
".",
"account",
".",
"refresh",
"(",
")",
"return",
"[",
"o",
"for",
"o",
"in",
"self",
".",
"account",
".",
"openorders",
"if",
"self",
".",
"bot",
"[",
"\"market\"",
"]",
"==",
"o",
".",
"market",
... | Return the bot's open accounts in the current market | [
"Return",
"the",
"bot",
"s",
"open",
"accounts",
"in",
"the",
"current",
"market"
] | train | https://github.com/xeroc/stakemachine/blob/c2d5bcfe7c013a93c8c7293bec44ef5690883b16/stakemachine/basestrategy.py#L116-L120 |
xeroc/stakemachine | stakemachine/basestrategy.py | BaseStrategy._callbackPlaceFillOrders | def _callbackPlaceFillOrders(self, d):
""" This method distringuishes notifications caused by Matched orders
from those caused by placed orders
"""
if isinstance(d, FilledOrder):
self.onOrderMatched(d)
elif isinstance(d, Order):
self.onOrderPlaced(d)
... | python | def _callbackPlaceFillOrders(self, d):
""" This method distringuishes notifications caused by Matched orders
from those caused by placed orders
"""
if isinstance(d, FilledOrder):
self.onOrderMatched(d)
elif isinstance(d, Order):
self.onOrderPlaced(d)
... | [
"def",
"_callbackPlaceFillOrders",
"(",
"self",
",",
"d",
")",
":",
"if",
"isinstance",
"(",
"d",
",",
"FilledOrder",
")",
":",
"self",
".",
"onOrderMatched",
"(",
"d",
")",
"elif",
"isinstance",
"(",
"d",
",",
"Order",
")",
":",
"self",
".",
"onOrderP... | This method distringuishes notifications caused by Matched orders
from those caused by placed orders | [
"This",
"method",
"distringuishes",
"notifications",
"caused",
"by",
"Matched",
"orders",
"from",
"those",
"caused",
"by",
"placed",
"orders"
] | train | https://github.com/xeroc/stakemachine/blob/c2d5bcfe7c013a93c8c7293bec44ef5690883b16/stakemachine/basestrategy.py#L147-L158 |
xeroc/stakemachine | stakemachine/basestrategy.py | BaseStrategy.execute | def execute(self):
""" Execute a bundle of operations
"""
self.bitshares.blocking = "head"
r = self.bitshares.txbuffer.broadcast()
self.bitshares.blocking = False
return r | python | def execute(self):
""" Execute a bundle of operations
"""
self.bitshares.blocking = "head"
r = self.bitshares.txbuffer.broadcast()
self.bitshares.blocking = False
return r | [
"def",
"execute",
"(",
"self",
")",
":",
"self",
".",
"bitshares",
".",
"blocking",
"=",
"\"head\"",
"r",
"=",
"self",
".",
"bitshares",
".",
"txbuffer",
".",
"broadcast",
"(",
")",
"self",
".",
"bitshares",
".",
"blocking",
"=",
"False",
"return",
"r"... | Execute a bundle of operations | [
"Execute",
"a",
"bundle",
"of",
"operations"
] | train | https://github.com/xeroc/stakemachine/blob/c2d5bcfe7c013a93c8c7293bec44ef5690883b16/stakemachine/basestrategy.py#L160-L166 |
xeroc/stakemachine | stakemachine/basestrategy.py | BaseStrategy.cancelall | def cancelall(self):
""" Cancel all orders of this bot
"""
if self.orders:
return self.bitshares.cancel(
[o["id"] for o in self.orders],
account=self.account
) | python | def cancelall(self):
""" Cancel all orders of this bot
"""
if self.orders:
return self.bitshares.cancel(
[o["id"] for o in self.orders],
account=self.account
) | [
"def",
"cancelall",
"(",
"self",
")",
":",
"if",
"self",
".",
"orders",
":",
"return",
"self",
".",
"bitshares",
".",
"cancel",
"(",
"[",
"o",
"[",
"\"id\"",
"]",
"for",
"o",
"in",
"self",
".",
"orders",
"]",
",",
"account",
"=",
"self",
".",
"ac... | Cancel all orders of this bot | [
"Cancel",
"all",
"orders",
"of",
"this",
"bot"
] | train | https://github.com/xeroc/stakemachine/blob/c2d5bcfe7c013a93c8c7293bec44ef5690883b16/stakemachine/basestrategy.py#L168-L175 |
erinxocon/requests-xml | requests_xml.py | BaseParser.raw_xml | def raw_xml(self) -> _RawXML:
"""Bytes representation of the XML content.
(`learn more <http://www.diveintopython3.net/strings.html>`_).
"""
if self._xml:
return self._xml
else:
return etree.tostring(self.element, encoding='unicode').strip().encode(self.en... | python | def raw_xml(self) -> _RawXML:
"""Bytes representation of the XML content.
(`learn more <http://www.diveintopython3.net/strings.html>`_).
"""
if self._xml:
return self._xml
else:
return etree.tostring(self.element, encoding='unicode').strip().encode(self.en... | [
"def",
"raw_xml",
"(",
"self",
")",
"->",
"_RawXML",
":",
"if",
"self",
".",
"_xml",
":",
"return",
"self",
".",
"_xml",
"else",
":",
"return",
"etree",
".",
"tostring",
"(",
"self",
".",
"element",
",",
"encoding",
"=",
"'unicode'",
")",
".",
"strip... | Bytes representation of the XML content.
(`learn more <http://www.diveintopython3.net/strings.html>`_). | [
"Bytes",
"representation",
"of",
"the",
"XML",
"content",
".",
"(",
"learn",
"more",
"<http",
":",
"//",
"www",
".",
"diveintopython3",
".",
"net",
"/",
"strings",
".",
"html",
">",
"_",
")",
"."
] | train | https://github.com/erinxocon/requests-xml/blob/923571ceae4ddd4f2f57a2fc8780d89b50f3e7a1/requests_xml.py#L72-L79 |
erinxocon/requests-xml | requests_xml.py | BaseParser.xml | def xml(self) -> _BaseXML:
"""Unicode representation of the XML content
(`learn more <http://www.diveintopython3.net/strings.html>`_).
"""
if self._xml:
return self.raw_xml.decode(self.encoding)
else:
return etree.tostring(self.element, encoding='unicode')... | python | def xml(self) -> _BaseXML:
"""Unicode representation of the XML content
(`learn more <http://www.diveintopython3.net/strings.html>`_).
"""
if self._xml:
return self.raw_xml.decode(self.encoding)
else:
return etree.tostring(self.element, encoding='unicode')... | [
"def",
"xml",
"(",
"self",
")",
"->",
"_BaseXML",
":",
"if",
"self",
".",
"_xml",
":",
"return",
"self",
".",
"raw_xml",
".",
"decode",
"(",
"self",
".",
"encoding",
")",
"else",
":",
"return",
"etree",
".",
"tostring",
"(",
"self",
".",
"element",
... | Unicode representation of the XML content
(`learn more <http://www.diveintopython3.net/strings.html>`_). | [
"Unicode",
"representation",
"of",
"the",
"XML",
"content",
"(",
"learn",
"more",
"<http",
":",
"//",
"www",
".",
"diveintopython3",
".",
"net",
"/",
"strings",
".",
"html",
">",
"_",
")",
"."
] | train | https://github.com/erinxocon/requests-xml/blob/923571ceae4ddd4f2f57a2fc8780d89b50f3e7a1/requests_xml.py#L83-L90 |
erinxocon/requests-xml | requests_xml.py | BaseParser.pq | def pq(self) -> PyQuery:
"""`PyQuery <https://pythonhosted.org/pyquery/>`_ representation
of the :class:`Element <Element>` or :class:`HTML <HTML>`.
"""
if self._pq is None:
self._pq = PyQuery(self.raw_xml)
return self._pq | python | def pq(self) -> PyQuery:
"""`PyQuery <https://pythonhosted.org/pyquery/>`_ representation
of the :class:`Element <Element>` or :class:`HTML <HTML>`.
"""
if self._pq is None:
self._pq = PyQuery(self.raw_xml)
return self._pq | [
"def",
"pq",
"(",
"self",
")",
"->",
"PyQuery",
":",
"if",
"self",
".",
"_pq",
"is",
"None",
":",
"self",
".",
"_pq",
"=",
"PyQuery",
"(",
"self",
".",
"raw_xml",
")",
"return",
"self",
".",
"_pq"
] | `PyQuery <https://pythonhosted.org/pyquery/>`_ representation
of the :class:`Element <Element>` or :class:`HTML <HTML>`. | [
"PyQuery",
"<https",
":",
"//",
"pythonhosted",
".",
"org",
"/",
"pyquery",
"/",
">",
"_",
"representation",
"of",
"the",
":",
"class",
":",
"Element",
"<Element",
">",
"or",
":",
"class",
":",
"HTML",
"<HTML",
">",
"."
] | train | https://github.com/erinxocon/requests-xml/blob/923571ceae4ddd4f2f57a2fc8780d89b50f3e7a1/requests_xml.py#L105-L112 |
erinxocon/requests-xml | requests_xml.py | BaseParser.lxml | def lxml(self) -> _LXML:
"""`lxml <http://lxml.de>`_ representation of the
:class:`Element <Element>` or :class:`XML <XML>`.
"""
if self._lxml is None:
self._lxml = etree.fromstring(self.raw_xml)
return self._lxml | python | def lxml(self) -> _LXML:
"""`lxml <http://lxml.de>`_ representation of the
:class:`Element <Element>` or :class:`XML <XML>`.
"""
if self._lxml is None:
self._lxml = etree.fromstring(self.raw_xml)
return self._lxml | [
"def",
"lxml",
"(",
"self",
")",
"->",
"_LXML",
":",
"if",
"self",
".",
"_lxml",
"is",
"None",
":",
"self",
".",
"_lxml",
"=",
"etree",
".",
"fromstring",
"(",
"self",
".",
"raw_xml",
")",
"return",
"self",
".",
"_lxml"
] | `lxml <http://lxml.de>`_ representation of the
:class:`Element <Element>` or :class:`XML <XML>`. | [
"lxml",
"<http",
":",
"//",
"lxml",
".",
"de",
">",
"_",
"representation",
"of",
"the",
":",
"class",
":",
"Element",
"<Element",
">",
"or",
":",
"class",
":",
"XML",
"<XML",
">",
"."
] | train | https://github.com/erinxocon/requests-xml/blob/923571ceae4ddd4f2f57a2fc8780d89b50f3e7a1/requests_xml.py#L115-L122 |
erinxocon/requests-xml | requests_xml.py | BaseParser.links | def links(self) -> _Links:
"""All found links on page, in as–is form. Only works for Atom feeds."""
return list(set(x.text for x in self.xpath('//link'))) | python | def links(self) -> _Links:
"""All found links on page, in as–is form. Only works for Atom feeds."""
return list(set(x.text for x in self.xpath('//link'))) | [
"def",
"links",
"(",
"self",
")",
"->",
"_Links",
":",
"return",
"list",
"(",
"set",
"(",
"x",
".",
"text",
"for",
"x",
"in",
"self",
".",
"xpath",
"(",
"'//link'",
")",
")",
")"
] | All found links on page, in as–is form. Only works for Atom feeds. | [
"All",
"found",
"links",
"on",
"page",
"in",
"as–is",
"form",
".",
"Only",
"works",
"for",
"Atom",
"feeds",
"."
] | train | https://github.com/erinxocon/requests-xml/blob/923571ceae4ddd4f2f57a2fc8780d89b50f3e7a1/requests_xml.py#L133-L135 |
erinxocon/requests-xml | requests_xml.py | BaseParser.encoding | def encoding(self) -> _Encoding:
"""The encoding string to be used, extracted from the XML and
:class:`XMLResponse <XMLResponse>` header.
"""
if self._encoding:
return self._encoding
# Scan meta tags for charset.
if self._xml:
self._encoding = htm... | python | def encoding(self) -> _Encoding:
"""The encoding string to be used, extracted from the XML and
:class:`XMLResponse <XMLResponse>` header.
"""
if self._encoding:
return self._encoding
# Scan meta tags for charset.
if self._xml:
self._encoding = htm... | [
"def",
"encoding",
"(",
"self",
")",
"->",
"_Encoding",
":",
"if",
"self",
".",
"_encoding",
":",
"return",
"self",
".",
"_encoding",
"# Scan meta tags for charset.",
"if",
"self",
".",
"_xml",
":",
"self",
".",
"_encoding",
"=",
"html_to_unicode",
"(",
"sel... | The encoding string to be used, extracted from the XML and
:class:`XMLResponse <XMLResponse>` header. | [
"The",
"encoding",
"string",
"to",
"be",
"used",
"extracted",
"from",
"the",
"XML",
"and",
":",
"class",
":",
"XMLResponse",
"<XMLResponse",
">",
"header",
"."
] | train | https://github.com/erinxocon/requests-xml/blob/923571ceae4ddd4f2f57a2fc8780d89b50f3e7a1/requests_xml.py#L157-L168 |
erinxocon/requests-xml | requests_xml.py | BaseParser.json | def json(self, conversion: _Text = 'badgerfish') -> Mapping:
"""A JSON Representation of the XML. Default is badgerfish.
:param conversion: Which conversion method to use. (`learn more <https://github.com/sanand0/xmljson#conventions>`_)
"""
if not self._json:
if conversion ... | python | def json(self, conversion: _Text = 'badgerfish') -> Mapping:
"""A JSON Representation of the XML. Default is badgerfish.
:param conversion: Which conversion method to use. (`learn more <https://github.com/sanand0/xmljson#conventions>`_)
"""
if not self._json:
if conversion ... | [
"def",
"json",
"(",
"self",
",",
"conversion",
":",
"_Text",
"=",
"'badgerfish'",
")",
"->",
"Mapping",
":",
"if",
"not",
"self",
".",
"_json",
":",
"if",
"conversion",
"is",
"'badgerfish'",
":",
"from",
"xmljson",
"import",
"badgerfish",
"as",
"serializer... | A JSON Representation of the XML. Default is badgerfish.
:param conversion: Which conversion method to use. (`learn more <https://github.com/sanand0/xmljson#conventions>`_) | [
"A",
"JSON",
"Representation",
"of",
"the",
"XML",
".",
"Default",
"is",
"badgerfish",
".",
":",
"param",
"conversion",
":",
"Which",
"conversion",
"method",
"to",
"use",
".",
"(",
"learn",
"more",
"<https",
":",
"//",
"github",
".",
"com",
"/",
"sanand0... | train | https://github.com/erinxocon/requests-xml/blob/923571ceae4ddd4f2f57a2fc8780d89b50f3e7a1/requests_xml.py#L177-L203 |
erinxocon/requests-xml | requests_xml.py | BaseParser.xpath | def xpath(self, selector: str, *, first: bool = False, _encoding: str = None) -> _XPath:
"""Given an XPath selector, returns a list of
:class:`Element <Element>` objects or a single one.
:param selector: XPath Selector to use.
:param first: Whether or not to return just the first result... | python | def xpath(self, selector: str, *, first: bool = False, _encoding: str = None) -> _XPath:
"""Given an XPath selector, returns a list of
:class:`Element <Element>` objects or a single one.
:param selector: XPath Selector to use.
:param first: Whether or not to return just the first result... | [
"def",
"xpath",
"(",
"self",
",",
"selector",
":",
"str",
",",
"*",
",",
"first",
":",
"bool",
"=",
"False",
",",
"_encoding",
":",
"str",
"=",
"None",
")",
"->",
"_XPath",
":",
"selected",
"=",
"self",
".",
"lxml",
".",
"xpath",
"(",
"selector",
... | Given an XPath selector, returns a list of
:class:`Element <Element>` objects or a single one.
:param selector: XPath Selector to use.
:param first: Whether or not to return just the first result.
:param _encoding: The encoding format.
If a sub-selector is specified (e.g. ``//a... | [
"Given",
"an",
"XPath",
"selector",
"returns",
"a",
"list",
"of",
":",
"class",
":",
"Element",
"<Element",
">",
"objects",
"or",
"a",
"single",
"one",
"."
] | train | https://github.com/erinxocon/requests-xml/blob/923571ceae4ddd4f2f57a2fc8780d89b50f3e7a1/requests_xml.py#L206-L232 |
erinxocon/requests-xml | requests_xml.py | BaseParser.search | def search(self, template: str, first: bool = False) -> _Result:
"""Search the :class:`Element <Element>` for the given parse
template.
:param template: The Parse template to use.
"""
elements = [r for r in findall(template, self.xml)]
return _get_first_or_list(elements... | python | def search(self, template: str, first: bool = False) -> _Result:
"""Search the :class:`Element <Element>` for the given parse
template.
:param template: The Parse template to use.
"""
elements = [r for r in findall(template, self.xml)]
return _get_first_or_list(elements... | [
"def",
"search",
"(",
"self",
",",
"template",
":",
"str",
",",
"first",
":",
"bool",
"=",
"False",
")",
"->",
"_Result",
":",
"elements",
"=",
"[",
"r",
"for",
"r",
"in",
"findall",
"(",
"template",
",",
"self",
".",
"xml",
")",
"]",
"return",
"... | Search the :class:`Element <Element>` for the given parse
template.
:param template: The Parse template to use. | [
"Search",
"the",
":",
"class",
":",
"Element",
"<Element",
">",
"for",
"the",
"given",
"parse",
"template",
"."
] | train | https://github.com/erinxocon/requests-xml/blob/923571ceae4ddd4f2f57a2fc8780d89b50f3e7a1/requests_xml.py#L235-L243 |
erinxocon/requests-xml | requests_xml.py | BaseParser.find | def find(self, selector: str = '*', containing: _Containing = None, first: bool = False, _encoding: str = None) -> _Find:
"""Given a simple element name, returns a list of
:class:`Element <Element>` objects or a single one.
:param selector: Element name to find.
:param c... | python | def find(self, selector: str = '*', containing: _Containing = None, first: bool = False, _encoding: str = None) -> _Find:
"""Given a simple element name, returns a list of
:class:`Element <Element>` objects or a single one.
:param selector: Element name to find.
:param c... | [
"def",
"find",
"(",
"self",
",",
"selector",
":",
"str",
"=",
"'*'",
",",
"containing",
":",
"_Containing",
"=",
"None",
",",
"first",
":",
"bool",
"=",
"False",
",",
"_encoding",
":",
"str",
"=",
"None",
")",
"->",
"_Find",
":",
"# Convert a single co... | Given a simple element name, returns a list of
:class:`Element <Element>` objects or a single one.
:param selector: Element name to find.
:param containing: If specified, only return elements that contain the provided text.
:param first: Whether or not to return just the... | [
"Given",
"a",
"simple",
"element",
"name",
"returns",
"a",
"list",
"of",
":",
"class",
":",
"Element",
"<Element",
">",
"objects",
"or",
"a",
"single",
"one",
"."
] | train | https://github.com/erinxocon/requests-xml/blob/923571ceae4ddd4f2f57a2fc8780d89b50f3e7a1/requests_xml.py#L246-L279 |
erinxocon/requests-xml | requests_xml.py | XMLSession._handle_response | def _handle_response(response, **kwargs) -> XMLResponse:
"""Requests HTTP Response handler. Attaches .html property to
class:`requests.Response <requests.Response>` objects.
"""
if not response.encoding:
response.encoding = DEFAULT_ENCODING
return response | python | def _handle_response(response, **kwargs) -> XMLResponse:
"""Requests HTTP Response handler. Attaches .html property to
class:`requests.Response <requests.Response>` objects.
"""
if not response.encoding:
response.encoding = DEFAULT_ENCODING
return response | [
"def",
"_handle_response",
"(",
"response",
",",
"*",
"*",
"kwargs",
")",
"->",
"XMLResponse",
":",
"if",
"not",
"response",
".",
"encoding",
":",
"response",
".",
"encoding",
"=",
"DEFAULT_ENCODING",
"return",
"response"
] | Requests HTTP Response handler. Attaches .html property to
class:`requests.Response <requests.Response>` objects. | [
"Requests",
"HTTP",
"Response",
"handler",
".",
"Attaches",
".",
"html",
"property",
"to",
"class",
":",
"requests",
".",
"Response",
"<requests",
".",
"Response",
">",
"objects",
"."
] | train | https://github.com/erinxocon/requests-xml/blob/923571ceae4ddd4f2f57a2fc8780d89b50f3e7a1/requests_xml.py#L410-L417 |
erinxocon/requests-xml | requests_xml.py | XMLSession.request | def request(self, *args, **kwargs) -> XMLResponse:
"""Makes an HTTP Request, with mocked User–Agent headers.
Returns a class:`HTTPResponse <HTTPResponse>`.
"""
# Convert Request object into HTTPRequest object.
r = super(XMLSession, self).request(*args, **kwargs)
return X... | python | def request(self, *args, **kwargs) -> XMLResponse:
"""Makes an HTTP Request, with mocked User–Agent headers.
Returns a class:`HTTPResponse <HTTPResponse>`.
"""
# Convert Request object into HTTPRequest object.
r = super(XMLSession, self).request(*args, **kwargs)
return X... | [
"def",
"request",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"->",
"XMLResponse",
":",
"# Convert Request object into HTTPRequest object.",
"r",
"=",
"super",
"(",
"XMLSession",
",",
"self",
")",
".",
"request",
"(",
"*",
"args",
",",
"*"... | Makes an HTTP Request, with mocked User–Agent headers.
Returns a class:`HTTPResponse <HTTPResponse>`. | [
"Makes",
"an",
"HTTP",
"Request",
"with",
"mocked",
"User–Agent",
"headers",
".",
"Returns",
"a",
"class",
":",
"HTTPResponse",
"<HTTPResponse",
">",
"."
] | train | https://github.com/erinxocon/requests-xml/blob/923571ceae4ddd4f2f57a2fc8780d89b50f3e7a1/requests_xml.py#L419-L426 |
erinxocon/requests-xml | requests_xml.py | AsyncXMLSession.response_hook | def response_hook(response, **kwargs) -> XMLResponse:
""" Change response enconding and replace it by a HTMLResponse. """
response.encoding = DEFAULT_ENCODING
return XMLResponse._from_response(response) | python | def response_hook(response, **kwargs) -> XMLResponse:
""" Change response enconding and replace it by a HTMLResponse. """
response.encoding = DEFAULT_ENCODING
return XMLResponse._from_response(response) | [
"def",
"response_hook",
"(",
"response",
",",
"*",
"*",
"kwargs",
")",
"->",
"XMLResponse",
":",
"response",
".",
"encoding",
"=",
"DEFAULT_ENCODING",
"return",
"XMLResponse",
".",
"_from_response",
"(",
"response",
")"
] | Change response enconding and replace it by a HTMLResponse. | [
"Change",
"response",
"enconding",
"and",
"replace",
"it",
"by",
"a",
"HTMLResponse",
"."
] | train | https://github.com/erinxocon/requests-xml/blob/923571ceae4ddd4f2f57a2fc8780d89b50f3e7a1/requests_xml.py#L452-L455 |
itamarst/crochet | examples/scheduling.py | _ExchangeRate.start | def start(self):
"""Start the background process."""
self._lc = LoopingCall(self._download)
# Run immediately, and then every 30 seconds:
self._lc.start(30, now=True) | python | def start(self):
"""Start the background process."""
self._lc = LoopingCall(self._download)
# Run immediately, and then every 30 seconds:
self._lc.start(30, now=True) | [
"def",
"start",
"(",
"self",
")",
":",
"self",
".",
"_lc",
"=",
"LoopingCall",
"(",
"self",
".",
"_download",
")",
"# Run immediately, and then every 30 seconds:",
"self",
".",
"_lc",
".",
"start",
"(",
"30",
",",
"now",
"=",
"True",
")"
] | Start the background process. | [
"Start",
"the",
"background",
"process",
"."
] | train | https://github.com/itamarst/crochet/blob/ecfc22cefa90f3dfbafa71883c1470e7294f2b6d/examples/scheduling.py#L42-L46 |
itamarst/crochet | examples/scheduling.py | _ExchangeRate._download | def _download(self):
"""Download the page."""
print("Downloading!")
def parse(result):
print("Got %r back from Yahoo." % (result,))
values = result.strip().split(",")
self._value = float(values[1])
d = getPage(
"http://download.finance.yaho... | python | def _download(self):
"""Download the page."""
print("Downloading!")
def parse(result):
print("Got %r back from Yahoo." % (result,))
values = result.strip().split(",")
self._value = float(values[1])
d = getPage(
"http://download.finance.yaho... | [
"def",
"_download",
"(",
"self",
")",
":",
"print",
"(",
"\"Downloading!\"",
")",
"def",
"parse",
"(",
"result",
")",
":",
"print",
"(",
"\"Got %r back from Yahoo.\"",
"%",
"(",
"result",
",",
")",
")",
"values",
"=",
"result",
".",
"strip",
"(",
")",
... | Download the page. | [
"Download",
"the",
"page",
"."
] | train | https://github.com/itamarst/crochet/blob/ecfc22cefa90f3dfbafa71883c1470e7294f2b6d/examples/scheduling.py#L48-L60 |
itamarst/crochet | crochet/_eventloop.py | ResultRegistry.register | def register(self, result):
"""
Register an EventualResult.
May be called in any thread.
"""
if self._stopped:
raise ReactorStopped()
self._results.add(result) | python | def register(self, result):
"""
Register an EventualResult.
May be called in any thread.
"""
if self._stopped:
raise ReactorStopped()
self._results.add(result) | [
"def",
"register",
"(",
"self",
",",
"result",
")",
":",
"if",
"self",
".",
"_stopped",
":",
"raise",
"ReactorStopped",
"(",
")",
"self",
".",
"_results",
".",
"add",
"(",
"result",
")"
] | Register an EventualResult.
May be called in any thread. | [
"Register",
"an",
"EventualResult",
"."
] | train | https://github.com/itamarst/crochet/blob/ecfc22cefa90f3dfbafa71883c1470e7294f2b6d/crochet/_eventloop.py#L80-L88 |
itamarst/crochet | crochet/_eventloop.py | ResultRegistry.stop | def stop(self):
"""
Indicate no more results will get pushed into EventualResults, since
the reactor has stopped.
This should be called in the reactor thread.
"""
self._stopped = True
for result in self._results:
result._set_result(Failure(ReactorStop... | python | def stop(self):
"""
Indicate no more results will get pushed into EventualResults, since
the reactor has stopped.
This should be called in the reactor thread.
"""
self._stopped = True
for result in self._results:
result._set_result(Failure(ReactorStop... | [
"def",
"stop",
"(",
"self",
")",
":",
"self",
".",
"_stopped",
"=",
"True",
"for",
"result",
"in",
"self",
".",
"_results",
":",
"result",
".",
"_set_result",
"(",
"Failure",
"(",
"ReactorStopped",
"(",
")",
")",
")"
] | Indicate no more results will get pushed into EventualResults, since
the reactor has stopped.
This should be called in the reactor thread. | [
"Indicate",
"no",
"more",
"results",
"will",
"get",
"pushed",
"into",
"EventualResults",
"since",
"the",
"reactor",
"has",
"stopped",
"."
] | train | https://github.com/itamarst/crochet/blob/ecfc22cefa90f3dfbafa71883c1470e7294f2b6d/crochet/_eventloop.py#L91-L100 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.