repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
davidblaisonneau-orange/foreman | foreman/item.py | ForemanItem.getParam | def getParam(self, name=None):
""" Function getParam
Return a dict of parameters or a parameter value
@param key: The parameter name
@return RETURN: dict of parameters or a parameter value
"""
if 'parameters' in self.keys():
l = {x['name']: x['value'] for x i... | python | def getParam(self, name=None):
""" Function getParam
Return a dict of parameters or a parameter value
@param key: The parameter name
@return RETURN: dict of parameters or a parameter value
"""
if 'parameters' in self.keys():
l = {x['name']: x['value'] for x i... | [
"def",
"getParam",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"if",
"'parameters'",
"in",
"self",
".",
"keys",
"(",
")",
":",
"l",
"=",
"{",
"x",
"[",
"'name'",
"]",
":",
"x",
"[",
"'value'",
"]",
"for",
"x",
"in",
"self",
"[",
"'paramete... | Function getParam
Return a dict of parameters or a parameter value
@param key: The parameter name
@return RETURN: dict of parameters or a parameter value | [
"Function",
"getParam",
"Return",
"a",
"dict",
"of",
"parameters",
"or",
"a",
"parameter",
"value"
] | train | https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/item.py#L91-L106 |
davidblaisonneau-orange/foreman | foreman/item.py | ForemanItem.checkAndCreateClasses | def checkAndCreateClasses(self, classes):
""" Function checkAndCreateClasses
Check and add puppet class
@param classes: The classes ids list
@return RETURN: boolean
"""
actual_classes = self['puppetclasses'].keys()
for i in classes:
if i not in actual... | python | def checkAndCreateClasses(self, classes):
""" Function checkAndCreateClasses
Check and add puppet class
@param classes: The classes ids list
@return RETURN: boolean
"""
actual_classes = self['puppetclasses'].keys()
for i in classes:
if i not in actual... | [
"def",
"checkAndCreateClasses",
"(",
"self",
",",
"classes",
")",
":",
"actual_classes",
"=",
"self",
"[",
"'puppetclasses'",
"]",
".",
"keys",
"(",
")",
"for",
"i",
"in",
"classes",
":",
"if",
"i",
"not",
"in",
"actual_classes",
":",
"self",
"[",
"'pupp... | Function checkAndCreateClasses
Check and add puppet class
@param classes: The classes ids list
@return RETURN: boolean | [
"Function",
"checkAndCreateClasses",
"Check",
"and",
"add",
"puppet",
"class"
] | train | https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/item.py#L108-L120 |
davidblaisonneau-orange/foreman | foreman/item.py | ForemanItem.checkAndCreateParams | def checkAndCreateParams(self, params):
""" Function checkAndCreateParams
Check and add global parameters
@param key: The parameter name
@param params: The params dict
@return RETURN: boolean
"""
actual_params = self['parameters'].keys()
for k, v in param... | python | def checkAndCreateParams(self, params):
""" Function checkAndCreateParams
Check and add global parameters
@param key: The parameter name
@param params: The params dict
@return RETURN: boolean
"""
actual_params = self['parameters'].keys()
for k, v in param... | [
"def",
"checkAndCreateParams",
"(",
"self",
",",
"params",
")",
":",
"actual_params",
"=",
"self",
"[",
"'parameters'",
"]",
".",
"keys",
"(",
")",
"for",
"k",
",",
"v",
"in",
"params",
".",
"items",
"(",
")",
":",
"if",
"k",
"not",
"in",
"actual_par... | Function checkAndCreateParams
Check and add global parameters
@param key: The parameter name
@param params: The params dict
@return RETURN: boolean | [
"Function",
"checkAndCreateParams",
"Check",
"and",
"add",
"global",
"parameters"
] | train | https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/item.py#L122-L135 |
mozilla-services/amo2kinto | amo2kinto/compare.py | version_dict | def version_dict(version):
"""Turn a version string into a dict with major/minor/... info."""
match = version_re.match(str(version) or '')
letters = 'alpha pre'.split()
numbers = 'major minor1 minor2 minor3 alpha_ver pre_ver'.split()
if match:
d = match.groupdict()
for letter in lett... | python | def version_dict(version):
"""Turn a version string into a dict with major/minor/... info."""
match = version_re.match(str(version) or '')
letters = 'alpha pre'.split()
numbers = 'major minor1 minor2 minor3 alpha_ver pre_ver'.split()
if match:
d = match.groupdict()
for letter in lett... | [
"def",
"version_dict",
"(",
"version",
")",
":",
"match",
"=",
"version_re",
".",
"match",
"(",
"str",
"(",
"version",
")",
"or",
"''",
")",
"letters",
"=",
"'alpha pre'",
".",
"split",
"(",
")",
"numbers",
"=",
"'major minor1 minor2 minor3 alpha_ver pre_ver'"... | Turn a version string into a dict with major/minor/... info. | [
"Turn",
"a",
"version",
"string",
"into",
"a",
"dict",
"with",
"major",
"/",
"minor",
"/",
"...",
"info",
"."
] | train | https://github.com/mozilla-services/amo2kinto/blob/1ec40647e77cf89badbea4a58d328243daed49a9/amo2kinto/compare.py#L21-L38 |
mozilla-services/amo2kinto | amo2kinto/synchronize.py | get_diff | def get_diff(source, dest):
"""Get the diff between two records list in this order:
- to_create
- to_delete
"""
# First build a dict from the lists, with the ID as the key.
source_dict = {record['id']: record for record in source}
dest_dict = {record['id']: record for record in dest}... | python | def get_diff(source, dest):
"""Get the diff between two records list in this order:
- to_create
- to_delete
"""
# First build a dict from the lists, with the ID as the key.
source_dict = {record['id']: record for record in source}
dest_dict = {record['id']: record for record in dest}... | [
"def",
"get_diff",
"(",
"source",
",",
"dest",
")",
":",
"# First build a dict from the lists, with the ID as the key.",
"source_dict",
"=",
"{",
"record",
"[",
"'id'",
"]",
":",
"record",
"for",
"record",
"in",
"source",
"}",
"dest_dict",
"=",
"{",
"record",
"[... | Get the diff between two records list in this order:
- to_create
- to_delete | [
"Get",
"the",
"diff",
"between",
"two",
"records",
"list",
"in",
"this",
"order",
":",
"-",
"to_create",
"-",
"to_delete"
] | train | https://github.com/mozilla-services/amo2kinto/blob/1ec40647e77cf89badbea4a58d328243daed49a9/amo2kinto/synchronize.py#L16-L45 |
developersociety/django-glitter | glitter/publisher/forms.py | object_version_choices | def object_version_choices(obj):
"""
Return a list of form choices for versions of this object which can be published.
"""
choices = BLANK_CHOICE_DASH + [(PublishAction.UNPUBLISH_CHOICE, 'Unpublish current version')]
# When creating a new object in the Django admin - obj will be None
if obj is ... | python | def object_version_choices(obj):
"""
Return a list of form choices for versions of this object which can be published.
"""
choices = BLANK_CHOICE_DASH + [(PublishAction.UNPUBLISH_CHOICE, 'Unpublish current version')]
# When creating a new object in the Django admin - obj will be None
if obj is ... | [
"def",
"object_version_choices",
"(",
"obj",
")",
":",
"choices",
"=",
"BLANK_CHOICE_DASH",
"+",
"[",
"(",
"PublishAction",
".",
"UNPUBLISH_CHOICE",
",",
"'Unpublish current version'",
")",
"]",
"# When creating a new object in the Django admin - obj will be None",
"if",
"o... | Return a list of form choices for versions of this object which can be published. | [
"Return",
"a",
"list",
"of",
"form",
"choices",
"for",
"versions",
"of",
"this",
"object",
"which",
"can",
"be",
"published",
"."
] | train | https://github.com/developersociety/django-glitter/blob/2c0280ec83afee80deee94ee3934fc54239c2e87/glitter/publisher/forms.py#L9-L27 |
quantmind/agile-toolkit | agiletoolkit/manager.py | Manager.manifest | def manifest(self, values, *paths, filename: str = None) -> Dict:
"""Load a manifest file and apply template values
"""
filename = filename or self.filename(*paths)
with open(filename, 'r') as fp:
template = Template(fp.read())
return yaml.load(template.render(values)... | python | def manifest(self, values, *paths, filename: str = None) -> Dict:
"""Load a manifest file and apply template values
"""
filename = filename or self.filename(*paths)
with open(filename, 'r') as fp:
template = Template(fp.read())
return yaml.load(template.render(values)... | [
"def",
"manifest",
"(",
"self",
",",
"values",
",",
"*",
"paths",
",",
"filename",
":",
"str",
"=",
"None",
")",
"->",
"Dict",
":",
"filename",
"=",
"filename",
"or",
"self",
".",
"filename",
"(",
"*",
"paths",
")",
"with",
"open",
"(",
"filename",
... | Load a manifest file and apply template values | [
"Load",
"a",
"manifest",
"file",
"and",
"apply",
"template",
"values"
] | train | https://github.com/quantmind/agile-toolkit/blob/96028e36a842c57b171907c20583a60d1045fec1/agiletoolkit/manager.py#L48-L54 |
xenadevel/PyXenaManager | xenamanager/xena_stream.py | XenaStream.set_packet_headers | def set_packet_headers(self, headers):
""" Set packet header.
The method will try to set ps_headerprotocol to inform the Xena GUI and tester how to interpret the packet
header byte sequence specified with PS_PACKETHEADER.
This is mainly for information purposes, and the stream will tran... | python | def set_packet_headers(self, headers):
""" Set packet header.
The method will try to set ps_headerprotocol to inform the Xena GUI and tester how to interpret the packet
header byte sequence specified with PS_PACKETHEADER.
This is mainly for information purposes, and the stream will tran... | [
"def",
"set_packet_headers",
"(",
"self",
",",
"headers",
")",
":",
"bin_headers",
"=",
"'0x'",
"+",
"binascii",
".",
"hexlify",
"(",
"headers",
".",
"bin",
"(",
")",
")",
".",
"decode",
"(",
"'utf-8'",
")",
"self",
".",
"set_attributes",
"(",
"ps_packet... | Set packet header.
The method will try to set ps_headerprotocol to inform the Xena GUI and tester how to interpret the packet
header byte sequence specified with PS_PACKETHEADER.
This is mainly for information purposes, and the stream will transmit the packet header bytes even if no
pro... | [
"Set",
"packet",
"header",
"."
] | train | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/xena_stream.py#L80-L107 |
xenadevel/PyXenaManager | xenamanager/xena_stream.py | XenaStream.add_modifier | def add_modifier(self, m_type=XenaModifierType.standard, **kwargs):
""" Add modifier.
:param m_type: modifier type - standard or extended.
:type: xenamanager.xena_stram.ModifierType
:return: newly created modifier.
:rtype: xenamanager.xena_stream.XenaModifier
"""
... | python | def add_modifier(self, m_type=XenaModifierType.standard, **kwargs):
""" Add modifier.
:param m_type: modifier type - standard or extended.
:type: xenamanager.xena_stram.ModifierType
:return: newly created modifier.
:rtype: xenamanager.xena_stream.XenaModifier
"""
... | [
"def",
"add_modifier",
"(",
"self",
",",
"m_type",
"=",
"XenaModifierType",
".",
"standard",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"m_type",
"==",
"XenaModifierType",
".",
"standard",
":",
"modifier",
"=",
"XenaModifier",
"(",
"self",
",",
"index",
"=",... | Add modifier.
:param m_type: modifier type - standard or extended.
:type: xenamanager.xena_stram.ModifierType
:return: newly created modifier.
:rtype: xenamanager.xena_stream.XenaModifier | [
"Add",
"modifier",
"."
] | train | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/xena_stream.py#L113-L129 |
xenadevel/PyXenaManager | xenamanager/xena_stream.py | XenaStream.remove_modifier | def remove_modifier(self, index, m_type=XenaModifierType.standard):
""" Remove modifier.
:param m_type: modifier type - standard or extended.
:param index: index of modifier to remove.
"""
if m_type == XenaModifierType.standard:
current_modifiers = OrderedDict(self.... | python | def remove_modifier(self, index, m_type=XenaModifierType.standard):
""" Remove modifier.
:param m_type: modifier type - standard or extended.
:param index: index of modifier to remove.
"""
if m_type == XenaModifierType.standard:
current_modifiers = OrderedDict(self.... | [
"def",
"remove_modifier",
"(",
"self",
",",
"index",
",",
"m_type",
"=",
"XenaModifierType",
".",
"standard",
")",
":",
"if",
"m_type",
"==",
"XenaModifierType",
".",
"standard",
":",
"current_modifiers",
"=",
"OrderedDict",
"(",
"self",
".",
"modifiers",
")",... | Remove modifier.
:param m_type: modifier type - standard or extended.
:param index: index of modifier to remove. | [
"Remove",
"modifier",
"."
] | train | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/xena_stream.py#L131-L155 |
xenadevel/PyXenaManager | xenamanager/xena_stream.py | XenaStream.modifiers | def modifiers(self):
"""
:return: dictionary {index: object} of standard modifiers.
"""
if not self.get_objects_by_type('modifier'):
for index in range(int(self.get_attribute('ps_modifiercount'))):
XenaModifier(self, index='{}/{}'.format(self.index, index)).ge... | python | def modifiers(self):
"""
:return: dictionary {index: object} of standard modifiers.
"""
if not self.get_objects_by_type('modifier'):
for index in range(int(self.get_attribute('ps_modifiercount'))):
XenaModifier(self, index='{}/{}'.format(self.index, index)).ge... | [
"def",
"modifiers",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"get_objects_by_type",
"(",
"'modifier'",
")",
":",
"for",
"index",
"in",
"range",
"(",
"int",
"(",
"self",
".",
"get_attribute",
"(",
"'ps_modifiercount'",
")",
")",
")",
":",
"XenaMod... | :return: dictionary {index: object} of standard modifiers. | [
":",
"return",
":",
"dictionary",
"{",
"index",
":",
"object",
"}",
"of",
"standard",
"modifiers",
"."
] | train | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/xena_stream.py#L162-L169 |
xenadevel/PyXenaManager | xenamanager/xena_stream.py | XenaStream.xmodifiers | def xmodifiers(self):
"""
:return: dictionary {index: object} of extended modifiers.
"""
if not self.get_objects_by_type('xmodifier'):
try:
for index in range(int(self.get_attribute('ps_modifierextcount'))):
XenaXModifier(self, index='{}/{}... | python | def xmodifiers(self):
"""
:return: dictionary {index: object} of extended modifiers.
"""
if not self.get_objects_by_type('xmodifier'):
try:
for index in range(int(self.get_attribute('ps_modifierextcount'))):
XenaXModifier(self, index='{}/{}... | [
"def",
"xmodifiers",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"get_objects_by_type",
"(",
"'xmodifier'",
")",
":",
"try",
":",
"for",
"index",
"in",
"range",
"(",
"int",
"(",
"self",
".",
"get_attribute",
"(",
"'ps_modifierextcount'",
")",
")",
"... | :return: dictionary {index: object} of extended modifiers. | [
":",
"return",
":",
"dictionary",
"{",
"index",
":",
"object",
"}",
"of",
"extended",
"modifiers",
"."
] | train | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/xena_stream.py#L172-L182 |
astroduff/commah | commah/cosmology_list.py | DRAGONS | def DRAGONS(flat=False, extras=True):
"""DRAGONS cosmology assumes WMAP7 + BAO + H_0 mean from
Komatsu et al. (2011) ApJS 192 18K (arxiv:1001.4538v1)
Parameters
----------
flat: boolean
If True, sets omega_lambda_0 = 1 - omega_M_0 to ensure omega_k_0
= 0 exactly. Also sets omega_k_0 =... | python | def DRAGONS(flat=False, extras=True):
"""DRAGONS cosmology assumes WMAP7 + BAO + H_0 mean from
Komatsu et al. (2011) ApJS 192 18K (arxiv:1001.4538v1)
Parameters
----------
flat: boolean
If True, sets omega_lambda_0 = 1 - omega_M_0 to ensure omega_k_0
= 0 exactly. Also sets omega_k_0 =... | [
"def",
"DRAGONS",
"(",
"flat",
"=",
"False",
",",
"extras",
"=",
"True",
")",
":",
"omega_c_0",
"=",
"0.2292",
"omega_b_0",
"=",
"0.0458",
"cosmo",
"=",
"{",
"'omega_b_0'",
":",
"omega_b_0",
",",
"'omega_M_0'",
":",
"omega_b_0",
"+",
"omega_c_0",
",",
"'... | DRAGONS cosmology assumes WMAP7 + BAO + H_0 mean from
Komatsu et al. (2011) ApJS 192 18K (arxiv:1001.4538v1)
Parameters
----------
flat: boolean
If True, sets omega_lambda_0 = 1 - omega_M_0 to ensure omega_k_0
= 0 exactly. Also sets omega_k_0 = 0 explicitly.
extras: boolean
If... | [
"DRAGONS",
"cosmology",
"assumes",
"WMAP7",
"+",
"BAO",
"+",
"H_0",
"mean",
"from",
"Komatsu",
"et",
"al",
".",
"(",
"2011",
")",
"ApJS",
"192",
"18K",
"(",
"arxiv",
":",
"1001",
".",
"4538v1",
")"
] | train | https://github.com/astroduff/commah/blob/3ec70338c5123a053c79ddcf2cb3beac26bc9137/commah/cosmology_list.py#L20-L55 |
astroduff/commah | commah/cosmology_list.py | Planck_2015 | def Planck_2015(flat=False, extras=True):
"""Planck 2015 XII: Cosmological parameters Table 4
column Planck TT, TE, EE + lowP + lensing + ext
from Ade et al. (2015) A&A in press (arxiv:1502.01589v1)
Parameters
----------
flat: boolean
If True, sets omega_lambda_0 = 1 - omega_M_0 to ensu... | python | def Planck_2015(flat=False, extras=True):
"""Planck 2015 XII: Cosmological parameters Table 4
column Planck TT, TE, EE + lowP + lensing + ext
from Ade et al. (2015) A&A in press (arxiv:1502.01589v1)
Parameters
----------
flat: boolean
If True, sets omega_lambda_0 = 1 - omega_M_0 to ensu... | [
"def",
"Planck_2015",
"(",
"flat",
"=",
"False",
",",
"extras",
"=",
"True",
")",
":",
"omega_b_0",
"=",
"0.02230",
"/",
"(",
"0.6774",
"**",
"2",
")",
"cosmo",
"=",
"{",
"'omega_b_0'",
":",
"omega_b_0",
",",
"'omega_M_0'",
":",
"0.3089",
",",
"'omega_... | Planck 2015 XII: Cosmological parameters Table 4
column Planck TT, TE, EE + lowP + lensing + ext
from Ade et al. (2015) A&A in press (arxiv:1502.01589v1)
Parameters
----------
flat: boolean
If True, sets omega_lambda_0 = 1 - omega_M_0 to ensure omega_k_0
= 0 exactly. Also sets omega_k... | [
"Planck",
"2015",
"XII",
":",
"Cosmological",
"parameters",
"Table",
"4",
"column",
"Planck",
"TT",
"TE",
"EE",
"+",
"lowP",
"+",
"lensing",
"+",
"ext",
"from",
"Ade",
"et",
"al",
".",
"(",
"2015",
")",
"A&A",
"in",
"press",
"(",
"arxiv",
":",
"1502"... | train | https://github.com/astroduff/commah/blob/3ec70338c5123a053c79ddcf2cb3beac26bc9137/commah/cosmology_list.py#L512-L547 |
Karaage-Cluster/python-tldap | tldap/backend/no_transactions.py | LDAPwrapper.add | def add(self, dn: str, mod_list: dict) -> None:
"""
Add a DN to the LDAP database; See ldap module. Doesn't return a result
if transactions enabled.
"""
return self._do_with_retry(lambda obj: obj.add_s(dn, mod_list)) | python | def add(self, dn: str, mod_list: dict) -> None:
"""
Add a DN to the LDAP database; See ldap module. Doesn't return a result
if transactions enabled.
"""
return self._do_with_retry(lambda obj: obj.add_s(dn, mod_list)) | [
"def",
"add",
"(",
"self",
",",
"dn",
":",
"str",
",",
"mod_list",
":",
"dict",
")",
"->",
"None",
":",
"return",
"self",
".",
"_do_with_retry",
"(",
"lambda",
"obj",
":",
"obj",
".",
"add_s",
"(",
"dn",
",",
"mod_list",
")",
")"
] | Add a DN to the LDAP database; See ldap module. Doesn't return a result
if transactions enabled. | [
"Add",
"a",
"DN",
"to",
"the",
"LDAP",
"database",
";",
"See",
"ldap",
"module",
".",
"Doesn",
"t",
"return",
"a",
"result",
"if",
"transactions",
"enabled",
"."
] | train | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/backend/no_transactions.py#L85-L91 |
Karaage-Cluster/python-tldap | tldap/backend/no_transactions.py | LDAPwrapper.modify | def modify(self, dn: str, mod_list: dict) -> None:
"""
Modify a DN in the LDAP database; See ldap module. Doesn't return a
result if transactions enabled.
"""
return self._do_with_retry(lambda obj: obj.modify_s(dn, mod_list)) | python | def modify(self, dn: str, mod_list: dict) -> None:
"""
Modify a DN in the LDAP database; See ldap module. Doesn't return a
result if transactions enabled.
"""
return self._do_with_retry(lambda obj: obj.modify_s(dn, mod_list)) | [
"def",
"modify",
"(",
"self",
",",
"dn",
":",
"str",
",",
"mod_list",
":",
"dict",
")",
"->",
"None",
":",
"return",
"self",
".",
"_do_with_retry",
"(",
"lambda",
"obj",
":",
"obj",
".",
"modify_s",
"(",
"dn",
",",
"mod_list",
")",
")"
] | Modify a DN in the LDAP database; See ldap module. Doesn't return a
result if transactions enabled. | [
"Modify",
"a",
"DN",
"in",
"the",
"LDAP",
"database",
";",
"See",
"ldap",
"module",
".",
"Doesn",
"t",
"return",
"a",
"result",
"if",
"transactions",
"enabled",
"."
] | train | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/backend/no_transactions.py#L93-L99 |
Karaage-Cluster/python-tldap | tldap/backend/no_transactions.py | LDAPwrapper.delete | def delete(self, dn: str) -> None:
"""
delete a dn in the ldap database; see ldap module. doesn't return a
result if transactions enabled.
"""
return self._do_with_retry(lambda obj: obj.delete_s(dn)) | python | def delete(self, dn: str) -> None:
"""
delete a dn in the ldap database; see ldap module. doesn't return a
result if transactions enabled.
"""
return self._do_with_retry(lambda obj: obj.delete_s(dn)) | [
"def",
"delete",
"(",
"self",
",",
"dn",
":",
"str",
")",
"->",
"None",
":",
"return",
"self",
".",
"_do_with_retry",
"(",
"lambda",
"obj",
":",
"obj",
".",
"delete_s",
"(",
"dn",
")",
")"
] | delete a dn in the ldap database; see ldap module. doesn't return a
result if transactions enabled. | [
"delete",
"a",
"dn",
"in",
"the",
"ldap",
"database",
";",
"see",
"ldap",
"module",
".",
"doesn",
"t",
"return",
"a",
"result",
"if",
"transactions",
"enabled",
"."
] | train | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/backend/no_transactions.py#L109-L115 |
Karaage-Cluster/python-tldap | tldap/backend/no_transactions.py | LDAPwrapper.rename | def rename(self, dn: str, new_rdn: str, new_base_dn: Optional[str] = None) -> None:
"""
rename a dn in the ldap database; see ldap module. doesn't return a
result if transactions enabled.
"""
return self._do_with_retry(
lambda obj: obj.rename_s(dn, new_rdn, new_base_... | python | def rename(self, dn: str, new_rdn: str, new_base_dn: Optional[str] = None) -> None:
"""
rename a dn in the ldap database; see ldap module. doesn't return a
result if transactions enabled.
"""
return self._do_with_retry(
lambda obj: obj.rename_s(dn, new_rdn, new_base_... | [
"def",
"rename",
"(",
"self",
",",
"dn",
":",
"str",
",",
"new_rdn",
":",
"str",
",",
"new_base_dn",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"None",
":",
"return",
"self",
".",
"_do_with_retry",
"(",
"lambda",
"obj",
":",
"obj",
"... | rename a dn in the ldap database; see ldap module. doesn't return a
result if transactions enabled. | [
"rename",
"a",
"dn",
"in",
"the",
"ldap",
"database",
";",
"see",
"ldap",
"module",
".",
"doesn",
"t",
"return",
"a",
"result",
"if",
"transactions",
"enabled",
"."
] | train | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/backend/no_transactions.py#L117-L124 |
developersociety/django-glitter | glitter/layouts.py | PageLayoutBase.get_column_name | def get_column_name(self, column_name):
""" Get a column for given column name from META api. """
name = pretty_name(column_name)
if column_name in self._meta.columns:
column_cls = self._meta.columns[column_name]
if column_cls.verbose_name:
name = column_c... | python | def get_column_name(self, column_name):
""" Get a column for given column name from META api. """
name = pretty_name(column_name)
if column_name in self._meta.columns:
column_cls = self._meta.columns[column_name]
if column_cls.verbose_name:
name = column_c... | [
"def",
"get_column_name",
"(",
"self",
",",
"column_name",
")",
":",
"name",
"=",
"pretty_name",
"(",
"column_name",
")",
"if",
"column_name",
"in",
"self",
".",
"_meta",
".",
"columns",
":",
"column_cls",
"=",
"self",
".",
"_meta",
".",
"columns",
"[",
... | Get a column for given column name from META api. | [
"Get",
"a",
"column",
"for",
"given",
"column",
"name",
"from",
"META",
"api",
"."
] | train | https://github.com/developersociety/django-glitter/blob/2c0280ec83afee80deee94ee3934fc54239c2e87/glitter/layouts.py#L86-L93 |
quantmind/agile-toolkit | agiletoolkit/repo.py | RepoManager.version | def version(self):
"""Software version of the current repository
"""
branches = self.branches()
if self.info['branch'] == branches.sandbox:
try:
return self.software_version()
except Exception as exc:
raise utils.CommandError(
... | python | def version(self):
"""Software version of the current repository
"""
branches = self.branches()
if self.info['branch'] == branches.sandbox:
try:
return self.software_version()
except Exception as exc:
raise utils.CommandError(
... | [
"def",
"version",
"(",
"self",
")",
":",
"branches",
"=",
"self",
".",
"branches",
"(",
")",
"if",
"self",
".",
"info",
"[",
"'branch'",
"]",
"==",
"branches",
".",
"sandbox",
":",
"try",
":",
"return",
"self",
".",
"software_version",
"(",
")",
"exc... | Software version of the current repository | [
"Software",
"version",
"of",
"the",
"current",
"repository"
] | train | https://github.com/quantmind/agile-toolkit/blob/96028e36a842c57b171907c20583a60d1045fec1/agiletoolkit/repo.py#L34-L49 |
quantmind/agile-toolkit | agiletoolkit/repo.py | RepoManager.validate_version | def validate_version(self, prefix='v'):
"""Validate version by checking if it is a valid semantic version
and its value is higher than latest github tag
"""
version = self.software_version()
repo = self.github_repo()
repo.releases.validate_tag(version, prefix)
ret... | python | def validate_version(self, prefix='v'):
"""Validate version by checking if it is a valid semantic version
and its value is higher than latest github tag
"""
version = self.software_version()
repo = self.github_repo()
repo.releases.validate_tag(version, prefix)
ret... | [
"def",
"validate_version",
"(",
"self",
",",
"prefix",
"=",
"'v'",
")",
":",
"version",
"=",
"self",
".",
"software_version",
"(",
")",
"repo",
"=",
"self",
".",
"github_repo",
"(",
")",
"repo",
".",
"releases",
".",
"validate_tag",
"(",
"version",
",",
... | Validate version by checking if it is a valid semantic version
and its value is higher than latest github tag | [
"Validate",
"version",
"by",
"checking",
"if",
"it",
"is",
"a",
"valid",
"semantic",
"version",
"and",
"its",
"value",
"is",
"higher",
"than",
"latest",
"github",
"tag"
] | train | https://github.com/quantmind/agile-toolkit/blob/96028e36a842c57b171907c20583a60d1045fec1/agiletoolkit/repo.py#L51-L58 |
quantmind/agile-toolkit | agiletoolkit/repo.py | RepoManager.skip_build | def skip_build(self):
"""Check if build should be skipped
"""
skip_msg = self.config.get('skip', '[ci skip]')
return (
os.environ.get('CODEBUILD_BUILD_SUCCEEDING') == '0' or
self.info['current_tag'] or
skip_msg in self.info['head']['message']
) | python | def skip_build(self):
"""Check if build should be skipped
"""
skip_msg = self.config.get('skip', '[ci skip]')
return (
os.environ.get('CODEBUILD_BUILD_SUCCEEDING') == '0' or
self.info['current_tag'] or
skip_msg in self.info['head']['message']
) | [
"def",
"skip_build",
"(",
"self",
")",
":",
"skip_msg",
"=",
"self",
".",
"config",
".",
"get",
"(",
"'skip'",
",",
"'[ci skip]'",
")",
"return",
"(",
"os",
".",
"environ",
".",
"get",
"(",
"'CODEBUILD_BUILD_SUCCEEDING'",
")",
"==",
"'0'",
"or",
"self",
... | Check if build should be skipped | [
"Check",
"if",
"build",
"should",
"be",
"skipped"
] | train | https://github.com/quantmind/agile-toolkit/blob/96028e36a842c57b171907c20583a60d1045fec1/agiletoolkit/repo.py#L60-L68 |
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"
] | train | https://github.com/quantmind/agile-toolkit/blob/96028e36a842c57b171907c20583a60d1045fec1/agiletoolkit/repo.py#L94-L101 |
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",
"."
] | train | https://github.com/mozilla-services/amo2kinto/blob/1ec40647e77cf89badbea4a58d328243daed49a9/amo2kinto/kinto.py#L4-L23 |
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"
] | train | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/api/xena_cli.py#L34-L43 |
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",
")",
"."
] | train | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/api/xena_cli.py#L48-L56 |
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",
"."
] | train | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/api/xena_cli.py#L58-L61 |
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",
"."
] | train | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/api/xena_cli.py#L63-L66 |
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",
"."
] | train | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/api/xena_cli.py#L68-L79 |
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",
"."
] | train | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/api/xena_cli.py#L81-L104 |
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",
"."
] | train | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/api/xena_cli.py#L106-L113 |
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",
"."
] | train | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/api/xena_cli.py#L115-L123 |
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",
"."
] | train | https://github.com/josiah-wolf-oberholtzer/uqbar/blob/eca7fefebbbee1e2ae13bf5d6baa838be66b1db6/uqbar/containers/UniqueTreeContainer.py#L128-L177 |
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",
"."
] | train | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/xena_port.py#L53-L67 |
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",
"."
] | train | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/xena_port.py#L91-L105 |
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",
"."
] | train | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/xena_port.py#L107-L116 |
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",
"."
] | train | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/xena_port.py#L118-L135 |
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",
"."
] | train | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/xena_port.py#L192-L201 |
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",
"."
] | train | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/xena_port.py#L203-L211 |
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",
"."
] | train | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/xena_port.py#L213-L221 |
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",
")"
] | train | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/xena_port.py#L228-L241 |
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",
")"
] | train | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/xena_port.py#L244-L254 |
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",
"."
] | train | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/xena_port.py#L282-L291 |
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",
"."
] | train | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/xena_port.py#L313-L354 |
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",
")"
] | train | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/xena_port.py#L361-L370 |
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"
] | train | https://github.com/MatterMiners/cobald/blob/264138de4382d1c9b53fabcbc6660e10b33a914d/cobald/controller/stepwise.py#L135-L165 |
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"
] | train | https://github.com/MatterMiners/cobald/blob/264138de4382d1c9b53fabcbc6660e10b33a914d/cobald/controller/stepwise.py#L167-L182 |
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"
] | train | https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/private/revision.py#L45-L53 |
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",
"."
] | train | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/database/__init__.py#L384-L389 |
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",
"."
] | train | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/database/__init__.py#L392-L404 |
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",
"."
] | train | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/database/__init__.py#L407-L423 |
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",
"."
] | train | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/database/__init__.py#L426-L445 |
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",
"."
] | train | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/database/__init__.py#L448-L475 |
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",
"."
] | train | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/database/__init__.py#L478-L494 |
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",
"."
] | train | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/database/__init__.py#L497-L530 |
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",
"."
] | train | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/database/__init__.py#L533-L543 |
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",
"."
] | train | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/database/__init__.py#L546-L605 |
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",
"."
] | train | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/database/__init__.py#L608-L616 |
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",
"."
] | train | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/database/__init__.py#L619-L622 |
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",
"."
] | train | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/database/__init__.py#L625-L675 |
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",
"/",
"{",
... | train | https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/provider/__init__.py#L21-L121 |
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"
] | train | https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/provider/__init__.py#L124-L150 |
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"
] | train | https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/provider/__init__.py#L153-L174 |
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"
] | train | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/modlist.py#L30-L44 |
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",
"()"
] | train | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/modlist.py#L52-L64 |
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",
"()"
] | train | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/modlist.py#L67-L147 |
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",
... | train | https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/private/platform.py#L39-L60 |
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... | train | https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/private/platform.py#L62-L72 |
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"
] | train | https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/private/platform.py#L86-L93 |
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"
] | train | https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/private/platform.py#L95-L101 |
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"
] | train | https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/private/platform.py#L103-L115 |
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",
"."
] | train | https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/private/platform.py#L119-L133 |
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",
"."
] | train | https://github.com/MainRo/cyclotron-aio/blob/4401076aafe4a72de1d3c4ad6bb7ffa648506f7e/cyclotron_aio/stop.py#L8-L40 |
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",
"."
] | train | https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/database/helpers.py#L38-L66 |
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",
"."
] | train | https://github.com/alixedi/palal/blob/325359f66ac48a9f96efea0489aec353f8a40837/palal/survey.py#L28-L31 |
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",
"."
] | train | https://github.com/alixedi/palal/blob/325359f66ac48a9f96efea0489aec353f8a40837/palal/survey.py#L105-L111 |
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",
"."
] | train | https://github.com/alixedi/palal/blob/325359f66ac48a9f96efea0489aec353f8a40837/palal/survey.py#L51-L57 |
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",
"."
] | train | https://github.com/alixedi/palal/blob/325359f66ac48a9f96efea0489aec353f8a40837/palal/survey.py#L59-L61 |
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",
"."
] | train | https://github.com/alixedi/palal/blob/325359f66ac48a9f96efea0489aec353f8a40837/palal/survey.py#L63-L76 |
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",
"."
] | train | https://github.com/alixedi/palal/blob/325359f66ac48a9f96efea0489aec353f8a40837/palal/survey.py#L78-L83 |
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",
"."
] | train | https://github.com/alixedi/palal/blob/325359f66ac48a9f96efea0489aec353f8a40837/palal/survey.py#L85-L90 |
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",
"."
] | train | https://github.com/alixedi/palal/blob/325359f66ac48a9f96efea0489aec353f8a40837/palal/survey.py#L92-L101 |
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",
"."
] | train | https://github.com/jamescooke/flake8-aaa/blob/29938b96845fe32ced4358ba66af3b3be2a37794/src/flake8_aaa/line_markers.py#L50-L69 |
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"
] | train | https://github.com/jamescooke/flake8-aaa/blob/29938b96845fe32ced4358ba66af3b3be2a37794/src/flake8_aaa/line_markers.py#L71-L80 |
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"
] | train | https://github.com/jamescooke/flake8-aaa/blob/29938b96845fe32ced4358ba66af3b3be2a37794/src/flake8_aaa/line_markers.py#L82-L91 |
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",
"."
] | train | https://github.com/jamescooke/flake8-aaa/blob/29938b96845fe32ced4358ba66af3b3be2a37794/src/flake8_aaa/line_markers.py#L93-L141 |
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",
"."
] | train | https://github.com/alixedi/palal/blob/325359f66ac48a9f96efea0489aec353f8a40837/palal/palal.py#L41-L49 |
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",
"."
] | train | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/xena_object.py#L44-L50 |
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",
"."
] | train | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/xena_object.py#L52-L54 |
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",
"."
] | train | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/xena_object.py#L56-L58 |
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"
] | train | https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/subDict.py#L47-L72 |
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__"
] | train | https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/subDict.py#L100-L114 |
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"
] | train | https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/subDict.py#L116-L124 |
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",
"."
] | train | https://github.com/josiah-wolf-oberholtzer/uqbar/blob/eca7fefebbbee1e2ae13bf5d6baa838be66b1db6/uqbar/objects.py#L87-L173 |
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",
"."
] | train | https://github.com/josiah-wolf-oberholtzer/uqbar/blob/eca7fefebbbee1e2ae13bf5d6baa838be66b1db6/uqbar/objects.py#L176-L287 |
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",
"."
] | train | https://github.com/josiah-wolf-oberholtzer/uqbar/blob/eca7fefebbbee1e2ae13bf5d6baa838be66b1db6/uqbar/objects.py#L290-L363 |
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",
"."
] | train | https://github.com/josiah-wolf-oberholtzer/uqbar/blob/eca7fefebbbee1e2ae13bf5d6baa838be66b1db6/uqbar/sphinx/api.py#L49-L113 |
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",
"."
] | train | https://github.com/josiah-wolf-oberholtzer/uqbar/blob/eca7fefebbbee1e2ae13bf5d6baa838be66b1db6/uqbar/sphinx/api.py#L116-L134 |
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",
"."
] | train | https://github.com/developersociety/django-glitter/blob/2c0280ec83afee80deee94ee3934fc54239c2e87/glitter/integration.py#L28-L39 |
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",
"."
] | train | https://github.com/developersociety/django-glitter/blob/2c0280ec83afee80deee94ee3934fc54239c2e87/glitter/integration.py#L41-L54 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.