repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
quantmind/agile-toolkit | agiletoolkit/repo.py | RepoManager.message | def message(self, msg):
"""Send a message to third party applications
"""
for broker in self.message_brokers:
try:
broker(msg)
except Exception as exc:
utils.error(exc) | python | def message(self, msg):
"""Send a message to third party applications
"""
for broker in self.message_brokers:
try:
broker(msg)
except Exception as exc:
utils.error(exc) | [
"def",
"message",
"(",
"self",
",",
"msg",
")",
":",
"for",
"broker",
"in",
"self",
".",
"message_brokers",
":",
"try",
":",
"broker",
"(",
"msg",
")",
"except",
"Exception",
"as",
"exc",
":",
"utils",
".",
"error",
"(",
"exc",
")"
] | Send a message to third party applications | [
"Send",
"a",
"message",
"to",
"third",
"party",
"applications"
] | 96028e36a842c57b171907c20583a60d1045fec1 | https://github.com/quantmind/agile-toolkit/blob/96028e36a842c57b171907c20583a60d1045fec1/agiletoolkit/repo.py#L94-L101 | train |
mozilla-services/amo2kinto | amo2kinto/kinto.py | get_kinto_records | def get_kinto_records(kinto_client, bucket, collection, permissions,
config=None):
"""Return all the kinto records for this bucket/collection."""
# Create bucket if needed
try:
kinto_client.create_bucket(id=bucket, if_not_exists=True)
except KintoException as e:
if ... | python | def get_kinto_records(kinto_client, bucket, collection, permissions,
config=None):
"""Return all the kinto records for this bucket/collection."""
# Create bucket if needed
try:
kinto_client.create_bucket(id=bucket, if_not_exists=True)
except KintoException as e:
if ... | [
"def",
"get_kinto_records",
"(",
"kinto_client",
",",
"bucket",
",",
"collection",
",",
"permissions",
",",
"config",
"=",
"None",
")",
":",
"# Create bucket if needed",
"try",
":",
"kinto_client",
".",
"create_bucket",
"(",
"id",
"=",
"bucket",
",",
"if_not_exi... | Return all the kinto records for this bucket/collection. | [
"Return",
"all",
"the",
"kinto",
"records",
"for",
"this",
"bucket",
"/",
"collection",
"."
] | 1ec40647e77cf89badbea4a58d328243daed49a9 | https://github.com/mozilla-services/amo2kinto/blob/1ec40647e77cf89badbea4a58d328243daed49a9/amo2kinto/kinto.py#L4-L23 | train |
xenadevel/PyXenaManager | xenamanager/api/xena_cli.py | XenaCliWrapper.add_chassis | def add_chassis(self, chassis):
"""
:param ip: chassis object
"""
self.chassis_list[chassis] = XenaSocket(self.logger, chassis.ip, chassis.port)
self.chassis_list[chassis].connect()
KeepAliveThread(self.chassis_list[chassis]).start()
self.send_command(chassis, 'c... | python | def add_chassis(self, chassis):
"""
:param ip: chassis object
"""
self.chassis_list[chassis] = XenaSocket(self.logger, chassis.ip, chassis.port)
self.chassis_list[chassis].connect()
KeepAliveThread(self.chassis_list[chassis]).start()
self.send_command(chassis, 'c... | [
"def",
"add_chassis",
"(",
"self",
",",
"chassis",
")",
":",
"self",
".",
"chassis_list",
"[",
"chassis",
"]",
"=",
"XenaSocket",
"(",
"self",
".",
"logger",
",",
"chassis",
".",
"ip",
",",
"chassis",
".",
"port",
")",
"self",
".",
"chassis_list",
"[",... | :param ip: chassis object | [
":",
"param",
"ip",
":",
"chassis",
"object"
] | 384ca265f73044b8a8b471f5dd7a6103fc54f4df | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/api/xena_cli.py#L34-L43 | train |
xenadevel/PyXenaManager | xenamanager/api/xena_cli.py | XenaCliWrapper.send_command | def send_command(self, obj, command, *arguments):
""" Send command and do not parse output (except for communication errors).
:param obj: requested object.
:param command: command to send.
:param arguments: list of command arguments.
"""
index_command = obj._build_index_... | python | def send_command(self, obj, command, *arguments):
""" Send command and do not parse output (except for communication errors).
:param obj: requested object.
:param command: command to send.
:param arguments: list of command arguments.
"""
index_command = obj._build_index_... | [
"def",
"send_command",
"(",
"self",
",",
"obj",
",",
"command",
",",
"*",
"arguments",
")",
":",
"index_command",
"=",
"obj",
".",
"_build_index_command",
"(",
"command",
",",
"*",
"arguments",
")",
"self",
".",
"chassis_list",
"[",
"obj",
".",
"chassis",
... | Send command and do not parse output (except for communication errors).
:param obj: requested object.
:param command: command to send.
:param arguments: list of command arguments. | [
"Send",
"command",
"and",
"do",
"not",
"parse",
"output",
"(",
"except",
"for",
"communication",
"errors",
")",
"."
] | 384ca265f73044b8a8b471f5dd7a6103fc54f4df | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/api/xena_cli.py#L48-L56 | train |
xenadevel/PyXenaManager | xenamanager/api/xena_cli.py | XenaCliWrapper.send_command_return | def send_command_return(self, obj, command, *arguments):
""" Send command and wait for single line output. """
index_command = obj._build_index_command(command, *arguments)
return obj._extract_return(command, self.chassis_list[obj.chassis].sendQuery(index_command)) | python | def send_command_return(self, obj, command, *arguments):
""" Send command and wait for single line output. """
index_command = obj._build_index_command(command, *arguments)
return obj._extract_return(command, self.chassis_list[obj.chassis].sendQuery(index_command)) | [
"def",
"send_command_return",
"(",
"self",
",",
"obj",
",",
"command",
",",
"*",
"arguments",
")",
":",
"index_command",
"=",
"obj",
".",
"_build_index_command",
"(",
"command",
",",
"*",
"arguments",
")",
"return",
"obj",
".",
"_extract_return",
"(",
"comma... | Send command and wait for single line output. | [
"Send",
"command",
"and",
"wait",
"for",
"single",
"line",
"output",
"."
] | 384ca265f73044b8a8b471f5dd7a6103fc54f4df | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/api/xena_cli.py#L58-L61 | train |
xenadevel/PyXenaManager | xenamanager/api/xena_cli.py | XenaCliWrapper.send_command_return_multilines | def send_command_return_multilines(self, obj, command, *arguments):
""" Send command and wait for multiple lines output. """
index_command = obj._build_index_command(command, *arguments)
return self.chassis_list[obj.chassis].sendQuery(index_command, True) | python | def send_command_return_multilines(self, obj, command, *arguments):
""" Send command and wait for multiple lines output. """
index_command = obj._build_index_command(command, *arguments)
return self.chassis_list[obj.chassis].sendQuery(index_command, True) | [
"def",
"send_command_return_multilines",
"(",
"self",
",",
"obj",
",",
"command",
",",
"*",
"arguments",
")",
":",
"index_command",
"=",
"obj",
".",
"_build_index_command",
"(",
"command",
",",
"*",
"arguments",
")",
"return",
"self",
".",
"chassis_list",
"[",... | Send command and wait for multiple lines output. | [
"Send",
"command",
"and",
"wait",
"for",
"multiple",
"lines",
"output",
"."
] | 384ca265f73044b8a8b471f5dd7a6103fc54f4df | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/api/xena_cli.py#L63-L66 | train |
xenadevel/PyXenaManager | xenamanager/api/xena_cli.py | XenaCliWrapper.get_attribute | def get_attribute(self, obj, attribute):
""" Returns single object attribute.
:param obj: requested object.
:param attribute: requested attribute to query.
:returns: returned value.
:rtype: str
"""
raw_return = self.send_command_return(obj, attribute, '?')
... | python | def get_attribute(self, obj, attribute):
""" Returns single object attribute.
:param obj: requested object.
:param attribute: requested attribute to query.
:returns: returned value.
:rtype: str
"""
raw_return = self.send_command_return(obj, attribute, '?')
... | [
"def",
"get_attribute",
"(",
"self",
",",
"obj",
",",
"attribute",
")",
":",
"raw_return",
"=",
"self",
".",
"send_command_return",
"(",
"obj",
",",
"attribute",
",",
"'?'",
")",
"if",
"len",
"(",
"raw_return",
")",
">",
"2",
"and",
"raw_return",
"[",
... | Returns single object attribute.
:param obj: requested object.
:param attribute: requested attribute to query.
:returns: returned value.
:rtype: str | [
"Returns",
"single",
"object",
"attribute",
"."
] | 384ca265f73044b8a8b471f5dd7a6103fc54f4df | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/api/xena_cli.py#L68-L79 | train |
xenadevel/PyXenaManager | xenamanager/api/xena_cli.py | XenaCliWrapper.get_attributes | def get_attributes(self, obj):
""" Get all object's attributes.
Sends multi-parameter info/config queries and returns the result as dictionary.
:param obj: requested object.
:returns: dictionary of <name, value> of all attributes returned by the query.
:rtype: dict of (str, str... | python | def get_attributes(self, obj):
""" Get all object's attributes.
Sends multi-parameter info/config queries and returns the result as dictionary.
:param obj: requested object.
:returns: dictionary of <name, value> of all attributes returned by the query.
:rtype: dict of (str, str... | [
"def",
"get_attributes",
"(",
"self",
",",
"obj",
")",
":",
"attributes",
"=",
"{",
"}",
"for",
"info_config_command",
"in",
"obj",
".",
"info_config_commands",
":",
"index_commands_values",
"=",
"self",
".",
"send_command_return_multilines",
"(",
"obj",
",",
"i... | Get all object's attributes.
Sends multi-parameter info/config queries and returns the result as dictionary.
:param obj: requested object.
:returns: dictionary of <name, value> of all attributes returned by the query.
:rtype: dict of (str, str) | [
"Get",
"all",
"object",
"s",
"attributes",
"."
] | 384ca265f73044b8a8b471f5dd7a6103fc54f4df | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/api/xena_cli.py#L81-L104 | train |
xenadevel/PyXenaManager | xenamanager/api/xena_cli.py | XenaCliWrapper.set_attributes | def set_attributes(self, obj, **attributes):
""" Set attributes.
:param obj: requested object.
:param attributes: dictionary of {attribute: value} to set
"""
for attribute, value in attributes.items():
self.send_command(obj, attribute, value) | python | def set_attributes(self, obj, **attributes):
""" Set attributes.
:param obj: requested object.
:param attributes: dictionary of {attribute: value} to set
"""
for attribute, value in attributes.items():
self.send_command(obj, attribute, value) | [
"def",
"set_attributes",
"(",
"self",
",",
"obj",
",",
"*",
"*",
"attributes",
")",
":",
"for",
"attribute",
",",
"value",
"in",
"attributes",
".",
"items",
"(",
")",
":",
"self",
".",
"send_command",
"(",
"obj",
",",
"attribute",
",",
"value",
")"
] | Set attributes.
:param obj: requested object.
:param attributes: dictionary of {attribute: value} to set | [
"Set",
"attributes",
"."
] | 384ca265f73044b8a8b471f5dd7a6103fc54f4df | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/api/xena_cli.py#L106-L113 | train |
xenadevel/PyXenaManager | xenamanager/api/xena_cli.py | XenaCliWrapper.get_stats | def get_stats(self, obj, stat_name):
""" Send CLI command that returns list of integer counters.
:param obj: requested object.
:param stat_name: statistics command name.
:return: list of counters.
:rtype: list(int)
"""
return [int(v) for v in self.get_attribute(o... | python | def get_stats(self, obj, stat_name):
""" Send CLI command that returns list of integer counters.
:param obj: requested object.
:param stat_name: statistics command name.
:return: list of counters.
:rtype: list(int)
"""
return [int(v) for v in self.get_attribute(o... | [
"def",
"get_stats",
"(",
"self",
",",
"obj",
",",
"stat_name",
")",
":",
"return",
"[",
"int",
"(",
"v",
")",
"for",
"v",
"in",
"self",
".",
"get_attribute",
"(",
"obj",
",",
"stat_name",
")",
".",
"split",
"(",
")",
"]"
] | Send CLI command that returns list of integer counters.
:param obj: requested object.
:param stat_name: statistics command name.
:return: list of counters.
:rtype: list(int) | [
"Send",
"CLI",
"command",
"that",
"returns",
"list",
"of",
"integer",
"counters",
"."
] | 384ca265f73044b8a8b471f5dd7a6103fc54f4df | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/api/xena_cli.py#L115-L123 | train |
josiah-wolf-oberholtzer/uqbar | uqbar/containers/UniqueTreeContainer.py | UniqueTreeContainer.depth_first | def depth_first(self, top_down=True):
"""
Iterate depth-first.
::
>>> from uqbar.containers import UniqueTreeContainer, UniqueTreeNode
>>> root_container = UniqueTreeContainer(name="root")
>>> outer_container = UniqueTreeContainer(name="outer")
>... | python | def depth_first(self, top_down=True):
"""
Iterate depth-first.
::
>>> from uqbar.containers import UniqueTreeContainer, UniqueTreeNode
>>> root_container = UniqueTreeContainer(name="root")
>>> outer_container = UniqueTreeContainer(name="outer")
>... | [
"def",
"depth_first",
"(",
"self",
",",
"top_down",
"=",
"True",
")",
":",
"for",
"child",
"in",
"tuple",
"(",
"self",
")",
":",
"if",
"top_down",
":",
"yield",
"child",
"if",
"isinstance",
"(",
"child",
",",
"UniqueTreeContainer",
")",
":",
"yield",
"... | Iterate depth-first.
::
>>> from uqbar.containers import UniqueTreeContainer, UniqueTreeNode
>>> root_container = UniqueTreeContainer(name="root")
>>> outer_container = UniqueTreeContainer(name="outer")
>>> inner_container = UniqueTreeContainer(name="inner")
... | [
"Iterate",
"depth",
"-",
"first",
"."
] | eca7fefebbbee1e2ae13bf5d6baa838be66b1db6 | https://github.com/josiah-wolf-oberholtzer/uqbar/blob/eca7fefebbbee1e2ae13bf5d6baa838be66b1db6/uqbar/containers/UniqueTreeContainer.py#L128-L177 | train |
xenadevel/PyXenaManager | xenamanager/xena_port.py | XenaPort.reserve | def reserve(self, force=False):
""" Reserve port.
XenaManager-2G -> Reserve/Relinquish Port.
:param force: True - take forcefully, False - fail if port is reserved by other user
"""
p_reservation = self.get_attribute('p_reservation')
if p_reservation == 'RESERVED_BY_YO... | python | def reserve(self, force=False):
""" Reserve port.
XenaManager-2G -> Reserve/Relinquish Port.
:param force: True - take forcefully, False - fail if port is reserved by other user
"""
p_reservation = self.get_attribute('p_reservation')
if p_reservation == 'RESERVED_BY_YO... | [
"def",
"reserve",
"(",
"self",
",",
"force",
"=",
"False",
")",
":",
"p_reservation",
"=",
"self",
".",
"get_attribute",
"(",
"'p_reservation'",
")",
"if",
"p_reservation",
"==",
"'RESERVED_BY_YOU'",
":",
"return",
"elif",
"p_reservation",
"==",
"'RESERVED_BY_OT... | Reserve port.
XenaManager-2G -> Reserve/Relinquish Port.
:param force: True - take forcefully, False - fail if port is reserved by other user | [
"Reserve",
"port",
"."
] | 384ca265f73044b8a8b471f5dd7a6103fc54f4df | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/xena_port.py#L53-L67 | train |
xenadevel/PyXenaManager | xenamanager/xena_port.py | XenaPort.load_config | def load_config(self, config_file_name):
""" Load configuration file from xpc file.
:param config_file_name: full path to the configuration file.
"""
with open(config_file_name) as f:
commands = f.read().splitlines()
for command in commands:
if not comm... | python | def load_config(self, config_file_name):
""" Load configuration file from xpc file.
:param config_file_name: full path to the configuration file.
"""
with open(config_file_name) as f:
commands = f.read().splitlines()
for command in commands:
if not comm... | [
"def",
"load_config",
"(",
"self",
",",
"config_file_name",
")",
":",
"with",
"open",
"(",
"config_file_name",
")",
"as",
"f",
":",
"commands",
"=",
"f",
".",
"read",
"(",
")",
".",
"splitlines",
"(",
")",
"for",
"command",
"in",
"commands",
":",
"if",... | Load configuration file from xpc file.
:param config_file_name: full path to the configuration file. | [
"Load",
"configuration",
"file",
"from",
"xpc",
"file",
"."
] | 384ca265f73044b8a8b471f5dd7a6103fc54f4df | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/xena_port.py#L91-L105 | train |
xenadevel/PyXenaManager | xenamanager/xena_port.py | XenaPort.save_config | def save_config(self, config_file_name):
""" Save configuration file to xpc file.
:param config_file_name: full path to the configuration file.
"""
with open(config_file_name, 'w+') as f:
f.write('P_RESET\n')
for line in self.send_command_return_multilines('p_fu... | python | def save_config(self, config_file_name):
""" Save configuration file to xpc file.
:param config_file_name: full path to the configuration file.
"""
with open(config_file_name, 'w+') as f:
f.write('P_RESET\n')
for line in self.send_command_return_multilines('p_fu... | [
"def",
"save_config",
"(",
"self",
",",
"config_file_name",
")",
":",
"with",
"open",
"(",
"config_file_name",
",",
"'w+'",
")",
"as",
"f",
":",
"f",
".",
"write",
"(",
"'P_RESET\\n'",
")",
"for",
"line",
"in",
"self",
".",
"send_command_return_multilines",
... | Save configuration file to xpc file.
:param config_file_name: full path to the configuration file. | [
"Save",
"configuration",
"file",
"to",
"xpc",
"file",
"."
] | 384ca265f73044b8a8b471f5dd7a6103fc54f4df | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/xena_port.py#L107-L116 | train |
xenadevel/PyXenaManager | xenamanager/xena_port.py | XenaPort.add_stream | def add_stream(self, name=None, tpld_id=None, state=XenaStreamState.enabled):
""" Add stream.
:param name: stream description.
:param tpld_id: TPLD ID. If None the a unique value will be set.
:param state: new stream state.
:type state: xenamanager.xena_stream.XenaStreamState
... | python | def add_stream(self, name=None, tpld_id=None, state=XenaStreamState.enabled):
""" Add stream.
:param name: stream description.
:param tpld_id: TPLD ID. If None the a unique value will be set.
:param state: new stream state.
:type state: xenamanager.xena_stream.XenaStreamState
... | [
"def",
"add_stream",
"(",
"self",
",",
"name",
"=",
"None",
",",
"tpld_id",
"=",
"None",
",",
"state",
"=",
"XenaStreamState",
".",
"enabled",
")",
":",
"stream",
"=",
"XenaStream",
"(",
"parent",
"=",
"self",
",",
"index",
"=",
"'{}/{}'",
".",
"format... | Add stream.
:param name: stream description.
:param tpld_id: TPLD ID. If None the a unique value will be set.
:param state: new stream state.
:type state: xenamanager.xena_stream.XenaStreamState
:return: newly created stream.
:rtype: xenamanager.xena_stream.XenaStream | [
"Add",
"stream",
"."
] | 384ca265f73044b8a8b471f5dd7a6103fc54f4df | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/xena_port.py#L118-L135 | train |
xenadevel/PyXenaManager | xenamanager/xena_port.py | XenaPort.read_port_stats | def read_port_stats(self):
"""
:return: dictionary {group name {stat name: value}}.
Sea XenaPort.stats_captions.
"""
stats_with_captions = OrderedDict()
for stat_name in self.stats_captions.keys():
stats_with_captions[stat_name] = self.read_stat(self.stat... | python | def read_port_stats(self):
"""
:return: dictionary {group name {stat name: value}}.
Sea XenaPort.stats_captions.
"""
stats_with_captions = OrderedDict()
for stat_name in self.stats_captions.keys():
stats_with_captions[stat_name] = self.read_stat(self.stat... | [
"def",
"read_port_stats",
"(",
"self",
")",
":",
"stats_with_captions",
"=",
"OrderedDict",
"(",
")",
"for",
"stat_name",
"in",
"self",
".",
"stats_captions",
".",
"keys",
"(",
")",
":",
"stats_with_captions",
"[",
"stat_name",
"]",
"=",
"self",
".",
"read_s... | :return: dictionary {group name {stat name: value}}.
Sea XenaPort.stats_captions. | [
":",
"return",
":",
"dictionary",
"{",
"group",
"name",
"{",
"stat",
"name",
":",
"value",
"}}",
".",
"Sea",
"XenaPort",
".",
"stats_captions",
"."
] | 384ca265f73044b8a8b471f5dd7a6103fc54f4df | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/xena_port.py#L192-L201 | train |
xenadevel/PyXenaManager | xenamanager/xena_port.py | XenaPort.read_stream_stats | def read_stream_stats(self):
"""
:return: dictionary {stream index {stat name: value}}.
Sea XenaStream.stats_captions.
"""
stream_stats = OrderedDict()
for stream in self.streams.values():
stream_stats[stream] = stream.read_stats()
return stream_st... | python | def read_stream_stats(self):
"""
:return: dictionary {stream index {stat name: value}}.
Sea XenaStream.stats_captions.
"""
stream_stats = OrderedDict()
for stream in self.streams.values():
stream_stats[stream] = stream.read_stats()
return stream_st... | [
"def",
"read_stream_stats",
"(",
"self",
")",
":",
"stream_stats",
"=",
"OrderedDict",
"(",
")",
"for",
"stream",
"in",
"self",
".",
"streams",
".",
"values",
"(",
")",
":",
"stream_stats",
"[",
"stream",
"]",
"=",
"stream",
".",
"read_stats",
"(",
")",
... | :return: dictionary {stream index {stat name: value}}.
Sea XenaStream.stats_captions. | [
":",
"return",
":",
"dictionary",
"{",
"stream",
"index",
"{",
"stat",
"name",
":",
"value",
"}}",
".",
"Sea",
"XenaStream",
".",
"stats_captions",
"."
] | 384ca265f73044b8a8b471f5dd7a6103fc54f4df | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/xena_port.py#L203-L211 | train |
xenadevel/PyXenaManager | xenamanager/xena_port.py | XenaPort.read_tpld_stats | def read_tpld_stats(self):
"""
:return: dictionary {tpld index {group name {stat name: value}}}.
Sea XenaTpld.stats_captions.
"""
payloads_stats = OrderedDict()
for tpld in self.tplds.values():
payloads_stats[tpld] = tpld.read_stats()
return payloa... | python | def read_tpld_stats(self):
"""
:return: dictionary {tpld index {group name {stat name: value}}}.
Sea XenaTpld.stats_captions.
"""
payloads_stats = OrderedDict()
for tpld in self.tplds.values():
payloads_stats[tpld] = tpld.read_stats()
return payloa... | [
"def",
"read_tpld_stats",
"(",
"self",
")",
":",
"payloads_stats",
"=",
"OrderedDict",
"(",
")",
"for",
"tpld",
"in",
"self",
".",
"tplds",
".",
"values",
"(",
")",
":",
"payloads_stats",
"[",
"tpld",
"]",
"=",
"tpld",
".",
"read_stats",
"(",
")",
"ret... | :return: dictionary {tpld index {group name {stat name: value}}}.
Sea XenaTpld.stats_captions. | [
":",
"return",
":",
"dictionary",
"{",
"tpld",
"index",
"{",
"group",
"name",
"{",
"stat",
"name",
":",
"value",
"}}}",
".",
"Sea",
"XenaTpld",
".",
"stats_captions",
"."
] | 384ca265f73044b8a8b471f5dd7a6103fc54f4df | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/xena_port.py#L213-L221 | train |
xenadevel/PyXenaManager | xenamanager/xena_port.py | XenaPort.streams | def streams(self):
"""
:return: dictionary {id: object} of all streams.
:rtype: dict of (int, xenamanager.xena_stream.XenaStream)
"""
if not self.get_objects_by_type('stream'):
tpld_ids = []
for index in self.get_attribute('ps_indices').split():
... | python | def streams(self):
"""
:return: dictionary {id: object} of all streams.
:rtype: dict of (int, xenamanager.xena_stream.XenaStream)
"""
if not self.get_objects_by_type('stream'):
tpld_ids = []
for index in self.get_attribute('ps_indices').split():
... | [
"def",
"streams",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"get_objects_by_type",
"(",
"'stream'",
")",
":",
"tpld_ids",
"=",
"[",
"]",
"for",
"index",
"in",
"self",
".",
"get_attribute",
"(",
"'ps_indices'",
")",
".",
"split",
"(",
")",
":",
... | :return: dictionary {id: object} of all streams.
:rtype: dict of (int, xenamanager.xena_stream.XenaStream) | [
":",
"return",
":",
"dictionary",
"{",
"id",
":",
"object",
"}",
"of",
"all",
"streams",
".",
":",
"rtype",
":",
"dict",
"of",
"(",
"int",
"xenamanager",
".",
"xena_stream",
".",
"XenaStream",
")"
] | 384ca265f73044b8a8b471f5dd7a6103fc54f4df | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/xena_port.py#L228-L241 | train |
xenadevel/PyXenaManager | xenamanager/xena_port.py | XenaPort.tplds | def tplds(self):
"""
:return: dictionary {id: object} of all current tplds.
:rtype: dict of (int, xenamanager.xena_port.XenaTpld)
"""
# As TPLDs are dynamic we must re-read them each time from the port.
self.parent.del_objects_by_type('tpld')
for tpld in self.get... | python | def tplds(self):
"""
:return: dictionary {id: object} of all current tplds.
:rtype: dict of (int, xenamanager.xena_port.XenaTpld)
"""
# As TPLDs are dynamic we must re-read them each time from the port.
self.parent.del_objects_by_type('tpld')
for tpld in self.get... | [
"def",
"tplds",
"(",
"self",
")",
":",
"# As TPLDs are dynamic we must re-read them each time from the port.",
"self",
".",
"parent",
".",
"del_objects_by_type",
"(",
"'tpld'",
")",
"for",
"tpld",
"in",
"self",
".",
"get_attribute",
"(",
"'pr_tplds'",
")",
".",
"spl... | :return: dictionary {id: object} of all current tplds.
:rtype: dict of (int, xenamanager.xena_port.XenaTpld) | [
":",
"return",
":",
"dictionary",
"{",
"id",
":",
"object",
"}",
"of",
"all",
"current",
"tplds",
".",
":",
"rtype",
":",
"dict",
"of",
"(",
"int",
"xenamanager",
".",
"xena_port",
".",
"XenaTpld",
")"
] | 384ca265f73044b8a8b471f5dd7a6103fc54f4df | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/xena_port.py#L244-L254 | train |
xenadevel/PyXenaManager | xenamanager/xena_port.py | XenaTpld.read_stats | def read_stats(self):
"""
:return: dictionary {group name {stat name: value}}.
Sea XenaTpld.stats_captions.
"""
stats_with_captions = OrderedDict()
for stat_name in self.stats_captions.keys():
stats_with_captions[stat_name] = self.read_stat(self.stats_cap... | python | def read_stats(self):
"""
:return: dictionary {group name {stat name: value}}.
Sea XenaTpld.stats_captions.
"""
stats_with_captions = OrderedDict()
for stat_name in self.stats_captions.keys():
stats_with_captions[stat_name] = self.read_stat(self.stats_cap... | [
"def",
"read_stats",
"(",
"self",
")",
":",
"stats_with_captions",
"=",
"OrderedDict",
"(",
")",
"for",
"stat_name",
"in",
"self",
".",
"stats_captions",
".",
"keys",
"(",
")",
":",
"stats_with_captions",
"[",
"stat_name",
"]",
"=",
"self",
".",
"read_stat",... | :return: dictionary {group name {stat name: value}}.
Sea XenaTpld.stats_captions. | [
":",
"return",
":",
"dictionary",
"{",
"group",
"name",
"{",
"stat",
"name",
":",
"value",
"}}",
".",
"Sea",
"XenaTpld",
".",
"stats_captions",
"."
] | 384ca265f73044b8a8b471f5dd7a6103fc54f4df | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/xena_port.py#L282-L291 | train |
xenadevel/PyXenaManager | xenamanager/xena_port.py | XenaCapture.get_packets | def get_packets(self, from_index=0, to_index=None, cap_type=XenaCaptureBufferType.text,
file_name=None, tshark=None):
""" Get captured packets from chassis.
:param from_index: index of first packet to read.
:param to_index: index of last packet to read. If None - read all pa... | python | def get_packets(self, from_index=0, to_index=None, cap_type=XenaCaptureBufferType.text,
file_name=None, tshark=None):
""" Get captured packets from chassis.
:param from_index: index of first packet to read.
:param to_index: index of last packet to read. If None - read all pa... | [
"def",
"get_packets",
"(",
"self",
",",
"from_index",
"=",
"0",
",",
"to_index",
"=",
"None",
",",
"cap_type",
"=",
"XenaCaptureBufferType",
".",
"text",
",",
"file_name",
"=",
"None",
",",
"tshark",
"=",
"None",
")",
":",
"to_index",
"=",
"to_index",
"i... | Get captured packets from chassis.
:param from_index: index of first packet to read.
:param to_index: index of last packet to read. If None - read all packets.
:param cap_type: returned capture format. If pcap then file name and tshark must be provided.
:param file_name: if specified, c... | [
"Get",
"captured",
"packets",
"from",
"chassis",
"."
] | 384ca265f73044b8a8b471f5dd7a6103fc54f4df | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/xena_port.py#L313-L354 | train |
xenadevel/PyXenaManager | xenamanager/xena_port.py | XenaCapture.packets | def packets(self):
"""
:return: dictionary {id: object} of all packets.
:rtype: dict of (int, xenamanager.xena_port.XenaCapturePacket)
"""
if not self.get_object_by_type('cappacket'):
for index in range(0, self.read_stats()['packets']):
XenaCapturePac... | python | def packets(self):
"""
:return: dictionary {id: object} of all packets.
:rtype: dict of (int, xenamanager.xena_port.XenaCapturePacket)
"""
if not self.get_object_by_type('cappacket'):
for index in range(0, self.read_stats()['packets']):
XenaCapturePac... | [
"def",
"packets",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"get_object_by_type",
"(",
"'cappacket'",
")",
":",
"for",
"index",
"in",
"range",
"(",
"0",
",",
"self",
".",
"read_stats",
"(",
")",
"[",
"'packets'",
"]",
")",
":",
"XenaCapturePacke... | :return: dictionary {id: object} of all packets.
:rtype: dict of (int, xenamanager.xena_port.XenaCapturePacket) | [
":",
"return",
":",
"dictionary",
"{",
"id",
":",
"object",
"}",
"of",
"all",
"packets",
".",
":",
"rtype",
":",
"dict",
"of",
"(",
"int",
"xenamanager",
".",
"xena_port",
".",
"XenaCapturePacket",
")"
] | 384ca265f73044b8a8b471f5dd7a6103fc54f4df | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/xena_port.py#L361-L370 | train |
MatterMiners/cobald | cobald/controller/stepwise.py | UnboundStepwise.add | def add(self, rule: ControlRule = None, *, supply: float):
"""
Register a new rule above a given ``supply`` threshold
Registration supports a single-argument form for use as a decorator,
as well as a two-argument form for direct application.
Use the former for ``def`` or ``class... | python | def add(self, rule: ControlRule = None, *, supply: float):
"""
Register a new rule above a given ``supply`` threshold
Registration supports a single-argument form for use as a decorator,
as well as a two-argument form for direct application.
Use the former for ``def`` or ``class... | [
"def",
"add",
"(",
"self",
",",
"rule",
":",
"ControlRule",
"=",
"None",
",",
"*",
",",
"supply",
":",
"float",
")",
":",
"if",
"supply",
"in",
"self",
".",
"_thresholds",
":",
"raise",
"ValueError",
"(",
"'rule for threshold %s re-defined'",
"%",
"supply"... | Register a new rule above a given ``supply`` threshold
Registration supports a single-argument form for use as a decorator,
as well as a two-argument form for direct application.
Use the former for ``def`` or ``class`` definitions,
and the later for ``lambda`` functions and existing cal... | [
"Register",
"a",
"new",
"rule",
"above",
"a",
"given",
"supply",
"threshold"
] | 264138de4382d1c9b53fabcbc6660e10b33a914d | https://github.com/MatterMiners/cobald/blob/264138de4382d1c9b53fabcbc6660e10b33a914d/cobald/controller/stepwise.py#L135-L165 | train |
MatterMiners/cobald | cobald/controller/stepwise.py | UnboundStepwise.s | def s(self, *args, **kwargs) -> Partial[Stepwise]:
"""
Create an unbound prototype of this class, partially applying arguments
.. code:: python
@stepwise
def control(pool: Pool, interval):
return 10
pipeline = control.s(interval=20) >> pool
... | python | def s(self, *args, **kwargs) -> Partial[Stepwise]:
"""
Create an unbound prototype of this class, partially applying arguments
.. code:: python
@stepwise
def control(pool: Pool, interval):
return 10
pipeline = control.s(interval=20) >> pool
... | [
"def",
"s",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"->",
"Partial",
"[",
"Stepwise",
"]",
":",
"return",
"Partial",
"(",
"Stepwise",
",",
"self",
".",
"base",
",",
"*",
"self",
".",
"rules",
",",
"*",
"args",
",",
"*",
"*"... | Create an unbound prototype of this class, partially applying arguments
.. code:: python
@stepwise
def control(pool: Pool, interval):
return 10
pipeline = control.s(interval=20) >> pool
:note: The partial rules are sealed, and :py:meth:`~.UnboundSt... | [
"Create",
"an",
"unbound",
"prototype",
"of",
"this",
"class",
"partially",
"applying",
"arguments"
] | 264138de4382d1c9b53fabcbc6660e10b33a914d | https://github.com/MatterMiners/cobald/blob/264138de4382d1c9b53fabcbc6660e10b33a914d/cobald/controller/stepwise.py#L167-L182 | train |
qubell/contrib-python-qubell-client | qubell/api/private/revision.py | Revision.revisionId | def revisionId(self):
"""
revisionId differs from id, it is details of implementation use self.id
:return: RevisionId
"""
log.warning("'RevisionId' requested, ensure that you are don't need 'id'")
revision_id = self.json()['revisionId']
assert revision_id == self.... | python | def revisionId(self):
"""
revisionId differs from id, it is details of implementation use self.id
:return: RevisionId
"""
log.warning("'RevisionId' requested, ensure that you are don't need 'id'")
revision_id = self.json()['revisionId']
assert revision_id == self.... | [
"def",
"revisionId",
"(",
"self",
")",
":",
"log",
".",
"warning",
"(",
"\"'RevisionId' requested, ensure that you are don't need 'id'\"",
")",
"revision_id",
"=",
"self",
".",
"json",
"(",
")",
"[",
"'revisionId'",
"]",
"assert",
"revision_id",
"==",
"self",
".",... | revisionId differs from id, it is details of implementation use self.id
:return: RevisionId | [
"revisionId",
"differs",
"from",
"id",
"it",
"is",
"details",
"of",
"implementation",
"use",
"self",
".",
"id",
":",
"return",
":",
"RevisionId"
] | 4586ea11d5103c2ff9607d3ed922b5a0991b8845 | https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/private/revision.py#L45-L53 | train |
Karaage-Cluster/python-tldap | tldap/database/__init__.py | changeset | def changeset(python_data: LdapObject, d: dict) -> Changeset:
""" Generate changes object for ldap object. """
table: LdapObjectClass = type(python_data)
fields = table.get_fields()
changes = Changeset(fields, src=python_data, d=d)
return changes | python | def changeset(python_data: LdapObject, d: dict) -> Changeset:
""" Generate changes object for ldap object. """
table: LdapObjectClass = type(python_data)
fields = table.get_fields()
changes = Changeset(fields, src=python_data, d=d)
return changes | [
"def",
"changeset",
"(",
"python_data",
":",
"LdapObject",
",",
"d",
":",
"dict",
")",
"->",
"Changeset",
":",
"table",
":",
"LdapObjectClass",
"=",
"type",
"(",
"python_data",
")",
"fields",
"=",
"table",
".",
"get_fields",
"(",
")",
"changes",
"=",
"Ch... | Generate changes object for ldap object. | [
"Generate",
"changes",
"object",
"for",
"ldap",
"object",
"."
] | 61f1af74a3648cb6491e7eeb1ee2eb395d67bf59 | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/database/__init__.py#L384-L389 | train |
Karaage-Cluster/python-tldap | tldap/database/__init__.py | _db_to_python | def _db_to_python(db_data: dict, table: LdapObjectClass, dn: str) -> LdapObject:
""" Convert a DbDate object to a LdapObject. """
fields = table.get_fields()
python_data = table({
name: field.to_python(db_data[name])
for name, field in fields.items()
if field.db_field
})
pyt... | python | def _db_to_python(db_data: dict, table: LdapObjectClass, dn: str) -> LdapObject:
""" Convert a DbDate object to a LdapObject. """
fields = table.get_fields()
python_data = table({
name: field.to_python(db_data[name])
for name, field in fields.items()
if field.db_field
})
pyt... | [
"def",
"_db_to_python",
"(",
"db_data",
":",
"dict",
",",
"table",
":",
"LdapObjectClass",
",",
"dn",
":",
"str",
")",
"->",
"LdapObject",
":",
"fields",
"=",
"table",
".",
"get_fields",
"(",
")",
"python_data",
"=",
"table",
"(",
"{",
"name",
":",
"fi... | Convert a DbDate object to a LdapObject. | [
"Convert",
"a",
"DbDate",
"object",
"to",
"a",
"LdapObject",
"."
] | 61f1af74a3648cb6491e7eeb1ee2eb395d67bf59 | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/database/__init__.py#L392-L404 | train |
Karaage-Cluster/python-tldap | tldap/database/__init__.py | _python_to_mod_new | def _python_to_mod_new(changes: Changeset) -> Dict[str, List[List[bytes]]]:
""" Convert a LdapChanges object to a modlist for add operation. """
table: LdapObjectClass = type(changes.src)
fields = table.get_fields()
result: Dict[str, List[List[bytes]]] = {}
for name, field in fields.items():
... | python | def _python_to_mod_new(changes: Changeset) -> Dict[str, List[List[bytes]]]:
""" Convert a LdapChanges object to a modlist for add operation. """
table: LdapObjectClass = type(changes.src)
fields = table.get_fields()
result: Dict[str, List[List[bytes]]] = {}
for name, field in fields.items():
... | [
"def",
"_python_to_mod_new",
"(",
"changes",
":",
"Changeset",
")",
"->",
"Dict",
"[",
"str",
",",
"List",
"[",
"List",
"[",
"bytes",
"]",
"]",
"]",
":",
"table",
":",
"LdapObjectClass",
"=",
"type",
"(",
"changes",
".",
"src",
")",
"fields",
"=",
"t... | Convert a LdapChanges object to a modlist for add operation. | [
"Convert",
"a",
"LdapChanges",
"object",
"to",
"a",
"modlist",
"for",
"add",
"operation",
"."
] | 61f1af74a3648cb6491e7eeb1ee2eb395d67bf59 | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/database/__init__.py#L407-L423 | train |
Karaage-Cluster/python-tldap | tldap/database/__init__.py | _python_to_mod_modify | def _python_to_mod_modify(changes: Changeset) -> Dict[str, List[Tuple[Operation, List[bytes]]]]:
""" Convert a LdapChanges object to a modlist for a modify operation. """
table: LdapObjectClass = type(changes.src)
changes = changes.changes
result: Dict[str, List[Tuple[Operation, List[bytes]]]] = {}
... | python | def _python_to_mod_modify(changes: Changeset) -> Dict[str, List[Tuple[Operation, List[bytes]]]]:
""" Convert a LdapChanges object to a modlist for a modify operation. """
table: LdapObjectClass = type(changes.src)
changes = changes.changes
result: Dict[str, List[Tuple[Operation, List[bytes]]]] = {}
... | [
"def",
"_python_to_mod_modify",
"(",
"changes",
":",
"Changeset",
")",
"->",
"Dict",
"[",
"str",
",",
"List",
"[",
"Tuple",
"[",
"Operation",
",",
"List",
"[",
"bytes",
"]",
"]",
"]",
"]",
":",
"table",
":",
"LdapObjectClass",
"=",
"type",
"(",
"change... | Convert a LdapChanges object to a modlist for a modify operation. | [
"Convert",
"a",
"LdapChanges",
"object",
"to",
"a",
"modlist",
"for",
"a",
"modify",
"operation",
"."
] | 61f1af74a3648cb6491e7eeb1ee2eb395d67bf59 | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/database/__init__.py#L426-L445 | train |
Karaage-Cluster/python-tldap | tldap/database/__init__.py | search | def search(table: LdapObjectClass, query: Optional[Q] = None,
database: Optional[Database] = None, base_dn: Optional[str] = None) -> Iterator[LdapObject]:
""" Search for a object of given type in the database. """
fields = table.get_fields()
db_fields = {
name: field
for name, fie... | python | def search(table: LdapObjectClass, query: Optional[Q] = None,
database: Optional[Database] = None, base_dn: Optional[str] = None) -> Iterator[LdapObject]:
""" Search for a object of given type in the database. """
fields = table.get_fields()
db_fields = {
name: field
for name, fie... | [
"def",
"search",
"(",
"table",
":",
"LdapObjectClass",
",",
"query",
":",
"Optional",
"[",
"Q",
"]",
"=",
"None",
",",
"database",
":",
"Optional",
"[",
"Database",
"]",
"=",
"None",
",",
"base_dn",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",... | Search for a object of given type in the database. | [
"Search",
"for",
"a",
"object",
"of",
"given",
"type",
"in",
"the",
"database",
"."
] | 61f1af74a3648cb6491e7eeb1ee2eb395d67bf59 | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/database/__init__.py#L448-L475 | train |
Karaage-Cluster/python-tldap | tldap/database/__init__.py | get_one | def get_one(table: LdapObjectClass, query: Optional[Q] = None,
database: Optional[Database] = None, base_dn: Optional[str] = None) -> LdapObject:
""" Get exactly one result from the database or fail. """
results = search(table, query, database, base_dn)
try:
result = next(results)
e... | python | def get_one(table: LdapObjectClass, query: Optional[Q] = None,
database: Optional[Database] = None, base_dn: Optional[str] = None) -> LdapObject:
""" Get exactly one result from the database or fail. """
results = search(table, query, database, base_dn)
try:
result = next(results)
e... | [
"def",
"get_one",
"(",
"table",
":",
"LdapObjectClass",
",",
"query",
":",
"Optional",
"[",
"Q",
"]",
"=",
"None",
",",
"database",
":",
"Optional",
"[",
"Database",
"]",
"=",
"None",
",",
"base_dn",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")"... | Get exactly one result from the database or fail. | [
"Get",
"exactly",
"one",
"result",
"from",
"the",
"database",
"or",
"fail",
"."
] | 61f1af74a3648cb6491e7eeb1ee2eb395d67bf59 | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/database/__init__.py#L478-L494 | train |
Karaage-Cluster/python-tldap | tldap/database/__init__.py | preload | def preload(python_data: LdapObject, database: Optional[Database] = None) -> LdapObject:
""" Preload all NotLoaded fields in LdapObject. """
changes = {}
# Load objects within lists.
def preload_item(value: Any) -> Any:
if isinstance(value, NotLoaded):
return value.load(database)
... | python | def preload(python_data: LdapObject, database: Optional[Database] = None) -> LdapObject:
""" Preload all NotLoaded fields in LdapObject. """
changes = {}
# Load objects within lists.
def preload_item(value: Any) -> Any:
if isinstance(value, NotLoaded):
return value.load(database)
... | [
"def",
"preload",
"(",
"python_data",
":",
"LdapObject",
",",
"database",
":",
"Optional",
"[",
"Database",
"]",
"=",
"None",
")",
"->",
"LdapObject",
":",
"changes",
"=",
"{",
"}",
"# Load objects within lists.",
"def",
"preload_item",
"(",
"value",
":",
"A... | Preload all NotLoaded fields in LdapObject. | [
"Preload",
"all",
"NotLoaded",
"fields",
"in",
"LdapObject",
"."
] | 61f1af74a3648cb6491e7eeb1ee2eb395d67bf59 | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/database/__init__.py#L497-L530 | train |
Karaage-Cluster/python-tldap | tldap/database/__init__.py | insert | def insert(python_data: LdapObject, database: Optional[Database] = None) -> LdapObject:
""" Insert a new python_data object in the database. """
assert isinstance(python_data, LdapObject)
table: LdapObjectClass = type(python_data)
# ADD NEW ENTRY
empty_data = table()
changes = changeset(empty_... | python | def insert(python_data: LdapObject, database: Optional[Database] = None) -> LdapObject:
""" Insert a new python_data object in the database. """
assert isinstance(python_data, LdapObject)
table: LdapObjectClass = type(python_data)
# ADD NEW ENTRY
empty_data = table()
changes = changeset(empty_... | [
"def",
"insert",
"(",
"python_data",
":",
"LdapObject",
",",
"database",
":",
"Optional",
"[",
"Database",
"]",
"=",
"None",
")",
"->",
"LdapObject",
":",
"assert",
"isinstance",
"(",
"python_data",
",",
"LdapObject",
")",
"table",
":",
"LdapObjectClass",
"=... | Insert a new python_data object in the database. | [
"Insert",
"a",
"new",
"python_data",
"object",
"in",
"the",
"database",
"."
] | 61f1af74a3648cb6491e7eeb1ee2eb395d67bf59 | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/database/__init__.py#L533-L543 | train |
Karaage-Cluster/python-tldap | tldap/database/__init__.py | save | def save(changes: Changeset, database: Optional[Database] = None) -> LdapObject:
""" Save all changes in a LdapChanges. """
assert isinstance(changes, Changeset)
if not changes.is_valid:
raise RuntimeError(f"Changeset has errors {changes.errors}.")
database = get_database(database)
connect... | python | def save(changes: Changeset, database: Optional[Database] = None) -> LdapObject:
""" Save all changes in a LdapChanges. """
assert isinstance(changes, Changeset)
if not changes.is_valid:
raise RuntimeError(f"Changeset has errors {changes.errors}.")
database = get_database(database)
connect... | [
"def",
"save",
"(",
"changes",
":",
"Changeset",
",",
"database",
":",
"Optional",
"[",
"Database",
"]",
"=",
"None",
")",
"->",
"LdapObject",
":",
"assert",
"isinstance",
"(",
"changes",
",",
"Changeset",
")",
"if",
"not",
"changes",
".",
"is_valid",
":... | Save all changes in a LdapChanges. | [
"Save",
"all",
"changes",
"in",
"a",
"LdapChanges",
"."
] | 61f1af74a3648cb6491e7eeb1ee2eb395d67bf59 | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/database/__init__.py#L546-L605 | train |
Karaage-Cluster/python-tldap | tldap/database/__init__.py | delete | def delete(python_data: LdapObject, database: Optional[Database] = None) -> None:
""" Delete a LdapObject from the database. """
dn = python_data.get_as_single('dn')
assert dn is not None
database = get_database(database)
connection = database.connection
connection.delete(dn) | python | def delete(python_data: LdapObject, database: Optional[Database] = None) -> None:
""" Delete a LdapObject from the database. """
dn = python_data.get_as_single('dn')
assert dn is not None
database = get_database(database)
connection = database.connection
connection.delete(dn) | [
"def",
"delete",
"(",
"python_data",
":",
"LdapObject",
",",
"database",
":",
"Optional",
"[",
"Database",
"]",
"=",
"None",
")",
"->",
"None",
":",
"dn",
"=",
"python_data",
".",
"get_as_single",
"(",
"'dn'",
")",
"assert",
"dn",
"is",
"not",
"None",
... | Delete a LdapObject from the database. | [
"Delete",
"a",
"LdapObject",
"from",
"the",
"database",
"."
] | 61f1af74a3648cb6491e7eeb1ee2eb395d67bf59 | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/database/__init__.py#L608-L616 | train |
Karaage-Cluster/python-tldap | tldap/database/__init__.py | _get_field_by_name | def _get_field_by_name(table: LdapObjectClass, name: str) -> tldap.fields.Field:
""" Lookup a field by its name. """
fields = table.get_fields()
return fields[name] | python | def _get_field_by_name(table: LdapObjectClass, name: str) -> tldap.fields.Field:
""" Lookup a field by its name. """
fields = table.get_fields()
return fields[name] | [
"def",
"_get_field_by_name",
"(",
"table",
":",
"LdapObjectClass",
",",
"name",
":",
"str",
")",
"->",
"tldap",
".",
"fields",
".",
"Field",
":",
"fields",
"=",
"table",
".",
"get_fields",
"(",
")",
"return",
"fields",
"[",
"name",
"]"
] | Lookup a field by its name. | [
"Lookup",
"a",
"field",
"by",
"its",
"name",
"."
] | 61f1af74a3648cb6491e7eeb1ee2eb395d67bf59 | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/database/__init__.py#L619-L622 | train |
Karaage-Cluster/python-tldap | tldap/database/__init__.py | rename | def rename(python_data: LdapObject, new_base_dn: str = None,
database: Optional[Database] = None, **kwargs) -> LdapObject:
""" Move/rename a LdapObject in the database. """
table = type(python_data)
dn = python_data.get_as_single('dn')
assert dn is not None
database = get_database(databa... | python | def rename(python_data: LdapObject, new_base_dn: str = None,
database: Optional[Database] = None, **kwargs) -> LdapObject:
""" Move/rename a LdapObject in the database. """
table = type(python_data)
dn = python_data.get_as_single('dn')
assert dn is not None
database = get_database(databa... | [
"def",
"rename",
"(",
"python_data",
":",
"LdapObject",
",",
"new_base_dn",
":",
"str",
"=",
"None",
",",
"database",
":",
"Optional",
"[",
"Database",
"]",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
"->",
"LdapObject",
":",
"table",
"=",
"type",
"(",
... | Move/rename a LdapObject in the database. | [
"Move",
"/",
"rename",
"a",
"LdapObject",
"in",
"the",
"database",
"."
] | 61f1af74a3648cb6491e7eeb1ee2eb395d67bf59 | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/database/__init__.py#L625-L675 | train |
qubell/contrib-python-qubell-client | qubell/api/provider/__init__.py | route | def route(route_str): # decorator param
"""
Provides play2 likes routes, with python formatter
All string fileds should be named parameters
:param route_str: a route "GET /parent/{parentID}/child/{childId}{ctype}"
:return: the response of requests.request
"""
def ilog(elapsed):
# s... | python | def route(route_str): # decorator param
"""
Provides play2 likes routes, with python formatter
All string fileds should be named parameters
:param route_str: a route "GET /parent/{parentID}/child/{childId}{ctype}"
:return: the response of requests.request
"""
def ilog(elapsed):
# s... | [
"def",
"route",
"(",
"route_str",
")",
":",
"# decorator param",
"def",
"ilog",
"(",
"elapsed",
")",
":",
"# statistic",
"last_stat",
"=",
"_routes_stat",
".",
"get",
"(",
"route_str",
",",
"{",
"\"count\"",
":",
"0",
",",
"\"min\"",
":",
"sys",
".",
"ma... | Provides play2 likes routes, with python formatter
All string fileds should be named parameters
:param route_str: a route "GET /parent/{parentID}/child/{childId}{ctype}"
:return: the response of requests.request | [
"Provides",
"play2",
"likes",
"routes",
"with",
"python",
"formatter",
"All",
"string",
"fileds",
"should",
"be",
"named",
"parameters",
":",
"param",
"route_str",
":",
"a",
"route",
"GET",
"/",
"parent",
"/",
"{",
"parentID",
"}",
"/",
"child",
"/",
"{",
... | 4586ea11d5103c2ff9607d3ed922b5a0991b8845 | https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/provider/__init__.py#L21-L121 | train |
qubell/contrib-python-qubell-client | qubell/api/provider/__init__.py | play_auth | def play_auth(f):
"""
Injects cookies, into requests call over route
:return: route
"""
def wrapper(*args, **kwargs):
self = args[0]
if 'cookies' in kwargs:
raise AttributeError("don't set cookies explicitly")
if 'auth' in kwargs:
raise AttributeError... | python | def play_auth(f):
"""
Injects cookies, into requests call over route
:return: route
"""
def wrapper(*args, **kwargs):
self = args[0]
if 'cookies' in kwargs:
raise AttributeError("don't set cookies explicitly")
if 'auth' in kwargs:
raise AttributeError... | [
"def",
"play_auth",
"(",
"f",
")",
":",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
"=",
"args",
"[",
"0",
"]",
"if",
"'cookies'",
"in",
"kwargs",
":",
"raise",
"AttributeError",
"(",
"\"don't set cookies explicitly\"",... | Injects cookies, into requests call over route
:return: route | [
"Injects",
"cookies",
"into",
"requests",
"call",
"over",
"route",
":",
"return",
":",
"route"
] | 4586ea11d5103c2ff9607d3ed922b5a0991b8845 | https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/provider/__init__.py#L124-L150 | train |
qubell/contrib-python-qubell-client | qubell/api/provider/__init__.py | basic_auth | def basic_auth(f):
"""
Injects auth, into requests call over route
:return: route
"""
def wrapper(*args, **kwargs):
self = args[0]
if 'auth' in kwargs:
raise AttributeError("don't set auth token explicitly")
assert self.is_connected, "not connected, call router.c... | python | def basic_auth(f):
"""
Injects auth, into requests call over route
:return: route
"""
def wrapper(*args, **kwargs):
self = args[0]
if 'auth' in kwargs:
raise AttributeError("don't set auth token explicitly")
assert self.is_connected, "not connected, call router.c... | [
"def",
"basic_auth",
"(",
"f",
")",
":",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
"=",
"args",
"[",
"0",
"]",
"if",
"'auth'",
"in",
"kwargs",
":",
"raise",
"AttributeError",
"(",
"\"don't set auth token explicitly\""... | Injects auth, into requests call over route
:return: route | [
"Injects",
"auth",
"into",
"requests",
"call",
"over",
"route",
":",
"return",
":",
"route"
] | 4586ea11d5103c2ff9607d3ed922b5a0991b8845 | https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/provider/__init__.py#L153-L174 | train |
Karaage-Cluster/python-tldap | tldap/modlist.py | _list_dict | def _list_dict(l: Iterator[str], case_insensitive: bool = False):
"""
return a dictionary with all items of l being the keys of the dictionary
If argument case_insensitive is non-zero ldap.cidict.cidict will be
used for case-insensitive string keys
"""
if case_insensitive:
raise NotImpl... | python | def _list_dict(l: Iterator[str], case_insensitive: bool = False):
"""
return a dictionary with all items of l being the keys of the dictionary
If argument case_insensitive is non-zero ldap.cidict.cidict will be
used for case-insensitive string keys
"""
if case_insensitive:
raise NotImpl... | [
"def",
"_list_dict",
"(",
"l",
":",
"Iterator",
"[",
"str",
"]",
",",
"case_insensitive",
":",
"bool",
"=",
"False",
")",
":",
"if",
"case_insensitive",
":",
"raise",
"NotImplementedError",
"(",
")",
"d",
"=",
"tldap",
".",
"dict",
".",
"CaseInsensitiveDic... | return a dictionary with all items of l being the keys of the dictionary
If argument case_insensitive is non-zero ldap.cidict.cidict will be
used for case-insensitive string keys | [
"return",
"a",
"dictionary",
"with",
"all",
"items",
"of",
"l",
"being",
"the",
"keys",
"of",
"the",
"dictionary"
] | 61f1af74a3648cb6491e7eeb1ee2eb395d67bf59 | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/modlist.py#L30-L44 | train |
Karaage-Cluster/python-tldap | tldap/modlist.py | addModlist | def addModlist(entry: dict, ignore_attr_types: Optional[List[str]] = None) -> Dict[str, List[bytes]]:
"""Build modify list for call of method LDAPObject.add()"""
ignore_attr_types = _list_dict(map(str.lower, (ignore_attr_types or [])))
modlist: Dict[str, List[bytes]] = {}
for attrtype in entry.keys():
... | python | def addModlist(entry: dict, ignore_attr_types: Optional[List[str]] = None) -> Dict[str, List[bytes]]:
"""Build modify list for call of method LDAPObject.add()"""
ignore_attr_types = _list_dict(map(str.lower, (ignore_attr_types or [])))
modlist: Dict[str, List[bytes]] = {}
for attrtype in entry.keys():
... | [
"def",
"addModlist",
"(",
"entry",
":",
"dict",
",",
"ignore_attr_types",
":",
"Optional",
"[",
"List",
"[",
"str",
"]",
"]",
"=",
"None",
")",
"->",
"Dict",
"[",
"str",
",",
"List",
"[",
"bytes",
"]",
"]",
":",
"ignore_attr_types",
"=",
"_list_dict",
... | Build modify list for call of method LDAPObject.add() | [
"Build",
"modify",
"list",
"for",
"call",
"of",
"method",
"LDAPObject",
".",
"add",
"()"
] | 61f1af74a3648cb6491e7eeb1ee2eb395d67bf59 | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/modlist.py#L52-L64 | train |
Karaage-Cluster/python-tldap | tldap/modlist.py | modifyModlist | def modifyModlist(
old_entry: dict, new_entry: dict, ignore_attr_types: Optional[List[str]] = None,
ignore_oldexistent: bool = False) -> Dict[str, Tuple[str, List[bytes]]]:
"""
Build differential modify list for calling LDAPObject.modify()/modify_s()
:param old_entry:
Dictionary hol... | python | def modifyModlist(
old_entry: dict, new_entry: dict, ignore_attr_types: Optional[List[str]] = None,
ignore_oldexistent: bool = False) -> Dict[str, Tuple[str, List[bytes]]]:
"""
Build differential modify list for calling LDAPObject.modify()/modify_s()
:param old_entry:
Dictionary hol... | [
"def",
"modifyModlist",
"(",
"old_entry",
":",
"dict",
",",
"new_entry",
":",
"dict",
",",
"ignore_attr_types",
":",
"Optional",
"[",
"List",
"[",
"str",
"]",
"]",
"=",
"None",
",",
"ignore_oldexistent",
":",
"bool",
"=",
"False",
")",
"->",
"Dict",
"[",... | Build differential modify list for calling LDAPObject.modify()/modify_s()
:param old_entry:
Dictionary holding the old entry
:param new_entry:
Dictionary holding what the new entry should be
:param ignore_attr_types:
List of attribute type names to be ignored completely
:param i... | [
"Build",
"differential",
"modify",
"list",
"for",
"calling",
"LDAPObject",
".",
"modify",
"()",
"/",
"modify_s",
"()"
] | 61f1af74a3648cb6491e7eeb1ee2eb395d67bf59 | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/modlist.py#L67-L147 | train |
qubell/contrib-python-qubell-client | qubell/api/private/platform.py | QubellPlatform.connect | def connect(tenant=None, user=None, password=None, token=None, is_public=False):
"""
Authenticates user and returns new platform to user.
This is an entry point to start working with Qubell Api.
:rtype: QubellPlatform
:param str tenant: url to tenant, default taken from 'QUBELL_T... | python | def connect(tenant=None, user=None, password=None, token=None, is_public=False):
"""
Authenticates user and returns new platform to user.
This is an entry point to start working with Qubell Api.
:rtype: QubellPlatform
:param str tenant: url to tenant, default taken from 'QUBELL_T... | [
"def",
"connect",
"(",
"tenant",
"=",
"None",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"token",
"=",
"None",
",",
"is_public",
"=",
"False",
")",
":",
"if",
"not",
"is_public",
":",
"router",
"=",
"PrivatePath",
"(",
"tenant",
")"... | Authenticates user and returns new platform to user.
This is an entry point to start working with Qubell Api.
:rtype: QubellPlatform
:param str tenant: url to tenant, default taken from 'QUBELL_TENANT'
:param str user: user email, default taken from 'QUBELL_USER'
:param str passw... | [
"Authenticates",
"user",
"and",
"returns",
"new",
"platform",
"to",
"user",
".",
"This",
"is",
"an",
"entry",
"point",
"to",
"start",
"working",
"with",
"Qubell",
"Api",
".",
":",
"rtype",
":",
"QubellPlatform",
":",
"param",
"str",
"tenant",
":",
"url",
... | 4586ea11d5103c2ff9607d3ed922b5a0991b8845 | https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/private/platform.py#L39-L60 | train |
qubell/contrib-python-qubell-client | qubell/api/private/platform.py | QubellPlatform.connect_to_another_user | def connect_to_another_user(self, user, password, token=None, is_public=False):
"""
Authenticates user with the same tenant as current platform using and returns new platform to user.
:rtype: QubellPlatform
:param str user: user email
:param str password: user password
:p... | python | def connect_to_another_user(self, user, password, token=None, is_public=False):
"""
Authenticates user with the same tenant as current platform using and returns new platform to user.
:rtype: QubellPlatform
:param str user: user email
:param str password: user password
:p... | [
"def",
"connect_to_another_user",
"(",
"self",
",",
"user",
",",
"password",
",",
"token",
"=",
"None",
",",
"is_public",
"=",
"False",
")",
":",
"return",
"QubellPlatform",
".",
"connect",
"(",
"self",
".",
"_router",
".",
"base_url",
",",
"user",
",",
... | Authenticates user with the same tenant as current platform using and returns new platform to user.
:rtype: QubellPlatform
:param str user: user email
:param str password: user password
:param str token: session token
:param bool is_public: either to use public or private api (pu... | [
"Authenticates",
"user",
"with",
"the",
"same",
"tenant",
"as",
"current",
"platform",
"using",
"and",
"returns",
"new",
"platform",
"to",
"user",
".",
":",
"rtype",
":",
"QubellPlatform",
":",
"param",
"str",
"user",
":",
"user",
"email",
":",
"param",
"s... | 4586ea11d5103c2ff9607d3ed922b5a0991b8845 | https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/private/platform.py#L62-L72 | train |
qubell/contrib-python-qubell-client | qubell/api/private/platform.py | QubellPlatform.create_organization | def create_organization(self, name):
"""
Creates new organization
:rtype: Organization
"""
org = Organization.new(name, self._router)
assert org.ready(), "Organization {} hasn't got ready after creation".format(name)
return org | python | def create_organization(self, name):
"""
Creates new organization
:rtype: Organization
"""
org = Organization.new(name, self._router)
assert org.ready(), "Organization {} hasn't got ready after creation".format(name)
return org | [
"def",
"create_organization",
"(",
"self",
",",
"name",
")",
":",
"org",
"=",
"Organization",
".",
"new",
"(",
"name",
",",
"self",
".",
"_router",
")",
"assert",
"org",
".",
"ready",
"(",
")",
",",
"\"Organization {} hasn't got ready after creation\"",
".",
... | Creates new organization
:rtype: Organization | [
"Creates",
"new",
"organization",
":",
"rtype",
":",
"Organization"
] | 4586ea11d5103c2ff9607d3ed922b5a0991b8845 | https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/private/platform.py#L86-L93 | train |
qubell/contrib-python-qubell-client | qubell/api/private/platform.py | QubellPlatform.get_organization | def get_organization(self, id=None, name=None):
"""
Gets existing and accessible organization
:rtype: Organization
"""
log.info("Picking organization: %s (%s)" % (name, id))
return self.organizations[id or name] | python | def get_organization(self, id=None, name=None):
"""
Gets existing and accessible organization
:rtype: Organization
"""
log.info("Picking organization: %s (%s)" % (name, id))
return self.organizations[id or name] | [
"def",
"get_organization",
"(",
"self",
",",
"id",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"log",
".",
"info",
"(",
"\"Picking organization: %s (%s)\"",
"%",
"(",
"name",
",",
"id",
")",
")",
"return",
"self",
".",
"organizations",
"[",
"id",
... | Gets existing and accessible organization
:rtype: Organization | [
"Gets",
"existing",
"and",
"accessible",
"organization",
":",
"rtype",
":",
"Organization"
] | 4586ea11d5103c2ff9607d3ed922b5a0991b8845 | https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/private/platform.py#L95-L101 | train |
qubell/contrib-python-qubell-client | qubell/api/private/platform.py | QubellPlatform.get_or_create_organization | def get_or_create_organization(self, id=None, name=None):
"""
Gets existing or creates new organization
:rtype: Organization
"""
if id:
return self.get_organization(id)
else:
assert name
try:
return self.get_organization... | python | def get_or_create_organization(self, id=None, name=None):
"""
Gets existing or creates new organization
:rtype: Organization
"""
if id:
return self.get_organization(id)
else:
assert name
try:
return self.get_organization... | [
"def",
"get_or_create_organization",
"(",
"self",
",",
"id",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"if",
"id",
":",
"return",
"self",
".",
"get_organization",
"(",
"id",
")",
"else",
":",
"assert",
"name",
"try",
":",
"return",
"self",
".",
... | Gets existing or creates new organization
:rtype: Organization | [
"Gets",
"existing",
"or",
"creates",
"new",
"organization",
":",
"rtype",
":",
"Organization"
] | 4586ea11d5103c2ff9607d3ed922b5a0991b8845 | https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/private/platform.py#L103-L115 | train |
qubell/contrib-python-qubell-client | qubell/api/private/platform.py | QubellPlatform.get_backends_versions | def get_backends_versions(self):
"""
Get backends versions
:return: dict containing name of backend and version.
"""
# We are not always have permission, so find open.
for i in range(0, len(self.organizations)):
try:
backends = self.organizatio... | python | def get_backends_versions(self):
"""
Get backends versions
:return: dict containing name of backend and version.
"""
# We are not always have permission, so find open.
for i in range(0, len(self.organizations)):
try:
backends = self.organizatio... | [
"def",
"get_backends_versions",
"(",
"self",
")",
":",
"# We are not always have permission, so find open.",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"self",
".",
"organizations",
")",
")",
":",
"try",
":",
"backends",
"=",
"self",
".",
"organizat... | Get backends versions
:return: dict containing name of backend and version. | [
"Get",
"backends",
"versions",
":",
"return",
":",
"dict",
"containing",
"name",
"of",
"backend",
"and",
"version",
"."
] | 4586ea11d5103c2ff9607d3ed922b5a0991b8845 | https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/private/platform.py#L119-L133 | train |
MainRo/cyclotron-aio | cyclotron_aio/stop.py | make_driver | def make_driver(loop=None):
''' Returns a stop driver.
The optional loop argument can be provided to use the driver in another
loop than the default one.
Parameters
-----------
loop: BaseEventLoop
The event loop to use instead of the default one.
'''
loop = loop or asynci... | python | def make_driver(loop=None):
''' Returns a stop driver.
The optional loop argument can be provided to use the driver in another
loop than the default one.
Parameters
-----------
loop: BaseEventLoop
The event loop to use instead of the default one.
'''
loop = loop or asynci... | [
"def",
"make_driver",
"(",
"loop",
"=",
"None",
")",
":",
"loop",
"=",
"loop",
"or",
"asyncio",
".",
"get_event_loop",
"(",
")",
"def",
"stop",
"(",
"i",
"=",
"None",
")",
":",
"loop",
".",
"stop",
"(",
")",
"def",
"driver",
"(",
"sink",
")",
":"... | Returns a stop driver.
The optional loop argument can be provided to use the driver in another
loop than the default one.
Parameters
-----------
loop: BaseEventLoop
The event loop to use instead of the default one. | [
"Returns",
"a",
"stop",
"driver",
".",
"The",
"optional",
"loop",
"argument",
"can",
"be",
"provided",
"to",
"use",
"the",
"driver",
"in",
"another",
"loop",
"than",
"the",
"default",
"one",
"."
] | 4401076aafe4a72de1d3c4ad6bb7ffa648506f7e | https://github.com/MainRo/cyclotron-aio/blob/4401076aafe4a72de1d3c4ad6bb7ffa648506f7e/cyclotron_aio/stop.py#L8-L40 | train |
Karaage-Cluster/python-tldap | tldap/database/helpers.py | rdn_to_dn | def rdn_to_dn(changes: Changeset, name: str, base_dn: str) -> Changeset:
""" Convert the rdn to a fully qualified DN for the specified LDAP
connection.
:param changes: The changes object to lookup.
:param name: rdn to convert.
:param base_dn: The base_dn to lookup.
:return: fully qualified DN.
... | python | def rdn_to_dn(changes: Changeset, name: str, base_dn: str) -> Changeset:
""" Convert the rdn to a fully qualified DN for the specified LDAP
connection.
:param changes: The changes object to lookup.
:param name: rdn to convert.
:param base_dn: The base_dn to lookup.
:return: fully qualified DN.
... | [
"def",
"rdn_to_dn",
"(",
"changes",
":",
"Changeset",
",",
"name",
":",
"str",
",",
"base_dn",
":",
"str",
")",
"->",
"Changeset",
":",
"dn",
"=",
"changes",
".",
"get_value_as_single",
"(",
"'dn'",
")",
"if",
"dn",
"is",
"not",
"None",
":",
"return",
... | Convert the rdn to a fully qualified DN for the specified LDAP
connection.
:param changes: The changes object to lookup.
:param name: rdn to convert.
:param base_dn: The base_dn to lookup.
:return: fully qualified DN. | [
"Convert",
"the",
"rdn",
"to",
"a",
"fully",
"qualified",
"DN",
"for",
"the",
"specified",
"LDAP",
"connection",
"."
] | 61f1af74a3648cb6491e7eeb1ee2eb395d67bf59 | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/database/helpers.py#L38-L66 | train |
alixedi/palal | palal/survey.py | _stdin_ | def _stdin_(p):
"""Takes input from user. Works for Python 2 and 3."""
_v = sys.version[0]
return input(p) if _v is '3' else raw_input(p) | python | def _stdin_(p):
"""Takes input from user. Works for Python 2 and 3."""
_v = sys.version[0]
return input(p) if _v is '3' else raw_input(p) | [
"def",
"_stdin_",
"(",
"p",
")",
":",
"_v",
"=",
"sys",
".",
"version",
"[",
"0",
"]",
"return",
"input",
"(",
"p",
")",
"if",
"_v",
"is",
"'3'",
"else",
"raw_input",
"(",
"p",
")"
] | Takes input from user. Works for Python 2 and 3. | [
"Takes",
"input",
"from",
"user",
".",
"Works",
"for",
"Python",
"2",
"and",
"3",
"."
] | 325359f66ac48a9f96efea0489aec353f8a40837 | https://github.com/alixedi/palal/blob/325359f66ac48a9f96efea0489aec353f8a40837/palal/survey.py#L28-L31 | train |
alixedi/palal | palal/survey.py | survey_loader | def survey_loader(sur_dir=SUR_DIR, sur_file=SUR_FILE):
"""Loads up the given survey in the given dir."""
survey_path = os.path.join(sur_dir, sur_file)
survey = None
with open(survey_path) as survey_file:
survey = Survey(survey_file.read())
return survey | python | def survey_loader(sur_dir=SUR_DIR, sur_file=SUR_FILE):
"""Loads up the given survey in the given dir."""
survey_path = os.path.join(sur_dir, sur_file)
survey = None
with open(survey_path) as survey_file:
survey = Survey(survey_file.read())
return survey | [
"def",
"survey_loader",
"(",
"sur_dir",
"=",
"SUR_DIR",
",",
"sur_file",
"=",
"SUR_FILE",
")",
":",
"survey_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"sur_dir",
",",
"sur_file",
")",
"survey",
"=",
"None",
"with",
"open",
"(",
"survey_path",
")",
... | Loads up the given survey in the given dir. | [
"Loads",
"up",
"the",
"given",
"survey",
"in",
"the",
"given",
"dir",
"."
] | 325359f66ac48a9f96efea0489aec353f8a40837 | https://github.com/alixedi/palal/blob/325359f66ac48a9f96efea0489aec353f8a40837/palal/survey.py#L105-L111 | train |
alixedi/palal | palal/survey.py | Survey.format_choices | def format_choices(self):
"""Return the choices in string form."""
ce = enumerate(self.choices)
f = lambda i, c: '%s (%d)' % (c, i+1)
# apply formatter and append help token
toks = [f(i,c) for i, c in ce] + ['Help (?)']
return ' '.join(toks) | python | def format_choices(self):
"""Return the choices in string form."""
ce = enumerate(self.choices)
f = lambda i, c: '%s (%d)' % (c, i+1)
# apply formatter and append help token
toks = [f(i,c) for i, c in ce] + ['Help (?)']
return ' '.join(toks) | [
"def",
"format_choices",
"(",
"self",
")",
":",
"ce",
"=",
"enumerate",
"(",
"self",
".",
"choices",
")",
"f",
"=",
"lambda",
"i",
",",
"c",
":",
"'%s (%d)'",
"%",
"(",
"c",
",",
"i",
"+",
"1",
")",
"# apply formatter and append help token",
"toks",
"=... | Return the choices in string form. | [
"Return",
"the",
"choices",
"in",
"string",
"form",
"."
] | 325359f66ac48a9f96efea0489aec353f8a40837 | https://github.com/alixedi/palal/blob/325359f66ac48a9f96efea0489aec353f8a40837/palal/survey.py#L51-L57 | train |
alixedi/palal | palal/survey.py | Survey.is_answer_valid | def is_answer_valid(self, ans):
"""Validate user's answer against available choices."""
return ans in [str(i+1) for i in range(len(self.choices))] | python | def is_answer_valid(self, ans):
"""Validate user's answer against available choices."""
return ans in [str(i+1) for i in range(len(self.choices))] | [
"def",
"is_answer_valid",
"(",
"self",
",",
"ans",
")",
":",
"return",
"ans",
"in",
"[",
"str",
"(",
"i",
"+",
"1",
")",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"choices",
")",
")",
"]"
] | Validate user's answer against available choices. | [
"Validate",
"user",
"s",
"answer",
"against",
"available",
"choices",
"."
] | 325359f66ac48a9f96efea0489aec353f8a40837 | https://github.com/alixedi/palal/blob/325359f66ac48a9f96efea0489aec353f8a40837/palal/survey.py#L59-L61 | train |
alixedi/palal | palal/survey.py | Survey.run_question | def run_question(self, question, input_func=_stdin_):
"""Run the given question."""
qi = '[%d/%d] ' % (self.qcount, self.qtotal)
print('%s %s:' % (qi, question['label']))
while True:
# ask for user input until we get a valid one
ans = input_func('%s > ' % self.for... | python | def run_question(self, question, input_func=_stdin_):
"""Run the given question."""
qi = '[%d/%d] ' % (self.qcount, self.qtotal)
print('%s %s:' % (qi, question['label']))
while True:
# ask for user input until we get a valid one
ans = input_func('%s > ' % self.for... | [
"def",
"run_question",
"(",
"self",
",",
"question",
",",
"input_func",
"=",
"_stdin_",
")",
":",
"qi",
"=",
"'[%d/%d] '",
"%",
"(",
"self",
".",
"qcount",
",",
"self",
".",
"qtotal",
")",
"print",
"(",
"'%s %s:'",
"%",
"(",
"qi",
",",
"question",
"[... | Run the given question. | [
"Run",
"the",
"given",
"question",
"."
] | 325359f66ac48a9f96efea0489aec353f8a40837 | https://github.com/alixedi/palal/blob/325359f66ac48a9f96efea0489aec353f8a40837/palal/survey.py#L63-L76 | train |
alixedi/palal | palal/survey.py | Survey.run_section | def run_section(self, name, input_func=_stdin_):
"""Run the given section."""
print('\nStuff %s by the license:\n' % name)
section = self.survey[name]
for question in section:
self.run_question(question, input_func) | python | def run_section(self, name, input_func=_stdin_):
"""Run the given section."""
print('\nStuff %s by the license:\n' % name)
section = self.survey[name]
for question in section:
self.run_question(question, input_func) | [
"def",
"run_section",
"(",
"self",
",",
"name",
",",
"input_func",
"=",
"_stdin_",
")",
":",
"print",
"(",
"'\\nStuff %s by the license:\\n'",
"%",
"name",
")",
"section",
"=",
"self",
".",
"survey",
"[",
"name",
"]",
"for",
"question",
"in",
"section",
":... | Run the given section. | [
"Run",
"the",
"given",
"section",
"."
] | 325359f66ac48a9f96efea0489aec353f8a40837 | https://github.com/alixedi/palal/blob/325359f66ac48a9f96efea0489aec353f8a40837/palal/survey.py#L78-L83 | train |
alixedi/palal | palal/survey.py | Survey.run | def run(self, input_func=_stdin_):
"""Run the sections."""
# reset question count
self.qcount = 1
for section_name in self.survey:
self.run_section(section_name, input_func) | python | def run(self, input_func=_stdin_):
"""Run the sections."""
# reset question count
self.qcount = 1
for section_name in self.survey:
self.run_section(section_name, input_func) | [
"def",
"run",
"(",
"self",
",",
"input_func",
"=",
"_stdin_",
")",
":",
"# reset question count",
"self",
".",
"qcount",
"=",
"1",
"for",
"section_name",
"in",
"self",
".",
"survey",
":",
"self",
".",
"run_section",
"(",
"section_name",
",",
"input_func",
... | Run the sections. | [
"Run",
"the",
"sections",
"."
] | 325359f66ac48a9f96efea0489aec353f8a40837 | https://github.com/alixedi/palal/blob/325359f66ac48a9f96efea0489aec353f8a40837/palal/survey.py#L85-L90 | train |
alixedi/palal | palal/survey.py | Survey.get_vector | def get_vector(self):
"""Return the vector for this survey."""
vec = {}
for dim in ['forbidden', 'required', 'permitted']:
if self.survey[dim] is None:
continue
dim_vec = map(lambda x: (x['tag'], x['answer']),
self.survey[dim])
... | python | def get_vector(self):
"""Return the vector for this survey."""
vec = {}
for dim in ['forbidden', 'required', 'permitted']:
if self.survey[dim] is None:
continue
dim_vec = map(lambda x: (x['tag'], x['answer']),
self.survey[dim])
... | [
"def",
"get_vector",
"(",
"self",
")",
":",
"vec",
"=",
"{",
"}",
"for",
"dim",
"in",
"[",
"'forbidden'",
",",
"'required'",
",",
"'permitted'",
"]",
":",
"if",
"self",
".",
"survey",
"[",
"dim",
"]",
"is",
"None",
":",
"continue",
"dim_vec",
"=",
... | Return the vector for this survey. | [
"Return",
"the",
"vector",
"for",
"this",
"survey",
"."
] | 325359f66ac48a9f96efea0489aec353f8a40837 | https://github.com/alixedi/palal/blob/325359f66ac48a9f96efea0489aec353f8a40837/palal/survey.py#L92-L101 | train |
jamescooke/flake8-aaa | src/flake8_aaa/line_markers.py | LineMarkers.update | def update(self, span: typing.Tuple[int, int], line_type: LineType) -> None:
"""
Updates line types for a block's span.
Args:
span: First and last relative line number of a Block.
line_type: The type of line to update to.
Raises:
ValidationError: A s... | python | def update(self, span: typing.Tuple[int, int], line_type: LineType) -> None:
"""
Updates line types for a block's span.
Args:
span: First and last relative line number of a Block.
line_type: The type of line to update to.
Raises:
ValidationError: A s... | [
"def",
"update",
"(",
"self",
",",
"span",
":",
"typing",
".",
"Tuple",
"[",
"int",
",",
"int",
"]",
",",
"line_type",
":",
"LineType",
")",
"->",
"None",
":",
"first_block_line",
",",
"last_block_line",
"=",
"span",
"for",
"i",
"in",
"range",
"(",
"... | Updates line types for a block's span.
Args:
span: First and last relative line number of a Block.
line_type: The type of line to update to.
Raises:
ValidationError: A special error on collision. This prevents Flake8
from crashing because it is conve... | [
"Updates",
"line",
"types",
"for",
"a",
"block",
"s",
"span",
"."
] | 29938b96845fe32ced4358ba66af3b3be2a37794 | https://github.com/jamescooke/flake8-aaa/blob/29938b96845fe32ced4358ba66af3b3be2a37794/src/flake8_aaa/line_markers.py#L50-L69 | train |
jamescooke/flake8-aaa | src/flake8_aaa/line_markers.py | LineMarkers.check_arrange_act_spacing | def check_arrange_act_spacing(self) -> typing.Generator[AAAError, None, None]:
"""
* When no spaces found, point error at line above act block
* When too many spaces found, point error at 2nd blank line
"""
yield from self.check_block_spacing(
LineType.arrange,
... | python | def check_arrange_act_spacing(self) -> typing.Generator[AAAError, None, None]:
"""
* When no spaces found, point error at line above act block
* When too many spaces found, point error at 2nd blank line
"""
yield from self.check_block_spacing(
LineType.arrange,
... | [
"def",
"check_arrange_act_spacing",
"(",
"self",
")",
"->",
"typing",
".",
"Generator",
"[",
"AAAError",
",",
"None",
",",
"None",
"]",
":",
"yield",
"from",
"self",
".",
"check_block_spacing",
"(",
"LineType",
".",
"arrange",
",",
"LineType",
".",
"act",
... | * When no spaces found, point error at line above act block
* When too many spaces found, point error at 2nd blank line | [
"*",
"When",
"no",
"spaces",
"found",
"point",
"error",
"at",
"line",
"above",
"act",
"block",
"*",
"When",
"too",
"many",
"spaces",
"found",
"point",
"error",
"at",
"2nd",
"blank",
"line"
] | 29938b96845fe32ced4358ba66af3b3be2a37794 | https://github.com/jamescooke/flake8-aaa/blob/29938b96845fe32ced4358ba66af3b3be2a37794/src/flake8_aaa/line_markers.py#L71-L80 | train |
jamescooke/flake8-aaa | src/flake8_aaa/line_markers.py | LineMarkers.check_act_assert_spacing | def check_act_assert_spacing(self) -> typing.Generator[AAAError, None, None]:
"""
* When no spaces found, point error at line above assert block
* When too many spaces found, point error at 2nd blank line
"""
yield from self.check_block_spacing(
LineType.act,
... | python | def check_act_assert_spacing(self) -> typing.Generator[AAAError, None, None]:
"""
* When no spaces found, point error at line above assert block
* When too many spaces found, point error at 2nd blank line
"""
yield from self.check_block_spacing(
LineType.act,
... | [
"def",
"check_act_assert_spacing",
"(",
"self",
")",
"->",
"typing",
".",
"Generator",
"[",
"AAAError",
",",
"None",
",",
"None",
"]",
":",
"yield",
"from",
"self",
".",
"check_block_spacing",
"(",
"LineType",
".",
"act",
",",
"LineType",
".",
"_assert",
"... | * When no spaces found, point error at line above assert block
* When too many spaces found, point error at 2nd blank line | [
"*",
"When",
"no",
"spaces",
"found",
"point",
"error",
"at",
"line",
"above",
"assert",
"block",
"*",
"When",
"too",
"many",
"spaces",
"found",
"point",
"error",
"at",
"2nd",
"blank",
"line"
] | 29938b96845fe32ced4358ba66af3b3be2a37794 | https://github.com/jamescooke/flake8-aaa/blob/29938b96845fe32ced4358ba66af3b3be2a37794/src/flake8_aaa/line_markers.py#L82-L91 | train |
jamescooke/flake8-aaa | src/flake8_aaa/line_markers.py | LineMarkers.check_block_spacing | def check_block_spacing(
self,
first_block_type: LineType,
second_block_type: LineType,
error_message: str,
) -> typing.Generator[AAAError, None, None]:
"""
Checks there is a clear single line between ``first_block_type`` and
``second_block_type``.
No... | python | def check_block_spacing(
self,
first_block_type: LineType,
second_block_type: LineType,
error_message: str,
) -> typing.Generator[AAAError, None, None]:
"""
Checks there is a clear single line between ``first_block_type`` and
``second_block_type``.
No... | [
"def",
"check_block_spacing",
"(",
"self",
",",
"first_block_type",
":",
"LineType",
",",
"second_block_type",
":",
"LineType",
",",
"error_message",
":",
"str",
",",
")",
"->",
"typing",
".",
"Generator",
"[",
"AAAError",
",",
"None",
",",
"None",
"]",
":",... | Checks there is a clear single line between ``first_block_type`` and
``second_block_type``.
Note:
Is tested via ``check_arrange_act_spacing()`` and
``check_act_assert_spacing()``. | [
"Checks",
"there",
"is",
"a",
"clear",
"single",
"line",
"between",
"first_block_type",
"and",
"second_block_type",
"."
] | 29938b96845fe32ced4358ba66af3b3be2a37794 | https://github.com/jamescooke/flake8-aaa/blob/29938b96845fe32ced4358ba66af3b3be2a37794/src/flake8_aaa/line_markers.py#L93-L141 | train |
alixedi/palal | palal/palal.py | vector_distance | def vector_distance(v1, v2):
"""Given 2 vectors of multiple dimensions, calculate the euclidean
distance measure between them."""
dist = 0
for dim in v1:
for x in v1[dim]:
dd = int(v1[dim][x]) - int(v2[dim][x])
dist = dist + dd**2
return dist | python | def vector_distance(v1, v2):
"""Given 2 vectors of multiple dimensions, calculate the euclidean
distance measure between them."""
dist = 0
for dim in v1:
for x in v1[dim]:
dd = int(v1[dim][x]) - int(v2[dim][x])
dist = dist + dd**2
return dist | [
"def",
"vector_distance",
"(",
"v1",
",",
"v2",
")",
":",
"dist",
"=",
"0",
"for",
"dim",
"in",
"v1",
":",
"for",
"x",
"in",
"v1",
"[",
"dim",
"]",
":",
"dd",
"=",
"int",
"(",
"v1",
"[",
"dim",
"]",
"[",
"x",
"]",
")",
"-",
"int",
"(",
"v... | Given 2 vectors of multiple dimensions, calculate the euclidean
distance measure between them. | [
"Given",
"2",
"vectors",
"of",
"multiple",
"dimensions",
"calculate",
"the",
"euclidean",
"distance",
"measure",
"between",
"them",
"."
] | 325359f66ac48a9f96efea0489aec353f8a40837 | https://github.com/alixedi/palal/blob/325359f66ac48a9f96efea0489aec353f8a40837/palal/palal.py#L41-L49 | train |
xenadevel/PyXenaManager | xenamanager/xena_object.py | XenaObject.send_command | def send_command(self, command, *arguments):
""" Send command with no output.
:param command: command to send.
:param arguments: list of command arguments.
"""
self.api.send_command(self, command, *arguments) | python | def send_command(self, command, *arguments):
""" Send command with no output.
:param command: command to send.
:param arguments: list of command arguments.
"""
self.api.send_command(self, command, *arguments) | [
"def",
"send_command",
"(",
"self",
",",
"command",
",",
"*",
"arguments",
")",
":",
"self",
".",
"api",
".",
"send_command",
"(",
"self",
",",
"command",
",",
"*",
"arguments",
")"
] | Send command with no output.
:param command: command to send.
:param arguments: list of command arguments. | [
"Send",
"command",
"with",
"no",
"output",
"."
] | 384ca265f73044b8a8b471f5dd7a6103fc54f4df | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/xena_object.py#L44-L50 | train |
xenadevel/PyXenaManager | xenamanager/xena_object.py | XenaObject.send_command_return | def send_command_return(self, command, *arguments):
""" Send command and wait for single line output. """
return self.api.send_command_return(self, command, *arguments) | python | def send_command_return(self, command, *arguments):
""" Send command and wait for single line output. """
return self.api.send_command_return(self, command, *arguments) | [
"def",
"send_command_return",
"(",
"self",
",",
"command",
",",
"*",
"arguments",
")",
":",
"return",
"self",
".",
"api",
".",
"send_command_return",
"(",
"self",
",",
"command",
",",
"*",
"arguments",
")"
] | Send command and wait for single line output. | [
"Send",
"command",
"and",
"wait",
"for",
"single",
"line",
"output",
"."
] | 384ca265f73044b8a8b471f5dd7a6103fc54f4df | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/xena_object.py#L52-L54 | train |
xenadevel/PyXenaManager | xenamanager/xena_object.py | XenaObject.send_command_return_multilines | def send_command_return_multilines(self, command, *arguments):
""" Send command and wait for multiple lines output. """
return self.api.send_command_return_multilines(self, command, *arguments) | python | def send_command_return_multilines(self, command, *arguments):
""" Send command and wait for multiple lines output. """
return self.api.send_command_return_multilines(self, command, *arguments) | [
"def",
"send_command_return_multilines",
"(",
"self",
",",
"command",
",",
"*",
"arguments",
")",
":",
"return",
"self",
".",
"api",
".",
"send_command_return_multilines",
"(",
"self",
",",
"command",
",",
"*",
"arguments",
")"
] | Send command and wait for multiple lines output. | [
"Send",
"command",
"and",
"wait",
"for",
"multiple",
"lines",
"output",
"."
] | 384ca265f73044b8a8b471f5dd7a6103fc54f4df | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/xena_object.py#L56-L58 | train |
davidblaisonneau-orange/foreman | foreman/subDict.py | SubDict.load | def load(self, limit=9999):
""" Function list
Get the list of all interfaces
@param key: The targeted object
@param limit: The limit of items to return
@return RETURN: A ForemanItem list
"""
subItemList = self.api.list('{}/{}/{}'.format(self.parentObjName,
... | python | def load(self, limit=9999):
""" Function list
Get the list of all interfaces
@param key: The targeted object
@param limit: The limit of items to return
@return RETURN: A ForemanItem list
"""
subItemList = self.api.list('{}/{}/{}'.format(self.parentObjName,
... | [
"def",
"load",
"(",
"self",
",",
"limit",
"=",
"9999",
")",
":",
"subItemList",
"=",
"self",
".",
"api",
".",
"list",
"(",
"'{}/{}/{}'",
".",
"format",
"(",
"self",
".",
"parentObjName",
",",
"self",
".",
"parentKey",
",",
"self",
".",
"objName",
","... | Function list
Get the list of all interfaces
@param key: The targeted object
@param limit: The limit of items to return
@return RETURN: A ForemanItem list | [
"Function",
"list",
"Get",
"the",
"list",
"of",
"all",
"interfaces"
] | acb8fd8d74657cfac3b25c82e9c6028b93eb6c92 | https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/subDict.py#L47-L72 | train |
davidblaisonneau-orange/foreman | foreman/subDict.py | SubDict.append | def append(self, payload):
""" Function __iadd__
@param payload: The payload corresponding to the object to add
@return RETURN: A ForemanItem
"""
if self.objType.setInParentPayload:
print('Error, {} is not elibible to addition, but only set'
.format... | python | def append(self, payload):
""" Function __iadd__
@param payload: The payload corresponding to the object to add
@return RETURN: A ForemanItem
"""
if self.objType.setInParentPayload:
print('Error, {} is not elibible to addition, but only set'
.format... | [
"def",
"append",
"(",
"self",
",",
"payload",
")",
":",
"if",
"self",
".",
"objType",
".",
"setInParentPayload",
":",
"print",
"(",
"'Error, {} is not elibible to addition, but only set'",
".",
"format",
"(",
"self",
".",
"objName",
")",
")",
"return",
"False",
... | Function __iadd__
@param payload: The payload corresponding to the object to add
@return RETURN: A ForemanItem | [
"Function",
"__iadd__"
] | acb8fd8d74657cfac3b25c82e9c6028b93eb6c92 | https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/subDict.py#L100-L114 | train |
davidblaisonneau-orange/foreman | foreman/subDict.py | SubDict.getPayloadStruct | def getPayloadStruct(self, payload):
""" Function getPayloadStruct
@param payload: The payload structure to the object to add
@return RETURN: A dict
"""
newSubItem = self.objType(self.api, 0, self.parentObjName,
self.parentPayloadObj, self.paren... | python | def getPayloadStruct(self, payload):
""" Function getPayloadStruct
@param payload: The payload structure to the object to add
@return RETURN: A dict
"""
newSubItem = self.objType(self.api, 0, self.parentObjName,
self.parentPayloadObj, self.paren... | [
"def",
"getPayloadStruct",
"(",
"self",
",",
"payload",
")",
":",
"newSubItem",
"=",
"self",
".",
"objType",
"(",
"self",
".",
"api",
",",
"0",
",",
"self",
".",
"parentObjName",
",",
"self",
".",
"parentPayloadObj",
",",
"self",
".",
"parentKey",
",",
... | Function getPayloadStruct
@param payload: The payload structure to the object to add
@return RETURN: A dict | [
"Function",
"getPayloadStruct"
] | acb8fd8d74657cfac3b25c82e9c6028b93eb6c92 | https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/subDict.py#L116-L124 | train |
josiah-wolf-oberholtzer/uqbar | uqbar/objects.py | get_repr | def get_repr(expr, multiline=False):
"""
Build a repr string for ``expr`` from its vars and signature.
::
>>> class MyObject:
... def __init__(self, arg1, arg2, *var_args, foo=None, bar=None, **kwargs):
... self.arg1 = arg1
... self.arg2 = arg2
.... | python | def get_repr(expr, multiline=False):
"""
Build a repr string for ``expr`` from its vars and signature.
::
>>> class MyObject:
... def __init__(self, arg1, arg2, *var_args, foo=None, bar=None, **kwargs):
... self.arg1 = arg1
... self.arg2 = arg2
.... | [
"def",
"get_repr",
"(",
"expr",
",",
"multiline",
"=",
"False",
")",
":",
"signature",
"=",
"_get_object_signature",
"(",
"expr",
")",
"if",
"signature",
"is",
"None",
":",
"return",
"\"{}()\"",
".",
"format",
"(",
"type",
"(",
"expr",
")",
".",
"__name_... | Build a repr string for ``expr`` from its vars and signature.
::
>>> class MyObject:
... def __init__(self, arg1, arg2, *var_args, foo=None, bar=None, **kwargs):
... self.arg1 = arg1
... self.arg2 = arg2
... self.var_args = var_args
... ... | [
"Build",
"a",
"repr",
"string",
"for",
"expr",
"from",
"its",
"vars",
"and",
"signature",
"."
] | eca7fefebbbee1e2ae13bf5d6baa838be66b1db6 | https://github.com/josiah-wolf-oberholtzer/uqbar/blob/eca7fefebbbee1e2ae13bf5d6baa838be66b1db6/uqbar/objects.py#L87-L173 | train |
josiah-wolf-oberholtzer/uqbar | uqbar/objects.py | get_vars | def get_vars(expr):
"""
Get ``args``, ``var args`` and ``kwargs`` for an object ``expr``.
::
>>> class MyObject:
... def __init__(self, arg1, arg2, *var_args, foo=None, bar=None, **kwargs):
... self.arg1 = arg1
... self.arg2 = arg2
... se... | python | def get_vars(expr):
"""
Get ``args``, ``var args`` and ``kwargs`` for an object ``expr``.
::
>>> class MyObject:
... def __init__(self, arg1, arg2, *var_args, foo=None, bar=None, **kwargs):
... self.arg1 = arg1
... self.arg2 = arg2
... se... | [
"def",
"get_vars",
"(",
"expr",
")",
":",
"# print('TYPE?', type(expr))",
"signature",
"=",
"_get_object_signature",
"(",
"expr",
")",
"if",
"signature",
"is",
"None",
":",
"return",
"(",
"{",
"}",
",",
"[",
"]",
",",
"{",
"}",
")",
"# print('SIG?', signatur... | Get ``args``, ``var args`` and ``kwargs`` for an object ``expr``.
::
>>> class MyObject:
... def __init__(self, arg1, arg2, *var_args, foo=None, bar=None, **kwargs):
... self.arg1 = arg1
... self.arg2 = arg2
... self.var_args = var_args
.... | [
"Get",
"args",
"var",
"args",
"and",
"kwargs",
"for",
"an",
"object",
"expr",
"."
] | eca7fefebbbee1e2ae13bf5d6baa838be66b1db6 | https://github.com/josiah-wolf-oberholtzer/uqbar/blob/eca7fefebbbee1e2ae13bf5d6baa838be66b1db6/uqbar/objects.py#L176-L287 | train |
josiah-wolf-oberholtzer/uqbar | uqbar/objects.py | new | def new(expr, *args, **kwargs):
"""
Template an object.
::
>>> class MyObject:
... def __init__(self, arg1, arg2, *var_args, foo=None, bar=None, **kwargs):
... self.arg1 = arg1
... self.arg2 = arg2
... self.var_args = var_args
...... | python | def new(expr, *args, **kwargs):
"""
Template an object.
::
>>> class MyObject:
... def __init__(self, arg1, arg2, *var_args, foo=None, bar=None, **kwargs):
... self.arg1 = arg1
... self.arg2 = arg2
... self.var_args = var_args
...... | [
"def",
"new",
"(",
"expr",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# TODO: Clarify old vs. new variable naming here.",
"current_args",
",",
"current_var_args",
",",
"current_kwargs",
"=",
"get_vars",
"(",
"expr",
")",
"new_kwargs",
"=",
"current_kwar... | Template an object.
::
>>> class MyObject:
... def __init__(self, arg1, arg2, *var_args, foo=None, bar=None, **kwargs):
... self.arg1 = arg1
... self.arg2 = arg2
... self.var_args = var_args
... self.foo = foo
... ... | [
"Template",
"an",
"object",
"."
] | eca7fefebbbee1e2ae13bf5d6baa838be66b1db6 | https://github.com/josiah-wolf-oberholtzer/uqbar/blob/eca7fefebbbee1e2ae13bf5d6baa838be66b1db6/uqbar/objects.py#L290-L363 | train |
josiah-wolf-oberholtzer/uqbar | uqbar/sphinx/api.py | on_builder_inited | def on_builder_inited(app):
"""
Hooks into Sphinx's ``builder-inited`` event.
Builds out the ReST API source.
"""
config = app.builder.config
target_directory = (
pathlib.Path(app.builder.env.srcdir) / config.uqbar_api_directory_name
)
initial_source_paths: List[str] = []
... | python | def on_builder_inited(app):
"""
Hooks into Sphinx's ``builder-inited`` event.
Builds out the ReST API source.
"""
config = app.builder.config
target_directory = (
pathlib.Path(app.builder.env.srcdir) / config.uqbar_api_directory_name
)
initial_source_paths: List[str] = []
... | [
"def",
"on_builder_inited",
"(",
"app",
")",
":",
"config",
"=",
"app",
".",
"builder",
".",
"config",
"target_directory",
"=",
"(",
"pathlib",
".",
"Path",
"(",
"app",
".",
"builder",
".",
"env",
".",
"srcdir",
")",
"/",
"config",
".",
"uqbar_api_direct... | Hooks into Sphinx's ``builder-inited`` event.
Builds out the ReST API source. | [
"Hooks",
"into",
"Sphinx",
"s",
"builder",
"-",
"inited",
"event",
"."
] | eca7fefebbbee1e2ae13bf5d6baa838be66b1db6 | https://github.com/josiah-wolf-oberholtzer/uqbar/blob/eca7fefebbbee1e2ae13bf5d6baa838be66b1db6/uqbar/sphinx/api.py#L49-L113 | train |
josiah-wolf-oberholtzer/uqbar | uqbar/sphinx/api.py | setup | def setup(app) -> Dict[str, Any]:
"""
Sets up Sphinx extension.
"""
app.add_config_value("uqbar_api_directory_name", "api", "env")
app.add_config_value("uqbar_api_document_empty_modules", False, "env")
app.add_config_value("uqbar_api_document_private_members", False, "env")
app.add_config_va... | python | def setup(app) -> Dict[str, Any]:
"""
Sets up Sphinx extension.
"""
app.add_config_value("uqbar_api_directory_name", "api", "env")
app.add_config_value("uqbar_api_document_empty_modules", False, "env")
app.add_config_value("uqbar_api_document_private_members", False, "env")
app.add_config_va... | [
"def",
"setup",
"(",
"app",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"app",
".",
"add_config_value",
"(",
"\"uqbar_api_directory_name\"",
",",
"\"api\"",
",",
"\"env\"",
")",
"app",
".",
"add_config_value",
"(",
"\"uqbar_api_document_empty_modules\""... | Sets up Sphinx extension. | [
"Sets",
"up",
"Sphinx",
"extension",
"."
] | eca7fefebbbee1e2ae13bf5d6baa838be66b1db6 | https://github.com/josiah-wolf-oberholtzer/uqbar/blob/eca7fefebbbee1e2ae13bf5d6baa838be66b1db6/uqbar/sphinx/api.py#L116-L134 | train |
developersociety/django-glitter | glitter/integration.py | GlitterAppPool.get_glitter_app | def get_glitter_app(self, glitter_app_name):
"""
Retrieve the Glitter App config for a specific Glitter App.
"""
if not self.discovered:
self.discover_glitter_apps()
try:
glitter_app = self.glitter_apps[glitter_app_name]
return glitter_app
... | python | def get_glitter_app(self, glitter_app_name):
"""
Retrieve the Glitter App config for a specific Glitter App.
"""
if not self.discovered:
self.discover_glitter_apps()
try:
glitter_app = self.glitter_apps[glitter_app_name]
return glitter_app
... | [
"def",
"get_glitter_app",
"(",
"self",
",",
"glitter_app_name",
")",
":",
"if",
"not",
"self",
".",
"discovered",
":",
"self",
".",
"discover_glitter_apps",
"(",
")",
"try",
":",
"glitter_app",
"=",
"self",
".",
"glitter_apps",
"[",
"glitter_app_name",
"]",
... | Retrieve the Glitter App config for a specific Glitter App. | [
"Retrieve",
"the",
"Glitter",
"App",
"config",
"for",
"a",
"specific",
"Glitter",
"App",
"."
] | 2c0280ec83afee80deee94ee3934fc54239c2e87 | https://github.com/developersociety/django-glitter/blob/2c0280ec83afee80deee94ee3934fc54239c2e87/glitter/integration.py#L28-L39 | train |
developersociety/django-glitter | glitter/integration.py | GlitterAppPool.discover_glitter_apps | def discover_glitter_apps(self):
"""
Find all the Glitter App configurations in the current project.
"""
for app_name in settings.INSTALLED_APPS:
module_name = '{app_name}.glitter_apps'.format(app_name=app_name)
try:
glitter_apps_module = import_mo... | python | def discover_glitter_apps(self):
"""
Find all the Glitter App configurations in the current project.
"""
for app_name in settings.INSTALLED_APPS:
module_name = '{app_name}.glitter_apps'.format(app_name=app_name)
try:
glitter_apps_module = import_mo... | [
"def",
"discover_glitter_apps",
"(",
"self",
")",
":",
"for",
"app_name",
"in",
"settings",
".",
"INSTALLED_APPS",
":",
"module_name",
"=",
"'{app_name}.glitter_apps'",
".",
"format",
"(",
"app_name",
"=",
"app_name",
")",
"try",
":",
"glitter_apps_module",
"=",
... | Find all the Glitter App configurations in the current project. | [
"Find",
"all",
"the",
"Glitter",
"App",
"configurations",
"in",
"the",
"current",
"project",
"."
] | 2c0280ec83afee80deee94ee3934fc54239c2e87 | https://github.com/developersociety/django-glitter/blob/2c0280ec83afee80deee94ee3934fc54239c2e87/glitter/integration.py#L41-L54 | train |
davidblaisonneau-orange/foreman | foreman/itemDomain.py | ItemDomain.enhance | def enhance(self):
""" Function enhance
Enhance the object with new item or enhanced items
"""
self.update({'parameters':
SubDict(self.api, self.objName,
self.payloadObj, self.key,
SubItemParameter)})
... | python | def enhance(self):
""" Function enhance
Enhance the object with new item or enhanced items
"""
self.update({'parameters':
SubDict(self.api, self.objName,
self.payloadObj, self.key,
SubItemParameter)})
... | [
"def",
"enhance",
"(",
"self",
")",
":",
"self",
".",
"update",
"(",
"{",
"'parameters'",
":",
"SubDict",
"(",
"self",
".",
"api",
",",
"self",
".",
"objName",
",",
"self",
".",
"payloadObj",
",",
"self",
".",
"key",
",",
"SubItemParameter",
")",
"}"... | Function enhance
Enhance the object with new item or enhanced items | [
"Function",
"enhance",
"Enhance",
"the",
"object",
"with",
"new",
"item",
"or",
"enhanced",
"items"
] | acb8fd8d74657cfac3b25c82e9c6028b93eb6c92 | https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/itemDomain.py#L37-L52 | train |
quantmind/agile-toolkit | agiletoolkit/kong.py | kong | def kong(ctx, namespace, yes):
"""Update the kong configuration
"""
m = KongManager(ctx.obj['agile'], namespace=namespace)
click.echo(utils.niceJson(m.create_kong(yes))) | python | def kong(ctx, namespace, yes):
"""Update the kong configuration
"""
m = KongManager(ctx.obj['agile'], namespace=namespace)
click.echo(utils.niceJson(m.create_kong(yes))) | [
"def",
"kong",
"(",
"ctx",
",",
"namespace",
",",
"yes",
")",
":",
"m",
"=",
"KongManager",
"(",
"ctx",
".",
"obj",
"[",
"'agile'",
"]",
",",
"namespace",
"=",
"namespace",
")",
"click",
".",
"echo",
"(",
"utils",
".",
"niceJson",
"(",
"m",
".",
... | Update the kong configuration | [
"Update",
"the",
"kong",
"configuration"
] | 96028e36a842c57b171907c20583a60d1045fec1 | https://github.com/quantmind/agile-toolkit/blob/96028e36a842c57b171907c20583a60d1045fec1/agiletoolkit/kong.py#L15-L19 | train |
developersociety/django-glitter | glitter/publisher/models.py | PublishAction.schedule_task | def schedule_task(self):
"""
Schedules this publish action as a Celery task.
"""
from .tasks import publish_task
publish_task.apply_async(kwargs={'pk': self.pk}, eta=self.scheduled_time) | python | def schedule_task(self):
"""
Schedules this publish action as a Celery task.
"""
from .tasks import publish_task
publish_task.apply_async(kwargs={'pk': self.pk}, eta=self.scheduled_time) | [
"def",
"schedule_task",
"(",
"self",
")",
":",
"from",
".",
"tasks",
"import",
"publish_task",
"publish_task",
".",
"apply_async",
"(",
"kwargs",
"=",
"{",
"'pk'",
":",
"self",
".",
"pk",
"}",
",",
"eta",
"=",
"self",
".",
"scheduled_time",
")"
] | Schedules this publish action as a Celery task. | [
"Schedules",
"this",
"publish",
"action",
"as",
"a",
"Celery",
"task",
"."
] | 2c0280ec83afee80deee94ee3934fc54239c2e87 | https://github.com/developersociety/django-glitter/blob/2c0280ec83afee80deee94ee3934fc54239c2e87/glitter/publisher/models.py#L52-L58 | train |
developersociety/django-glitter | glitter/publisher/models.py | PublishAction.get_version | def get_version(self):
"""
Get the version object for the related object.
"""
return Version.objects.get(
content_type=self.content_type,
object_id=self.object_id,
version_number=self.publish_version,
) | python | def get_version(self):
"""
Get the version object for the related object.
"""
return Version.objects.get(
content_type=self.content_type,
object_id=self.object_id,
version_number=self.publish_version,
) | [
"def",
"get_version",
"(",
"self",
")",
":",
"return",
"Version",
".",
"objects",
".",
"get",
"(",
"content_type",
"=",
"self",
".",
"content_type",
",",
"object_id",
"=",
"self",
".",
"object_id",
",",
"version_number",
"=",
"self",
".",
"publish_version",
... | Get the version object for the related object. | [
"Get",
"the",
"version",
"object",
"for",
"the",
"related",
"object",
"."
] | 2c0280ec83afee80deee94ee3934fc54239c2e87 | https://github.com/developersociety/django-glitter/blob/2c0280ec83afee80deee94ee3934fc54239c2e87/glitter/publisher/models.py#L60-L68 | train |
developersociety/django-glitter | glitter/publisher/models.py | PublishAction._publish | def _publish(self):
"""
Process a publish action on the related object, returns a boolean if a change is made.
Only objects where a version change is needed will be updated.
"""
obj = self.content_object
version = self.get_version()
actioned = False
# On... | python | def _publish(self):
"""
Process a publish action on the related object, returns a boolean if a change is made.
Only objects where a version change is needed will be updated.
"""
obj = self.content_object
version = self.get_version()
actioned = False
# On... | [
"def",
"_publish",
"(",
"self",
")",
":",
"obj",
"=",
"self",
".",
"content_object",
"version",
"=",
"self",
".",
"get_version",
"(",
")",
"actioned",
"=",
"False",
"# Only update if needed",
"if",
"obj",
".",
"current_version",
"!=",
"version",
":",
"versio... | Process a publish action on the related object, returns a boolean if a change is made.
Only objects where a version change is needed will be updated. | [
"Process",
"a",
"publish",
"action",
"on",
"the",
"related",
"object",
"returns",
"a",
"boolean",
"if",
"a",
"change",
"is",
"made",
"."
] | 2c0280ec83afee80deee94ee3934fc54239c2e87 | https://github.com/developersociety/django-glitter/blob/2c0280ec83afee80deee94ee3934fc54239c2e87/glitter/publisher/models.py#L70-L87 | train |
developersociety/django-glitter | glitter/publisher/models.py | PublishAction._unpublish | def _unpublish(self):
"""
Process an unpublish action on the related object, returns a boolean if a change is made.
Only objects with a current active version will be updated.
"""
obj = self.content_object
actioned = False
# Only update if needed
if obj.... | python | def _unpublish(self):
"""
Process an unpublish action on the related object, returns a boolean if a change is made.
Only objects with a current active version will be updated.
"""
obj = self.content_object
actioned = False
# Only update if needed
if obj.... | [
"def",
"_unpublish",
"(",
"self",
")",
":",
"obj",
"=",
"self",
".",
"content_object",
"actioned",
"=",
"False",
"# Only update if needed",
"if",
"obj",
".",
"current_version",
"is",
"not",
"None",
":",
"obj",
".",
"current_version",
"=",
"None",
"obj",
".",... | Process an unpublish action on the related object, returns a boolean if a change is made.
Only objects with a current active version will be updated. | [
"Process",
"an",
"unpublish",
"action",
"on",
"the",
"related",
"object",
"returns",
"a",
"boolean",
"if",
"a",
"change",
"is",
"made",
"."
] | 2c0280ec83afee80deee94ee3934fc54239c2e87 | https://github.com/developersociety/django-glitter/blob/2c0280ec83afee80deee94ee3934fc54239c2e87/glitter/publisher/models.py#L89-L104 | train |
developersociety/django-glitter | glitter/publisher/models.py | PublishAction._log_action | def _log_action(self):
"""
Adds a log entry for this action to the object history in the Django admin.
"""
if self.publish_version == self.UNPUBLISH_CHOICE:
message = 'Unpublished page (scheduled)'
else:
message = 'Published version {} (scheduled)'.format(... | python | def _log_action(self):
"""
Adds a log entry for this action to the object history in the Django admin.
"""
if self.publish_version == self.UNPUBLISH_CHOICE:
message = 'Unpublished page (scheduled)'
else:
message = 'Published version {} (scheduled)'.format(... | [
"def",
"_log_action",
"(",
"self",
")",
":",
"if",
"self",
".",
"publish_version",
"==",
"self",
".",
"UNPUBLISH_CHOICE",
":",
"message",
"=",
"'Unpublished page (scheduled)'",
"else",
":",
"message",
"=",
"'Published version {} (scheduled)'",
".",
"format",
"(",
... | Adds a log entry for this action to the object history in the Django admin. | [
"Adds",
"a",
"log",
"entry",
"for",
"this",
"action",
"to",
"the",
"object",
"history",
"in",
"the",
"Django",
"admin",
"."
] | 2c0280ec83afee80deee94ee3934fc54239c2e87 | https://github.com/developersociety/django-glitter/blob/2c0280ec83afee80deee94ee3934fc54239c2e87/glitter/publisher/models.py#L106-L122 | train |
developersociety/django-glitter | glitter/publisher/models.py | PublishAction.process_action | def process_action(self):
"""
Process the action and update the related object, returns a boolean if a change is made.
"""
if self.publish_version == self.UNPUBLISH_CHOICE:
actioned = self._unpublish()
else:
actioned = self._publish()
# Only log i... | python | def process_action(self):
"""
Process the action and update the related object, returns a boolean if a change is made.
"""
if self.publish_version == self.UNPUBLISH_CHOICE:
actioned = self._unpublish()
else:
actioned = self._publish()
# Only log i... | [
"def",
"process_action",
"(",
"self",
")",
":",
"if",
"self",
".",
"publish_version",
"==",
"self",
".",
"UNPUBLISH_CHOICE",
":",
"actioned",
"=",
"self",
".",
"_unpublish",
"(",
")",
"else",
":",
"actioned",
"=",
"self",
".",
"_publish",
"(",
")",
"# On... | Process the action and update the related object, returns a boolean if a change is made. | [
"Process",
"the",
"action",
"and",
"update",
"the",
"related",
"object",
"returns",
"a",
"boolean",
"if",
"a",
"change",
"is",
"made",
"."
] | 2c0280ec83afee80deee94ee3934fc54239c2e87 | https://github.com/developersociety/django-glitter/blob/2c0280ec83afee80deee94ee3934fc54239c2e87/glitter/publisher/models.py#L124-L137 | train |
davidblaisonneau-orange/foreman | foreman/hostgroups.py | HostGroups.checkAndCreate | def checkAndCreate(self, key, payload,
hostgroupConf,
hostgroupParent,
puppetClassesId):
""" Function checkAndCreate
check And Create procedure for an hostgroup
- check the hostgroup is not existing
- create the hostgro... | python | def checkAndCreate(self, key, payload,
hostgroupConf,
hostgroupParent,
puppetClassesId):
""" Function checkAndCreate
check And Create procedure for an hostgroup
- check the hostgroup is not existing
- create the hostgro... | [
"def",
"checkAndCreate",
"(",
"self",
",",
"key",
",",
"payload",
",",
"hostgroupConf",
",",
"hostgroupParent",
",",
"puppetClassesId",
")",
":",
"if",
"key",
"not",
"in",
"self",
":",
"self",
"[",
"key",
"]",
"=",
"payload",
"oid",
"=",
"self",
"[",
"... | Function checkAndCreate
check And Create procedure for an hostgroup
- check the hostgroup is not existing
- create the hostgroup
- Add puppet classes from puppetClassesId
- Add params from hostgroupConf
@param key: The hostgroup name or ID
@param payload: The des... | [
"Function",
"checkAndCreate",
"check",
"And",
"Create",
"procedure",
"for",
"an",
"hostgroup",
"-",
"check",
"the",
"hostgroup",
"is",
"not",
"existing",
"-",
"create",
"the",
"hostgroup",
"-",
"Add",
"puppet",
"classes",
"from",
"puppetClassesId",
"-",
"Add",
... | acb8fd8d74657cfac3b25c82e9c6028b93eb6c92 | https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/hostgroups.py#L56-L96 | train |
qubell/contrib-python-qubell-client | qubell/__init__.py | doublewrap | def doublewrap(f):
'''
a decorator decorator, allowing the decorator to be used as:
@decorator(with, arguments, and=kwargs)
or
@decorator
Ref: http://stackoverflow.com/questions/653368/how-to-create-a-python-decorator-that-can-be-used-either-with-or-without-paramet
'''
@functools.wraps(f... | python | def doublewrap(f):
'''
a decorator decorator, allowing the decorator to be used as:
@decorator(with, arguments, and=kwargs)
or
@decorator
Ref: http://stackoverflow.com/questions/653368/how-to-create-a-python-decorator-that-can-be-used-either-with-or-without-paramet
'''
@functools.wraps(f... | [
"def",
"doublewrap",
"(",
"f",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"f",
")",
"def",
"new_dec",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"len",
"(",
"args",
")",
"==",
"1",
"and",
"len",
"(",
"kwargs",
")",
"==",
"... | a decorator decorator, allowing the decorator to be used as:
@decorator(with, arguments, and=kwargs)
or
@decorator
Ref: http://stackoverflow.com/questions/653368/how-to-create-a-python-decorator-that-can-be-used-either-with-or-without-paramet | [
"a",
"decorator",
"decorator",
"allowing",
"the",
"decorator",
"to",
"be",
"used",
"as",
":"
] | 4586ea11d5103c2ff9607d3ed922b5a0991b8845 | https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/__init__.py#L27-L44 | train |
qubell/contrib-python-qubell-client | qubell/__init__.py | deprecated | def deprecated(func, msg=None):
"""
A decorator which can be used to mark functions
as deprecated.It will result in a deprecation warning being shown
when the function is used.
"""
message = msg or "Use of deprecated function '{}`.".format(func.__name__)
@functools.wraps(func)
def wrap... | python | def deprecated(func, msg=None):
"""
A decorator which can be used to mark functions
as deprecated.It will result in a deprecation warning being shown
when the function is used.
"""
message = msg or "Use of deprecated function '{}`.".format(func.__name__)
@functools.wraps(func)
def wrap... | [
"def",
"deprecated",
"(",
"func",
",",
"msg",
"=",
"None",
")",
":",
"message",
"=",
"msg",
"or",
"\"Use of deprecated function '{}`.\"",
".",
"format",
"(",
"func",
".",
"__name__",
")",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"wrapper_fu... | A decorator which can be used to mark functions
as deprecated.It will result in a deprecation warning being shown
when the function is used. | [
"A",
"decorator",
"which",
"can",
"be",
"used",
"to",
"mark",
"functions",
"as",
"deprecated",
".",
"It",
"will",
"result",
"in",
"a",
"deprecation",
"warning",
"being",
"shown",
"when",
"the",
"function",
"is",
"used",
"."
] | 4586ea11d5103c2ff9607d3ed922b5a0991b8845 | https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/__init__.py#L47-L61 | train |
MatterMiners/cobald | cobald/daemon/core/logger.py | create_handler | def create_handler(target: str):
"""Create a handler for logging to ``target``"""
if target == 'stderr':
return logging.StreamHandler(sys.stderr)
elif target == 'stdout':
return logging.StreamHandler(sys.stdout)
else:
return logging.handlers.WatchedFileHandler(filename=target) | python | def create_handler(target: str):
"""Create a handler for logging to ``target``"""
if target == 'stderr':
return logging.StreamHandler(sys.stderr)
elif target == 'stdout':
return logging.StreamHandler(sys.stdout)
else:
return logging.handlers.WatchedFileHandler(filename=target) | [
"def",
"create_handler",
"(",
"target",
":",
"str",
")",
":",
"if",
"target",
"==",
"'stderr'",
":",
"return",
"logging",
".",
"StreamHandler",
"(",
"sys",
".",
"stderr",
")",
"elif",
"target",
"==",
"'stdout'",
":",
"return",
"logging",
".",
"StreamHandle... | Create a handler for logging to ``target`` | [
"Create",
"a",
"handler",
"for",
"logging",
"to",
"target"
] | 264138de4382d1c9b53fabcbc6660e10b33a914d | https://github.com/MatterMiners/cobald/blob/264138de4382d1c9b53fabcbc6660e10b33a914d/cobald/daemon/core/logger.py#L6-L13 | train |
MatterMiners/cobald | cobald/daemon/core/logger.py | initialise_logging | def initialise_logging(level: str, target: str, short_format: bool):
"""Initialise basic logging facilities"""
try:
log_level = getattr(logging, level)
except AttributeError:
raise SystemExit(
"invalid log level %r, expected any of 'DEBUG', 'INFO', 'WARNING', 'ERROR' or 'CRITICAL... | python | def initialise_logging(level: str, target: str, short_format: bool):
"""Initialise basic logging facilities"""
try:
log_level = getattr(logging, level)
except AttributeError:
raise SystemExit(
"invalid log level %r, expected any of 'DEBUG', 'INFO', 'WARNING', 'ERROR' or 'CRITICAL... | [
"def",
"initialise_logging",
"(",
"level",
":",
"str",
",",
"target",
":",
"str",
",",
"short_format",
":",
"bool",
")",
":",
"try",
":",
"log_level",
"=",
"getattr",
"(",
"logging",
",",
"level",
")",
"except",
"AttributeError",
":",
"raise",
"SystemExit"... | Initialise basic logging facilities | [
"Initialise",
"basic",
"logging",
"facilities"
] | 264138de4382d1c9b53fabcbc6660e10b33a914d | https://github.com/MatterMiners/cobald/blob/264138de4382d1c9b53fabcbc6660e10b33a914d/cobald/daemon/core/logger.py#L16-L30 | train |
Karaage-Cluster/python-tldap | tldap/dn.py | escape_dn_chars | def escape_dn_chars(s):
"""
Escape all DN special characters found in s
with a back-slash (see RFC 4514, section 2.4)
"""
if s:
assert isinstance(s, six.string_types)
s = s.replace('\\', '\\\\')
s = s.replace(',', '\\,')
s = s.replace('+', '\\+')
s = s.replace... | python | def escape_dn_chars(s):
"""
Escape all DN special characters found in s
with a back-slash (see RFC 4514, section 2.4)
"""
if s:
assert isinstance(s, six.string_types)
s = s.replace('\\', '\\\\')
s = s.replace(',', '\\,')
s = s.replace('+', '\\+')
s = s.replace... | [
"def",
"escape_dn_chars",
"(",
"s",
")",
":",
"if",
"s",
":",
"assert",
"isinstance",
"(",
"s",
",",
"six",
".",
"string_types",
")",
"s",
"=",
"s",
".",
"replace",
"(",
"'\\\\'",
",",
"'\\\\\\\\'",
")",
"s",
"=",
"s",
".",
"replace",
"(",
"','",
... | Escape all DN special characters found in s
with a back-slash (see RFC 4514, section 2.4) | [
"Escape",
"all",
"DN",
"special",
"characters",
"found",
"in",
"s",
"with",
"a",
"back",
"-",
"slash",
"(",
"see",
"RFC",
"4514",
"section",
"2",
".",
"4",
")"
] | 61f1af74a3648cb6491e7eeb1ee2eb395d67bf59 | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/dn.py#L9-L29 | train |
Karaage-Cluster/python-tldap | tldap/dn.py | str2dn | def str2dn(dn, flags=0):
"""
This function takes a DN as string as parameter and returns
a decomposed DN. It's the inverse to dn2str().
flags describes the format of the dn
See also the OpenLDAP man-page ldap_str2dn(3)
"""
# if python2, we need unicode string
if not isinstance(dn, six... | python | def str2dn(dn, flags=0):
"""
This function takes a DN as string as parameter and returns
a decomposed DN. It's the inverse to dn2str().
flags describes the format of the dn
See also the OpenLDAP man-page ldap_str2dn(3)
"""
# if python2, we need unicode string
if not isinstance(dn, six... | [
"def",
"str2dn",
"(",
"dn",
",",
"flags",
"=",
"0",
")",
":",
"# if python2, we need unicode string",
"if",
"not",
"isinstance",
"(",
"dn",
",",
"six",
".",
"text_type",
")",
":",
"dn",
"=",
"dn",
".",
"decode",
"(",
"\"utf_8\"",
")",
"assert",
"flags",
... | This function takes a DN as string as parameter and returns
a decomposed DN. It's the inverse to dn2str().
flags describes the format of the dn
See also the OpenLDAP man-page ldap_str2dn(3) | [
"This",
"function",
"takes",
"a",
"DN",
"as",
"string",
"as",
"parameter",
"and",
"returns",
"a",
"decomposed",
"DN",
".",
"It",
"s",
"the",
"inverse",
"to",
"dn2str",
"()",
"."
] | 61f1af74a3648cb6491e7eeb1ee2eb395d67bf59 | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/dn.py#L510-L530 | train |
Karaage-Cluster/python-tldap | tldap/dn.py | dn2str | def dn2str(dn):
"""
This function takes a decomposed DN as parameter and returns
a single string. It's the inverse to str2dn() but will always
return a DN in LDAPv3 format compliant to RFC 4514.
"""
for rdn in dn:
for atype, avalue, dummy in rdn:
assert isinstance(atype, six.... | python | def dn2str(dn):
"""
This function takes a decomposed DN as parameter and returns
a single string. It's the inverse to str2dn() but will always
return a DN in LDAPv3 format compliant to RFC 4514.
"""
for rdn in dn:
for atype, avalue, dummy in rdn:
assert isinstance(atype, six.... | [
"def",
"dn2str",
"(",
"dn",
")",
":",
"for",
"rdn",
"in",
"dn",
":",
"for",
"atype",
",",
"avalue",
",",
"dummy",
"in",
"rdn",
":",
"assert",
"isinstance",
"(",
"atype",
",",
"six",
".",
"string_types",
")",
"assert",
"isinstance",
"(",
"avalue",
","... | This function takes a decomposed DN as parameter and returns
a single string. It's the inverse to str2dn() but will always
return a DN in LDAPv3 format compliant to RFC 4514. | [
"This",
"function",
"takes",
"a",
"decomposed",
"DN",
"as",
"parameter",
"and",
"returns",
"a",
"single",
"string",
".",
"It",
"s",
"the",
"inverse",
"to",
"str2dn",
"()",
"but",
"will",
"always",
"return",
"a",
"DN",
"in",
"LDAPv3",
"format",
"compliant",... | 61f1af74a3648cb6491e7eeb1ee2eb395d67bf59 | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/dn.py#L533-L550 | train |
Karaage-Cluster/python-tldap | tldap/dn.py | explode_dn | def explode_dn(dn, notypes=0, flags=0):
"""
explode_dn(dn [, notypes=0]) -> list
This function takes a DN and breaks it up into its component parts.
The notypes parameter is used to specify that only the component's
attribute values be returned and not the attribute types.
"""
if not dn:
... | python | def explode_dn(dn, notypes=0, flags=0):
"""
explode_dn(dn [, notypes=0]) -> list
This function takes a DN and breaks it up into its component parts.
The notypes parameter is used to specify that only the component's
attribute values be returned and not the attribute types.
"""
if not dn:
... | [
"def",
"explode_dn",
"(",
"dn",
",",
"notypes",
"=",
"0",
",",
"flags",
"=",
"0",
")",
":",
"if",
"not",
"dn",
":",
"return",
"[",
"]",
"dn_decomp",
"=",
"str2dn",
"(",
"dn",
",",
"flags",
")",
"rdn_list",
"=",
"[",
"]",
"for",
"rdn",
"in",
"dn... | explode_dn(dn [, notypes=0]) -> list
This function takes a DN and breaks it up into its component parts.
The notypes parameter is used to specify that only the component's
attribute values be returned and not the attribute types. | [
"explode_dn",
"(",
"dn",
"[",
"notypes",
"=",
"0",
"]",
")",
"-",
">",
"list"
] | 61f1af74a3648cb6491e7eeb1ee2eb395d67bf59 | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/dn.py#L553-L576 | train |
Karaage-Cluster/python-tldap | tldap/dn.py | explode_rdn | def explode_rdn(rdn, notypes=0, flags=0):
"""
explode_rdn(rdn [, notypes=0]) -> list
This function takes a RDN and breaks it up into its component parts
if it is a multi-valued RDN.
The notypes parameter is used to specify that only the component's
attribute values be returned and not the attri... | python | def explode_rdn(rdn, notypes=0, flags=0):
"""
explode_rdn(rdn [, notypes=0]) -> list
This function takes a RDN and breaks it up into its component parts
if it is a multi-valued RDN.
The notypes parameter is used to specify that only the component's
attribute values be returned and not the attri... | [
"def",
"explode_rdn",
"(",
"rdn",
",",
"notypes",
"=",
"0",
",",
"flags",
"=",
"0",
")",
":",
"if",
"not",
"rdn",
":",
"return",
"[",
"]",
"rdn_decomp",
"=",
"str2dn",
"(",
"rdn",
",",
"flags",
")",
"[",
"0",
"]",
"if",
"notypes",
":",
"return",
... | explode_rdn(rdn [, notypes=0]) -> list
This function takes a RDN and breaks it up into its component parts
if it is a multi-valued RDN.
The notypes parameter is used to specify that only the component's
attribute values be returned and not the attribute types. | [
"explode_rdn",
"(",
"rdn",
"[",
"notypes",
"=",
"0",
"]",
")",
"-",
">",
"list"
] | 61f1af74a3648cb6491e7eeb1ee2eb395d67bf59 | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/dn.py#L579-L595 | train |
quantmind/agile-toolkit | agiletoolkit/github/labels.py | labels | def labels(ctx):
"""Crate or update labels in github
"""
config = ctx.obj['agile']
repos = config.get('repositories')
labels = config.get('labels')
if not isinstance(repos, list):
raise CommandError(
'You need to specify the "repos" list in the config'
)
if not is... | python | def labels(ctx):
"""Crate or update labels in github
"""
config = ctx.obj['agile']
repos = config.get('repositories')
labels = config.get('labels')
if not isinstance(repos, list):
raise CommandError(
'You need to specify the "repos" list in the config'
)
if not is... | [
"def",
"labels",
"(",
"ctx",
")",
":",
"config",
"=",
"ctx",
".",
"obj",
"[",
"'agile'",
"]",
"repos",
"=",
"config",
".",
"get",
"(",
"'repositories'",
")",
"labels",
"=",
"config",
".",
"get",
"(",
"'labels'",
")",
"if",
"not",
"isinstance",
"(",
... | Crate or update labels in github | [
"Crate",
"or",
"update",
"labels",
"in",
"github"
] | 96028e36a842c57b171907c20583a60d1045fec1 | https://github.com/quantmind/agile-toolkit/blob/96028e36a842c57b171907c20583a60d1045fec1/agiletoolkit/github/labels.py#L9-L30 | train |
fredrike/pypoint | pypoint/__init__.py | PointSession.get_access_token | def get_access_token(self, code):
"""Get new access token."""
try:
self._token = super().fetch_token(
MINUT_TOKEN_URL,
client_id=self._client_id,
client_secret=self._client_secret,
code=code,
)
# except Excep... | python | def get_access_token(self, code):
"""Get new access token."""
try:
self._token = super().fetch_token(
MINUT_TOKEN_URL,
client_id=self._client_id,
client_secret=self._client_secret,
code=code,
)
# except Excep... | [
"def",
"get_access_token",
"(",
"self",
",",
"code",
")",
":",
"try",
":",
"self",
".",
"_token",
"=",
"super",
"(",
")",
".",
"fetch_token",
"(",
"MINUT_TOKEN_URL",
",",
"client_id",
"=",
"self",
".",
"_client_id",
",",
"client_secret",
"=",
"self",
"."... | Get new access token. | [
"Get",
"new",
"access",
"token",
"."
] | b5c9a701d2b7e24d796aa7f8c410360b61d8ec8a | https://github.com/fredrike/pypoint/blob/b5c9a701d2b7e24d796aa7f8c410360b61d8ec8a/pypoint/__init__.py#L76-L88 | train |
fredrike/pypoint | pypoint/__init__.py | PointSession._request | def _request(self, url, request_type='GET', **params):
"""Send a request to the Minut Point API."""
try:
_LOGGER.debug('Request %s %s', url, params)
response = self.request(
request_type, url, timeout=TIMEOUT.seconds, **params)
response.raise_for_statu... | python | def _request(self, url, request_type='GET', **params):
"""Send a request to the Minut Point API."""
try:
_LOGGER.debug('Request %s %s', url, params)
response = self.request(
request_type, url, timeout=TIMEOUT.seconds, **params)
response.raise_for_statu... | [
"def",
"_request",
"(",
"self",
",",
"url",
",",
"request_type",
"=",
"'GET'",
",",
"*",
"*",
"params",
")",
":",
"try",
":",
"_LOGGER",
".",
"debug",
"(",
"'Request %s %s'",
",",
"url",
",",
"params",
")",
"response",
"=",
"self",
".",
"request",
"(... | Send a request to the Minut Point API. | [
"Send",
"a",
"request",
"to",
"the",
"Minut",
"Point",
"API",
"."
] | b5c9a701d2b7e24d796aa7f8c410360b61d8ec8a | https://github.com/fredrike/pypoint/blob/b5c9a701d2b7e24d796aa7f8c410360b61d8ec8a/pypoint/__init__.py#L90-L104 | train |
fredrike/pypoint | pypoint/__init__.py | PointSession._request_devices | def _request_devices(self, url, _type):
"""Request list of devices."""
res = self._request(url)
return res.get(_type) if res else {} | python | def _request_devices(self, url, _type):
"""Request list of devices."""
res = self._request(url)
return res.get(_type) if res else {} | [
"def",
"_request_devices",
"(",
"self",
",",
"url",
",",
"_type",
")",
":",
"res",
"=",
"self",
".",
"_request",
"(",
"url",
")",
"return",
"res",
".",
"get",
"(",
"_type",
")",
"if",
"res",
"else",
"{",
"}"
] | Request list of devices. | [
"Request",
"list",
"of",
"devices",
"."
] | b5c9a701d2b7e24d796aa7f8c410360b61d8ec8a | https://github.com/fredrike/pypoint/blob/b5c9a701d2b7e24d796aa7f8c410360b61d8ec8a/pypoint/__init__.py#L106-L109 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.