repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
kmedian/korr | korr/find_unrelated.py | find_unrelated | def find_unrelated(x, plim=0.1, axis=0):
"""Find indicies of insignificant un-/correlated variables
Example:
--------
i, j = find_unrelated(x, plim, rlim)
"""
# transpose if axis<>0
if axis is not 0:
x = x.T
# read dimensions and allocate variables
_, c = x.shape
p... | python | def find_unrelated(x, plim=0.1, axis=0):
"""Find indicies of insignificant un-/correlated variables
Example:
--------
i, j = find_unrelated(x, plim, rlim)
"""
# transpose if axis<>0
if axis is not 0:
x = x.T
# read dimensions and allocate variables
_, c = x.shape
p... | [
"def",
"find_unrelated",
"(",
"x",
",",
"plim",
"=",
"0.1",
",",
"axis",
"=",
"0",
")",
":",
"# transpose if axis<>0",
"if",
"axis",
"is",
"not",
"0",
":",
"x",
"=",
"x",
".",
"T",
"# read dimensions and allocate variables",
"_",
",",
"c",
"=",
"x",
".... | Find indicies of insignificant un-/correlated variables
Example:
--------
i, j = find_unrelated(x, plim, rlim) | [
"Find",
"indicies",
"of",
"insignificant",
"un",
"-",
"/",
"correlated",
"variables"
] | train | https://github.com/kmedian/korr/blob/4eb86fc14b1fc1b69204069b7753d115b327c937/korr/find_unrelated.py#L5-L28 |
QualiSystems/cloudshell-networking-devices | cloudshell/devices/runners/connectivity_runner.py | ConnectivityRunner.apply_connectivity_changes | def apply_connectivity_changes(self, request):
""" Handle apply connectivity changes request json, trigger add or remove vlan methods,
get responce from them and create json response
:param request: json with all required action to configure or remove vlans from certain port
:return Ser... | python | def apply_connectivity_changes(self, request):
""" Handle apply connectivity changes request json, trigger add or remove vlan methods,
get responce from them and create json response
:param request: json with all required action to configure or remove vlans from certain port
:return Ser... | [
"def",
"apply_connectivity_changes",
"(",
"self",
",",
"request",
")",
":",
"if",
"request",
"is",
"None",
"or",
"request",
"==",
"\"\"",
":",
"raise",
"Exception",
"(",
"self",
".",
"__class__",
".",
"__name__",
",",
"\"request is None or empty\"",
")",
"hold... | Handle apply connectivity changes request json, trigger add or remove vlan methods,
get responce from them and create json response
:param request: json with all required action to configure or remove vlans from certain port
:return Serialized DriverResponseRoot to json
:rtype json | [
"Handle",
"apply",
"connectivity",
"changes",
"request",
"json",
"trigger",
"add",
"or",
"remove",
"vlan",
"methods",
"get",
"responce",
"from",
"them",
"and",
"create",
"json",
"response"
] | train | https://github.com/QualiSystems/cloudshell-networking-devices/blob/009aab33edb30035b52fe10dbb91db61c95ba4d9/cloudshell/devices/runners/connectivity_runner.py#L58-L145 |
QualiSystems/cloudshell-networking-devices | cloudshell/devices/runners/connectivity_runner.py | ConnectivityRunner._validate_request_action | def _validate_request_action(self, action):
""" Validate action from the request json,
according to APPLY_CONNECTIVITY_CHANGES_ACTION_REQUIRED_ATTRIBUTE_LIST
"""
is_fail = False
fail_attribute = ""
for class_attribute in self.APPLY_CONNECTIVITY_CHANGES_ACTION_REQUIRED... | python | def _validate_request_action(self, action):
""" Validate action from the request json,
according to APPLY_CONNECTIVITY_CHANGES_ACTION_REQUIRED_ATTRIBUTE_LIST
"""
is_fail = False
fail_attribute = ""
for class_attribute in self.APPLY_CONNECTIVITY_CHANGES_ACTION_REQUIRED... | [
"def",
"_validate_request_action",
"(",
"self",
",",
"action",
")",
":",
"is_fail",
"=",
"False",
"fail_attribute",
"=",
"\"\"",
"for",
"class_attribute",
"in",
"self",
".",
"APPLY_CONNECTIVITY_CHANGES_ACTION_REQUIRED_ATTRIBUTE_LIST",
":",
"if",
"type",
"(",
"class_at... | Validate action from the request json,
according to APPLY_CONNECTIVITY_CHANGES_ACTION_REQUIRED_ATTRIBUTE_LIST | [
"Validate",
"action",
"from",
"the",
"request",
"json",
"according",
"to",
"APPLY_CONNECTIVITY_CHANGES_ACTION_REQUIRED_ATTRIBUTE_LIST"
] | train | https://github.com/QualiSystems/cloudshell-networking-devices/blob/009aab33edb30035b52fe10dbb91db61c95ba4d9/cloudshell/devices/runners/connectivity_runner.py#L147-L169 |
QualiSystems/cloudshell-networking-devices | cloudshell/devices/runners/connectivity_runner.py | ConnectivityRunner._get_vlan_list | def _get_vlan_list(self, vlan_str):
""" Get VLAN list from input string
:param vlan_str:
:return list of VLANs or Exception
"""
result = set()
for splitted_vlan in vlan_str.split(","):
if "-" not in splitted_vlan:
if validate_vlan_number(spli... | python | def _get_vlan_list(self, vlan_str):
""" Get VLAN list from input string
:param vlan_str:
:return list of VLANs or Exception
"""
result = set()
for splitted_vlan in vlan_str.split(","):
if "-" not in splitted_vlan:
if validate_vlan_number(spli... | [
"def",
"_get_vlan_list",
"(",
"self",
",",
"vlan_str",
")",
":",
"result",
"=",
"set",
"(",
")",
"for",
"splitted_vlan",
"in",
"vlan_str",
".",
"split",
"(",
"\",\"",
")",
":",
"if",
"\"-\"",
"not",
"in",
"splitted_vlan",
":",
"if",
"validate_vlan_number",... | Get VLAN list from input string
:param vlan_str:
:return list of VLANs or Exception | [
"Get",
"VLAN",
"list",
"from",
"input",
"string"
] | train | https://github.com/QualiSystems/cloudshell-networking-devices/blob/009aab33edb30035b52fe10dbb91db61c95ba4d9/cloudshell/devices/runners/connectivity_runner.py#L171-L201 |
QualiSystems/cloudshell-networking-devices | cloudshell/devices/runners/connectivity_runner.py | ConnectivityRunner.add_vlan | def add_vlan(self, vlan_id, full_name, port_mode, qnq, c_tag):
""" Run flow to add VLAN(s) to interface
:param vlan_id: Already validated number of VLAN(s)
:param full_name: Full interface name. Example: 2950/Chassis 0/FastEthernet0-23
:param port_mode: port mode type. Should be trunk o... | python | def add_vlan(self, vlan_id, full_name, port_mode, qnq, c_tag):
""" Run flow to add VLAN(s) to interface
:param vlan_id: Already validated number of VLAN(s)
:param full_name: Full interface name. Example: 2950/Chassis 0/FastEthernet0-23
:param port_mode: port mode type. Should be trunk o... | [
"def",
"add_vlan",
"(",
"self",
",",
"vlan_id",
",",
"full_name",
",",
"port_mode",
",",
"qnq",
",",
"c_tag",
")",
":",
"try",
":",
"action_result",
"=",
"self",
".",
"add_vlan_flow",
".",
"execute_flow",
"(",
"vlan_range",
"=",
"vlan_id",
",",
"port_mode"... | Run flow to add VLAN(s) to interface
:param vlan_id: Already validated number of VLAN(s)
:param full_name: Full interface name. Example: 2950/Chassis 0/FastEthernet0-23
:param port_mode: port mode type. Should be trunk or access
:param qnq:
:param c_tag: | [
"Run",
"flow",
"to",
"add",
"VLAN",
"(",
"s",
")",
"to",
"interface"
] | train | https://github.com/QualiSystems/cloudshell-networking-devices/blob/009aab33edb30035b52fe10dbb91db61c95ba4d9/cloudshell/devices/runners/connectivity_runner.py#L203-L222 |
QualiSystems/cloudshell-networking-devices | cloudshell/devices/runners/connectivity_runner.py | ConnectivityRunner.remove_vlan | def remove_vlan(self, vlan_id, full_name, port_mode):
"""
Run flow to remove VLAN(s) from interface
:param vlan_id: Already validated number of VLAN(s)
:param full_name: Full interface name. Example: 2950/Chassis 0/FastEthernet0-23
:param port_mode: port mode type. Should be trun... | python | def remove_vlan(self, vlan_id, full_name, port_mode):
"""
Run flow to remove VLAN(s) from interface
:param vlan_id: Already validated number of VLAN(s)
:param full_name: Full interface name. Example: 2950/Chassis 0/FastEthernet0-23
:param port_mode: port mode type. Should be trun... | [
"def",
"remove_vlan",
"(",
"self",
",",
"vlan_id",
",",
"full_name",
",",
"port_mode",
")",
":",
"try",
":",
"action_result",
"=",
"self",
".",
"remove_vlan_flow",
".",
"execute_flow",
"(",
"vlan_range",
"=",
"vlan_id",
",",
"port_name",
"=",
"full_name",
",... | Run flow to remove VLAN(s) from interface
:param vlan_id: Already validated number of VLAN(s)
:param full_name: Full interface name. Example: 2950/Chassis 0/FastEthernet0-23
:param port_mode: port mode type. Should be trunk or access | [
"Run",
"flow",
"to",
"remove",
"VLAN",
"(",
"s",
")",
"from",
"interface",
":",
"param",
"vlan_id",
":",
"Already",
"validated",
"number",
"of",
"VLAN",
"(",
"s",
")",
":",
"param",
"full_name",
":",
"Full",
"interface",
"name",
".",
"Example",
":",
"2... | train | https://github.com/QualiSystems/cloudshell-networking-devices/blob/009aab33edb30035b52fe10dbb91db61c95ba4d9/cloudshell/devices/runners/connectivity_runner.py#L224-L240 |
eumis/pyviews | pyviews/rendering/views.py | render_view | def render_view(view_name, **args):
'''Process view and return root Node'''
try:
root_xml = get_view_root(view_name)
return render(root_xml, **args)
except CoreError as error:
error.add_view_info(ViewInfo(view_name, None))
raise
except:
info = exc_info()
e... | python | def render_view(view_name, **args):
'''Process view and return root Node'''
try:
root_xml = get_view_root(view_name)
return render(root_xml, **args)
except CoreError as error:
error.add_view_info(ViewInfo(view_name, None))
raise
except:
info = exc_info()
e... | [
"def",
"render_view",
"(",
"view_name",
",",
"*",
"*",
"args",
")",
":",
"try",
":",
"root_xml",
"=",
"get_view_root",
"(",
"view_name",
")",
"return",
"render",
"(",
"root_xml",
",",
"*",
"*",
"args",
")",
"except",
"CoreError",
"as",
"error",
":",
"e... | Process view and return root Node | [
"Process",
"view",
"and",
"return",
"root",
"Node"
] | train | https://github.com/eumis/pyviews/blob/80a868242ee9cdc6f4ded594b3e0544cc238ed55/pyviews/rendering/views.py#L13-L25 |
eumis/pyviews | pyviews/rendering/views.py | get_view_root | def get_view_root(view_name: str) -> XmlNode:
'''Parses xml file and return root XmlNode'''
try:
path = join(deps.views_folder, '{0}.{1}'.format(view_name, deps.view_ext))
parser = Parser()
if path not in _XML_CACHE:
with open(path, 'rb') as xml_file:
_XML_CAC... | python | def get_view_root(view_name: str) -> XmlNode:
'''Parses xml file and return root XmlNode'''
try:
path = join(deps.views_folder, '{0}.{1}'.format(view_name, deps.view_ext))
parser = Parser()
if path not in _XML_CACHE:
with open(path, 'rb') as xml_file:
_XML_CAC... | [
"def",
"get_view_root",
"(",
"view_name",
":",
"str",
")",
"->",
"XmlNode",
":",
"try",
":",
"path",
"=",
"join",
"(",
"deps",
".",
"views_folder",
",",
"'{0}.{1}'",
".",
"format",
"(",
"view_name",
",",
"deps",
".",
"view_ext",
")",
")",
"parser",
"="... | Parses xml file and return root XmlNode | [
"Parses",
"xml",
"file",
"and",
"return",
"root",
"XmlNode"
] | train | https://github.com/eumis/pyviews/blob/80a868242ee9cdc6f4ded594b3e0544cc238ed55/pyviews/rendering/views.py#L29-L50 |
eumis/pyviews | pyviews/rendering/modifiers.py | import_global | def import_global(node: Node, key: str, path: Any):
"""Import passed module, class, function full name and stores it to node's globals"""
node.node_globals[key] = import_path(path) | python | def import_global(node: Node, key: str, path: Any):
"""Import passed module, class, function full name and stores it to node's globals"""
node.node_globals[key] = import_path(path) | [
"def",
"import_global",
"(",
"node",
":",
"Node",
",",
"key",
":",
"str",
",",
"path",
":",
"Any",
")",
":",
"node",
".",
"node_globals",
"[",
"key",
"]",
"=",
"import_path",
"(",
"path",
")"
] | Import passed module, class, function full name and stores it to node's globals | [
"Import",
"passed",
"module",
"class",
"function",
"full",
"name",
"and",
"stores",
"it",
"to",
"node",
"s",
"globals"
] | train | https://github.com/eumis/pyviews/blob/80a868242ee9cdc6f4ded594b3e0544cc238ed55/pyviews/rendering/modifiers.py#L8-L10 |
eumis/pyviews | pyviews/rendering/modifiers.py | inject_global | def inject_global(node: Node, global_key: str, inject_key: Any):
"""Resolves passed dependency and stores it to node's globals"""
value = get_current_scope().container.get(inject_key)
set_global(node, global_key, value) | python | def inject_global(node: Node, global_key: str, inject_key: Any):
"""Resolves passed dependency and stores it to node's globals"""
value = get_current_scope().container.get(inject_key)
set_global(node, global_key, value) | [
"def",
"inject_global",
"(",
"node",
":",
"Node",
",",
"global_key",
":",
"str",
",",
"inject_key",
":",
"Any",
")",
":",
"value",
"=",
"get_current_scope",
"(",
")",
".",
"container",
".",
"get",
"(",
"inject_key",
")",
"set_global",
"(",
"node",
",",
... | Resolves passed dependency and stores it to node's globals | [
"Resolves",
"passed",
"dependency",
"and",
"stores",
"it",
"to",
"node",
"s",
"globals"
] | train | https://github.com/eumis/pyviews/blob/80a868242ee9cdc6f4ded594b3e0544cc238ed55/pyviews/rendering/modifiers.py#L13-L16 |
eumis/pyviews | pyviews/rendering/modifiers.py | set_global | def set_global(node: Node, key: str, value: Any):
"""Adds passed value to node's globals"""
node.node_globals[key] = value | python | def set_global(node: Node, key: str, value: Any):
"""Adds passed value to node's globals"""
node.node_globals[key] = value | [
"def",
"set_global",
"(",
"node",
":",
"Node",
",",
"key",
":",
"str",
",",
"value",
":",
"Any",
")",
":",
"node",
".",
"node_globals",
"[",
"key",
"]",
"=",
"value"
] | Adds passed value to node's globals | [
"Adds",
"passed",
"value",
"to",
"node",
"s",
"globals"
] | train | https://github.com/eumis/pyviews/blob/80a868242ee9cdc6f4ded594b3e0544cc238ed55/pyviews/rendering/modifiers.py#L19-L21 |
eumis/pyviews | pyviews/rendering/modifiers.py | call | def call(node: Node, key: str, value: Any):
"""Calls node or node instance method"""
value = _to_list(value)
if not value or not isinstance(value[-1], dict):
value.append({})
args = value[0:-1]
kwargs = value[-1]
node.__dict__[key](*args, **kwargs) | python | def call(node: Node, key: str, value: Any):
"""Calls node or node instance method"""
value = _to_list(value)
if not value or not isinstance(value[-1], dict):
value.append({})
args = value[0:-1]
kwargs = value[-1]
node.__dict__[key](*args, **kwargs) | [
"def",
"call",
"(",
"node",
":",
"Node",
",",
"key",
":",
"str",
",",
"value",
":",
"Any",
")",
":",
"value",
"=",
"_to_list",
"(",
"value",
")",
"if",
"not",
"value",
"or",
"not",
"isinstance",
"(",
"value",
"[",
"-",
"1",
"]",
",",
"dict",
")... | Calls node or node instance method | [
"Calls",
"node",
"or",
"node",
"instance",
"method"
] | train | https://github.com/eumis/pyviews/blob/80a868242ee9cdc6f4ded594b3e0544cc238ed55/pyviews/rendering/modifiers.py#L24-L31 |
upsight/doctor | doctor/docs/flask.py | AutoFlaskHarness.iter_annotations | def iter_annotations(self):
"""Yield a tuple for each Flask handler containing annotated methods.
Each tuple contains a heading, routing rule, the view class associated
with the rule, and the annotations for the methods in that class.
"""
# Need to store a list of route, view_cl... | python | def iter_annotations(self):
"""Yield a tuple for each Flask handler containing annotated methods.
Each tuple contains a heading, routing rule, the view class associated
with the rule, and the annotations for the methods in that class.
"""
# Need to store a list of route, view_cl... | [
"def",
"iter_annotations",
"(",
"self",
")",
":",
"# Need to store a list of route, view_class, and annotations by a",
"# section key so that all methods of a resource are kept together in",
"# the documentation. The key of the section will be the heading that",
"# the route documentation goes un... | Yield a tuple for each Flask handler containing annotated methods.
Each tuple contains a heading, routing rule, the view class associated
with the rule, and the annotations for the methods in that class. | [
"Yield",
"a",
"tuple",
"for",
"each",
"Flask",
"handler",
"containing",
"annotated",
"methods",
"."
] | train | https://github.com/upsight/doctor/blob/2cf1d433f6f1aa1355644b449a757c0660793cdd/doctor/docs/flask.py#L41-L81 |
upsight/doctor | doctor/docs/flask.py | AutoFlaskHarness.request | def request(self, rule, view_class, annotation):
"""Make a request against the app.
This attempts to use the schema to replace any url params in the path
pattern. If there are any unused parameters in the schema, after
substituting the ones in the path, they will be sent as query string... | python | def request(self, rule, view_class, annotation):
"""Make a request against the app.
This attempts to use the schema to replace any url params in the path
pattern. If there are any unused parameters in the schema, after
substituting the ones in the path, they will be sent as query string... | [
"def",
"request",
"(",
"self",
",",
"rule",
",",
"view_class",
",",
"annotation",
")",
":",
"headers",
"=",
"self",
".",
"_get_headers",
"(",
"rule",
",",
"annotation",
")",
"example_values",
"=",
"self",
".",
"_get_example_values",
"(",
"rule",
",",
"anno... | Make a request against the app.
This attempts to use the schema to replace any url params in the path
pattern. If there are any unused parameters in the schema, after
substituting the ones in the path, they will be sent as query string
parameters or form parameters. The substituted valu... | [
"Make",
"a",
"request",
"against",
"the",
"app",
"."
] | train | https://github.com/upsight/doctor/blob/2cf1d433f6f1aa1355644b449a757c0660793cdd/doctor/docs/flask.py#L83-L135 |
eumis/pyviews | pyviews/core/observable.py | Observable.observe | def observe(self, key: str, callback: Callable[[Any, Any], None]):
"""Subscribes to key changes"""
if key not in self._callbacks:
self._add_key(key)
self._callbacks[key].append(callback) | python | def observe(self, key: str, callback: Callable[[Any, Any], None]):
"""Subscribes to key changes"""
if key not in self._callbacks:
self._add_key(key)
self._callbacks[key].append(callback) | [
"def",
"observe",
"(",
"self",
",",
"key",
":",
"str",
",",
"callback",
":",
"Callable",
"[",
"[",
"Any",
",",
"Any",
"]",
",",
"None",
"]",
")",
":",
"if",
"key",
"not",
"in",
"self",
".",
"_callbacks",
":",
"self",
".",
"_add_key",
"(",
"key",
... | Subscribes to key changes | [
"Subscribes",
"to",
"key",
"changes"
] | train | https://github.com/eumis/pyviews/blob/80a868242ee9cdc6f4ded594b3e0544cc238ed55/pyviews/core/observable.py#L12-L16 |
eumis/pyviews | pyviews/core/observable.py | Observable.release | def release(self, key: str, callback: Callable[[Any, Any], None]):
"""Releases callback from key changes"""
try:
self._callbacks[key].remove(callback)
except (KeyError, ValueError):
pass | python | def release(self, key: str, callback: Callable[[Any, Any], None]):
"""Releases callback from key changes"""
try:
self._callbacks[key].remove(callback)
except (KeyError, ValueError):
pass | [
"def",
"release",
"(",
"self",
",",
"key",
":",
"str",
",",
"callback",
":",
"Callable",
"[",
"[",
"Any",
",",
"Any",
"]",
",",
"None",
"]",
")",
":",
"try",
":",
"self",
".",
"_callbacks",
"[",
"key",
"]",
".",
"remove",
"(",
"callback",
")",
... | Releases callback from key changes | [
"Releases",
"callback",
"from",
"key",
"changes"
] | train | https://github.com/eumis/pyviews/blob/80a868242ee9cdc6f4ded594b3e0544cc238ed55/pyviews/core/observable.py#L30-L35 |
eumis/pyviews | pyviews/core/observable.py | ObservableEntity.observe | def observe(self, key, callback: Callable[[Any, Any], None]):
"""Subscribes to key changes"""
if key not in self.__dict__ and key not in self._callbacks:
raise KeyError('Entity ' + str(self) + 'doesn''t have attribute' + key)
super().observe(key, callback) | python | def observe(self, key, callback: Callable[[Any, Any], None]):
"""Subscribes to key changes"""
if key not in self.__dict__ and key not in self._callbacks:
raise KeyError('Entity ' + str(self) + 'doesn''t have attribute' + key)
super().observe(key, callback) | [
"def",
"observe",
"(",
"self",
",",
"key",
",",
"callback",
":",
"Callable",
"[",
"[",
"Any",
",",
"Any",
"]",
",",
"None",
"]",
")",
":",
"if",
"key",
"not",
"in",
"self",
".",
"__dict__",
"and",
"key",
"not",
"in",
"self",
".",
"_callbacks",
":... | Subscribes to key changes | [
"Subscribes",
"to",
"key",
"changes"
] | train | https://github.com/eumis/pyviews/blob/80a868242ee9cdc6f4ded594b3e0544cc238ed55/pyviews/core/observable.py#L50-L54 |
eumis/pyviews | pyviews/core/observable.py | InheritedDict.inherit | def inherit(self, parent):
"""Inherit passed dictionary"""
if self._parent == parent:
return
if self._parent:
self._parent.release_all(self._parent_changed)
self_values = {key: self._container[key] for key in self._own_keys}
self._container = {**parent.to_... | python | def inherit(self, parent):
"""Inherit passed dictionary"""
if self._parent == parent:
return
if self._parent:
self._parent.release_all(self._parent_changed)
self_values = {key: self._container[key] for key in self._own_keys}
self._container = {**parent.to_... | [
"def",
"inherit",
"(",
"self",
",",
"parent",
")",
":",
"if",
"self",
".",
"_parent",
"==",
"parent",
":",
"return",
"if",
"self",
".",
"_parent",
":",
"self",
".",
"_parent",
".",
"release_all",
"(",
"self",
".",
"_parent_changed",
")",
"self_values",
... | Inherit passed dictionary | [
"Inherit",
"passed",
"dictionary"
] | train | https://github.com/eumis/pyviews/blob/80a868242ee9cdc6f4ded594b3e0544cc238ed55/pyviews/core/observable.py#L99-L108 |
eumis/pyviews | pyviews/core/observable.py | InheritedDict.observe_all | def observe_all(self, callback: Callable[[str, Any, Any], None]):
"""Subscribes to all keys changes"""
self._all_callbacks.append(callback) | python | def observe_all(self, callback: Callable[[str, Any, Any], None]):
"""Subscribes to all keys changes"""
self._all_callbacks.append(callback) | [
"def",
"observe_all",
"(",
"self",
",",
"callback",
":",
"Callable",
"[",
"[",
"str",
",",
"Any",
",",
"Any",
"]",
",",
"None",
"]",
")",
":",
"self",
".",
"_all_callbacks",
".",
"append",
"(",
"callback",
")"
] | Subscribes to all keys changes | [
"Subscribes",
"to",
"all",
"keys",
"changes"
] | train | https://github.com/eumis/pyviews/blob/80a868242ee9cdc6f4ded594b3e0544cc238ed55/pyviews/core/observable.py#L110-L112 |
eumis/pyviews | pyviews/core/observable.py | InheritedDict.release_all | def release_all(self, callback: Callable[[str, Any, Any], None]):
"""Releases callback from all keys changes"""
self._all_callbacks.remove(callback) | python | def release_all(self, callback: Callable[[str, Any, Any], None]):
"""Releases callback from all keys changes"""
self._all_callbacks.remove(callback) | [
"def",
"release_all",
"(",
"self",
",",
"callback",
":",
"Callable",
"[",
"[",
"str",
",",
"Any",
",",
"Any",
"]",
",",
"None",
"]",
")",
":",
"self",
".",
"_all_callbacks",
".",
"remove",
"(",
"callback",
")"
] | Releases callback from all keys changes | [
"Releases",
"callback",
"from",
"all",
"keys",
"changes"
] | train | https://github.com/eumis/pyviews/blob/80a868242ee9cdc6f4ded594b3e0544cc238ed55/pyviews/core/observable.py#L124-L126 |
eumis/pyviews | pyviews/core/observable.py | InheritedDict.remove_key | def remove_key(self, key):
"""Remove own key, value"""
try:
self._own_keys.discard(key)
if self._parent and self._parent.has_key(key):
self._container[key] = self._parent[key]
else:
del self._container[key]
except KeyError:
... | python | def remove_key(self, key):
"""Remove own key, value"""
try:
self._own_keys.discard(key)
if self._parent and self._parent.has_key(key):
self._container[key] = self._parent[key]
else:
del self._container[key]
except KeyError:
... | [
"def",
"remove_key",
"(",
"self",
",",
"key",
")",
":",
"try",
":",
"self",
".",
"_own_keys",
".",
"discard",
"(",
"key",
")",
"if",
"self",
".",
"_parent",
"and",
"self",
".",
"_parent",
".",
"has_key",
"(",
"key",
")",
":",
"self",
".",
"_contain... | Remove own key, value | [
"Remove",
"own",
"key",
"value"
] | train | https://github.com/eumis/pyviews/blob/80a868242ee9cdc6f4ded594b3e0544cc238ed55/pyviews/core/observable.py#L136-L145 |
eumis/pyviews | pyviews/core/binding.py | Binder.add_rule | def add_rule(self, binding_type: str, rule: BindingRule):
"""Adds new rule"""
if binding_type not in self._rules:
self._rules[binding_type] = []
self._rules[binding_type].insert(0, rule) | python | def add_rule(self, binding_type: str, rule: BindingRule):
"""Adds new rule"""
if binding_type not in self._rules:
self._rules[binding_type] = []
self._rules[binding_type].insert(0, rule) | [
"def",
"add_rule",
"(",
"self",
",",
"binding_type",
":",
"str",
",",
"rule",
":",
"BindingRule",
")",
":",
"if",
"binding_type",
"not",
"in",
"self",
".",
"_rules",
":",
"self",
".",
"_rules",
"[",
"binding_type",
"]",
"=",
"[",
"]",
"self",
".",
"_... | Adds new rule | [
"Adds",
"new",
"rule"
] | train | https://github.com/eumis/pyviews/blob/80a868242ee9cdc6f4ded594b3e0544cc238ed55/pyviews/core/binding.py#L53-L58 |
eumis/pyviews | pyviews/core/binding.py | Binder.find_rule | def find_rule(self, binding_type: str, **args):
"""Finds rule by binding type and args"""
try:
rules = self._rules[binding_type]
return next(rule for rule in rules if rule.suitable(**args))
except (KeyError, StopIteration):
return None | python | def find_rule(self, binding_type: str, **args):
"""Finds rule by binding type and args"""
try:
rules = self._rules[binding_type]
return next(rule for rule in rules if rule.suitable(**args))
except (KeyError, StopIteration):
return None | [
"def",
"find_rule",
"(",
"self",
",",
"binding_type",
":",
"str",
",",
"*",
"*",
"args",
")",
":",
"try",
":",
"rules",
"=",
"self",
".",
"_rules",
"[",
"binding_type",
"]",
"return",
"next",
"(",
"rule",
"for",
"rule",
"in",
"rules",
"if",
"rule",
... | Finds rule by binding type and args | [
"Finds",
"rule",
"by",
"binding",
"type",
"and",
"args"
] | train | https://github.com/eumis/pyviews/blob/80a868242ee9cdc6f4ded594b3e0544cc238ed55/pyviews/core/binding.py#L60-L66 |
eumis/pyviews | pyviews/core/binding.py | Binder.apply | def apply(self, binding_type, **args):
"""Returns apply function"""
rule = self.find_rule(binding_type, **args)
if rule is None:
error = BindingError('Binding rule is not found')
error.add_info('Binding type', binding_type)
error.add_info('args', args)
... | python | def apply(self, binding_type, **args):
"""Returns apply function"""
rule = self.find_rule(binding_type, **args)
if rule is None:
error = BindingError('Binding rule is not found')
error.add_info('Binding type', binding_type)
error.add_info('args', args)
... | [
"def",
"apply",
"(",
"self",
",",
"binding_type",
",",
"*",
"*",
"args",
")",
":",
"rule",
"=",
"self",
".",
"find_rule",
"(",
"binding_type",
",",
"*",
"*",
"args",
")",
"if",
"rule",
"is",
"None",
":",
"error",
"=",
"BindingError",
"(",
"'Binding r... | Returns apply function | [
"Returns",
"apply",
"function"
] | train | https://github.com/eumis/pyviews/blob/80a868242ee9cdc6f4ded594b3e0544cc238ed55/pyviews/core/binding.py#L68-L78 |
eumis/pyviews | pyviews/binding/implementations.py | get_expression_target | def get_expression_target(expression: Expression, expr_vars: InheritedDict) -> BindingTarget:
'''Factory method to create expression target'''
root = expression.get_object_tree()
if len(root.children) != 1 or not PROPERTY_EXPRESSION_REGEX.fullmatch(expression.code):
error = BindingError('Expression ... | python | def get_expression_target(expression: Expression, expr_vars: InheritedDict) -> BindingTarget:
'''Factory method to create expression target'''
root = expression.get_object_tree()
if len(root.children) != 1 or not PROPERTY_EXPRESSION_REGEX.fullmatch(expression.code):
error = BindingError('Expression ... | [
"def",
"get_expression_target",
"(",
"expression",
":",
"Expression",
",",
"expr_vars",
":",
"InheritedDict",
")",
"->",
"BindingTarget",
":",
"root",
"=",
"expression",
".",
"get_object_tree",
"(",
")",
"if",
"len",
"(",
"root",
".",
"children",
")",
"!=",
... | Factory method to create expression target | [
"Factory",
"method",
"to",
"create",
"expression",
"target"
] | train | https://github.com/eumis/pyviews/blob/80a868242ee9cdc6f4ded594b3e0544cc238ed55/pyviews/binding/implementations.py#L219-L228 |
eumis/pyviews | pyviews/binding/implementations.py | PropertyTarget.on_change | def on_change(self, value):
'''Calles modifier on instance with passed value'''
self._modifier(self.inst, self.prop, value) | python | def on_change(self, value):
'''Calles modifier on instance with passed value'''
self._modifier(self.inst, self.prop, value) | [
"def",
"on_change",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"_modifier",
"(",
"self",
".",
"inst",
",",
"self",
".",
"prop",
",",
"value",
")"
] | Calles modifier on instance with passed value | [
"Calles",
"modifier",
"on",
"instance",
"with",
"passed",
"value"
] | train | https://github.com/eumis/pyviews/blob/80a868242ee9cdc6f4ded594b3e0544cc238ed55/pyviews/binding/implementations.py#L18-L20 |
eumis/pyviews | pyviews/binding/implementations.py | Dependency.destroy | def destroy(self):
'''Unsubscribes callback from observable'''
self._observable.release(self._key, self._callback)
self._observable = None
self._key = None
self._callback = None | python | def destroy(self):
'''Unsubscribes callback from observable'''
self._observable.release(self._key, self._callback)
self._observable = None
self._key = None
self._callback = None | [
"def",
"destroy",
"(",
"self",
")",
":",
"self",
".",
"_observable",
".",
"release",
"(",
"self",
".",
"_key",
",",
"self",
".",
"_callback",
")",
"self",
".",
"_observable",
"=",
"None",
"self",
".",
"_key",
"=",
"None",
"self",
".",
"_callback",
"=... | Unsubscribes callback from observable | [
"Unsubscribes",
"callback",
"from",
"observable"
] | train | https://github.com/eumis/pyviews/blob/80a868242ee9cdc6f4ded594b3e0544cc238ed55/pyviews/binding/implementations.py#L37-L42 |
Workiva/furious | example/runner.py | args | def args():
"""Add and parse the arguments for the script.
url: the url of the example to run
gae-sdk-path: this allows a user to point the script to their GAE SDK
if it's not in /usr/local/google_appengine.
"""
parser = argparse.ArgumentParser(description='Run the Furious Example... | python | def args():
"""Add and parse the arguments for the script.
url: the url of the example to run
gae-sdk-path: this allows a user to point the script to their GAE SDK
if it's not in /usr/local/google_appengine.
"""
parser = argparse.ArgumentParser(description='Run the Furious Example... | [
"def",
"args",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'Run the Furious Examples.'",
")",
"parser",
".",
"add_argument",
"(",
"'--gae-sdk-path'",
",",
"metavar",
"=",
"'S'",
",",
"dest",
"=",
"\"gae_lib_path\"",... | Add and parse the arguments for the script.
url: the url of the example to run
gae-sdk-path: this allows a user to point the script to their GAE SDK
if it's not in /usr/local/google_appengine. | [
"Add",
"and",
"parse",
"the",
"arguments",
"for",
"the",
"script",
"."
] | train | https://github.com/Workiva/furious/blob/c29823ec8b98549e7439d7273aa064d1e5830632/example/runner.py#L17-L33 |
Workiva/furious | example/runner.py | setup | def setup(options):
"""Grabs the gae_lib_path from the options and inserts it into the first
index of the sys.path. Then calls GAE's fix_sys_path to get all the proper
GAE paths included.
:param options:
"""
sys.path.insert(0, options.gae_lib_path)
from dev_appserver import fix_sys_path
... | python | def setup(options):
"""Grabs the gae_lib_path from the options and inserts it into the first
index of the sys.path. Then calls GAE's fix_sys_path to get all the proper
GAE paths included.
:param options:
"""
sys.path.insert(0, options.gae_lib_path)
from dev_appserver import fix_sys_path
... | [
"def",
"setup",
"(",
"options",
")",
":",
"sys",
".",
"path",
".",
"insert",
"(",
"0",
",",
"options",
".",
"gae_lib_path",
")",
"from",
"dev_appserver",
"import",
"fix_sys_path",
"fix_sys_path",
"(",
")"
] | Grabs the gae_lib_path from the options and inserts it into the first
index of the sys.path. Then calls GAE's fix_sys_path to get all the proper
GAE paths included.
:param options: | [
"Grabs",
"the",
"gae_lib_path",
"from",
"the",
"options",
"and",
"inserts",
"it",
"into",
"the",
"first",
"index",
"of",
"the",
"sys",
".",
"path",
".",
"Then",
"calls",
"GAE",
"s",
"fix_sys_path",
"to",
"get",
"all",
"the",
"proper",
"GAE",
"paths",
"in... | train | https://github.com/Workiva/furious/blob/c29823ec8b98549e7439d7273aa064d1e5830632/example/runner.py#L36-L46 |
Workiva/furious | example/runner.py | run | def run(options):
"""Run the passed in url of the example using GAE's rpc runner.
Uses appengine_rpc.HttpRpcServer to send a request to the url passed in
via the options.
:param options:
"""
from google.appengine.tools import appengine_rpc
from google.appengine.tools import appcfg
sou... | python | def run(options):
"""Run the passed in url of the example using GAE's rpc runner.
Uses appengine_rpc.HttpRpcServer to send a request to the url passed in
via the options.
:param options:
"""
from google.appengine.tools import appengine_rpc
from google.appengine.tools import appcfg
sou... | [
"def",
"run",
"(",
"options",
")",
":",
"from",
"google",
".",
"appengine",
".",
"tools",
"import",
"appengine_rpc",
"from",
"google",
".",
"appengine",
".",
"tools",
"import",
"appcfg",
"source",
"=",
"'furious'",
"# use the same user agent that GAE uses in appcfg"... | Run the passed in url of the example using GAE's rpc runner.
Uses appengine_rpc.HttpRpcServer to send a request to the url passed in
via the options.
:param options: | [
"Run",
"the",
"passed",
"in",
"url",
"of",
"the",
"example",
"using",
"GAE",
"s",
"rpc",
"runner",
"."
] | train | https://github.com/Workiva/furious/blob/c29823ec8b98549e7439d7273aa064d1e5830632/example/runner.py#L49-L82 |
QualiSystems/cloudshell-networking-devices | cloudshell/devices/runners/autoload_runner.py | AutoloadRunner.discover | def discover(self):
"""Enable and Disable SNMP communityon the device, Read it's structure and attributes: chassis, modules,
submodules, ports, port-channels and power supplies
:return: AutoLoadDetails object
:rtype: cloudshell.shell.core.driver_context.AutoLoadDetails
"""
... | python | def discover(self):
"""Enable and Disable SNMP communityon the device, Read it's structure and attributes: chassis, modules,
submodules, ports, port-channels and power supplies
:return: AutoLoadDetails object
:rtype: cloudshell.shell.core.driver_context.AutoLoadDetails
"""
... | [
"def",
"discover",
"(",
"self",
")",
":",
"details",
"=",
"self",
".",
"autoload_flow",
".",
"execute_flow",
"(",
"self",
".",
"resource_config",
".",
"supported_os",
",",
"self",
".",
"resource_config",
".",
"shell_name",
",",
"self",
".",
"resource_config",
... | Enable and Disable SNMP communityon the device, Read it's structure and attributes: chassis, modules,
submodules, ports, port-channels and power supplies
:return: AutoLoadDetails object
:rtype: cloudshell.shell.core.driver_context.AutoLoadDetails | [
"Enable",
"and",
"Disable",
"SNMP",
"communityon",
"the",
"device",
"Read",
"it",
"s",
"structure",
"and",
"attributes",
":",
"chassis",
"modules",
"submodules",
"ports",
"port",
"-",
"channels",
"and",
"power",
"supplies"
] | train | https://github.com/QualiSystems/cloudshell-networking-devices/blob/009aab33edb30035b52fe10dbb91db61c95ba4d9/cloudshell/devices/runners/autoload_runner.py#L50-L64 |
horejsek/python-sqlpuzzle | sqlpuzzle/_queries/query.py | Query.has | def has(self, querypart_name, value=None):
"""Returns True if `querypart_name` with `value` is set.
For example you can check if you already used condition by `sql.has('where')`.
If you want to check for more information, for example if that condition
also contain ID, you can do this b... | python | def has(self, querypart_name, value=None):
"""Returns True if `querypart_name` with `value` is set.
For example you can check if you already used condition by `sql.has('where')`.
If you want to check for more information, for example if that condition
also contain ID, you can do this b... | [
"def",
"has",
"(",
"self",
",",
"querypart_name",
",",
"value",
"=",
"None",
")",
":",
"querypart",
"=",
"self",
".",
"_queryparts",
".",
"get",
"(",
"querypart_name",
")",
"if",
"not",
"querypart",
":",
"return",
"False",
"if",
"not",
"querypart",
".",
... | Returns True if `querypart_name` with `value` is set.
For example you can check if you already used condition by `sql.has('where')`.
If you want to check for more information, for example if that condition
also contain ID, you can do this by `sql.has('where', 'id')`. | [
"Returns",
"True",
"if",
"querypart_name",
"with",
"value",
"is",
"set",
"."
] | train | https://github.com/horejsek/python-sqlpuzzle/blob/d3a42ed1b339b8eafddb8d2c28a3a5832b3998dd/sqlpuzzle/_queries/query.py#L46-L61 |
eumis/pyviews | pyviews/compilation/expression.py | CompiledExpression.execute | def execute(self, parameters: dict = None):
"""Executes expression with passed parameters and returns result"""
try:
parameters = {} if parameters is None else parameters
return eval(self._compiled_code, parameters, {})
except:
info = exc_info()
er... | python | def execute(self, parameters: dict = None):
"""Executes expression with passed parameters and returns result"""
try:
parameters = {} if parameters is None else parameters
return eval(self._compiled_code, parameters, {})
except:
info = exc_info()
er... | [
"def",
"execute",
"(",
"self",
",",
"parameters",
":",
"dict",
"=",
"None",
")",
":",
"try",
":",
"parameters",
"=",
"{",
"}",
"if",
"parameters",
"is",
"None",
"else",
"parameters",
"return",
"eval",
"(",
"self",
".",
"_compiled_code",
",",
"parameters"... | Executes expression with passed parameters and returns result | [
"Executes",
"expression",
"with",
"passed",
"parameters",
"and",
"returns",
"result"
] | train | https://github.com/eumis/pyviews/blob/80a868242ee9cdc6f4ded594b3e0544cc238ed55/pyviews/compilation/expression.py#L88-L97 |
Workiva/furious | example/abort_and_restart.py | aborting_function | def aborting_function():
"""There is a 50% chance that this function will AbortAndRestart or
complete successfully.
The 50% chance simply represents a process that will fail half the time
and succeed half the time.
"""
import random
logging.info('In aborting_function')
if random.rando... | python | def aborting_function():
"""There is a 50% chance that this function will AbortAndRestart or
complete successfully.
The 50% chance simply represents a process that will fail half the time
and succeed half the time.
"""
import random
logging.info('In aborting_function')
if random.rando... | [
"def",
"aborting_function",
"(",
")",
":",
"import",
"random",
"logging",
".",
"info",
"(",
"'In aborting_function'",
")",
"if",
"random",
".",
"random",
"(",
")",
"<",
".5",
":",
"from",
"furious",
".",
"errors",
"import",
"AbortAndRestart",
"logging",
".",... | There is a 50% chance that this function will AbortAndRestart or
complete successfully.
The 50% chance simply represents a process that will fail half the time
and succeed half the time. | [
"There",
"is",
"a",
"50%",
"chance",
"that",
"this",
"function",
"will",
"AbortAndRestart",
"or",
"complete",
"successfully",
"."
] | train | https://github.com/Workiva/furious/blob/c29823ec8b98549e7439d7273aa064d1e5830632/example/abort_and_restart.py#L41-L60 |
datacamp/shellwhat | shellwhat/checks/check_funcs.py | strip_ansi | def strip_ansi(state):
"""Remove ANSI escape codes from student result."""
stu_res = _strip_ansi(state.student_result)
return state.to_child(student_result = stu_res) | python | def strip_ansi(state):
"""Remove ANSI escape codes from student result."""
stu_res = _strip_ansi(state.student_result)
return state.to_child(student_result = stu_res) | [
"def",
"strip_ansi",
"(",
"state",
")",
":",
"stu_res",
"=",
"_strip_ansi",
"(",
"state",
".",
"student_result",
")",
"return",
"state",
".",
"to_child",
"(",
"student_result",
"=",
"stu_res",
")"
] | Remove ANSI escape codes from student result. | [
"Remove",
"ANSI",
"escape",
"codes",
"from",
"student",
"result",
"."
] | train | https://github.com/datacamp/shellwhat/blob/ee2f875e3db0eb06d69cc946c8e9700e0edceea2/shellwhat/checks/check_funcs.py#L9-L13 |
datacamp/shellwhat | shellwhat/checks/check_funcs.py | has_code | def has_code(state, text, incorrect_msg="The checker expected to find `{{text}}` in your command.", fixed=False):
"""Check whether the student code contains text.
This function is a simpler override of the `has_code` function in protowhat,
because ``ast_node._get_text()`` is not implemented in the OSH pars... | python | def has_code(state, text, incorrect_msg="The checker expected to find `{{text}}` in your command.", fixed=False):
"""Check whether the student code contains text.
This function is a simpler override of the `has_code` function in protowhat,
because ``ast_node._get_text()`` is not implemented in the OSH pars... | [
"def",
"has_code",
"(",
"state",
",",
"text",
",",
"incorrect_msg",
"=",
"\"The checker expected to find `{{text}}` in your command.\"",
",",
"fixed",
"=",
"False",
")",
":",
"stu_code",
"=",
"state",
".",
"student_code",
"# either simple text matching or regex test",
"re... | Check whether the student code contains text.
This function is a simpler override of the `has_code` function in protowhat,
because ``ast_node._get_text()`` is not implemented in the OSH parser
Using ``has_code()`` should be a last resort. It is always better to look at the result of code
or the side e... | [
"Check",
"whether",
"the",
"student",
"code",
"contains",
"text",
"."
] | train | https://github.com/datacamp/shellwhat/blob/ee2f875e3db0eb06d69cc946c8e9700e0edceea2/shellwhat/checks/check_funcs.py#L15-L60 |
datacamp/shellwhat | shellwhat/checks/check_funcs.py | has_output | def has_output(state,
text,
incorrect_msg="The checker expected to find {{'' if fixed else 'the pattern '}}`{{text}}` in the output of your command.",
fixed=False,
strip_ansi=True):
"""Check whether student output contains specific text.
Before you us... | python | def has_output(state,
text,
incorrect_msg="The checker expected to find {{'' if fixed else 'the pattern '}}`{{text}}` in the output of your command.",
fixed=False,
strip_ansi=True):
"""Check whether student output contains specific text.
Before you us... | [
"def",
"has_output",
"(",
"state",
",",
"text",
",",
"incorrect_msg",
"=",
"\"The checker expected to find {{'' if fixed else 'the pattern '}}`{{text}}` in the output of your command.\"",
",",
"fixed",
"=",
"False",
",",
"strip_ansi",
"=",
"True",
")",
":",
"stu_output",
"=... | Check whether student output contains specific text.
Before you use ``has_output()``, have a look at ``has_expr_output()`` or ``has_expr_error()``;
they might be more fit for your use case.
Args:
state: State instance describing student and solution code. Can be omitted if used with ``Ex()``.
... | [
"Check",
"whether",
"student",
"output",
"contains",
"specific",
"text",
"."
] | train | https://github.com/datacamp/shellwhat/blob/ee2f875e3db0eb06d69cc946c8e9700e0edceea2/shellwhat/checks/check_funcs.py#L62-L111 |
datacamp/shellwhat | shellwhat/checks/check_funcs.py | has_cwd | def has_cwd(state, dir, incorrect_msg="Your current working directory should be `{{dir}}`. Use `cd {{dir}}` to navigate there."):
"""Check whether the student is in the expected directory.
This check is typically used before using ``has_expr_output()``
to make sure the student didn't navigate somewhere els... | python | def has_cwd(state, dir, incorrect_msg="Your current working directory should be `{{dir}}`. Use `cd {{dir}}` to navigate there."):
"""Check whether the student is in the expected directory.
This check is typically used before using ``has_expr_output()``
to make sure the student didn't navigate somewhere els... | [
"def",
"has_cwd",
"(",
"state",
",",
"dir",
",",
"incorrect_msg",
"=",
"\"Your current working directory should be `{{dir}}`. Use `cd {{dir}}` to navigate there.\"",
")",
":",
"expr",
"=",
"\"[[ $PWD == '{}' ]]\"",
".",
"format",
"(",
"dir",
")",
"_msg",
"=",
"state",
"... | Check whether the student is in the expected directory.
This check is typically used before using ``has_expr_output()``
to make sure the student didn't navigate somewhere else.
Args:
state: State instance describing student and solution code. Can be omitted if used with ``Ex()``.
dir: Dire... | [
"Check",
"whether",
"the",
"student",
"is",
"in",
"the",
"expected",
"directory",
"."
] | train | https://github.com/datacamp/shellwhat/blob/ee2f875e3db0eb06d69cc946c8e9700e0edceea2/shellwhat/checks/check_funcs.py#L113-L135 |
internetarchive/doublethink | doublethink/services.py | ServiceRegistry.heartbeat | def heartbeat(self, status_info):
'''
Update service status, indicating "up"-ness.
Args:
status_info (dict): a dictionary representing the status of the
service
`status_info` must have at least the fields 'role', 'load', and
'ttl'. Some additional fields... | python | def heartbeat(self, status_info):
'''
Update service status, indicating "up"-ness.
Args:
status_info (dict): a dictionary representing the status of the
service
`status_info` must have at least the fields 'role', 'load', and
'ttl'. Some additional fields... | [
"def",
"heartbeat",
"(",
"self",
",",
"status_info",
")",
":",
"for",
"field",
"in",
"'role'",
",",
"'ttl'",
",",
"'load'",
":",
"if",
"not",
"field",
"in",
"status_info",
":",
"raise",
"Exception",
"(",
"'status_info is missing required field %s'",
",",
"repr... | Update service status, indicating "up"-ness.
Args:
status_info (dict): a dictionary representing the status of the
service
`status_info` must have at least the fields 'role', 'load', and
'ttl'. Some additional fields are populated automatically by this
method. I... | [
"Update",
"service",
"status",
"indicating",
"up",
"-",
"ness",
"."
] | train | https://github.com/internetarchive/doublethink/blob/f7fc7da725c9b572d473c717b3dad9af98a7a2b4/doublethink/services.py#L115-L161 |
internetarchive/doublethink | doublethink/services.py | ServiceRegistry.unregister | def unregister(self, id):
'''
Remove the service with id `id` from the service registry.
'''
result = self.rr.table(self.table).get(id).delete().run()
if result != {
'deleted':1, 'errors':0,'inserted':0,
'replaced':0,'skipped':0,'unchanged':0}:
... | python | def unregister(self, id):
'''
Remove the service with id `id` from the service registry.
'''
result = self.rr.table(self.table).get(id).delete().run()
if result != {
'deleted':1, 'errors':0,'inserted':0,
'replaced':0,'skipped':0,'unchanged':0}:
... | [
"def",
"unregister",
"(",
"self",
",",
"id",
")",
":",
"result",
"=",
"self",
".",
"rr",
".",
"table",
"(",
"self",
".",
"table",
")",
".",
"get",
"(",
"id",
")",
".",
"delete",
"(",
")",
".",
"run",
"(",
")",
"if",
"result",
"!=",
"{",
"'del... | Remove the service with id `id` from the service registry. | [
"Remove",
"the",
"service",
"with",
"id",
"id",
"from",
"the",
"service",
"registry",
"."
] | train | https://github.com/internetarchive/doublethink/blob/f7fc7da725c9b572d473c717b3dad9af98a7a2b4/doublethink/services.py#L163-L173 |
internetarchive/doublethink | doublethink/services.py | ServiceRegistry.unique_service | def unique_service(self, role, candidate=None):
'''
Retrieve a unique service, possibly setting or heartbeating it first.
A "unique service" is a service with only one instance for a given
role. Uniqueness is enforced by using the role name as the primary key
`{'id':role, ...}`.... | python | def unique_service(self, role, candidate=None):
'''
Retrieve a unique service, possibly setting or heartbeating it first.
A "unique service" is a service with only one instance for a given
role. Uniqueness is enforced by using the role name as the primary key
`{'id':role, ...}`.... | [
"def",
"unique_service",
"(",
"self",
",",
"role",
",",
"candidate",
"=",
"None",
")",
":",
"# use the same concept of 'now' for all queries",
"now",
"=",
"doublethink",
".",
"utcnow",
"(",
")",
"if",
"candidate",
"is",
"not",
"None",
":",
"candidate",
"[",
"'... | Retrieve a unique service, possibly setting or heartbeating it first.
A "unique service" is a service with only one instance for a given
role. Uniqueness is enforced by using the role name as the primary key
`{'id':role, ...}`.
Args:
role (str): role name
candid... | [
"Retrieve",
"a",
"unique",
"service",
"possibly",
"setting",
"or",
"heartbeating",
"it",
"first",
"."
] | train | https://github.com/internetarchive/doublethink/blob/f7fc7da725c9b572d473c717b3dad9af98a7a2b4/doublethink/services.py#L175-L261 |
internetarchive/doublethink | doublethink/services.py | ServiceRegistry.healthy_services | def healthy_services(self, role=None):
'''
Look up healthy services in the registry.
A service is considered healthy if its 'last_heartbeat' was less than
'ttl' seconds ago
Args:
role (str, optional): role name
Returns:
If `role` is supplied, re... | python | def healthy_services(self, role=None):
'''
Look up healthy services in the registry.
A service is considered healthy if its 'last_heartbeat' was less than
'ttl' seconds ago
Args:
role (str, optional): role name
Returns:
If `role` is supplied, re... | [
"def",
"healthy_services",
"(",
"self",
",",
"role",
"=",
"None",
")",
":",
"try",
":",
"query",
"=",
"self",
".",
"rr",
".",
"table",
"(",
"self",
".",
"table",
")",
"if",
"role",
":",
"query",
"=",
"query",
".",
"get_all",
"(",
"role",
",",
"in... | Look up healthy services in the registry.
A service is considered healthy if its 'last_heartbeat' was less than
'ttl' seconds ago
Args:
role (str, optional): role name
Returns:
If `role` is supplied, returns list of healthy services for the
given ro... | [
"Look",
"up",
"healthy",
"services",
"in",
"the",
"registry",
"."
] | train | https://github.com/internetarchive/doublethink/blob/f7fc7da725c9b572d473c717b3dad9af98a7a2b4/doublethink/services.py#L285-L310 |
Workiva/furious | furious/context/__init__.py | new | def new(batch_size=None, **options):
"""Get a new furious context and add it to the registry. If a batch size is
specified, use an AutoContext which inserts tasks in batches as they are
added to the context.
"""
if batch_size:
new_context = AutoContext(batch_size=batch_size, **options)
... | python | def new(batch_size=None, **options):
"""Get a new furious context and add it to the registry. If a batch size is
specified, use an AutoContext which inserts tasks in batches as they are
added to the context.
"""
if batch_size:
new_context = AutoContext(batch_size=batch_size, **options)
... | [
"def",
"new",
"(",
"batch_size",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"if",
"batch_size",
":",
"new_context",
"=",
"AutoContext",
"(",
"batch_size",
"=",
"batch_size",
",",
"*",
"*",
"options",
")",
"else",
":",
"new_context",
"=",
"Context",... | Get a new furious context and add it to the registry. If a batch size is
specified, use an AutoContext which inserts tasks in batches as they are
added to the context. | [
"Get",
"a",
"new",
"furious",
"context",
"and",
"add",
"it",
"to",
"the",
"registry",
".",
"If",
"a",
"batch",
"size",
"is",
"specified",
"use",
"an",
"AutoContext",
"which",
"inserts",
"tasks",
"in",
"batches",
"as",
"they",
"are",
"added",
"to",
"the",... | train | https://github.com/Workiva/furious/blob/c29823ec8b98549e7439d7273aa064d1e5830632/furious/context/__init__.py#L53-L66 |
Workiva/furious | furious/context/__init__.py | get_current_async | def get_current_async():
"""Return a reference to the currently executing Async job object
or None if not in an Async job.
"""
local_context = _local.get_local_context()
if local_context._executing_async:
return local_context._executing_async[-1]
raise errors.NotInContextError('Not in ... | python | def get_current_async():
"""Return a reference to the currently executing Async job object
or None if not in an Async job.
"""
local_context = _local.get_local_context()
if local_context._executing_async:
return local_context._executing_async[-1]
raise errors.NotInContextError('Not in ... | [
"def",
"get_current_async",
"(",
")",
":",
"local_context",
"=",
"_local",
".",
"get_local_context",
"(",
")",
"if",
"local_context",
".",
"_executing_async",
":",
"return",
"local_context",
".",
"_executing_async",
"[",
"-",
"1",
"]",
"raise",
"errors",
".",
... | Return a reference to the currently executing Async job object
or None if not in an Async job. | [
"Return",
"a",
"reference",
"to",
"the",
"currently",
"executing",
"Async",
"job",
"object",
"or",
"None",
"if",
"not",
"in",
"an",
"Async",
"job",
"."
] | train | https://github.com/Workiva/furious/blob/c29823ec8b98549e7439d7273aa064d1e5830632/furious/context/__init__.py#L69-L78 |
Workiva/furious | furious/context/__init__.py | get_current_context | def get_current_context():
"""Return a reference to the current Context object.
"""
local_context = _local.get_local_context()
if local_context.registry:
return local_context.registry[-1]
raise errors.NotInContextError('Not in a Context.') | python | def get_current_context():
"""Return a reference to the current Context object.
"""
local_context = _local.get_local_context()
if local_context.registry:
return local_context.registry[-1]
raise errors.NotInContextError('Not in a Context.') | [
"def",
"get_current_context",
"(",
")",
":",
"local_context",
"=",
"_local",
".",
"get_local_context",
"(",
")",
"if",
"local_context",
".",
"registry",
":",
"return",
"local_context",
".",
"registry",
"[",
"-",
"1",
"]",
"raise",
"errors",
".",
"NotInContextE... | Return a reference to the current Context object. | [
"Return",
"a",
"reference",
"to",
"the",
"current",
"Context",
"object",
"."
] | train | https://github.com/Workiva/furious/blob/c29823ec8b98549e7439d7273aa064d1e5830632/furious/context/__init__.py#L81-L89 |
Workiva/furious | furious/extras/xsrf.py | XSRFToken.generate_token_string | def generate_token_string(self, action=None):
"""Generate a hash of the given token contents that can be verified.
:param action:
A string representing the action that the generated hash is valid
for. This string is usually a URL.
:returns:
A string containin... | python | def generate_token_string(self, action=None):
"""Generate a hash of the given token contents that can be verified.
:param action:
A string representing the action that the generated hash is valid
for. This string is usually a URL.
:returns:
A string containin... | [
"def",
"generate_token_string",
"(",
"self",
",",
"action",
"=",
"None",
")",
":",
"digest_maker",
"=",
"self",
".",
"_digest_maker",
"(",
")",
"digest_maker",
".",
"update",
"(",
"self",
".",
"user_id",
")",
"digest_maker",
".",
"update",
"(",
"self",
"."... | Generate a hash of the given token contents that can be verified.
:param action:
A string representing the action that the generated hash is valid
for. This string is usually a URL.
:returns:
A string containing the hash contents of the given `action` and the
... | [
"Generate",
"a",
"hash",
"of",
"the",
"given",
"token",
"contents",
"that",
"can",
"be",
"verified",
"."
] | train | https://github.com/Workiva/furious/blob/c29823ec8b98549e7439d7273aa064d1e5830632/furious/extras/xsrf.py#L57-L79 |
Workiva/furious | furious/extras/xsrf.py | XSRFToken.verify_token_string | def verify_token_string(self,
token_string,
action=None,
timeout=None,
current_time=None):
"""Generate a hash of the given token contents that can be verified.
:param token_string:
... | python | def verify_token_string(self,
token_string,
action=None,
timeout=None,
current_time=None):
"""Generate a hash of the given token contents that can be verified.
:param token_string:
... | [
"def",
"verify_token_string",
"(",
"self",
",",
"token_string",
",",
"action",
"=",
"None",
",",
"timeout",
"=",
"None",
",",
"current_time",
"=",
"None",
")",
":",
"try",
":",
"decoded_token_string",
"=",
"base64",
".",
"urlsafe_b64decode",
"(",
"token_string... | Generate a hash of the given token contents that can be verified.
:param token_string:
A string containing the hashed token (generated by
`generate_token_string`).
:param action:
A string containing the action that is being verified.
:param timeout:
... | [
"Generate",
"a",
"hash",
"of",
"the",
"given",
"token",
"contents",
"that",
"can",
"be",
"verified",
"."
] | train | https://github.com/Workiva/furious/blob/c29823ec8b98549e7439d7273aa064d1e5830632/furious/extras/xsrf.py#L81-L139 |
tommyjcarpenter/dictsearch | dictsearch/search.py | iterate_dictionary | def iterate_dictionary(d, path, squash_single = False):
"""
Takes a dict, and a path delimited with slashes like A/B/C/D, and returns a list of objects found at all leaf nodes at all trajectories `dict[A][B][C][D]`. It does this using BFS not DFS.
The word "leaf" hereby refers to an item at the se... | python | def iterate_dictionary(d, path, squash_single = False):
"""
Takes a dict, and a path delimited with slashes like A/B/C/D, and returns a list of objects found at all leaf nodes at all trajectories `dict[A][B][C][D]`. It does this using BFS not DFS.
The word "leaf" hereby refers to an item at the se... | [
"def",
"iterate_dictionary",
"(",
"d",
",",
"path",
",",
"squash_single",
"=",
"False",
")",
":",
"path_parts",
"=",
"path",
".",
"split",
"(",
"\"/\"",
")",
"return_list",
"=",
"[",
"]",
"if",
"len",
"(",
"path_parts",
")",
"==",
"0",
":",
"#no search... | Takes a dict, and a path delimited with slashes like A/B/C/D, and returns a list of objects found at all leaf nodes at all trajectories `dict[A][B][C][D]`. It does this using BFS not DFS.
The word "leaf" hereby refers to an item at the search path level. That is, upon calling the function
it... | [
"Takes",
"a",
"dict",
"and",
"a",
"path",
"delimited",
"with",
"slashes",
"like",
"A",
"/",
"B",
"/",
"C",
"/",
"D",
"and",
"returns",
"a",
"list",
"of",
"objects",
"found",
"at",
"all",
"leaf",
"nodes",
"at",
"all",
"trajectories",
"dict",
"[",
"A",... | train | https://github.com/tommyjcarpenter/dictsearch/blob/a14ca489b6bdd5b636099381add0cc6b94ec665d/dictsearch/search.py#L1-L56 |
QualiSystems/cloudshell-networking-devices | cloudshell/devices/snmp_handler.py | SnmpHandler.get_snmp_service | def get_snmp_service(self):
"""
Enable/Disable snmp
:param snmp_parameters:
:return:
:rtype: SnmpContextManager
"""
return SnmpContextManager(self.enable_flow, self.disable_flow, self._snmp_parameters, self._logger) | python | def get_snmp_service(self):
"""
Enable/Disable snmp
:param snmp_parameters:
:return:
:rtype: SnmpContextManager
"""
return SnmpContextManager(self.enable_flow, self.disable_flow, self._snmp_parameters, self._logger) | [
"def",
"get_snmp_service",
"(",
"self",
")",
":",
"return",
"SnmpContextManager",
"(",
"self",
".",
"enable_flow",
",",
"self",
".",
"disable_flow",
",",
"self",
".",
"_snmp_parameters",
",",
"self",
".",
"_logger",
")"
] | Enable/Disable snmp
:param snmp_parameters:
:return:
:rtype: SnmpContextManager | [
"Enable",
"/",
"Disable",
"snmp",
":",
"param",
"snmp_parameters",
":",
":",
"return",
":",
":",
"rtype",
":",
"SnmpContextManager"
] | train | https://github.com/QualiSystems/cloudshell-networking-devices/blob/009aab33edb30035b52fe10dbb91db61c95ba4d9/cloudshell/devices/snmp_handler.py#L85-L92 |
internetarchive/doublethink | doublethink/cli.py | purge_stale_services | def purge_stale_services(argv=None):
"""Command-line utility to periodically purge stale entries from the "services" table.
It is designed to be used in conjunction with cron.
"""
argv = argv or sys.argv
arg_parser = argparse.ArgumentParser(
prog=os.path.basename(argv[0]), description=(... | python | def purge_stale_services(argv=None):
"""Command-line utility to periodically purge stale entries from the "services" table.
It is designed to be used in conjunction with cron.
"""
argv = argv or sys.argv
arg_parser = argparse.ArgumentParser(
prog=os.path.basename(argv[0]), description=(... | [
"def",
"purge_stale_services",
"(",
"argv",
"=",
"None",
")",
":",
"argv",
"=",
"argv",
"or",
"sys",
".",
"argv",
"arg_parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"prog",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"argv",
"[",
"0",
"]",
... | Command-line utility to periodically purge stale entries from the "services" table.
It is designed to be used in conjunction with cron. | [
"Command",
"-",
"line",
"utility",
"to",
"periodically",
"purge",
"stale",
"entries",
"from",
"the",
"services",
"table",
"."
] | train | https://github.com/internetarchive/doublethink/blob/f7fc7da725c9b572d473c717b3dad9af98a7a2b4/doublethink/cli.py#L25-L59 |
Workiva/furious | furious/context/context.py | _insert_tasks | def _insert_tasks(tasks, queue, transactional=False,
retry_transient_errors=True,
retry_delay=RETRY_SLEEP_SECS):
"""Insert a batch of tasks into the specified queue. If an error occurs
during insertion, split the batch and retry until they are successfully
inserted. Retur... | python | def _insert_tasks(tasks, queue, transactional=False,
retry_transient_errors=True,
retry_delay=RETRY_SLEEP_SECS):
"""Insert a batch of tasks into the specified queue. If an error occurs
during insertion, split the batch and retry until they are successfully
inserted. Retur... | [
"def",
"_insert_tasks",
"(",
"tasks",
",",
"queue",
",",
"transactional",
"=",
"False",
",",
"retry_transient_errors",
"=",
"True",
",",
"retry_delay",
"=",
"RETRY_SLEEP_SECS",
")",
":",
"from",
"google",
".",
"appengine",
".",
"api",
"import",
"taskqueue",
"i... | Insert a batch of tasks into the specified queue. If an error occurs
during insertion, split the batch and retry until they are successfully
inserted. Return the number of successfully inserted tasks. | [
"Insert",
"a",
"batch",
"of",
"tasks",
"into",
"the",
"specified",
"queue",
".",
"If",
"an",
"error",
"occurs",
"during",
"insertion",
"split",
"the",
"batch",
"and",
"retry",
"until",
"they",
"are",
"successfully",
"inserted",
".",
"Return",
"the",
"number"... | train | https://github.com/Workiva/furious/blob/c29823ec8b98549e7439d7273aa064d1e5830632/furious/context/context.py#L368-L416 |
Workiva/furious | furious/context/context.py | _tasks_to_reinsert | def _tasks_to_reinsert(tasks, transactional):
"""Return a list containing the tasks that should be reinserted based on the
was_enqueued property and whether the insert is transactional or not.
"""
if transactional:
return tasks
return [task for task in tasks if not task.was_enqueued] | python | def _tasks_to_reinsert(tasks, transactional):
"""Return a list containing the tasks that should be reinserted based on the
was_enqueued property and whether the insert is transactional or not.
"""
if transactional:
return tasks
return [task for task in tasks if not task.was_enqueued] | [
"def",
"_tasks_to_reinsert",
"(",
"tasks",
",",
"transactional",
")",
":",
"if",
"transactional",
":",
"return",
"tasks",
"return",
"[",
"task",
"for",
"task",
"in",
"tasks",
"if",
"not",
"task",
".",
"was_enqueued",
"]"
] | Return a list containing the tasks that should be reinserted based on the
was_enqueued property and whether the insert is transactional or not. | [
"Return",
"a",
"list",
"containing",
"the",
"tasks",
"that",
"should",
"be",
"reinserted",
"based",
"on",
"the",
"was_enqueued",
"property",
"and",
"whether",
"the",
"insert",
"is",
"transactional",
"or",
"not",
"."
] | train | https://github.com/Workiva/furious/blob/c29823ec8b98549e7439d7273aa064d1e5830632/furious/context/context.py#L419-L426 |
Workiva/furious | furious/context/context.py | _task_batcher | def _task_batcher(tasks, batch_size=None):
"""Batches large task lists into groups of 100 so that they can all be
inserted.
"""
from itertools import izip_longest
if not batch_size:
batch_size = DEFAULT_TASK_BATCH_SIZE
# Ensure the batch size is under the task api limit.
batch_size... | python | def _task_batcher(tasks, batch_size=None):
"""Batches large task lists into groups of 100 so that they can all be
inserted.
"""
from itertools import izip_longest
if not batch_size:
batch_size = DEFAULT_TASK_BATCH_SIZE
# Ensure the batch size is under the task api limit.
batch_size... | [
"def",
"_task_batcher",
"(",
"tasks",
",",
"batch_size",
"=",
"None",
")",
":",
"from",
"itertools",
"import",
"izip_longest",
"if",
"not",
"batch_size",
":",
"batch_size",
"=",
"DEFAULT_TASK_BATCH_SIZE",
"# Ensure the batch size is under the task api limit.",
"batch_size... | Batches large task lists into groups of 100 so that they can all be
inserted. | [
"Batches",
"large",
"task",
"lists",
"into",
"groups",
"of",
"100",
"so",
"that",
"they",
"can",
"all",
"be",
"inserted",
"."
] | train | https://github.com/Workiva/furious/blob/c29823ec8b98549e7439d7273aa064d1e5830632/furious/context/context.py#L429-L442 |
Workiva/furious | furious/context/context.py | Context._handle_tasks_insert | def _handle_tasks_insert(self, batch_size=None):
"""Convert all Async's into tasks, then insert them into queues."""
if self._tasks_inserted:
raise errors.ContextAlreadyStartedError(
"This Context has already had its tasks inserted.")
task_map = self._get_tasks_by_qu... | python | def _handle_tasks_insert(self, batch_size=None):
"""Convert all Async's into tasks, then insert them into queues."""
if self._tasks_inserted:
raise errors.ContextAlreadyStartedError(
"This Context has already had its tasks inserted.")
task_map = self._get_tasks_by_qu... | [
"def",
"_handle_tasks_insert",
"(",
"self",
",",
"batch_size",
"=",
"None",
")",
":",
"if",
"self",
".",
"_tasks_inserted",
":",
"raise",
"errors",
".",
"ContextAlreadyStartedError",
"(",
"\"This Context has already had its tasks inserted.\"",
")",
"task_map",
"=",
"s... | Convert all Async's into tasks, then insert them into queues. | [
"Convert",
"all",
"Async",
"s",
"into",
"tasks",
"then",
"insert",
"them",
"into",
"queues",
"."
] | train | https://github.com/Workiva/furious/blob/c29823ec8b98549e7439d7273aa064d1e5830632/furious/context/context.py#L127-L157 |
Workiva/furious | furious/context/context.py | Context._get_tasks_by_queue | def _get_tasks_by_queue(self):
"""Return the tasks for this Context, grouped by queue."""
task_map = {}
_checker = None
# Ask the persistence engine for an Async to use for checking if the
# context is complete.
if self._persistence_engine:
_checker = self._p... | python | def _get_tasks_by_queue(self):
"""Return the tasks for this Context, grouped by queue."""
task_map = {}
_checker = None
# Ask the persistence engine for an Async to use for checking if the
# context is complete.
if self._persistence_engine:
_checker = self._p... | [
"def",
"_get_tasks_by_queue",
"(",
"self",
")",
":",
"task_map",
"=",
"{",
"}",
"_checker",
"=",
"None",
"# Ask the persistence engine for an Async to use for checking if the",
"# context is complete.",
"if",
"self",
".",
"_persistence_engine",
":",
"_checker",
"=",
"self... | Return the tasks for this Context, grouped by queue. | [
"Return",
"the",
"tasks",
"for",
"this",
"Context",
"grouped",
"by",
"queue",
"."
] | train | https://github.com/Workiva/furious/blob/c29823ec8b98549e7439d7273aa064d1e5830632/furious/context/context.py#L167-L185 |
Workiva/furious | furious/context/context.py | Context.set_event_handler | def set_event_handler(self, event, handler):
"""Add an Async to be run on event."""
# QUESTION: Should we raise an exception if `event` is not in some
# known event-type list?
self._prepare_persistence_engine()
callbacks = self._options.get('callbacks', {})
callbacks[ev... | python | def set_event_handler(self, event, handler):
"""Add an Async to be run on event."""
# QUESTION: Should we raise an exception if `event` is not in some
# known event-type list?
self._prepare_persistence_engine()
callbacks = self._options.get('callbacks', {})
callbacks[ev... | [
"def",
"set_event_handler",
"(",
"self",
",",
"event",
",",
"handler",
")",
":",
"# QUESTION: Should we raise an exception if `event` is not in some",
"# known event-type list?",
"self",
".",
"_prepare_persistence_engine",
"(",
")",
"callbacks",
"=",
"self",
".",
"_options"... | Add an Async to be run on event. | [
"Add",
"an",
"Async",
"to",
"be",
"run",
"on",
"event",
"."
] | train | https://github.com/Workiva/furious/blob/c29823ec8b98549e7439d7273aa064d1e5830632/furious/context/context.py#L204-L213 |
Workiva/furious | furious/context/context.py | Context.exec_event_handler | def exec_event_handler(self, event, transactional=False):
"""Execute the Async set to be run on event."""
# QUESTION: Should we raise an exception if `event` is not in some
# known event-type list?
callbacks = self._options.get('callbacks', {})
handler = callbacks.get(event)
... | python | def exec_event_handler(self, event, transactional=False):
"""Execute the Async set to be run on event."""
# QUESTION: Should we raise an exception if `event` is not in some
# known event-type list?
callbacks = self._options.get('callbacks', {})
handler = callbacks.get(event)
... | [
"def",
"exec_event_handler",
"(",
"self",
",",
"event",
",",
"transactional",
"=",
"False",
")",
":",
"# QUESTION: Should we raise an exception if `event` is not in some",
"# known event-type list?",
"callbacks",
"=",
"self",
".",
"_options",
".",
"get",
"(",
"'callbacks'... | Execute the Async set to be run on event. | [
"Execute",
"the",
"Async",
"set",
"to",
"be",
"run",
"on",
"event",
"."
] | train | https://github.com/Workiva/furious/blob/c29823ec8b98549e7439d7273aa064d1e5830632/furious/context/context.py#L215-L227 |
Workiva/furious | furious/context/context.py | Context.add | def add(self, target, args=None, kwargs=None, **options):
"""Add an Async job to this context.
Takes an Async object or the arguments to construct an Async
object as arguments. Returns the newly added Async object.
"""
from furious.async import Async
from furious.batche... | python | def add(self, target, args=None, kwargs=None, **options):
"""Add an Async job to this context.
Takes an Async object or the arguments to construct an Async
object as arguments. Returns the newly added Async object.
"""
from furious.async import Async
from furious.batche... | [
"def",
"add",
"(",
"self",
",",
"target",
",",
"args",
"=",
"None",
",",
"kwargs",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"from",
"furious",
".",
"async",
"import",
"Async",
"from",
"furious",
".",
"batcher",
"import",
"Message",
"if",
"sel... | Add an Async job to this context.
Takes an Async object or the arguments to construct an Async
object as arguments. Returns the newly added Async object. | [
"Add",
"an",
"Async",
"job",
"to",
"this",
"context",
"."
] | train | https://github.com/Workiva/furious/blob/c29823ec8b98549e7439d7273aa064d1e5830632/furious/context/context.py#L229-L253 |
Workiva/furious | furious/context/context.py | Context.load | def load(cls, context_id, persistence_engine=None):
"""Load and instantiate a Context from the persistence_engine."""
if not persistence_engine:
from furious.config import get_default_persistence_engine
persistence_engine = get_default_persistence_engine()
if not persist... | python | def load(cls, context_id, persistence_engine=None):
"""Load and instantiate a Context from the persistence_engine."""
if not persistence_engine:
from furious.config import get_default_persistence_engine
persistence_engine = get_default_persistence_engine()
if not persist... | [
"def",
"load",
"(",
"cls",
",",
"context_id",
",",
"persistence_engine",
"=",
"None",
")",
":",
"if",
"not",
"persistence_engine",
":",
"from",
"furious",
".",
"config",
"import",
"get_default_persistence_engine",
"persistence_engine",
"=",
"get_default_persistence_en... | Load and instantiate a Context from the persistence_engine. | [
"Load",
"and",
"instantiate",
"a",
"Context",
"from",
"the",
"persistence_engine",
"."
] | train | https://github.com/Workiva/furious/blob/c29823ec8b98549e7439d7273aa064d1e5830632/furious/context/context.py#L269-L279 |
Workiva/furious | furious/context/context.py | Context.to_dict | def to_dict(self):
"""Return this Context as a dict suitable for json encoding."""
import copy
options = copy.deepcopy(self._options)
if self._insert_tasks:
options['insert_tasks'] = reference_to_path(self._insert_tasks)
if self._persistence_engine:
opt... | python | def to_dict(self):
"""Return this Context as a dict suitable for json encoding."""
import copy
options = copy.deepcopy(self._options)
if self._insert_tasks:
options['insert_tasks'] = reference_to_path(self._insert_tasks)
if self._persistence_engine:
opt... | [
"def",
"to_dict",
"(",
"self",
")",
":",
"import",
"copy",
"options",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
".",
"_options",
")",
"if",
"self",
".",
"_insert_tasks",
":",
"options",
"[",
"'insert_tasks'",
"]",
"=",
"reference_to_path",
"(",
"self",
... | Return this Context as a dict suitable for json encoding. | [
"Return",
"this",
"Context",
"as",
"a",
"dict",
"suitable",
"for",
"json",
"encoding",
"."
] | train | https://github.com/Workiva/furious/blob/c29823ec8b98549e7439d7273aa064d1e5830632/furious/context/context.py#L281-L302 |
Workiva/furious | furious/context/context.py | Context.from_dict | def from_dict(cls, context_options_dict):
"""Return a context job from a dict output by Context.to_dict."""
import copy
context_options = copy.deepcopy(context_options_dict)
tasks_inserted = context_options.pop('_tasks_inserted', False)
insert_tasks = context_options.pop('inse... | python | def from_dict(cls, context_options_dict):
"""Return a context job from a dict output by Context.to_dict."""
import copy
context_options = copy.deepcopy(context_options_dict)
tasks_inserted = context_options.pop('_tasks_inserted', False)
insert_tasks = context_options.pop('inse... | [
"def",
"from_dict",
"(",
"cls",
",",
"context_options_dict",
")",
":",
"import",
"copy",
"context_options",
"=",
"copy",
".",
"deepcopy",
"(",
"context_options_dict",
")",
"tasks_inserted",
"=",
"context_options",
".",
"pop",
"(",
"'_tasks_inserted'",
",",
"False"... | Return a context job from a dict output by Context.to_dict. | [
"Return",
"a",
"context",
"job",
"from",
"a",
"dict",
"output",
"by",
"Context",
".",
"to_dict",
"."
] | train | https://github.com/Workiva/furious/blob/c29823ec8b98549e7439d7273aa064d1e5830632/furious/context/context.py#L305-L332 |
Workiva/furious | furious/context/context.py | Context.result | def result(self):
"""Return the context result object pulled from the persistence_engine
if it has been set.
"""
if not self._result:
if not self._persistence_engine:
return None
self._result = self._persistence_engine.get_context_result(self)
... | python | def result(self):
"""Return the context result object pulled from the persistence_engine
if it has been set.
"""
if not self._result:
if not self._persistence_engine:
return None
self._result = self._persistence_engine.get_context_result(self)
... | [
"def",
"result",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_result",
":",
"if",
"not",
"self",
".",
"_persistence_engine",
":",
"return",
"None",
"self",
".",
"_result",
"=",
"self",
".",
"_persistence_engine",
".",
"get_context_result",
"(",
"self... | Return the context result object pulled from the persistence_engine
if it has been set. | [
"Return",
"the",
"context",
"result",
"object",
"pulled",
"from",
"the",
"persistence_engine",
"if",
"it",
"has",
"been",
"set",
"."
] | train | https://github.com/Workiva/furious/blob/c29823ec8b98549e7439d7273aa064d1e5830632/furious/context/context.py#L335-L345 |
Workiva/furious | furious/extras/insert_task_handlers.py | insert_tasks_ignore_duplicate_names | def insert_tasks_ignore_duplicate_names(tasks, queue, *args, **kwargs):
"""Insert a batch of tasks into a specific queue. If a
DuplicateTaskNameError is raised, loop through the tasks and insert the
remaining, ignoring and logging the duplicate tasks.
Returns the number of successfully inserted tasks.... | python | def insert_tasks_ignore_duplicate_names(tasks, queue, *args, **kwargs):
"""Insert a batch of tasks into a specific queue. If a
DuplicateTaskNameError is raised, loop through the tasks and insert the
remaining, ignoring and logging the duplicate tasks.
Returns the number of successfully inserted tasks.... | [
"def",
"insert_tasks_ignore_duplicate_names",
"(",
"tasks",
",",
"queue",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"google",
".",
"appengine",
".",
"api",
"import",
"taskqueue",
"try",
":",
"inserted",
"=",
"_insert_tasks",
"(",
"tasks",
... | Insert a batch of tasks into a specific queue. If a
DuplicateTaskNameError is raised, loop through the tasks and insert the
remaining, ignoring and logging the duplicate tasks.
Returns the number of successfully inserted tasks. | [
"Insert",
"a",
"batch",
"of",
"tasks",
"into",
"a",
"specific",
"queue",
".",
"If",
"a",
"DuplicateTaskNameError",
"is",
"raised",
"loop",
"through",
"the",
"tasks",
"and",
"insert",
"the",
"remaining",
"ignoring",
"and",
"logging",
"the",
"duplicate",
"tasks"... | train | https://github.com/Workiva/furious/blob/c29823ec8b98549e7439d7273aa064d1e5830632/furious/extras/insert_task_handlers.py#L5-L32 |
Workiva/furious | example/grep.py | log_results | def log_results():
"""This is the callback that is run once the Async task is finished. It
takes the output from grep and logs it."""
from furious.context import get_current_async
# Get the recently finished Async object.
async = get_current_async()
# Pull out the result data and log it.
f... | python | def log_results():
"""This is the callback that is run once the Async task is finished. It
takes the output from grep and logs it."""
from furious.context import get_current_async
# Get the recently finished Async object.
async = get_current_async()
# Pull out the result data and log it.
f... | [
"def",
"log_results",
"(",
")",
":",
"from",
"furious",
".",
"context",
"import",
"get_current_async",
"# Get the recently finished Async object.",
"async",
"=",
"get_current_async",
"(",
")",
"# Pull out the result data and log it.",
"for",
"result",
"in",
"async",
".",
... | This is the callback that is run once the Async task is finished. It
takes the output from grep and logs it. | [
"This",
"is",
"the",
"callback",
"that",
"is",
"run",
"once",
"the",
"Async",
"task",
"is",
"finished",
".",
"It",
"takes",
"the",
"output",
"from",
"grep",
"and",
"logs",
"it",
"."
] | train | https://github.com/Workiva/furious/blob/c29823ec8b98549e7439d7273aa064d1e5830632/example/grep.py#L47-L57 |
Workiva/furious | example/grep.py | build_and_start | def build_and_start(query, directory):
"""This function will create and then start a new Async task with the
default callbacks argument defined in the decorator."""
Async(target=grep, args=[query, directory]).start() | python | def build_and_start(query, directory):
"""This function will create and then start a new Async task with the
default callbacks argument defined in the decorator."""
Async(target=grep, args=[query, directory]).start() | [
"def",
"build_and_start",
"(",
"query",
",",
"directory",
")",
":",
"Async",
"(",
"target",
"=",
"grep",
",",
"args",
"=",
"[",
"query",
",",
"directory",
"]",
")",
".",
"start",
"(",
")"
] | This function will create and then start a new Async task with the
default callbacks argument defined in the decorator. | [
"This",
"function",
"will",
"create",
"and",
"then",
"start",
"a",
"new",
"Async",
"task",
"with",
"the",
"default",
"callbacks",
"argument",
"defined",
"in",
"the",
"decorator",
"."
] | train | https://github.com/Workiva/furious/blob/c29823ec8b98549e7439d7273aa064d1e5830632/example/grep.py#L60-L64 |
Workiva/furious | example/grep.py | grep_file | def grep_file(query, item):
"""This function performs the actual grep on a given file."""
return ['%s: %s' % (item, line) for line in open(item)
if re.search(query, line)] | python | def grep_file(query, item):
"""This function performs the actual grep on a given file."""
return ['%s: %s' % (item, line) for line in open(item)
if re.search(query, line)] | [
"def",
"grep_file",
"(",
"query",
",",
"item",
")",
":",
"return",
"[",
"'%s: %s'",
"%",
"(",
"item",
",",
"line",
")",
"for",
"line",
"in",
"open",
"(",
"item",
")",
"if",
"re",
".",
"search",
"(",
"query",
",",
"line",
")",
"]"
] | This function performs the actual grep on a given file. | [
"This",
"function",
"performs",
"the",
"actual",
"grep",
"on",
"a",
"given",
"file",
"."
] | train | https://github.com/Workiva/furious/blob/c29823ec8b98549e7439d7273aa064d1e5830632/example/grep.py#L67-L70 |
Workiva/furious | example/grep.py | grep | def grep(query, directory):
"""This function will search through the directory structure of the
application and for each directory it finds it launches an Async task to
run itself. For each .py file it finds, it actually greps the file and then
returns the found output."""
dir_contents = os.listdir... | python | def grep(query, directory):
"""This function will search through the directory structure of the
application and for each directory it finds it launches an Async task to
run itself. For each .py file it finds, it actually greps the file and then
returns the found output."""
dir_contents = os.listdir... | [
"def",
"grep",
"(",
"query",
",",
"directory",
")",
":",
"dir_contents",
"=",
"os",
".",
"listdir",
"(",
"directory",
")",
"results",
"=",
"[",
"]",
"for",
"item",
"in",
"dir_contents",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"director... | This function will search through the directory structure of the
application and for each directory it finds it launches an Async task to
run itself. For each .py file it finds, it actually greps the file and then
returns the found output. | [
"This",
"function",
"will",
"search",
"through",
"the",
"directory",
"structure",
"of",
"the",
"application",
"and",
"for",
"each",
"directory",
"it",
"finds",
"it",
"launches",
"an",
"Async",
"task",
"to",
"run",
"itself",
".",
"For",
"each",
".",
"py",
"... | train | https://github.com/Workiva/furious/blob/c29823ec8b98549e7439d7273aa064d1e5830632/example/grep.py#L74-L89 |
Workiva/furious | furious/config.py | _get_configured_module | def _get_configured_module(option_name, known_modules=None):
"""Get the module specified by the value of option_name. The value of the
configuration option will be used to load the module by name from the known
module list or treated as a path if not found in known_modules.
Args:
option_name: na... | python | def _get_configured_module(option_name, known_modules=None):
"""Get the module specified by the value of option_name. The value of the
configuration option will be used to load the module by name from the known
module list or treated as a path if not found in known_modules.
Args:
option_name: na... | [
"def",
"_get_configured_module",
"(",
"option_name",
",",
"known_modules",
"=",
"None",
")",
":",
"from",
"furious",
".",
"job_utils",
"import",
"path_to_reference",
"config",
"=",
"get_config",
"(",
")",
"option_value",
"=",
"config",
"[",
"option_name",
"]",
"... | Get the module specified by the value of option_name. The value of the
configuration option will be used to load the module by name from the known
module list or treated as a path if not found in known_modules.
Args:
option_name: name of persistence module
known_modules: dictionary of module... | [
"Get",
"the",
"module",
"specified",
"by",
"the",
"value",
"of",
"option_name",
".",
"The",
"value",
"of",
"the",
"configuration",
"option",
"will",
"be",
"used",
"to",
"load",
"the",
"module",
"by",
"name",
"from",
"the",
"known",
"module",
"list",
"or",
... | train | https://github.com/Workiva/furious/blob/c29823ec8b98549e7439d7273aa064d1e5830632/furious/config.py#L74-L95 |
Workiva/furious | furious/config.py | find_furious_yaml | def find_furious_yaml(config_file=__file__):
"""
Traverse directory trees to find a furious.yaml file
Begins with the location of this file then checks the
working directory if not found
Args:
config_file: location of this file, override for
testing
Returns:
the path of... | python | def find_furious_yaml(config_file=__file__):
"""
Traverse directory trees to find a furious.yaml file
Begins with the location of this file then checks the
working directory if not found
Args:
config_file: location of this file, override for
testing
Returns:
the path of... | [
"def",
"find_furious_yaml",
"(",
"config_file",
"=",
"__file__",
")",
":",
"checked",
"=",
"set",
"(",
")",
"result",
"=",
"_find_furious_yaml",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"config_file",
")",
",",
"checked",
")",
"if",
"not",
"result",
... | Traverse directory trees to find a furious.yaml file
Begins with the location of this file then checks the
working directory if not found
Args:
config_file: location of this file, override for
testing
Returns:
the path of furious.yaml or None if not found | [
"Traverse",
"directory",
"trees",
"to",
"find",
"a",
"furious",
".",
"yaml",
"file"
] | train | https://github.com/Workiva/furious/blob/c29823ec8b98549e7439d7273aa064d1e5830632/furious/config.py#L98-L115 |
Workiva/furious | furious/config.py | _find_furious_yaml | def _find_furious_yaml(start, checked):
"""Traverse the directory tree identified by start
until a directory already in checked is encountered or the path
of furious.yaml is found.
Checked is present both to make the loop termination easy
to reason about and so the same directories do not get
r... | python | def _find_furious_yaml(start, checked):
"""Traverse the directory tree identified by start
until a directory already in checked is encountered or the path
of furious.yaml is found.
Checked is present both to make the loop termination easy
to reason about and so the same directories do not get
r... | [
"def",
"_find_furious_yaml",
"(",
"start",
",",
"checked",
")",
":",
"directory",
"=",
"start",
"while",
"directory",
"not",
"in",
"checked",
":",
"checked",
".",
"add",
"(",
"directory",
")",
"for",
"fs_yaml_name",
"in",
"FURIOUS_YAML_NAMES",
":",
"yaml_path"... | Traverse the directory tree identified by start
until a directory already in checked is encountered or the path
of furious.yaml is found.
Checked is present both to make the loop termination easy
to reason about and so the same directories do not get
rechecked
Args:
start: the path to ... | [
"Traverse",
"the",
"directory",
"tree",
"identified",
"by",
"start",
"until",
"a",
"directory",
"already",
"in",
"checked",
"is",
"encountered",
"or",
"the",
"path",
"of",
"furious",
".",
"yaml",
"is",
"found",
"."
] | train | https://github.com/Workiva/furious/blob/c29823ec8b98549e7439d7273aa064d1e5830632/furious/config.py#L118-L142 |
Workiva/furious | furious/config.py | _load_yaml_config | def _load_yaml_config(path=None):
"""Open and return the yaml contents."""
furious_yaml_path = path or find_furious_yaml()
if furious_yaml_path is None:
logging.debug("furious.yaml not found.")
return None
with open(furious_yaml_path) as yaml_file:
return yaml_file.read() | python | def _load_yaml_config(path=None):
"""Open and return the yaml contents."""
furious_yaml_path = path or find_furious_yaml()
if furious_yaml_path is None:
logging.debug("furious.yaml not found.")
return None
with open(furious_yaml_path) as yaml_file:
return yaml_file.read() | [
"def",
"_load_yaml_config",
"(",
"path",
"=",
"None",
")",
":",
"furious_yaml_path",
"=",
"path",
"or",
"find_furious_yaml",
"(",
")",
"if",
"furious_yaml_path",
"is",
"None",
":",
"logging",
".",
"debug",
"(",
"\"furious.yaml not found.\"",
")",
"return",
"None... | Open and return the yaml contents. | [
"Open",
"and",
"return",
"the",
"yaml",
"contents",
"."
] | train | https://github.com/Workiva/furious/blob/c29823ec8b98549e7439d7273aa064d1e5830632/furious/config.py#L161-L169 |
Workiva/furious | furious/config.py | _parse_yaml_config | def _parse_yaml_config(config_data=None):
"""
Gets the configuration from the found furious.yaml
file and parses the data.
Returns:
a dictionary parsed from the yaml file
"""
data_map = default_config()
# If we were given config data to use, use it. Otherwise, see if there is
#... | python | def _parse_yaml_config(config_data=None):
"""
Gets the configuration from the found furious.yaml
file and parses the data.
Returns:
a dictionary parsed from the yaml file
"""
data_map = default_config()
# If we were given config data to use, use it. Otherwise, see if there is
#... | [
"def",
"_parse_yaml_config",
"(",
"config_data",
"=",
"None",
")",
":",
"data_map",
"=",
"default_config",
"(",
")",
"# If we were given config data to use, use it. Otherwise, see if there is",
"# a furious.yaml to read the config from. Note that the empty string will",
"# result in ... | Gets the configuration from the found furious.yaml
file and parses the data.
Returns:
a dictionary parsed from the yaml file | [
"Gets",
"the",
"configuration",
"from",
"the",
"found",
"furious",
".",
"yaml",
"file",
"and",
"parses",
"the",
"data",
".",
"Returns",
":",
"a",
"dictionary",
"parsed",
"from",
"the",
"yaml",
"file"
] | train | https://github.com/Workiva/furious/blob/c29823ec8b98549e7439d7273aa064d1e5830632/furious/config.py#L172-L204 |
horejsek/python-sqlpuzzle | sqlpuzzle/_queryparts/tables.py | Table._minimize_joins | def _minimize_joins(self):
"""
Minimizing of joins.
Left/right and inner join of the same condition is only inner join.
"""
joins_group = []
for join in self._joins:
append_new = True
for join_group in joins_group:
if join_group[0][... | python | def _minimize_joins(self):
"""
Minimizing of joins.
Left/right and inner join of the same condition is only inner join.
"""
joins_group = []
for join in self._joins:
append_new = True
for join_group in joins_group:
if join_group[0][... | [
"def",
"_minimize_joins",
"(",
"self",
")",
":",
"joins_group",
"=",
"[",
"]",
"for",
"join",
"in",
"self",
".",
"_joins",
":",
"append_new",
"=",
"True",
"for",
"join_group",
"in",
"joins_group",
":",
"if",
"join_group",
"[",
"0",
"]",
"[",
"'table'",
... | Minimizing of joins.
Left/right and inner join of the same condition is only inner join. | [
"Minimizing",
"of",
"joins",
".",
"Left",
"/",
"right",
"and",
"inner",
"join",
"of",
"the",
"same",
"condition",
"is",
"only",
"inner",
"join",
"."
] | train | https://github.com/horejsek/python-sqlpuzzle/blob/d3a42ed1b339b8eafddb8d2c28a3a5832b3998dd/sqlpuzzle/_queryparts/tables.py#L143-L167 |
eumis/pyviews | pyviews/code.py | run_code | def run_code(node: Code, parent_node: Node = None, node_globals: InheritedDict = None, **args): #pylint: disable=unused-argument
'''Executes node content as python module and adds its definitions to globals'''
if not node.xml_node.text:
return
code = node.xml_node.text
try:
globs = node_... | python | def run_code(node: Code, parent_node: Node = None, node_globals: InheritedDict = None, **args): #pylint: disable=unused-argument
'''Executes node content as python module and adds its definitions to globals'''
if not node.xml_node.text:
return
code = node.xml_node.text
try:
globs = node_... | [
"def",
"run_code",
"(",
"node",
":",
"Code",
",",
"parent_node",
":",
"Node",
"=",
"None",
",",
"node_globals",
":",
"InheritedDict",
"=",
"None",
",",
"*",
"*",
"args",
")",
":",
"#pylint: disable=unused-argument",
"if",
"not",
"node",
".",
"xml_node",
".... | Executes node content as python module and adds its definitions to globals | [
"Executes",
"node",
"content",
"as",
"python",
"module",
"and",
"adds",
"its",
"definitions",
"to",
"globals"
] | train | https://github.com/eumis/pyviews/blob/80a868242ee9cdc6f4ded594b3e0544cc238ed55/pyviews/code.py#L13-L33 |
bcj/AttrDict | attrdict/merge.py | merge | def merge(left, right):
"""
Merge two mappings objects together, combining overlapping Mappings,
and favoring right-values
left: The left Mapping object.
right: The right (favored) Mapping object.
NOTE: This is not commutative (merge(a,b) != merge(b,a)).
"""
merged = {}
left_keys ... | python | def merge(left, right):
"""
Merge two mappings objects together, combining overlapping Mappings,
and favoring right-values
left: The left Mapping object.
right: The right (favored) Mapping object.
NOTE: This is not commutative (merge(a,b) != merge(b,a)).
"""
merged = {}
left_keys ... | [
"def",
"merge",
"(",
"left",
",",
"right",
")",
":",
"merged",
"=",
"{",
"}",
"left_keys",
"=",
"frozenset",
"(",
"left",
")",
"right_keys",
"=",
"frozenset",
"(",
"right",
")",
"# Items only in the left Mapping",
"for",
"key",
"in",
"left_keys",
"-",
"rig... | Merge two mappings objects together, combining overlapping Mappings,
and favoring right-values
left: The left Mapping object.
right: The right (favored) Mapping object.
NOTE: This is not commutative (merge(a,b) != merge(b,a)). | [
"Merge",
"two",
"mappings",
"objects",
"together",
"combining",
"overlapping",
"Mappings",
"and",
"favoring",
"right",
"-",
"values"
] | train | https://github.com/bcj/AttrDict/blob/8c1883162178a124ee29144ca7abcd83cbd9d222/attrdict/merge.py#L10-L44 |
bcj/AttrDict | attrdict/default.py | AttrDefault._constructor | def _constructor(cls, mapping, configuration):
"""
A standardized constructor.
"""
sequence_type, default_factory, pass_key = configuration
return cls(default_factory, mapping, sequence_type=sequence_type,
pass_key=pass_key) | python | def _constructor(cls, mapping, configuration):
"""
A standardized constructor.
"""
sequence_type, default_factory, pass_key = configuration
return cls(default_factory, mapping, sequence_type=sequence_type,
pass_key=pass_key) | [
"def",
"_constructor",
"(",
"cls",
",",
"mapping",
",",
"configuration",
")",
":",
"sequence_type",
",",
"default_factory",
",",
"pass_key",
"=",
"configuration",
"return",
"cls",
"(",
"default_factory",
",",
"mapping",
",",
"sequence_type",
"=",
"sequence_type",
... | A standardized constructor. | [
"A",
"standardized",
"constructor",
"."
] | train | https://github.com/bcj/AttrDict/blob/8c1883162178a124ee29144ca7abcd83cbd9d222/attrdict/default.py#L124-L130 |
bcj/AttrDict | attrdict/dictionary.py | AttrDict._constructor | def _constructor(cls, mapping, configuration):
"""
A standardized constructor.
"""
attr = cls(mapping)
attr._setattr('_sequence_type', configuration)
return attr | python | def _constructor(cls, mapping, configuration):
"""
A standardized constructor.
"""
attr = cls(mapping)
attr._setattr('_sequence_type', configuration)
return attr | [
"def",
"_constructor",
"(",
"cls",
",",
"mapping",
",",
"configuration",
")",
":",
"attr",
"=",
"cls",
"(",
"mapping",
")",
"attr",
".",
"_setattr",
"(",
"'_sequence_type'",
",",
"configuration",
")",
"return",
"attr"
] | A standardized constructor. | [
"A",
"standardized",
"constructor",
"."
] | train | https://github.com/bcj/AttrDict/blob/8c1883162178a124ee29144ca7abcd83cbd9d222/attrdict/dictionary.py#L53-L60 |
ruipgil/changepy | changepy/pelt.py | pelt | def pelt(cost, length, pen=None):
""" PELT algorithm to compute changepoints in time series
Ported from:
https://github.com/STOR-i/Changepoints.jl
https://github.com/rkillick/changepoint/
Reference:
Killick R, Fearnhead P, Eckley IA (2012) Optimal detection
of changepoin... | python | def pelt(cost, length, pen=None):
""" PELT algorithm to compute changepoints in time series
Ported from:
https://github.com/STOR-i/Changepoints.jl
https://github.com/rkillick/changepoint/
Reference:
Killick R, Fearnhead P, Eckley IA (2012) Optimal detection
of changepoin... | [
"def",
"pelt",
"(",
"cost",
",",
"length",
",",
"pen",
"=",
"None",
")",
":",
"if",
"pen",
"is",
"None",
":",
"pen",
"=",
"np",
".",
"log",
"(",
"length",
")",
"F",
"=",
"np",
".",
"zeros",
"(",
"length",
"+",
"1",
")",
"R",
"=",
"np",
".",... | PELT algorithm to compute changepoints in time series
Ported from:
https://github.com/STOR-i/Changepoints.jl
https://github.com/rkillick/changepoint/
Reference:
Killick R, Fearnhead P, Eckley IA (2012) Optimal detection
of changepoints with a linear computational cost, JASA
... | [
"PELT",
"algorithm",
"to",
"compute",
"changepoints",
"in",
"time",
"series"
] | train | https://github.com/ruipgil/changepy/blob/95a903a24d532d658d4f1775d298c7fd51cdf47c/changepy/pelt.py#L14-L65 |
ruipgil/changepy | changepy/costs.py | normal_mean | def normal_mean(data, variance):
""" Creates a segment cost function for a time series with a
Normal distribution with changing mean
Args:
data (:obj:`list` of float): 1D time series data
variance (float): variance
Returns:
function: Function with signature
(int,... | python | def normal_mean(data, variance):
""" Creates a segment cost function for a time series with a
Normal distribution with changing mean
Args:
data (:obj:`list` of float): 1D time series data
variance (float): variance
Returns:
function: Function with signature
(int,... | [
"def",
"normal_mean",
"(",
"data",
",",
"variance",
")",
":",
"if",
"not",
"isinstance",
"(",
"data",
",",
"np",
".",
"ndarray",
")",
":",
"data",
"=",
"np",
".",
"array",
"(",
"data",
")",
"i_variance_2",
"=",
"1",
"/",
"(",
"variance",
"**",
"2",... | Creates a segment cost function for a time series with a
Normal distribution with changing mean
Args:
data (:obj:`list` of float): 1D time series data
variance (float): variance
Returns:
function: Function with signature
(int, int) -> float
where the firs... | [
"Creates",
"a",
"segment",
"cost",
"function",
"for",
"a",
"time",
"series",
"with",
"a",
"Normal",
"distribution",
"with",
"changing",
"mean"
] | train | https://github.com/ruipgil/changepy/blob/95a903a24d532d658d4f1775d298c7fd51cdf47c/changepy/costs.py#L3-L41 |
ruipgil/changepy | changepy/costs.py | normal_var | def normal_var(data, mean):
""" Creates a segment cost function for a time series with a
Normal distribution with changing variance
Args:
data (:obj:`list` of float): 1D time series data
variance (float): variance
Returns:
function: Function with signature
(int, ... | python | def normal_var(data, mean):
""" Creates a segment cost function for a time series with a
Normal distribution with changing variance
Args:
data (:obj:`list` of float): 1D time series data
variance (float): variance
Returns:
function: Function with signature
(int, ... | [
"def",
"normal_var",
"(",
"data",
",",
"mean",
")",
":",
"if",
"not",
"isinstance",
"(",
"data",
",",
"np",
".",
"ndarray",
")",
":",
"data",
"=",
"np",
".",
"array",
"(",
"data",
")",
"cumm",
"=",
"[",
"0.0",
"]",
"cumm",
".",
"extend",
"(",
"... | Creates a segment cost function for a time series with a
Normal distribution with changing variance
Args:
data (:obj:`list` of float): 1D time series data
variance (float): variance
Returns:
function: Function with signature
(int, int) -> float
where the ... | [
"Creates",
"a",
"segment",
"cost",
"function",
"for",
"a",
"time",
"series",
"with",
"a",
"Normal",
"distribution",
"with",
"changing",
"variance"
] | train | https://github.com/ruipgil/changepy/blob/95a903a24d532d658d4f1775d298c7fd51cdf47c/changepy/costs.py#L43-L75 |
ruipgil/changepy | changepy/costs.py | normal_meanvar | def normal_meanvar(data):
""" Creates a segment cost function for a time series with a
Normal distribution with changing mean and variance
Args:
data (:obj:`list` of float): 1D time series data
Returns:
function: Function with signature
(int, int) -> float
wh... | python | def normal_meanvar(data):
""" Creates a segment cost function for a time series with a
Normal distribution with changing mean and variance
Args:
data (:obj:`list` of float): 1D time series data
Returns:
function: Function with signature
(int, int) -> float
wh... | [
"def",
"normal_meanvar",
"(",
"data",
")",
":",
"data",
"=",
"np",
".",
"hstack",
"(",
"(",
"[",
"0.0",
"]",
",",
"np",
".",
"array",
"(",
"data",
")",
")",
")",
"cumm",
"=",
"np",
".",
"cumsum",
"(",
"data",
")",
"cumm_sq",
"=",
"np",
".",
"... | Creates a segment cost function for a time series with a
Normal distribution with changing mean and variance
Args:
data (:obj:`list` of float): 1D time series data
Returns:
function: Function with signature
(int, int) -> float
where the first arg is the starting ... | [
"Creates",
"a",
"segment",
"cost",
"function",
"for",
"a",
"time",
"series",
"with",
"a",
"Normal",
"distribution",
"with",
"changing",
"mean",
"and",
"variance"
] | train | https://github.com/ruipgil/changepy/blob/95a903a24d532d658d4f1775d298c7fd51cdf47c/changepy/costs.py#L77-L109 |
ruipgil/changepy | changepy/costs.py | poisson | def poisson(data):
""" Creates a segment cost function for a time series with a
poisson distribution with changing mean
Args:
data (:obj:`list` of float): 1D time series data
Returns:
function: Function with signature
(int, int) -> float
where the first arg i... | python | def poisson(data):
""" Creates a segment cost function for a time series with a
poisson distribution with changing mean
Args:
data (:obj:`list` of float): 1D time series data
Returns:
function: Function with signature
(int, int) -> float
where the first arg i... | [
"def",
"poisson",
"(",
"data",
")",
":",
"data",
"=",
"np",
".",
"hstack",
"(",
"(",
"[",
"0.0",
"]",
",",
"np",
".",
"array",
"(",
"data",
")",
")",
")",
"cumm",
"=",
"np",
".",
"cumsum",
"(",
"data",
")",
"def",
"cost",
"(",
"s",
",",
"t"... | Creates a segment cost function for a time series with a
poisson distribution with changing mean
Args:
data (:obj:`list` of float): 1D time series data
Returns:
function: Function with signature
(int, int) -> float
where the first arg is the starting index, and t... | [
"Creates",
"a",
"segment",
"cost",
"function",
"for",
"a",
"time",
"series",
"with",
"a",
"poisson",
"distribution",
"with",
"changing",
"mean"
] | train | https://github.com/ruipgil/changepy/blob/95a903a24d532d658d4f1775d298c7fd51cdf47c/changepy/costs.py#L111-L141 |
ruipgil/changepy | changepy/costs.py | exponential | def exponential(data):
""" Creates a segment cost function for a time series with a
exponential distribution with changing mean
Args:
data (:obj:`list` of float): 1D time series data
Returns:
function: Function with signature
(int, int) -> float
where the fir... | python | def exponential(data):
""" Creates a segment cost function for a time series with a
exponential distribution with changing mean
Args:
data (:obj:`list` of float): 1D time series data
Returns:
function: Function with signature
(int, int) -> float
where the fir... | [
"def",
"exponential",
"(",
"data",
")",
":",
"data",
"=",
"np",
".",
"hstack",
"(",
"(",
"[",
"0.0",
"]",
",",
"np",
".",
"array",
"(",
"data",
")",
")",
")",
"cumm",
"=",
"np",
".",
"cumsum",
"(",
"data",
")",
"def",
"cost",
"(",
"s",
",",
... | Creates a segment cost function for a time series with a
exponential distribution with changing mean
Args:
data (:obj:`list` of float): 1D time series data
Returns:
function: Function with signature
(int, int) -> float
where the first arg is the starting index, a... | [
"Creates",
"a",
"segment",
"cost",
"function",
"for",
"a",
"time",
"series",
"with",
"a",
"exponential",
"distribution",
"with",
"changing",
"mean"
] | train | https://github.com/ruipgil/changepy/blob/95a903a24d532d658d4f1775d298c7fd51cdf47c/changepy/costs.py#L143-L169 |
openaddresses/pyesridump | esridump/dumper.py | EsriDumper._get_layer_min_max | def _get_layer_min_max(self, oid_field_name):
""" Find the min and max values for the OID field. """
query_args = self._build_query_args({
'f': 'json',
'outFields': '',
'outStatistics': json.dumps([
dict(statisticType='min', onStatisticField=oid_field_... | python | def _get_layer_min_max(self, oid_field_name):
""" Find the min and max values for the OID field. """
query_args = self._build_query_args({
'f': 'json',
'outFields': '',
'outStatistics': json.dumps([
dict(statisticType='min', onStatisticField=oid_field_... | [
"def",
"_get_layer_min_max",
"(",
"self",
",",
"oid_field_name",
")",
":",
"query_args",
"=",
"self",
".",
"_build_query_args",
"(",
"{",
"'f'",
":",
"'json'",
",",
"'outFields'",
":",
"''",
",",
"'outStatistics'",
":",
"json",
".",
"dumps",
"(",
"[",
"dic... | Find the min and max values for the OID field. | [
"Find",
"the",
"min",
"and",
"max",
"values",
"for",
"the",
"OID",
"field",
"."
] | train | https://github.com/openaddresses/pyesridump/blob/378155816559134b8d2b3de0d0f2fddc74f23fcd/esridump/dumper.py#L166-L211 |
openaddresses/pyesridump | esridump/esri2geojson.py | ring_is_clockwise | def ring_is_clockwise(ring):
"""
Determine if polygon ring coordinates are clockwise. Clockwise signifies
outer ring, counter-clockwise an inner ring or hole. this logic was found
at http://stackoverflow.com/questions/1165647/how-to-determine-if-a-list-of-polygon-points-are-in-clockwise-order
this c... | python | def ring_is_clockwise(ring):
"""
Determine if polygon ring coordinates are clockwise. Clockwise signifies
outer ring, counter-clockwise an inner ring or hole. this logic was found
at http://stackoverflow.com/questions/1165647/how-to-determine-if-a-list-of-polygon-points-are-in-clockwise-order
this c... | [
"def",
"ring_is_clockwise",
"(",
"ring",
")",
":",
"total",
"=",
"0",
"for",
"(",
"pt1",
",",
"pt2",
")",
"in",
"pairwise",
"(",
"ring",
")",
":",
"total",
"+=",
"(",
"pt2",
"[",
"0",
"]",
"-",
"pt1",
"[",
"0",
"]",
")",
"*",
"(",
"pt2",
"[",... | Determine if polygon ring coordinates are clockwise. Clockwise signifies
outer ring, counter-clockwise an inner ring or hole. this logic was found
at http://stackoverflow.com/questions/1165647/how-to-determine-if-a-list-of-polygon-points-are-in-clockwise-order
this code taken from http://esri.github.com/geo... | [
"Determine",
"if",
"polygon",
"ring",
"coordinates",
"are",
"clockwise",
".",
"Clockwise",
"signifies",
"outer",
"ring",
"counter",
"-",
"clockwise",
"an",
"inner",
"ring",
"or",
"hole",
".",
"this",
"logic",
"was",
"found",
"at",
"http",
":",
"//",
"stackov... | train | https://github.com/openaddresses/pyesridump/blob/378155816559134b8d2b3de0d0f2fddc74f23fcd/esridump/esri2geojson.py#L126-L136 |
mdsol/rwslib | rwslib/rws_requests/__init__.py | format_date_argument | def format_date_argument(date_element):
"""
Take a date as either a datetime.date/datetime or a string and return it as a iso8601 formatted value
:param Union[datetime.date, datetime.datetime] date_element: passed argument
:rtype str
:return:
"""
if not isinstance(date_element, (datetime.dat... | python | def format_date_argument(date_element):
"""
Take a date as either a datetime.date/datetime or a string and return it as a iso8601 formatted value
:param Union[datetime.date, datetime.datetime] date_element: passed argument
:rtype str
:return:
"""
if not isinstance(date_element, (datetime.dat... | [
"def",
"format_date_argument",
"(",
"date_element",
")",
":",
"if",
"not",
"isinstance",
"(",
"date_element",
",",
"(",
"datetime",
".",
"datetime",
",",
"datetime",
".",
"date",
")",
")",
":",
"# TODO:",
"if",
"\"T\"",
"in",
"date_element",
":",
"_date",
... | Take a date as either a datetime.date/datetime or a string and return it as a iso8601 formatted value
:param Union[datetime.date, datetime.datetime] date_element: passed argument
:rtype str
:return: | [
"Take",
"a",
"date",
"as",
"either",
"a",
"datetime",
".",
"date",
"/",
"datetime",
"or",
"a",
"string",
"and",
"return",
"it",
"as",
"a",
"iso8601",
"formatted",
"value",
":",
"param",
"Union",
"[",
"datetime",
".",
"date",
"datetime",
".",
"datetime",
... | train | https://github.com/mdsol/rwslib/blob/1a86bc072d408c009ed1de8bf6e98a1769f54d18/rwslib/rws_requests/__init__.py#L35-L50 |
mdsol/rwslib | rwslib/rws_requests/__init__.py | make_url | def make_url(*args, **kwargs):
"""Makes a URL from component parts"""
base = "/".join(args)
if kwargs:
return "%s?%s" % (base, urlencode(kwargs))
else:
return base | python | def make_url(*args, **kwargs):
"""Makes a URL from component parts"""
base = "/".join(args)
if kwargs:
return "%s?%s" % (base, urlencode(kwargs))
else:
return base | [
"def",
"make_url",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"base",
"=",
"\"/\"",
".",
"join",
"(",
"args",
")",
"if",
"kwargs",
":",
"return",
"\"%s?%s\"",
"%",
"(",
"base",
",",
"urlencode",
"(",
"kwargs",
")",
")",
"else",
":",
"re... | Makes a URL from component parts | [
"Makes",
"a",
"URL",
"from",
"component",
"parts"
] | train | https://github.com/mdsol/rwslib/blob/1a86bc072d408c009ed1de8bf6e98a1769f54d18/rwslib/rws_requests/__init__.py#L56-L62 |
mdsol/rwslib | rwslib/rws_requests/__init__.py | QueryOptionGetRequest._querystring | def _querystring(self):
"""Get additional keyword arguments"""
kw = {}
for key in self.KNOWN_QUERY_OPTIONS:
val = getattr(self, key)
if val is not None:
kw[key] = val
return kw | python | def _querystring(self):
"""Get additional keyword arguments"""
kw = {}
for key in self.KNOWN_QUERY_OPTIONS:
val = getattr(self, key)
if val is not None:
kw[key] = val
return kw | [
"def",
"_querystring",
"(",
"self",
")",
":",
"kw",
"=",
"{",
"}",
"for",
"key",
"in",
"self",
".",
"KNOWN_QUERY_OPTIONS",
":",
"val",
"=",
"getattr",
"(",
"self",
",",
"key",
")",
"if",
"val",
"is",
"not",
"None",
":",
"kw",
"[",
"key",
"]",
"="... | Get additional keyword arguments | [
"Get",
"additional",
"keyword",
"arguments"
] | train | https://github.com/mdsol/rwslib/blob/1a86bc072d408c009ed1de8bf6e98a1769f54d18/rwslib/rws_requests/__init__.py#L130-L138 |
mdsol/rwslib | rwslib/rws_requests/__init__.py | StudySubjectsRequest._querystring | def _querystring(self):
"""Additional keyword arguments"""
kw = {}
if self.status:
kw["status"] = "all"
if self.links:
kw["links"] = "all"
if self.include is not None:
kw["include"] = self.include
if self.subject_key_type != "SubjectN... | python | def _querystring(self):
"""Additional keyword arguments"""
kw = {}
if self.status:
kw["status"] = "all"
if self.links:
kw["links"] = "all"
if self.include is not None:
kw["include"] = self.include
if self.subject_key_type != "SubjectN... | [
"def",
"_querystring",
"(",
"self",
")",
":",
"kw",
"=",
"{",
"}",
"if",
"self",
".",
"status",
":",
"kw",
"[",
"\"status\"",
"]",
"=",
"\"all\"",
"if",
"self",
".",
"links",
":",
"kw",
"[",
"\"links\"",
"]",
"=",
"\"all\"",
"if",
"self",
".",
"i... | Additional keyword arguments | [
"Additional",
"keyword",
"arguments"
] | train | https://github.com/mdsol/rwslib/blob/1a86bc072d408c009ed1de8bf6e98a1769f54d18/rwslib/rws_requests/__init__.py#L478-L491 |
mdsol/rwslib | rwslib/rws_requests/__init__.py | ConfigurableDatasetRequest.dataset | def dataset(self):
"""
Qualify the dataset_name with the dataset_format if supplied
:return: dataset name
:rtype: str
"""
if self.dataset_format:
return ".".join([self.dataset_name, self.dataset_format])
return self.dataset_name | python | def dataset(self):
"""
Qualify the dataset_name with the dataset_format if supplied
:return: dataset name
:rtype: str
"""
if self.dataset_format:
return ".".join([self.dataset_name, self.dataset_format])
return self.dataset_name | [
"def",
"dataset",
"(",
"self",
")",
":",
"if",
"self",
".",
"dataset_format",
":",
"return",
"\".\"",
".",
"join",
"(",
"[",
"self",
".",
"dataset_name",
",",
"self",
".",
"dataset_format",
"]",
")",
"return",
"self",
".",
"dataset_name"
] | Qualify the dataset_name with the dataset_format if supplied
:return: dataset name
:rtype: str | [
"Qualify",
"the",
"dataset_name",
"with",
"the",
"dataset_format",
"if",
"supplied",
":",
"return",
":",
"dataset",
"name",
":",
"rtype",
":",
"str"
] | train | https://github.com/mdsol/rwslib/blob/1a86bc072d408c009ed1de8bf6e98a1769f54d18/rwslib/rws_requests/__init__.py#L797-L805 |
mdsol/rwslib | rwslib/rws_requests/biostats_gateway.py | check_dataset_format | def check_dataset_format(ds_format):
"""
Ensure dataset format is XML or CSV
:param str ds_format: Format of the Dataset (expected to be one of `csv` or `xml`)
"""
if ds_format.lower() not in DATASET_FORMATS.keys():
raise ValueError(
"dataset_format is expected to be one of %s. ... | python | def check_dataset_format(ds_format):
"""
Ensure dataset format is XML or CSV
:param str ds_format: Format of the Dataset (expected to be one of `csv` or `xml`)
"""
if ds_format.lower() not in DATASET_FORMATS.keys():
raise ValueError(
"dataset_format is expected to be one of %s. ... | [
"def",
"check_dataset_format",
"(",
"ds_format",
")",
":",
"if",
"ds_format",
".",
"lower",
"(",
")",
"not",
"in",
"DATASET_FORMATS",
".",
"keys",
"(",
")",
":",
"raise",
"ValueError",
"(",
"\"dataset_format is expected to be one of %s. '%s' is not valid\"",
"%",
"(... | Ensure dataset format is XML or CSV
:param str ds_format: Format of the Dataset (expected to be one of `csv` or `xml`) | [
"Ensure",
"dataset",
"format",
"is",
"XML",
"or",
"CSV"
] | train | https://github.com/mdsol/rwslib/blob/1a86bc072d408c009ed1de8bf6e98a1769f54d18/rwslib/rws_requests/biostats_gateway.py#L16-L26 |
mdsol/rwslib | rwslib/rws_requests/biostats_gateway.py | dataset_format_to_extension | def dataset_format_to_extension(ds_format):
"""
Get the preferred Dataset format extension
:param str ds_format: Format of the Dataset (expected to be one of `csv` or `xml`)
:rtype: str
"""
try:
return DATASET_FORMATS[ds_format]
except KeyError:
raise ValueError(
... | python | def dataset_format_to_extension(ds_format):
"""
Get the preferred Dataset format extension
:param str ds_format: Format of the Dataset (expected to be one of `csv` or `xml`)
:rtype: str
"""
try:
return DATASET_FORMATS[ds_format]
except KeyError:
raise ValueError(
... | [
"def",
"dataset_format_to_extension",
"(",
"ds_format",
")",
":",
"try",
":",
"return",
"DATASET_FORMATS",
"[",
"ds_format",
"]",
"except",
"KeyError",
":",
"raise",
"ValueError",
"(",
"\"dataset_format is expected to be one of %s. '%s' is not valid\"",
"%",
"(",
"\", \""... | Get the preferred Dataset format extension
:param str ds_format: Format of the Dataset (expected to be one of `csv` or `xml`)
:rtype: str | [
"Get",
"the",
"preferred",
"Dataset",
"format",
"extension"
] | train | https://github.com/mdsol/rwslib/blob/1a86bc072d408c009ed1de8bf6e98a1769f54d18/rwslib/rws_requests/biostats_gateway.py#L29-L42 |
mdsol/rwslib | rwslib/extras/rwscmd/rwscmd.py | get_data | def get_data(ctx, study, environment, subject):
"""
Call rwscmd_getdata custom dataset to retrieve currently enterable, empty fields
"""
cfg = GetDataConfigurableDataset(GET_DATA_DATASET,
study,
environment,
... | python | def get_data(ctx, study, environment, subject):
"""
Call rwscmd_getdata custom dataset to retrieve currently enterable, empty fields
"""
cfg = GetDataConfigurableDataset(GET_DATA_DATASET,
study,
environment,
... | [
"def",
"get_data",
"(",
"ctx",
",",
"study",
",",
"environment",
",",
"subject",
")",
":",
"cfg",
"=",
"GetDataConfigurableDataset",
"(",
"GET_DATA_DATASET",
",",
"study",
",",
"environment",
",",
"subject",
",",
"params",
"=",
"dict",
"(",
"IncludeIDs",
"="... | Call rwscmd_getdata custom dataset to retrieve currently enterable, empty fields | [
"Call",
"rwscmd_getdata",
"custom",
"dataset",
"to",
"retrieve",
"currently",
"enterable",
"empty",
"fields"
] | train | https://github.com/mdsol/rwslib/blob/1a86bc072d408c009ed1de8bf6e98a1769f54d18/rwslib/extras/rwscmd/rwscmd.py#L66-L91 |
mdsol/rwslib | rwslib/extras/rwscmd/rwscmd.py | rws_call | def rws_call(ctx, method, default_attr=None):
"""Make request to RWS"""
try:
response = ctx.obj['RWS'].send_request(method)
if ctx.obj['RAW']: # use response from RWS
result = ctx.obj['RWS'].last_result.text
elif default_attr is not None: # human-readable summary
... | python | def rws_call(ctx, method, default_attr=None):
"""Make request to RWS"""
try:
response = ctx.obj['RWS'].send_request(method)
if ctx.obj['RAW']: # use response from RWS
result = ctx.obj['RWS'].last_result.text
elif default_attr is not None: # human-readable summary
... | [
"def",
"rws_call",
"(",
"ctx",
",",
"method",
",",
"default_attr",
"=",
"None",
")",
":",
"try",
":",
"response",
"=",
"ctx",
".",
"obj",
"[",
"'RWS'",
"]",
".",
"send_request",
"(",
"method",
")",
"if",
"ctx",
".",
"obj",
"[",
"'RAW'",
"]",
":",
... | Make request to RWS | [
"Make",
"request",
"to",
"RWS"
] | train | https://github.com/mdsol/rwslib/blob/1a86bc072d408c009ed1de8bf6e98a1769f54d18/rwslib/extras/rwscmd/rwscmd.py#L94-L114 |
mdsol/rwslib | rwslib/extras/rwscmd/rwscmd.py | data | def data(ctx, path):
"""List EDC data for [STUDY] [ENV] [SUBJECT]"""
_rws = partial(rws_call, ctx)
if len(path) == 0:
_rws(ClinicalStudiesRequest(), default_attr='oid')
elif len(path) == 1:
_rws(StudySubjectsRequest(path[0], 'Prod'), default_attr='subjectkey')
elif len(path) == 2:
... | python | def data(ctx, path):
"""List EDC data for [STUDY] [ENV] [SUBJECT]"""
_rws = partial(rws_call, ctx)
if len(path) == 0:
_rws(ClinicalStudiesRequest(), default_attr='oid')
elif len(path) == 1:
_rws(StudySubjectsRequest(path[0], 'Prod'), default_attr='subjectkey')
elif len(path) == 2:
... | [
"def",
"data",
"(",
"ctx",
",",
"path",
")",
":",
"_rws",
"=",
"partial",
"(",
"rws_call",
",",
"ctx",
")",
"if",
"len",
"(",
"path",
")",
"==",
"0",
":",
"_rws",
"(",
"ClinicalStudiesRequest",
"(",
")",
",",
"default_attr",
"=",
"'oid'",
")",
"eli... | List EDC data for [STUDY] [ENV] [SUBJECT] | [
"List",
"EDC",
"data",
"for",
"[",
"STUDY",
"]",
"[",
"ENV",
"]",
"[",
"SUBJECT",
"]"
] | train | https://github.com/mdsol/rwslib/blob/1a86bc072d408c009ed1de8bf6e98a1769f54d18/rwslib/extras/rwscmd/rwscmd.py#L127-L144 |
mdsol/rwslib | rwslib/extras/rwscmd/rwscmd.py | post | def post(ctx, odm):
"""Post ODM clinical data"""
try:
ctx.obj['RWS'].send_request(PostDataRequest(odm.read()))
if ctx.obj['RAW']:
click.echo(ctx.obj['RWS'].last_result.text)
except RWSException as e:
click.echo(e.message) | python | def post(ctx, odm):
"""Post ODM clinical data"""
try:
ctx.obj['RWS'].send_request(PostDataRequest(odm.read()))
if ctx.obj['RAW']:
click.echo(ctx.obj['RWS'].last_result.text)
except RWSException as e:
click.echo(e.message) | [
"def",
"post",
"(",
"ctx",
",",
"odm",
")",
":",
"try",
":",
"ctx",
".",
"obj",
"[",
"'RWS'",
"]",
".",
"send_request",
"(",
"PostDataRequest",
"(",
"odm",
".",
"read",
"(",
")",
")",
")",
"if",
"ctx",
".",
"obj",
"[",
"'RAW'",
"]",
":",
"click... | Post ODM clinical data | [
"Post",
"ODM",
"clinical",
"data"
] | train | https://github.com/mdsol/rwslib/blob/1a86bc072d408c009ed1de8bf6e98a1769f54d18/rwslib/extras/rwscmd/rwscmd.py#L150-L157 |
mdsol/rwslib | rwslib/extras/rwscmd/rwscmd.py | metadata | def metadata(ctx, drafts, path):
"""List metadata for [PROJECT] [VERSION]"""
_rws = partial(rws_call, ctx)
if len(path) == 0:
_rws(MetadataStudiesRequest(), default_attr='oid')
elif len(path) == 1:
if drafts:
_rws(StudyDraftsRequest(path[0]), default_attr='oid')
else:... | python | def metadata(ctx, drafts, path):
"""List metadata for [PROJECT] [VERSION]"""
_rws = partial(rws_call, ctx)
if len(path) == 0:
_rws(MetadataStudiesRequest(), default_attr='oid')
elif len(path) == 1:
if drafts:
_rws(StudyDraftsRequest(path[0]), default_attr='oid')
else:... | [
"def",
"metadata",
"(",
"ctx",
",",
"drafts",
",",
"path",
")",
":",
"_rws",
"=",
"partial",
"(",
"rws_call",
",",
"ctx",
")",
"if",
"len",
"(",
"path",
")",
"==",
"0",
":",
"_rws",
"(",
"MetadataStudiesRequest",
"(",
")",
",",
"default_attr",
"=",
... | List metadata for [PROJECT] [VERSION] | [
"List",
"metadata",
"for",
"[",
"PROJECT",
"]",
"[",
"VERSION",
"]"
] | train | https://github.com/mdsol/rwslib/blob/1a86bc072d408c009ed1de8bf6e98a1769f54d18/rwslib/extras/rwscmd/rwscmd.py#L164-L177 |
mdsol/rwslib | rwslib/extras/rwscmd/rwscmd.py | direct | def direct(ctx, path):
"""Make direct call to RWS, bypassing rwslib"""
try:
url = make_url(ctx.obj['RWS'].base_url, path)
resp = requests.get(url, auth=HTTPBasicAuth(ctx.obj['USERNAME'], ctx.obj['PASSWORD']))
click.echo(resp.text)
except RWSException as e:
click.echo(e.messag... | python | def direct(ctx, path):
"""Make direct call to RWS, bypassing rwslib"""
try:
url = make_url(ctx.obj['RWS'].base_url, path)
resp = requests.get(url, auth=HTTPBasicAuth(ctx.obj['USERNAME'], ctx.obj['PASSWORD']))
click.echo(resp.text)
except RWSException as e:
click.echo(e.messag... | [
"def",
"direct",
"(",
"ctx",
",",
"path",
")",
":",
"try",
":",
"url",
"=",
"make_url",
"(",
"ctx",
".",
"obj",
"[",
"'RWS'",
"]",
".",
"base_url",
",",
"path",
")",
"resp",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"auth",
"=",
"HTTPBasicAut... | Make direct call to RWS, bypassing rwslib | [
"Make",
"direct",
"call",
"to",
"RWS",
"bypassing",
"rwslib"
] | train | https://github.com/mdsol/rwslib/blob/1a86bc072d408c009ed1de8bf6e98a1769f54d18/rwslib/extras/rwscmd/rwscmd.py#L183-L192 |
mdsol/rwslib | rwslib/extras/rwscmd/rwscmd.py | autofill | def autofill(ctx, steps, metadata, fixed, study, environment, subject):
"""Request enterable data for a subject, generate data values and post back to Rave.
Requires 'rwscmd_getdata' configurable dataset to be installed on the Rave URL."""
if metadata is not None: # Read metadata from file, if supplied
... | python | def autofill(ctx, steps, metadata, fixed, study, environment, subject):
"""Request enterable data for a subject, generate data values and post back to Rave.
Requires 'rwscmd_getdata' configurable dataset to be installed on the Rave URL."""
if metadata is not None: # Read metadata from file, if supplied
... | [
"def",
"autofill",
"(",
"ctx",
",",
"steps",
",",
"metadata",
",",
"fixed",
",",
"study",
",",
"environment",
",",
"subject",
")",
":",
"if",
"metadata",
"is",
"not",
"None",
":",
"# Read metadata from file, if supplied",
"odm_metadata",
"=",
"metadata",
".",
... | Request enterable data for a subject, generate data values and post back to Rave.
Requires 'rwscmd_getdata' configurable dataset to be installed on the Rave URL. | [
"Request",
"enterable",
"data",
"for",
"a",
"subject",
"generate",
"data",
"values",
"and",
"post",
"back",
"to",
"Rave",
".",
"Requires",
"rwscmd_getdata",
"configurable",
"dataset",
"to",
"be",
"installed",
"on",
"the",
"Rave",
"URL",
"."
] | train | https://github.com/mdsol/rwslib/blob/1a86bc072d408c009ed1de8bf6e98a1769f54d18/rwslib/extras/rwscmd/rwscmd.py#L205-L274 |
mdsol/rwslib | rwslib/builders/metadata.py | Study.build | def build(self, builder):
"""Build XML by appending to builder"""
params = dict(OID=self.oid)
params["mdsol:ProjectType"] = self.project_type
builder.start("Study", params)
# Ask children
if self.global_variables is not None:
self.global_variables.build(buil... | python | def build(self, builder):
"""Build XML by appending to builder"""
params = dict(OID=self.oid)
params["mdsol:ProjectType"] = self.project_type
builder.start("Study", params)
# Ask children
if self.global_variables is not None:
self.global_variables.build(buil... | [
"def",
"build",
"(",
"self",
",",
"builder",
")",
":",
"params",
"=",
"dict",
"(",
"OID",
"=",
"self",
".",
"oid",
")",
"params",
"[",
"\"mdsol:ProjectType\"",
"]",
"=",
"self",
".",
"project_type",
"builder",
".",
"start",
"(",
"\"Study\"",
",",
"para... | Build XML by appending to builder | [
"Build",
"XML",
"by",
"appending",
"to",
"builder"
] | train | https://github.com/mdsol/rwslib/blob/1a86bc072d408c009ed1de8bf6e98a1769f54d18/rwslib/builders/metadata.py#L54-L71 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.