Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
Binding.add_operations | (self, root, definitions) | Add <operation/> children | Add <operation/> children | def add_operations(self, root, definitions):
""" Add <operation/> children """
dsop = Element('operation', ns=soapns)
for c in root.getChildren('operation'):
op = Facade('Operation')
op.name = c.get('name')
sop = c.getChild('operation', default=dsop)
... | [
"def",
"add_operations",
"(",
"self",
",",
"root",
",",
"definitions",
")",
":",
"dsop",
"=",
"Element",
"(",
"'operation'",
",",
"ns",
"=",
"soapns",
")",
"for",
"c",
"in",
"root",
".",
"getChildren",
"(",
"'operation'",
")",
":",
"op",
"=",
"Facade",... | [
565,
4
] | [
607,
41
] | python | de | ['de', 'de', 'en'] | True |
Binding.body | (self, definitions, body, root) | add the input/output body properties | add the input/output body properties | def body(self, definitions, body, root):
""" add the input/output body properties """
if root is None:
body.use = 'literal'
body.namespace = definitions.tns
body.parts = ()
return
parts = root.get('parts')
if parts is None:
body... | [
"def",
"body",
"(",
"self",
",",
"definitions",
",",
"body",
",",
"root",
")",
":",
"if",
"root",
"is",
"None",
":",
"body",
".",
"use",
"=",
"'literal'",
"body",
".",
"namespace",
"=",
"definitions",
".",
"tns",
"body",
".",
"parts",
"=",
"(",
")"... | [
609,
4
] | [
627,
41
] | python | en | ['en', 'en', 'en'] | True |
Binding.header | (self, definitions, parent, root) | add the input/output header properties | add the input/output header properties | def header(self, definitions, parent, root):
""" add the input/output header properties """
if root is None:
return
header = Facade('Header')
parent.headers.append(header)
header.use = root.get('use', default='literal')
ns = root.get('namespace')
if ns... | [
"def",
"header",
"(",
"self",
",",
"definitions",
",",
"parent",
",",
"root",
")",
":",
"if",
"root",
"is",
"None",
":",
"return",
"header",
"=",
"Facade",
"(",
"'Header'",
")",
"parent",
".",
"headers",
".",
"append",
"(",
"header",
")",
"header",
"... | [
629,
4
] | [
647,
30
] | python | en | ['en', 'lb', 'en'] | True |
Binding.resolve | (self, definitions) |
Resolve named references to other WSDL objects. This includes
cross-linking information (from) the portType (to) the I{soap}
protocol information on the binding for each operation.
@param definitions: A definitions object.
@type definitions: L{Definitions}
|
Resolve named references to other WSDL objects. This includes
cross-linking information (from) the portType (to) the I{soap}
protocol information on the binding for each operation.
| def resolve(self, definitions):
"""
Resolve named references to other WSDL objects. This includes
cross-linking information (from) the portType (to) the I{soap}
protocol information on the binding for each operation.
@param definitions: A definitions object.
@type defini... | [
"def",
"resolve",
"(",
"self",
",",
"definitions",
")",
":",
"self",
".",
"resolveport",
"(",
"definitions",
")",
"for",
"op",
"in",
"self",
".",
"operations",
".",
"values",
"(",
")",
":",
"self",
".",
"resolvesoapbody",
"(",
"definitions",
",",
"op",
... | [
649,
4
] | [
661,
47
] | python | en | ['en', 'error', 'th'] | False |
Binding.resolveport | (self, definitions) |
Resolve port_type reference.
@param definitions: A definitions object.
@type definitions: L{Definitions}
|
Resolve port_type reference.
| def resolveport(self, definitions):
"""
Resolve port_type reference.
@param definitions: A definitions object.
@type definitions: L{Definitions}
"""
ref = qualify(self.type, self.root, definitions.tns)
port_type = definitions.port_types.get(ref)
if port_ty... | [
"def",
"resolveport",
"(",
"self",
",",
"definitions",
")",
":",
"ref",
"=",
"qualify",
"(",
"self",
".",
"type",
",",
"self",
".",
"root",
",",
"definitions",
".",
"tns",
")",
"port_type",
"=",
"definitions",
".",
"port_types",
".",
"get",
"(",
"ref",... | [
663,
4
] | [
674,
33
] | python | en | ['en', 'error', 'th'] | False |
Binding.resolvesoapbody | (self, definitions, op) |
Resolve soap body I{message} parts by
cross-referencing with operation defined in port type.
@param definitions: A definitions object.
@type definitions: L{Definitions}
@param op: An I{operation} object.
@type op: I{operation}
|
Resolve soap body I{message} parts by
cross-referencing with operation defined in port type.
| def resolvesoapbody(self, definitions, op):
"""
Resolve soap body I{message} parts by
cross-referencing with operation defined in port type.
@param definitions: A definitions object.
@type definitions: L{Definitions}
@param op: An I{operation} object.
@type op: I... | [
"def",
"resolvesoapbody",
"(",
"self",
",",
"definitions",
",",
"op",
")",
":",
"ptop",
"=",
"self",
".",
"type",
".",
"operation",
"(",
"op",
".",
"name",
")",
"if",
"ptop",
"is",
"None",
":",
"raise",
"Exception",
",",
"\"operation '%s' not defined in po... | [
676,
4
] | [
707,
54
] | python | en | ['en', 'error', 'th'] | False |
Binding.resolveheaders | (self, definitions, op) |
Resolve soap header I{message} references.
@param definitions: A definitions object.
@type definitions: L{Definitions}
@param op: An I{operation} object.
@type op: I{operation}
|
Resolve soap header I{message} references.
| def resolveheaders(self, definitions, op):
"""
Resolve soap header I{message} references.
@param definitions: A definitions object.
@type definitions: L{Definitions}
@param op: An I{operation} object.
@type op: I{operation}
"""
soap = op.soap
heade... | [
"def",
"resolveheaders",
"(",
"self",
",",
"definitions",
",",
"op",
")",
":",
"soap",
"=",
"op",
".",
"soap",
"headers",
"=",
"soap",
".",
"input",
".",
"headers",
"+",
"soap",
".",
"output",
".",
"headers",
"for",
"header",
"in",
"headers",
":",
"m... | [
709,
4
] | [
732,
70
] | python | en | ['en', 'error', 'th'] | False |
Binding.resolvefaults | (self, definitions, op) |
Resolve soap fault I{message} references by
cross-referencing with operation defined in port type.
@param definitions: A definitions object.
@type definitions: L{Definitions}
@param op: An I{operation} object.
@type op: I{operation}
|
Resolve soap fault I{message} references by
cross-referencing with operation defined in port type.
| def resolvefaults(self, definitions, op):
"""
Resolve soap fault I{message} references by
cross-referencing with operation defined in port type.
@param definitions: A definitions object.
@type definitions: L{Definitions}
@param op: An I{operation} object.
@type op... | [
"def",
"resolvefaults",
"(",
"self",
",",
"definitions",
",",
"op",
")",
":",
"ptop",
"=",
"self",
".",
"type",
".",
"operation",
"(",
"op",
".",
"name",
")",
"if",
"ptop",
"is",
"None",
":",
"raise",
"Exception",
",",
"\"operation '%s' not defined in port... | [
734,
4
] | [
756,
88
] | python | en | ['en', 'error', 'th'] | False |
Binding.operation | (self, name) |
Shortcut used to get a contained operation by name.
@param name: An operation name.
@type name: str
@return: The named operation.
@rtype: Operation
@raise L{MethodNotFound}: When not found.
|
Shortcut used to get a contained operation by name.
| def operation(self, name):
"""
Shortcut used to get a contained operation by name.
@param name: An operation name.
@type name: str
@return: The named operation.
@rtype: Operation
@raise L{MethodNotFound}: When not found.
"""
try:
return... | [
"def",
"operation",
"(",
"self",
",",
"name",
")",
":",
"try",
":",
"return",
"self",
".",
"operations",
"[",
"name",
"]",
"except",
":",
"raise",
"MethodNotFound",
"(",
"name",
")"
] | [
758,
4
] | [
770,
38
] | python | en | ['en', 'error', 'th'] | False |
Port.__init__ | (self, root, definitions, service) |
@param root: An XML root element.
@type root: L{Element}
@param definitions: A definitions object.
@type definitions: L{Definitions}
@param service: A service object.
@type service: L{Service}
| def __init__(self, root, definitions, service):
"""
@param root: An XML root element.
@type root: L{Element}
@param definitions: A definitions object.
@type definitions: L{Definitions}
@param service: A service object.
@type service: L{Service}
"""
... | [
"def",
"__init__",
"(",
"self",
",",
"root",
",",
"definitions",
",",
"service",
")",
":",
"NamedObject",
".",
"__init__",
"(",
"self",
",",
"root",
",",
"definitions",
")",
"self",
".",
"__service",
"=",
"service",
"self",
".",
"binding",
"=",
"root",
... | [
787,
4
] | [
804,
25
] | python | en | ['en', 'error', 'th'] | False | |
Port.method | (self, name) |
Get a method defined in this portType by name.
@param name: A method name.
@type name: str
@return: The requested method object.
@rtype: I{Method}
|
Get a method defined in this portType by name.
| def method(self, name):
"""
Get a method defined in this portType by name.
@param name: A method name.
@type name: str
@return: The requested method object.
@rtype: I{Method}
"""
return self.methods.get(name) | [
"def",
"method",
"(",
"self",
",",
"name",
")",
":",
"return",
"self",
".",
"methods",
".",
"get",
"(",
"name",
")"
] | [
806,
4
] | [
814,
37
] | python | en | ['en', 'error', 'th'] | False |
Service.__init__ | (self, root, definitions) |
@param root: An XML root element.
@type root: L{Element}
@param definitions: A definitions object.
@type definitions: L{Definitions}
| def __init__(self, root, definitions):
"""
@param root: An XML root element.
@type root: L{Element}
@param definitions: A definitions object.
@type definitions: L{Definitions}
"""
NamedObject.__init__(self, root, definitions)
self.ports = []
for p ... | [
"def",
"__init__",
"(",
"self",
",",
"root",
",",
"definitions",
")",
":",
"NamedObject",
".",
"__init__",
"(",
"self",
",",
"root",
",",
"definitions",
")",
"self",
".",
"ports",
"=",
"[",
"]",
"for",
"p",
"in",
"root",
".",
"getChildren",
"(",
"'po... | [
826,
4
] | [
837,
35
] | python | en | ['en', 'error', 'th'] | False | |
Service.port | (self, name) |
Locate a port by name.
@param name: A port name.
@type name: str
@return: The port object.
@rtype: L{Port}
|
Locate a port by name.
| def port(self, name):
"""
Locate a port by name.
@param name: A port name.
@type name: str
@return: The port object.
@rtype: L{Port}
"""
for p in self.ports:
if p.name == name:
return p
return None | [
"def",
"port",
"(",
"self",
",",
"name",
")",
":",
"for",
"p",
"in",
"self",
".",
"ports",
":",
"if",
"p",
".",
"name",
"==",
"name",
":",
"return",
"p",
"return",
"None"
] | [
839,
4
] | [
850,
19
] | python | en | ['en', 'error', 'th'] | False |
Service.setlocation | (self, url, names=None) |
Override the invocation location (url) for service method.
@param url: A url location.
@type url: A url.
@param names: A list of method names. None=ALL
@type names: [str,..]
|
Override the invocation location (url) for service method.
| def setlocation(self, url, names=None):
"""
Override the invocation location (url) for service method.
@param url: A url location.
@type url: A url.
@param names: A list of method names. None=ALL
@type names: [str,..]
"""
for p in self.ports:
... | [
"def",
"setlocation",
"(",
"self",
",",
"url",
",",
"names",
"=",
"None",
")",
":",
"for",
"p",
"in",
"self",
".",
"ports",
":",
"for",
"m",
"in",
"p",
".",
"methods",
".",
"values",
"(",
")",
":",
"if",
"names",
"is",
"None",
"or",
"m",
".",
... | [
852,
4
] | [
863,
36
] | python | en | ['en', 'error', 'th'] | False |
Service.resolve | (self, definitions) |
Resolve named references to other WSDL objects.
Ports without soap bindings are discarded.
@param definitions: A definitions object.
@type definitions: L{Definitions}
|
Resolve named references to other WSDL objects.
Ports without soap bindings are discarded.
| def resolve(self, definitions):
"""
Resolve named references to other WSDL objects.
Ports without soap bindings are discarded.
@param definitions: A definitions object.
@type definitions: L{Definitions}
"""
filtered = []
for p in self.ports:
re... | [
"def",
"resolve",
"(",
"self",
",",
"definitions",
")",
":",
"filtered",
"=",
"[",
"]",
"for",
"p",
"in",
"self",
".",
"ports",
":",
"ref",
"=",
"qualify",
"(",
"p",
".",
"binding",
",",
"self",
".",
"root",
",",
"definitions",
".",
"tns",
")",
"... | [
865,
4
] | [
883,
29
] | python | en | ['en', 'error', 'th'] | False |
Factory.create | (cls, root, definitions) |
Create an object based on the root tag name.
@param root: An XML root element.
@type root: L{Element}
@param definitions: A definitions object.
@type definitions: L{Definitions}
@return: The created object.
@rtype: L{WObject}
|
Create an object based on the root tag name.
| def create(cls, root, definitions):
"""
Create an object based on the root tag name.
@param root: An XML root element.
@type root: L{Element}
@param definitions: A definitions object.
@type definitions: L{Definitions}
@return: The created object.
@rtype: L... | [
"def",
"create",
"(",
"cls",
",",
"root",
",",
"definitions",
")",
":",
"fn",
"=",
"cls",
".",
"tags",
".",
"get",
"(",
"root",
".",
"name",
")",
"if",
"fn",
"is",
"not",
"None",
":",
"return",
"fn",
"(",
"root",
",",
"definitions",
")",
"else",
... | [
907,
4
] | [
921,
23
] | python | en | ['en', 'error', 'th'] | False |
get_module_constant | (module, symbol, default=-1, paths=None) | Find 'module' by searching 'paths', and extract 'symbol'
Return 'None' if 'module' does not exist on 'paths', or it does not define
'symbol'. If the module defines 'symbol' as a constant, return the
constant. Otherwise, return 'default'. | Find 'module' by searching 'paths', and extract 'symbol' | def get_module_constant(module, symbol, default=-1, paths=None):
"""Find 'module' by searching 'paths', and extract 'symbol'
Return 'None' if 'module' does not exist on 'paths', or it does not define
'symbol'. If the module defines 'symbol' as a constant, return the
constant. Otherwise, return 'defau... | [
"def",
"get_module_constant",
"(",
"module",
",",
"symbol",
",",
"default",
"=",
"-",
"1",
",",
"paths",
"=",
"None",
")",
":",
"try",
":",
"f",
",",
"path",
",",
"(",
"suffix",
",",
"mode",
",",
"kind",
")",
"=",
"info",
"=",
"find_module",
"(",
... | [
94,
0
] | [
120,
50
] | python | en | ['en', 'en', 'en'] | True |
extract_constant | (code, symbol, default=-1) | Extract the constant value of 'symbol' from 'code'
If the name 'symbol' is bound to a constant value by the Python code
object 'code', return that value. If 'symbol' is bound to an expression,
return 'default'. Otherwise, return 'None'.
Return value is based on the first assignment to 'symbol'. 'sy... | Extract the constant value of 'symbol' from 'code' | def extract_constant(code, symbol, default=-1):
"""Extract the constant value of 'symbol' from 'code'
If the name 'symbol' is bound to a constant value by the Python code
object 'code', return that value. If 'symbol' is bound to an expression,
return 'default'. Otherwise, return 'None'.
Return v... | [
"def",
"extract_constant",
"(",
"code",
",",
"symbol",
",",
"default",
"=",
"-",
"1",
")",
":",
"if",
"symbol",
"not",
"in",
"code",
".",
"co_names",
":",
"# name's not there, can't possibly be an assignment",
"return",
"None",
"name_idx",
"=",
"list",
"(",
"c... | [
123,
0
] | [
156,
27
] | python | en | ['en', 'en', 'en'] | True |
_update_globals | () |
Patch the globals to remove the objects not available on some platforms.
XXX it'd be better to test assertions about bytecode instead.
|
Patch the globals to remove the objects not available on some platforms. | def _update_globals():
"""
Patch the globals to remove the objects not available on some platforms.
XXX it'd be better to test assertions about bytecode instead.
"""
if not sys.platform.startswith('java') and sys.platform != 'cli':
return
incompatible = 'extract_constant', 'get_module_... | [
"def",
"_update_globals",
"(",
")",
":",
"if",
"not",
"sys",
".",
"platform",
".",
"startswith",
"(",
"'java'",
")",
"and",
"sys",
".",
"platform",
"!=",
"'cli'",
":",
"return",
"incompatible",
"=",
"'extract_constant'",
",",
"'get_module_constant'",
"for",
... | [
159,
0
] | [
171,
28
] | python | en | ['en', 'error', 'th'] | False |
Require.full_name | (self) | Return full package/distribution name, w/version | Return full package/distribution name, w/version | def full_name(self):
"""Return full package/distribution name, w/version"""
if self.requested_version is not None:
return '%s-%s' % (self.name, self.requested_version)
return self.name | [
"def",
"full_name",
"(",
"self",
")",
":",
"if",
"self",
".",
"requested_version",
"is",
"not",
"None",
":",
"return",
"'%s-%s'",
"%",
"(",
"self",
".",
"name",
",",
"self",
".",
"requested_version",
")",
"return",
"self",
".",
"name"
] | [
33,
4
] | [
37,
24
] | python | en | ['en', 'en', 'en'] | True |
Require.version_ok | (self, version) | Is 'version' sufficiently up-to-date? | Is 'version' sufficiently up-to-date? | def version_ok(self, version):
"""Is 'version' sufficiently up-to-date?"""
return self.attribute is None or self.format is None or \
str(version) != "unknown" and version >= self.requested_version | [
"def",
"version_ok",
"(",
"self",
",",
"version",
")",
":",
"return",
"self",
".",
"attribute",
"is",
"None",
"or",
"self",
".",
"format",
"is",
"None",
"or",
"str",
"(",
"version",
")",
"!=",
"\"unknown\"",
"and",
"version",
">=",
"self",
".",
"reques... | [
39,
4
] | [
42,
75
] | python | en | ['en', 'en', 'en'] | True |
Require.get_version | (self, paths=None, default="unknown") | Get version number of installed module, 'None', or 'default'
Search 'paths' for module. If not found, return 'None'. If found,
return the extracted version attribute, or 'default' if no version
attribute was specified, or the value cannot be determined without
importing the module. T... | Get version number of installed module, 'None', or 'default' | def get_version(self, paths=None, default="unknown"):
"""Get version number of installed module, 'None', or 'default'
Search 'paths' for module. If not found, return 'None'. If found,
return the extracted version attribute, or 'default' if no version
attribute was specified, or the va... | [
"def",
"get_version",
"(",
"self",
",",
"paths",
"=",
"None",
",",
"default",
"=",
"\"unknown\"",
")",
":",
"if",
"self",
".",
"attribute",
"is",
"None",
":",
"try",
":",
"f",
",",
"p",
",",
"i",
"=",
"find_module",
"(",
"self",
".",
"module",
",",... | [
44,
4
] | [
69,
16
] | python | en | ['en', 'en', 'en'] | True |
Require.is_present | (self, paths=None) | Return true if dependency is present on 'paths | Return true if dependency is present on 'paths | def is_present(self, paths=None):
"""Return true if dependency is present on 'paths'"""
return self.get_version(paths) is not None | [
"def",
"is_present",
"(",
"self",
",",
"paths",
"=",
"None",
")",
":",
"return",
"self",
".",
"get_version",
"(",
"paths",
")",
"is",
"not",
"None"
] | [
71,
4
] | [
73,
50
] | python | en | ['en', 'af', 'en'] | True |
Require.is_current | (self, paths=None) | Return true if dependency is present and up-to-date on 'paths | Return true if dependency is present and up-to-date on 'paths | def is_current(self, paths=None):
"""Return true if dependency is present and up-to-date on 'paths'"""
version = self.get_version(paths)
if version is None:
return False
return self.version_ok(version) | [
"def",
"is_current",
"(",
"self",
",",
"paths",
"=",
"None",
")",
":",
"version",
"=",
"self",
".",
"get_version",
"(",
"paths",
")",
"if",
"version",
"is",
"None",
":",
"return",
"False",
"return",
"self",
".",
"version_ok",
"(",
"version",
")"
] | [
75,
4
] | [
80,
39
] | python | en | ['en', 'en', 'en'] | True |
DomainFilterAction.filter | (self, table, domains, filter_string) | Naive case-insensitive search. | Naive case-insensitive search. | def filter(self, table, domains, filter_string):
"""Naive case-insensitive search."""
q = filter_string.lower()
def comp(domain):
if q in domain.name.lower():
return True
return False
return filter(comp, domains) | [
"def",
"filter",
"(",
"self",
",",
"table",
",",
"domains",
",",
"filter_string",
")",
":",
"q",
"=",
"filter_string",
".",
"lower",
"(",
")",
"def",
"comp",
"(",
"domain",
")",
":",
"if",
"q",
"in",
"domain",
".",
"name",
".",
"lower",
"(",
")",
... | [
209,
4
] | [
218,
36
] | python | en | ['en', 'it', 'en'] | True |
TestAdminVolumeTypes.test_volume_type_create_delete | (self) | This test case checks create, delete volume type:
Steps:
1. Login to Horizon Dashboard as admin user
2. Navigate to Admin -> Volume -> Volume Types page
3. Create new volume type
4. Check that the volume type is in the list
5. Check that no Error messages present
... | This test case checks create, delete volume type: | def test_volume_type_create_delete(self):
"""This test case checks create, delete volume type:
Steps:
1. Login to Horizon Dashboard as admin user
2. Navigate to Admin -> Volume -> Volume Types page
3. Create new volume type
4. Check that the volume type is in the list
... | [
"def",
"test_volume_type_create_delete",
"(",
"self",
")",
":",
"volume_types_page",
"=",
"self",
".",
"home_pg",
".",
"go_to_admin_volume_volumetypespage",
"(",
")",
"volume_types_page",
".",
"create_volume_type",
"(",
"self",
".",
"VOLUME_TYPE_NAME",
")",
"self",
".... | [
19,
4
] | [
50,
35
] | python | en | ['en', 'el-Latn', 'en'] | True |
TestQoSSpec.test_qos_spec_create_delete | (self) | tests the QoS Spec creation and deletion functionality
* creates a new QoS Spec
* verifies the QoS Spec appears in the QoS Specs table
* deletes the newly created QoS Spec
* verifies the QoS Spec does not appear in the table after deletion
| tests the QoS Spec creation and deletion functionality | def test_qos_spec_create_delete(self):
"""tests the QoS Spec creation and deletion functionality
* creates a new QoS Spec
* verifies the QoS Spec appears in the QoS Specs table
* deletes the newly created QoS Spec
* verifies the QoS Spec does not appear in the table after deleti... | [
"def",
"test_qos_spec_create_delete",
"(",
"self",
")",
":",
"qos_spec_page",
"=",
"self",
".",
"home_pg",
".",
"go_to_admin_volume_volumetypespage",
"(",
")",
"qos_spec_page",
".",
"create_qos_spec",
"(",
"self",
".",
"QOS_SPEC_NAME",
")",
"self",
".",
"assertTrue"... | [
56,
4
] | [
78,
79
] | python | en | ['en', 'en', 'en'] | True |
TestQoSSpec.test_qos_spec_edit_consumer | (self) | tests Edit Consumer of QoS Spec functionality
* creates a new QoS Spec
* verifies the QoS Spec appears in the QoS Specs table
* edit consumer of created QoS Spec (check all options - front-end,
both, back-end)
* verifies current consumer of the QoS Spec in the QoS Specs table
... | tests Edit Consumer of QoS Spec functionality | def test_qos_spec_edit_consumer(self):
"""tests Edit Consumer of QoS Spec functionality
* creates a new QoS Spec
* verifies the QoS Spec appears in the QoS Specs table
* edit consumer of created QoS Spec (check all options - front-end,
both, back-end)
* verifies curren... | [
"def",
"test_qos_spec_edit_consumer",
"(",
"self",
")",
":",
"qos_spec_name",
"=",
"helpers",
".",
"gen_random_resource_name",
"(",
"\"qos_spec\"",
")",
"qos_spec_page",
"=",
"self",
".",
"home_pg",
".",
"go_to_admin_volume_volumetypespage",
"(",
")",
"nova_compute_cons... | [
80,
4
] | [
133,
74
] | python | en | ['en', 'en', 'en'] | True |
MidiIoTest.CheckPrettyMidiAndSequence | (self, midi, sequence_proto) | Compares PrettyMIDI object against a sequence proto.
Args:
midi: A pretty_midi.PrettyMIDI object.
sequence_proto: A NoteSequence proto.
| Compares PrettyMIDI object against a sequence proto. | def CheckPrettyMidiAndSequence(self, midi, sequence_proto):
"""Compares PrettyMIDI object against a sequence proto.
Args:
midi: A pretty_midi.PrettyMIDI object.
sequence_proto: A NoteSequence proto.
"""
# Test time signature changes.
self.assertEqual(len(midi.time_signature_changes),
... | [
"def",
"CheckPrettyMidiAndSequence",
"(",
"self",
",",
"midi",
",",
"sequence_proto",
")",
":",
"# Test time signature changes.",
"self",
".",
"assertEqual",
"(",
"len",
"(",
"midi",
".",
"time_signature_changes",
")",
",",
"len",
"(",
"sequence_proto",
".",
"time... | [
67,
2
] | [
148,
78
] | python | en | ['en', 'it', 'en'] | True |
MidiIoTest.CheckMidiToSequence | (self, filename) | Test the translation from PrettyMIDI to Sequence proto. | Test the translation from PrettyMIDI to Sequence proto. | def CheckMidiToSequence(self, filename):
"""Test the translation from PrettyMIDI to Sequence proto."""
source_midi = pretty_midi.PrettyMIDI(filename)
sequence_proto = midi_io.midi_to_sequence_proto(source_midi)
self.CheckPrettyMidiAndSequence(source_midi, sequence_proto) | [
"def",
"CheckMidiToSequence",
"(",
"self",
",",
"filename",
")",
":",
"source_midi",
"=",
"pretty_midi",
".",
"PrettyMIDI",
"(",
"filename",
")",
"sequence_proto",
"=",
"midi_io",
".",
"midi_to_sequence_proto",
"(",
"source_midi",
")",
"self",
".",
"CheckPrettyMid... | [
150,
2
] | [
154,
64
] | python | en | ['en', 'en', 'en'] | True |
MidiIoTest.CheckSequenceToPrettyMidi | (self, filename) | Test the translation from Sequence proto to PrettyMIDI. | Test the translation from Sequence proto to PrettyMIDI. | def CheckSequenceToPrettyMidi(self, filename):
"""Test the translation from Sequence proto to PrettyMIDI."""
source_midi = pretty_midi.PrettyMIDI(filename)
sequence_proto = midi_io.midi_to_sequence_proto(source_midi)
translated_midi = midi_io.sequence_proto_to_pretty_midi(sequence_proto)
self.CheckP... | [
"def",
"CheckSequenceToPrettyMidi",
"(",
"self",
",",
"filename",
")",
":",
"source_midi",
"=",
"pretty_midi",
".",
"PrettyMIDI",
"(",
"filename",
")",
"sequence_proto",
"=",
"midi_io",
".",
"midi_to_sequence_proto",
"(",
"source_midi",
")",
"translated_midi",
"=",
... | [
156,
2
] | [
161,
68
] | python | en | ['en', 'en', 'en'] | True |
MidiIoTest.CheckReadWriteMidi | (self, filename) | Test writing to a MIDI file and comparing it to the original Sequence. | Test writing to a MIDI file and comparing it to the original Sequence. | def CheckReadWriteMidi(self, filename):
"""Test writing to a MIDI file and comparing it to the original Sequence."""
# TODO(deck): The input MIDI file is opened in pretty-midi and
# re-written to a temp file, sanitizing the MIDI data (reordering
# note ons, etc). Issue 85 in the pretty-midi GitHub
... | [
"def",
"CheckReadWriteMidi",
"(",
"self",
",",
"filename",
")",
":",
"# TODO(deck): The input MIDI file is opened in pretty-midi and",
"# re-written to a temp file, sanitizing the MIDI data (reordering",
"# note ons, etc). Issue 85 in the pretty-midi GitHub",
"# (http://github.com/craffel/pret... | [
163,
2
] | [
190,
65
] | python | en | ['en', 'en', 'en'] | True |
MidiIoTest.testIsDrumDetection | (self) | Verify that is_drum instruments are properly tracked.
self.midi_is_drum_filename is a MIDI file containing two tracks
set to channel 9 (is_drum == True). Each contains one NoteOn. This
test is designed to catch a bug where the second track would lose
is_drum, remapping the drum track to an instrument t... | Verify that is_drum instruments are properly tracked. | def testIsDrumDetection(self):
"""Verify that is_drum instruments are properly tracked.
self.midi_is_drum_filename is a MIDI file containing two tracks
set to channel 9 (is_drum == True). Each contains one NoteOn. This
test is designed to catch a bug where the second track would lose
is_drum, remap... | [
"def",
"testIsDrumDetection",
"(",
"self",
")",
":",
"sequence_proto",
"=",
"midi_io",
".",
"midi_file_to_sequence_proto",
"(",
"self",
".",
"midi_is_drum_filename",
")",
"with",
"tempfile",
".",
"NamedTemporaryFile",
"(",
"prefix",
"=",
"'MidiDrumTest'",
")",
"as",... | [
314,
2
] | [
338,
44
] | python | en | ['en', 'en', 'en'] | True |
test_show_fixtures_and_test | (testdir) | Verifies that fixtures are not executed. | Verifies that fixtures are not executed. | def test_show_fixtures_and_test(testdir):
""" Verifies that fixtures are not executed. """
p = testdir.makepyfile('''
import pytest
@pytest.fixture
def arg():
assert False
def test_arg(arg):
assert False
''')
result = testdir.runpytest("--setup-pl... | [
"def",
"test_show_fixtures_and_test",
"(",
"testdir",
")",
":",
"p",
"=",
"testdir",
".",
"makepyfile",
"(",
"'''\n import pytest\n @pytest.fixture\n def arg():\n assert False\n def test_arg(arg):\n assert False\n '''",
")",
"result",
... | [
0,
0
] | [
18,
6
] | python | en | ['en', 'en', 'en'] | True |
install_scripts.write_script | (self, script_name, contents, mode="t", *ignored) | Write an executable file to the scripts directory | Write an executable file to the scripts directory | def write_script(self, script_name, contents, mode="t", *ignored):
"""Write an executable file to the scripts directory"""
from setuptools.command.easy_install import chmod, current_umask
log.info("Installing %s script to %s", script_name, self.install_dir)
target = os.path.join(self.in... | [
"def",
"write_script",
"(",
"self",
",",
"script_name",
",",
"contents",
",",
"mode",
"=",
"\"t\"",
",",
"*",
"ignored",
")",
":",
"from",
"setuptools",
".",
"command",
".",
"easy_install",
"import",
"chmod",
",",
"current_umask",
"log",
".",
"info",
"(",
... | [
53,
4
] | [
67,
39
] | python | en | ['en', 'en', 'en'] | True |
HtmlTreeBranch.staircase_text | (self) |
produces representation of a node in staircase-like format:
html
body.main-section
p#intro
|
produces representation of a node in staircase-like format: | def staircase_text(self) -> str:
"""
produces representation of a node in staircase-like format:
html
body.main-section
p#intro
"""
res = "\n"
indent = " " * 4
for t in self.tags:
res += indent + t.text() + "\n... | [
"def",
"staircase_text",
"(",
"self",
")",
"->",
"str",
":",
"res",
"=",
"\"\\n\"",
"indent",
"=",
"\" \"",
"*",
"4",
"for",
"t",
"in",
"self",
".",
"tags",
":",
"res",
"+=",
"indent",
"+",
"t",
".",
"text",
"(",
")",
"+",
"\"\\n\"",
"indent",
"+... | [
29,
4
] | [
43,
18
] | python | en | ['en', 'error', 'th'] | False |
HtmlTreeBranch.text | (self) |
produces one-line representation of branch:
html body.main-section p#intro
|
produces one-line representation of branch: | def text(self) -> str:
"""
produces one-line representation of branch:
html body.main-section p#intro
"""
return " ".join(t.text() for t in self.tags) | [
"def",
"text",
"(",
"self",
")",
"->",
"str",
":",
"return",
"\" \"",
".",
"join",
"(",
"t",
".",
"text",
"(",
")",
"for",
"t",
"in",
"self",
".",
"tags",
")"
] | [
45,
4
] | [
51,
52
] | python | en | ['en', 'error', 'th'] | False |
ConfDBScaling.setUp | (self) | Setting up test. | Setting up test. | def setUp(self):
"""Setting up test."""
self.server_url = self.conf_get('main', 'url')
credential_host = self.conf_get('credential', 'host')
credential_port = self.conf_getInt('credential', 'port')
self.username, self.pwd = xmlrpc_get_credential(
credential_h... | [
"def",
"setUp",
"(",
"self",
")",
":",
"self",
".",
"server_url",
"=",
"self",
".",
"conf_get",
"(",
"'main'",
",",
"'url'",
")",
"credential_host",
"=",
"self",
".",
"conf_get",
"(",
"'credential'",
",",
"'host'",
")",
"credential_port",
"=",
"self",
".... | [
15,
4
] | [
24,
30
] | python | en | ['en', 'en', 'en'] | True |
test_log_cli_default_level_multiple_tests | (testdir, request) | Ensure we reset the first newline added by the live logger between tests | Ensure we reset the first newline added by the live logger between tests | def test_log_cli_default_level_multiple_tests(testdir, request):
"""Ensure we reset the first newline added by the live logger between tests"""
filename = request.node.name + '.py'
testdir.makepyfile('''
import logging
def test_log_1():
logging.warning("log message from test_log... | [
"def",
"test_log_cli_default_level_multiple_tests",
"(",
"testdir",
",",
"request",
")",
":",
"filename",
"=",
"request",
".",
"node",
".",
"name",
"+",
"'.py'",
"testdir",
".",
"makepyfile",
"(",
"'''\n import logging\n\n def test_log_1():\n loggin... | [
198,
0
] | [
224,
6
] | python | en | ['en', 'en', 'en'] | True |
test_log_cli_default_level_sections | (testdir, request) | Check that with live logging enable we are printing the correct headers during setup/call/teardown. | Check that with live logging enable we are printing the correct headers during setup/call/teardown. | def test_log_cli_default_level_sections(testdir, request):
"""Check that with live logging enable we are printing the correct headers during setup/call/teardown."""
filename = request.node.name + '.py'
testdir.makepyfile('''
import pytest
import logging
@pytest.fixture
def f... | [
"def",
"test_log_cli_default_level_sections",
"(",
"testdir",
",",
"request",
")",
":",
"filename",
"=",
"request",
".",
"node",
".",
"name",
"+",
"'.py'",
"testdir",
".",
"makepyfile",
"(",
"'''\n import pytest\n import logging\n\n @pytest.fixture\n ... | [
227,
0
] | [
271,
6
] | python | en | ['en', 'en', 'en'] | True |
test_live_logs_unknown_sections | (testdir, request) | Check that with live logging enable we are printing the correct headers during
start/setup/call/teardown/finish. | Check that with live logging enable we are printing the correct headers during
start/setup/call/teardown/finish. | def test_live_logs_unknown_sections(testdir, request):
"""Check that with live logging enable we are printing the correct headers during
start/setup/call/teardown/finish."""
filename = request.node.name + '.py'
testdir.makeconftest('''
import pytest
import logging
def pytest_run... | [
"def",
"test_live_logs_unknown_sections",
"(",
"testdir",
",",
"request",
")",
":",
"filename",
"=",
"request",
".",
"node",
".",
"name",
"+",
"'.py'",
"testdir",
".",
"makeconftest",
"(",
"'''\n import pytest\n import logging\n\n def pytest_runtest_pro... | [
274,
0
] | [
325,
6
] | python | en | ['en', 'en', 'en'] | True |
test_live_logging_suspends_capture | (has_capture_manager, request) | Test that capture manager is suspended when we emitting messages for live logging.
This tests the implementation calls instead of behavior because it is difficult/impossible to do it using
``testdir`` facilities because they do their own capturing.
We parametrize the test to also make sure _LiveLoggingStr... | Test that capture manager is suspended when we emitting messages for live logging. | def test_live_logging_suspends_capture(has_capture_manager, request):
"""Test that capture manager is suspended when we emitting messages for live logging.
This tests the implementation calls instead of behavior because it is difficult/impossible to do it using
``testdir`` facilities because they do their ... | [
"def",
"test_live_logging_suspends_capture",
"(",
"has_capture_manager",
",",
"request",
")",
":",
"import",
"logging",
"from",
"functools",
"import",
"partial",
"from",
"_pytest",
".",
"capture",
"import",
"CaptureManager",
"from",
"_pytest",
".",
"logging",
"import"... | [
548,
0
] | [
594,
52
] | python | en | ['en', 'en', 'en'] | True |
main | () | Script entry point. | Script entry point. | def main():
"""Script entry point."""
register_custom_components()
cfg = custom_parse_args(evaluation=True)
status = enjoy(cfg)
return status | [
"def",
"main",
"(",
")",
":",
"register_custom_components",
"(",
")",
"cfg",
"=",
"custom_parse_args",
"(",
"evaluation",
"=",
"True",
")",
"status",
"=",
"enjoy",
"(",
"cfg",
")",
"return",
"status"
] | [
6,
0
] | [
11,
17
] | python | en | ['en', 'en', 'en'] | True |
format_email_subject | (email_subject: str) |
Escape CR and LF characters.
|
Escape CR and LF characters.
| def format_email_subject(email_subject: str) -> str:
"""
Escape CR and LF characters.
"""
return email_subject.replace("\n", "\\n").replace("\r", "\\r") | [
"def",
"format_email_subject",
"(",
"email_subject",
":",
"str",
")",
"->",
"str",
":",
"return",
"email_subject",
".",
"replace",
"(",
"\"\\n\"",
",",
"\"\\\\n\"",
")",
".",
"replace",
"(",
"\"\\r\"",
",",
"\"\\\\r\"",
")"
] | [
15,
0
] | [
19,
66
] | python | en | ['en', 'error', 'th'] | False |
CaseInsensitiveDict.lower_items | (self) | Like iteritems(), but with all lowercase keys. | Like iteritems(), but with all lowercase keys. | def lower_items(self):
"""Like iteritems(), but with all lowercase keys."""
return (
(lowerkey, keyval[1])
for (lowerkey, keyval)
in self._store.items()
) | [
"def",
"lower_items",
"(",
"self",
")",
":",
"return",
"(",
"(",
"lowerkey",
",",
"keyval",
"[",
"1",
"]",
")",
"for",
"(",
"lowerkey",
",",
"keyval",
")",
"in",
"self",
".",
"_store",
".",
"items",
"(",
")",
")"
] | [
64,
4
] | [
70,
9
] | python | en | ['en', 'en', 'en'] | True |
nagios_from_file | (results_file: str) | Returns a nagios-appropriate string and return code obtained by
parsing the desired file on disk. The file on disk should be of format
%s|%s % (timestamp, nagios_string)
This file is created by various nagios checking cron jobs such as
check-rabbitmq-queues and check-rabbitmq-consumers | Returns a nagios-appropriate string and return code obtained by
parsing the desired file on disk. The file on disk should be of format | def nagios_from_file(results_file: str) -> Tuple[int, str]:
"""Returns a nagios-appropriate string and return code obtained by
parsing the desired file on disk. The file on disk should be of format
%s|%s % (timestamp, nagios_string)
This file is created by various nagios checking cron jobs such as
... | [
"def",
"nagios_from_file",
"(",
"results_file",
":",
"str",
")",
"->",
"Tuple",
"[",
"int",
",",
"str",
"]",
":",
"try",
":",
"with",
"open",
"(",
"results_file",
")",
"as",
"f",
":",
"data",
"=",
"f",
".",
"read",
"(",
")",
".",
"strip",
"(",
")... | [
4,
0
] | [
40,
36
] | python | en | ['en', 'en', 'en'] | True |
TestRouters.test_router_create | (self) | Checks create, clear/set gateway, delete router functionality
Executed by non-admin user.
Steps:
1. Login to Horizon Dashboard as horizon user
2. Navigate to Project -> Network -> Routers page
3. Create new router
4. Check that the router appears in the routers table as... | Checks create, clear/set gateway, delete router functionality | def test_router_create(self):
"""Checks create, clear/set gateway, delete router functionality
Executed by non-admin user.
Steps:
1. Login to Horizon Dashboard as horizon user
2. Navigate to Project -> Network -> Routers page
3. Create new router
4. Check that t... | [
"def",
"test_router_create",
"(",
"self",
")",
":",
"routers_page",
"=",
"self",
".",
"home_pg",
".",
"go_to_project_network_routerspage",
"(",
")",
"routers_page",
".",
"create_router",
"(",
"self",
".",
"ROUTER_NAME",
")",
"self",
".",
"assertTrue",
"(",
"rout... | [
21,
4
] | [
69,
74
] | python | en | ['sv', 'en', 'en'] | True |
parse_tag | (tag) |
Parses the provided tag (e.g. `py3-none-any`) into a frozenset of Tag instances.
Returning a set is required due to the possibility that the tag is a
compressed tag set.
|
Parses the provided tag (e.g. `py3-none-any`) into a frozenset of Tag instances. | def parse_tag(tag):
# type: (str) -> FrozenSet[Tag]
"""
Parses the provided tag (e.g. `py3-none-any`) into a frozenset of Tag instances.
Returning a set is required due to the possibility that the tag is a
compressed tag set.
"""
tags = set()
interpreters, abis, platforms = tag.split("-... | [
"def",
"parse_tag",
"(",
"tag",
")",
":",
"# type: (str) -> FrozenSet[Tag]",
"tags",
"=",
"set",
"(",
")",
"interpreters",
",",
"abis",
",",
"platforms",
"=",
"tag",
".",
"split",
"(",
"\"-\"",
")",
"for",
"interpreter",
"in",
"interpreters",
".",
"split",
... | [
114,
0
] | [
128,
26
] | python | en | ['en', 'error', 'th'] | False |
_warn_keyword_parameter | (func_name, kwargs) |
Backwards-compatibility with Python 2.7 to allow treating 'warn' as keyword-only.
|
Backwards-compatibility with Python 2.7 to allow treating 'warn' as keyword-only.
| def _warn_keyword_parameter(func_name, kwargs):
# type: (str, Dict[str, bool]) -> bool
"""
Backwards-compatibility with Python 2.7 to allow treating 'warn' as keyword-only.
"""
if not kwargs:
return False
elif len(kwargs) > 1 or "warn" not in kwargs:
kwargs.pop("warn", None)
... | [
"def",
"_warn_keyword_parameter",
"(",
"func_name",
",",
"kwargs",
")",
":",
"# type: (str, Dict[str, bool]) -> bool",
"if",
"not",
"kwargs",
":",
"return",
"False",
"elif",
"len",
"(",
"kwargs",
")",
">",
"1",
"or",
"\"warn\"",
"not",
"in",
"kwargs",
":",
"kw... | [
131,
0
] | [
144,
25
] | python | en | ['en', 'error', 'th'] | False |
_abi3_applies | (python_version) |
Determine if the Python version supports abi3.
PEP 384 was first implemented in Python 3.2.
|
Determine if the Python version supports abi3. | def _abi3_applies(python_version):
# type: (PythonVersion) -> bool
"""
Determine if the Python version supports abi3.
PEP 384 was first implemented in Python 3.2.
"""
return len(python_version) > 1 and tuple(python_version) >= (3, 2) | [
"def",
"_abi3_applies",
"(",
"python_version",
")",
":",
"# type: (PythonVersion) -> bool",
"return",
"len",
"(",
"python_version",
")",
">",
"1",
"and",
"tuple",
"(",
"python_version",
")",
">=",
"(",
"3",
",",
"2",
")"
] | [
162,
0
] | [
169,
70
] | python | en | ['en', 'error', 'th'] | False |
cpython_tags | (
python_version=None, # type: Optional[PythonVersion]
abis=None, # type: Optional[Iterable[str]]
platforms=None, # type: Optional[Iterable[str]]
**kwargs # type: bool
) |
Yields the tags for a CPython interpreter.
The tags consist of:
- cp<python_version>-<abi>-<platform>
- cp<python_version>-abi3-<platform>
- cp<python_version>-none-<platform>
- cp<less than python_version>-abi3-<platform> # Older Python versions down to 3.2.
If python_version only speci... |
Yields the tags for a CPython interpreter. | def cpython_tags(
python_version=None, # type: Optional[PythonVersion]
abis=None, # type: Optional[Iterable[str]]
platforms=None, # type: Optional[Iterable[str]]
**kwargs # type: bool
):
# type: (...) -> Iterator[Tag]
"""
Yields the tags for a CPython interpreter.
The tags consist o... | [
"def",
"cpython_tags",
"(",
"python_version",
"=",
"None",
",",
"# type: Optional[PythonVersion]",
"abis",
"=",
"None",
",",
"# type: Optional[Iterable[str]]",
"platforms",
"=",
"None",
",",
"# type: Optional[Iterable[str]]",
"*",
"*",
"kwargs",
"# type: bool",
")",
":"... | [
209,
0
] | [
266,
57
] | python | en | ['en', 'error', 'th'] | False |
generic_tags | (
interpreter=None, # type: Optional[str]
abis=None, # type: Optional[Iterable[str]]
platforms=None, # type: Optional[Iterable[str]]
**kwargs # type: bool
) |
Yields the tags for a generic interpreter.
The tags consist of:
- <interpreter>-<abi>-<platform>
The "none" ABI will be added if it was not explicitly provided.
|
Yields the tags for a generic interpreter. | def generic_tags(
interpreter=None, # type: Optional[str]
abis=None, # type: Optional[Iterable[str]]
platforms=None, # type: Optional[Iterable[str]]
**kwargs # type: bool
):
# type: (...) -> Iterator[Tag]
"""
Yields the tags for a generic interpreter.
The tags consist of:
- <int... | [
"def",
"generic_tags",
"(",
"interpreter",
"=",
"None",
",",
"# type: Optional[str]",
"abis",
"=",
"None",
",",
"# type: Optional[Iterable[str]]",
"platforms",
"=",
"None",
",",
"# type: Optional[Iterable[str]]",
"*",
"*",
"kwargs",
"# type: bool",
")",
":",
"# type: ... | [
276,
0
] | [
304,
50
] | python | en | ['en', 'error', 'th'] | False |
_py_interpreter_range | (py_version) |
Yields Python versions in descending order.
After the latest version, the major-only version will be yielded, and then
all previous versions of that major version.
|
Yields Python versions in descending order. | def _py_interpreter_range(py_version):
# type: (PythonVersion) -> Iterator[str]
"""
Yields Python versions in descending order.
After the latest version, the major-only version will be yielded, and then
all previous versions of that major version.
"""
if len(py_version) > 1:
yield "... | [
"def",
"_py_interpreter_range",
"(",
"py_version",
")",
":",
"# type: (PythonVersion) -> Iterator[str]",
"if",
"len",
"(",
"py_version",
")",
">",
"1",
":",
"yield",
"\"py{version}\"",
".",
"format",
"(",
"version",
"=",
"_version_nodot",
"(",
"py_version",
"[",
"... | [
307,
0
] | [
320,
86
] | python | en | ['en', 'error', 'th'] | False |
compatible_tags | (
python_version=None, # type: Optional[PythonVersion]
interpreter=None, # type: Optional[str]
platforms=None, # type: Optional[Iterable[str]]
) |
Yields the sequence of tags that are compatible with a specific version of Python.
The tags consist of:
- py*-none-<platform>
- <interpreter>-none-any # ... if `interpreter` is provided.
- py*-none-any
|
Yields the sequence of tags that are compatible with a specific version of Python. | def compatible_tags(
python_version=None, # type: Optional[PythonVersion]
interpreter=None, # type: Optional[str]
platforms=None, # type: Optional[Iterable[str]]
):
# type: (...) -> Iterator[Tag]
"""
Yields the sequence of tags that are compatible with a specific version of Python.
The t... | [
"def",
"compatible_tags",
"(",
"python_version",
"=",
"None",
",",
"# type: Optional[PythonVersion]",
"interpreter",
"=",
"None",
",",
"# type: Optional[str]",
"platforms",
"=",
"None",
",",
"# type: Optional[Iterable[str]]",
")",
":",
"# type: (...) -> Iterator[Tag]",
"if"... | [
323,
0
] | [
346,
41
] | python | en | ['en', 'error', 'th'] | False |
mac_platforms | (version=None, arch=None) |
Yields the platform tags for a macOS system.
The `version` parameter is a two-item tuple specifying the macOS version to
generate platform tags for. The `arch` parameter is the CPU architecture to
generate platform tags for. Both parameters default to the appropriate value
for the current system.
... |
Yields the platform tags for a macOS system. | def mac_platforms(version=None, arch=None):
# type: (Optional[MacVersion], Optional[str]) -> Iterator[str]
"""
Yields the platform tags for a macOS system.
The `version` parameter is a two-item tuple specifying the macOS version to
generate platform tags for. The `arch` parameter is the CPU archite... | [
"def",
"mac_platforms",
"(",
"version",
"=",
"None",
",",
"arch",
"=",
"None",
")",
":",
"# type: (Optional[MacVersion], Optional[str]) -> Iterator[str]",
"version_str",
",",
"_",
",",
"cpu_arch",
"=",
"platform",
".",
"mac_ver",
"(",
")",
"# type: ignore",
"if",
... | [
388,
0
] | [
415,
13
] | python | en | ['en', 'error', 'th'] | False |
_glibc_version_string_confstr | () |
Primary implementation of glibc_version_string using os.confstr.
|
Primary implementation of glibc_version_string using os.confstr.
| def _glibc_version_string_confstr():
# type: () -> Optional[str]
"""
Primary implementation of glibc_version_string using os.confstr.
"""
# os.confstr is quite a bit faster than ctypes.DLL. It's also less likely
# to be broken or missing. This strategy is used in the standard library
# platf... | [
"def",
"_glibc_version_string_confstr",
"(",
")",
":",
"# type: () -> Optional[str]",
"# os.confstr is quite a bit faster than ctypes.DLL. It's also less likely",
"# to be broken or missing. This strategy is used in the standard library",
"# platform module.",
"# https://github.com/python/cpython/... | [
439,
0
] | [
458,
18
] | python | en | ['en', 'error', 'th'] | False |
_glibc_version_string_ctypes | () |
Fallback implementation of glibc_version_string using ctypes.
|
Fallback implementation of glibc_version_string using ctypes.
| def _glibc_version_string_ctypes():
# type: () -> Optional[str]
"""
Fallback implementation of glibc_version_string using ctypes.
"""
try:
import ctypes
except ImportError:
return None
# ctypes.CDLL(None) internally calls dlopen(NULL), and as the dlopen
# manpage says, "... | [
"def",
"_glibc_version_string_ctypes",
"(",
")",
":",
"# type: () -> Optional[str]",
"try",
":",
"import",
"ctypes",
"except",
"ImportError",
":",
"return",
"None",
"# ctypes.CDLL(None) internally calls dlopen(NULL), and as the dlopen",
"# manpage says, \"If filename is NULL, then th... | [
461,
0
] | [
492,
22
] | python | en | ['en', 'error', 'th'] | False |
_platform_tags | () |
Provides the platform tags for this installation.
|
Provides the platform tags for this installation.
| def _platform_tags():
# type: () -> Iterator[str]
"""
Provides the platform tags for this installation.
"""
if platform.system() == "Darwin":
return mac_platforms()
elif platform.system() == "Linux":
return _linux_platforms()
else:
return _generic_platforms() | [
"def",
"_platform_tags",
"(",
")",
":",
"# type: () -> Iterator[str]",
"if",
"platform",
".",
"system",
"(",
")",
"==",
"\"Darwin\"",
":",
"return",
"mac_platforms",
"(",
")",
"elif",
"platform",
".",
"system",
"(",
")",
"==",
"\"Linux\"",
":",
"return",
"_l... | [
682,
0
] | [
692,
35
] | python | en | ['en', 'error', 'th'] | False |
interpreter_name | () |
Returns the name of the running interpreter.
|
Returns the name of the running interpreter.
| def interpreter_name():
# type: () -> str
"""
Returns the name of the running interpreter.
"""
try:
name = sys.implementation.name # type: ignore
except AttributeError: # pragma: no cover
# Python 2.7 compatibility.
name = platform.python_implementation().lower()
re... | [
"def",
"interpreter_name",
"(",
")",
":",
"# type: () -> str",
"try",
":",
"name",
"=",
"sys",
".",
"implementation",
".",
"name",
"# type: ignore",
"except",
"AttributeError",
":",
"# pragma: no cover",
"# Python 2.7 compatibility.",
"name",
"=",
"platform",
".",
"... | [
695,
0
] | [
705,
52
] | python | en | ['en', 'error', 'th'] | False |
interpreter_version | (**kwargs) |
Returns the version of the running interpreter.
|
Returns the version of the running interpreter.
| def interpreter_version(**kwargs):
# type: (bool) -> str
"""
Returns the version of the running interpreter.
"""
warn = _warn_keyword_parameter("interpreter_version", kwargs)
version = _get_config_var("py_version_nodot", warn=warn)
if version:
version = str(version)
else:
... | [
"def",
"interpreter_version",
"(",
"*",
"*",
"kwargs",
")",
":",
"# type: (bool) -> str",
"warn",
"=",
"_warn_keyword_parameter",
"(",
"\"interpreter_version\"",
",",
"kwargs",
")",
"version",
"=",
"_get_config_var",
"(",
"\"py_version_nodot\"",
",",
"warn",
"=",
"w... | [
708,
0
] | [
719,
18
] | python | en | ['en', 'error', 'th'] | False |
sys_tags | (**kwargs) |
Returns the sequence of tag triples for the running interpreter.
The order of the sequence corresponds to priority order for the
interpreter, from most to least important.
|
Returns the sequence of tag triples for the running interpreter. | def sys_tags(**kwargs):
# type: (bool) -> Iterator[Tag]
"""
Returns the sequence of tag triples for the running interpreter.
The order of the sequence corresponds to priority order for the
interpreter, from most to least important.
"""
warn = _warn_keyword_parameter("sys_tags", kwargs)
... | [
"def",
"sys_tags",
"(",
"*",
"*",
"kwargs",
")",
":",
"# type: (bool) -> Iterator[Tag]",
"warn",
"=",
"_warn_keyword_parameter",
"(",
"\"sys_tags\"",
",",
"kwargs",
")",
"interp_name",
"=",
"interpreter_name",
"(",
")",
"if",
"interp_name",
"==",
"\"cp\"",
":",
... | [
731,
0
] | [
750,
17
] | python | en | ['en', 'error', 'th'] | False |
ResourceBrowser.set_tables | (self, tables) | Sets the table instances on the browser.
``tables`` argument specifies tables to be set.
It is a dictionary mapping table names to table instances
(as constructed by MultiTableView).
| Sets the table instances on the browser. | def set_tables(self, tables):
"""Sets the table instances on the browser.
``tables`` argument specifies tables to be set.
It is a dictionary mapping table names to table instances
(as constructed by MultiTableView).
"""
self.navigation_table = tables[self.navigation_tabl... | [
"def",
"set_tables",
"(",
"self",
",",
"tables",
")",
":",
"self",
".",
"navigation_table",
"=",
"tables",
"[",
"self",
".",
"navigation_table_class",
".",
"_meta",
".",
"name",
"]",
"self",
".",
"content_table",
"=",
"tables",
"[",
"self",
".",
"content_t... | [
120,
4
] | [
132,
74
] | python | en | ['en', 'en', 'en'] | True |
response_chunks | (response, chunk_size=CONTENT_CHUNK_SIZE) | Given a requests Response, provide the data chunks.
| Given a requests Response, provide the data chunks.
| def response_chunks(response, chunk_size=CONTENT_CHUNK_SIZE):
# type: (Response, int) -> Iterator[bytes]
"""Given a requests Response, provide the data chunks.
"""
try:
# Special case for urllib3.
for chunk in response.raw.stream(
chunk_size,
# We use decode_conte... | [
"def",
"response_chunks",
"(",
"response",
",",
"chunk_size",
"=",
"CONTENT_CHUNK_SIZE",
")",
":",
"# type: (Response, int) -> Iterator[bytes]",
"try",
":",
"# Special case for urllib3.",
"for",
"chunk",
"in",
"response",
".",
"raw",
".",
"stream",
"(",
"chunk_size",
... | [
57,
0
] | [
96,
23
] | python | en | ['en', 'en', 'en'] | True |
FencedCodeExtension.extendMarkdown | (self, md: Markdown) | Add FencedBlockPreprocessor to the Markdown instance. | Add FencedBlockPreprocessor to the Markdown instance. | def extendMarkdown(self, md: Markdown) -> None:
"""Add FencedBlockPreprocessor to the Markdown instance."""
md.registerExtension(self)
processor = FencedBlockPreprocessor(
md, run_content_validators=self.config["run_content_validators"][0]
)
md.preprocessors.register(... | [
"def",
"extendMarkdown",
"(",
"self",
",",
"md",
":",
"Markdown",
")",
"->",
"None",
":",
"md",
".",
"registerExtension",
"(",
"self",
")",
"processor",
"=",
"FencedBlockPreprocessor",
"(",
"md",
",",
"run_content_validators",
"=",
"self",
".",
"config",
"["... | [
158,
4
] | [
164,
69
] | python | en | ['en', 'it', 'en'] | True |
FencedBlockPreprocessor.run | (self, lines: Iterable[str]) | Match and store Fenced Code Blocks in the HtmlStash. | Match and store Fenced Code Blocks in the HtmlStash. | def run(self, lines: Iterable[str]) -> List[str]:
"""Match and store Fenced Code Blocks in the HtmlStash."""
output: List[str] = []
processor = self
self.handlers: List[BaseHandler] = []
default_language = None
try:
default_language = self.md.zulip_realm.de... | [
"def",
"run",
"(",
"self",
",",
"lines",
":",
"Iterable",
"[",
"str",
"]",
")",
"->",
"List",
"[",
"str",
"]",
":",
"output",
":",
"List",
"[",
"str",
"]",
"=",
"[",
"]",
"processor",
"=",
"self",
"self",
".",
"handlers",
":",
"List",
"[",
"Bas... | [
380,
4
] | [
407,
21
] | python | en | ['en', 'en', 'en'] | True |
FencedBlockPreprocessor._escape | (self, txt: str) | basic html escaping | basic html escaping | def _escape(self, txt: str) -> str:
"""basic html escaping"""
txt = txt.replace("&", "&")
txt = txt.replace("<", "<")
txt = txt.replace(">", ">")
txt = txt.replace('"', """)
return txt | [
"def",
"_escape",
"(",
"self",
",",
"txt",
":",
"str",
")",
"->",
"str",
":",
"txt",
"=",
"txt",
".",
"replace",
"(",
"\"&\"",
",",
"\"&\"",
")",
"txt",
"=",
"txt",
".",
"replace",
"(",
"\"<\"",
",",
"\"<\"",
")",
"txt",
"=",
"txt",
".",
... | [
503,
4
] | [
509,
18
] | python | en | ['es', 'en', 'en'] | True |
read_mach_header | (lib_file, seek=None) |
This funcition parse mach-O header and extract
information about minimal system version
:param lib_file: reference to opened library file with pointer
|
This funcition parse mach-O header and extract
information about minimal system version | def read_mach_header(lib_file, seek=None):
"""
This funcition parse mach-O header and extract
information about minimal system version
:param lib_file: reference to opened library file with pointer
"""
if seek is not None:
lib_file.seek(seek)
base_class, magic_number = get_base_clas... | [
"def",
"read_mach_header",
"(",
"lib_file",
",",
"seek",
"=",
"None",
")",
":",
"if",
"seek",
"is",
"not",
"None",
":",
"lib_file",
".",
"seek",
"(",
"seek",
")",
"base_class",
",",
"magic_number",
"=",
"get_base_class_and_magic_number",
"(",
"lib_file",
")"... | [
290,
0
] | [
334,
20
] | python | en | ['en', 'error', 'th'] | False |
calculate_macosx_platform_tag | (archive_root, platform_tag) |
Calculate proper macosx platform tag basing on files which are included to wheel
Example platform tag `macosx-10.14-x86_64`
|
Calculate proper macosx platform tag basing on files which are included to wheel | def calculate_macosx_platform_tag(archive_root, platform_tag):
"""
Calculate proper macosx platform tag basing on files which are included to wheel
Example platform tag `macosx-10.14-x86_64`
"""
prefix, base_version, suffix = platform_tag.split('-')
base_version = tuple([int(x) for x in base_ve... | [
"def",
"calculate_macosx_platform_tag",
"(",
"archive_root",
",",
"platform_tag",
")",
":",
"prefix",
",",
"base_version",
",",
"suffix",
"=",
"platform_tag",
".",
"split",
"(",
"'-'",
")",
"base_version",
"=",
"tuple",
"(",
"[",
"int",
"(",
"x",
")",
"for",... | [
344,
0
] | [
409,
23
] | python | en | ['en', 'error', 'th'] | False |
dequote | (string) | Remove quotes from around a string. | Remove quotes from around a string. | def dequote(string):
"""Remove quotes from around a string."""
if ( ( string.startswith('"') and string.endswith('"'))
or (string.startswith("'") and string.endswith("'")) ):
return string[1:-1]
else:
return string | [
"def",
"dequote",
"(",
"string",
")",
":",
"if",
"(",
"(",
"string",
".",
"startswith",
"(",
"'\"'",
")",
"and",
"string",
".",
"endswith",
"(",
"'\"'",
")",
")",
"or",
"(",
"string",
".",
"startswith",
"(",
"\"'\"",
")",
"and",
"string",
".",
"end... | [
93,
0
] | [
99,
21
] | python | en | ['en', 'en', 'en'] | True |
handleAttributes | (text, parent) | Set values of an element based on attribute definitions ({@id=123}). | Set values of an element based on attribute definitions ({ | def handleAttributes(text, parent):
"""Set values of an element based on attribute definitions ({@id=123})."""
def attributeCallback(match):
parent.set(match.group(1), match.group(2).replace('\n', ' '))
return ATTR_RE.sub(attributeCallback, text) | [
"def",
"handleAttributes",
"(",
"text",
",",
"parent",
")",
":",
"def",
"attributeCallback",
"(",
"match",
")",
":",
"parent",
".",
"set",
"(",
"match",
".",
"group",
"(",
"1",
")",
",",
"match",
".",
"group",
"(",
"2",
")",
".",
"replace",
"(",
"'... | [
103,
0
] | [
107,
47
] | python | en | ['en', 'en', 'en'] | True |
Pattern.__init__ | (self, pattern, markdown_instance=None) |
Create an instant of an inline pattern.
Keyword arguments:
* pattern: A regular expression that matches a pattern
|
Create an instant of an inline pattern. | def __init__ (self, pattern, markdown_instance=None):
"""
Create an instant of an inline pattern.
Keyword arguments:
* pattern: A regular expression that matches a pattern
"""
self.pattern = pattern
self.compiled_re = re.compile("^(.*?)%s(.*?)$" % pattern, re.D... | [
"def",
"__init__",
"(",
"self",
",",
"pattern",
",",
"markdown_instance",
"=",
"None",
")",
":",
"self",
".",
"pattern",
"=",
"pattern",
"self",
".",
"compiled_re",
"=",
"re",
".",
"compile",
"(",
"\"^(.*?)%s(.*?)$\"",
"%",
"pattern",
",",
"re",
".",
"DO... | [
118,
4
] | [
133,
45
] | python | en | ['en', 'error', 'th'] | False |
Pattern.getCompiledRegExp | (self) | Return a compiled regular expression. | Return a compiled regular expression. | def getCompiledRegExp (self):
""" Return a compiled regular expression. """
return self.compiled_re | [
"def",
"getCompiledRegExp",
"(",
"self",
")",
":",
"return",
"self",
".",
"compiled_re"
] | [
135,
4
] | [
137,
31
] | python | en | ['en', 'da', 'en'] | True |
Pattern.handleMatch | (self, m) | Return a ElementTree element from the given match.
Subclasses should override this method.
Keyword arguments:
* m: A re match object containing a match of the pattern.
| Return a ElementTree element from the given match. | def handleMatch(self, m):
"""Return a ElementTree element from the given match.
Subclasses should override this method.
Keyword arguments:
* m: A re match object containing a match of the pattern.
"""
pass | [
"def",
"handleMatch",
"(",
"self",
",",
"m",
")",
":",
"pass"
] | [
139,
4
] | [
149,
12
] | python | en | ['en', 'en', 'en'] | True |
Pattern.type | (self) | Return class name, to define pattern type | Return class name, to define pattern type | def type(self):
""" Return class name, to define pattern type """
return self.__class__.__name__ | [
"def",
"type",
"(",
"self",
")",
":",
"return",
"self",
".",
"__class__",
".",
"__name__"
] | [
151,
4
] | [
153,
38
] | python | en | ['it', 'en', 'en'] | True |
LinkPattern.sanitize_url | (self, url) |
Sanitize a url against xss attacks in "safe_mode".
Rather than specifically blacklisting `javascript:alert("XSS")` and all
its aliases (see <http://ha.ckers.org/xss.html>), we whitelist known
safe url formats. Most urls contain a network location, however some
are known not to ... |
Sanitize a url against xss attacks in "safe_mode". | def sanitize_url(self, url):
"""
Sanitize a url against xss attacks in "safe_mode".
Rather than specifically blacklisting `javascript:alert("XSS")` and all
its aliases (see <http://ha.ckers.org/xss.html>), we whitelist known
safe url formats. Most urls contain a network location... | [
"def",
"sanitize_url",
"(",
"self",
",",
"url",
")",
":",
"locless_schemes",
"=",
"[",
"''",
",",
"'mailto'",
",",
"'news'",
"]",
"scheme",
",",
"netloc",
",",
"path",
",",
"params",
",",
"query",
",",
"fragment",
"=",
"url",
"=",
"urlparse",
"(",
"u... | [
242,
4
] | [
272,
34
] | python | en | ['en', 'error', 'th'] | False |
_execfile | (filename, globals, locals=None) |
Python 3 implementation of execfile.
|
Python 3 implementation of execfile.
| def _execfile(filename, globals, locals=None):
"""
Python 3 implementation of execfile.
"""
mode = 'rb'
with open(filename, mode) as stream:
script = stream.read()
if locals is None:
locals = globals
code = compile(script, filename, 'exec')
exec(code, globals, locals) | [
"def",
"_execfile",
"(",
"filename",
",",
"globals",
",",
"locals",
"=",
"None",
")",
":",
"mode",
"=",
"'rb'",
"with",
"open",
"(",
"filename",
",",
"mode",
")",
"as",
"stream",
":",
"script",
"=",
"stream",
".",
"read",
"(",
")",
"if",
"locals",
... | [
32,
0
] | [
42,
31
] | python | en | ['en', 'error', 'th'] | False |
override_temp | (replacement) |
Monkey-patch tempfile.tempdir with replacement, ensuring it exists
|
Monkey-patch tempfile.tempdir with replacement, ensuring it exists
| def override_temp(replacement):
"""
Monkey-patch tempfile.tempdir with replacement, ensuring it exists
"""
os.makedirs(replacement, exist_ok=True)
saved = tempfile.tempdir
tempfile.tempdir = replacement
try:
yield
finally:
tempfile.tempdir = saved | [
"def",
"override_temp",
"(",
"replacement",
")",
":",
"os",
".",
"makedirs",
"(",
"replacement",
",",
"exist_ok",
"=",
"True",
")",
"saved",
"=",
"tempfile",
".",
"tempdir",
"tempfile",
".",
"tempdir",
"=",
"replacement",
"try",
":",
"yield",
"finally",
":... | [
66,
0
] | [
79,
32
] | python | en | ['en', 'error', 'th'] | False |
save_modules | () |
Context in which imported modules are saved.
Translates exceptions internal to the context into the equivalent exception
outside the context.
|
Context in which imported modules are saved. | def save_modules():
"""
Context in which imported modules are saved.
Translates exceptions internal to the context into the equivalent exception
outside the context.
"""
saved = sys.modules.copy()
with ExceptionSaver() as saved_exc:
yield saved
sys.modules.update(saved)
# r... | [
"def",
"save_modules",
"(",
")",
":",
"saved",
"=",
"sys",
".",
"modules",
".",
"copy",
"(",
")",
"with",
"ExceptionSaver",
"(",
")",
"as",
"saved_exc",
":",
"yield",
"saved",
"sys",
".",
"modules",
".",
"update",
"(",
"saved",
")",
"# remove any modules... | [
142,
0
] | [
163,
22
] | python | en | ['en', 'error', 'th'] | False |
_needs_hiding | (mod_name) |
>>> _needs_hiding('setuptools')
True
>>> _needs_hiding('pkg_resources')
True
>>> _needs_hiding('setuptools_plugin')
False
>>> _needs_hiding('setuptools.__init__')
True
>>> _needs_hiding('distutils')
True
>>> _needs_hiding('os')
False
>>> _needs_hiding('Cython')
T... |
>>> _needs_hiding('setuptools')
True
>>> _needs_hiding('pkg_resources')
True
>>> _needs_hiding('setuptools_plugin')
False
>>> _needs_hiding('setuptools.__init__')
True
>>> _needs_hiding('distutils')
True
>>> _needs_hiding('os')
False
>>> _needs_hiding('Cython')
T... | def _needs_hiding(mod_name):
"""
>>> _needs_hiding('setuptools')
True
>>> _needs_hiding('pkg_resources')
True
>>> _needs_hiding('setuptools_plugin')
False
>>> _needs_hiding('setuptools.__init__')
True
>>> _needs_hiding('distutils')
True
>>> _needs_hiding('os')
False
... | [
"def",
"_needs_hiding",
"(",
"mod_name",
")",
":",
"base_module",
"=",
"mod_name",
".",
"split",
"(",
"'.'",
",",
"1",
")",
"[",
"0",
"]",
"return",
"base_module",
"in",
"_MODULES_TO_HIDE"
] | [
204,
0
] | [
222,
42
] | python | en | ['en', 'error', 'th'] | False |
hide_setuptools | () |
Remove references to setuptools' modules from sys.modules to allow the
invocation to import the most appropriate setuptools. This technique is
necessary to avoid issues such as #315 where setuptools upgrading itself
would fail to find a function declared in the metadata.
|
Remove references to setuptools' modules from sys.modules to allow the
invocation to import the most appropriate setuptools. This technique is
necessary to avoid issues such as #315 where setuptools upgrading itself
would fail to find a function declared in the metadata.
| def hide_setuptools():
"""
Remove references to setuptools' modules from sys.modules to allow the
invocation to import the most appropriate setuptools. This technique is
necessary to avoid issues such as #315 where setuptools upgrading itself
would fail to find a function declared in the metadata.
... | [
"def",
"hide_setuptools",
"(",
")",
":",
"_distutils_hack",
"=",
"sys",
".",
"modules",
".",
"get",
"(",
"'_distutils_hack'",
",",
"None",
")",
"if",
"_distutils_hack",
"is",
"not",
"None",
":",
"_distutils_hack",
".",
"remove_shim",
"(",
")",
"modules",
"="... | [
225,
0
] | [
237,
27
] | python | en | ['en', 'error', 'th'] | False |
run_setup | (setup_script, args) | Run a distutils setup script, sandboxed in its directory | Run a distutils setup script, sandboxed in its directory | def run_setup(setup_script, args):
"""Run a distutils setup script, sandboxed in its directory"""
setup_dir = os.path.abspath(os.path.dirname(setup_script))
with setup_context(setup_dir):
try:
sys.argv[:] = [setup_script] + list(args)
sys.path.insert(0, setup_dir)
... | [
"def",
"run_setup",
"(",
"setup_script",
",",
"args",
")",
":",
"setup_dir",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"setup_script",
")",
")",
"with",
"setup_context",
"(",
"setup_dir",
")",
":",
"try",
":",... | [
240,
0
] | [
256,
21
] | python | en | ['en', 'lb', 'en'] | True |
UnpickleableException.dump | (type, exc) |
Always return a dumped (pickled) type and exc. If exc can't be pickled,
wrap it in UnpickleableException first.
|
Always return a dumped (pickled) type and exc. If exc can't be pickled,
wrap it in UnpickleableException first.
| def dump(type, exc):
"""
Always return a dumped (pickled) type and exc. If exc can't be pickled,
wrap it in UnpickleableException first.
"""
try:
return pickle.dumps(type), pickle.dumps(exc)
except Exception:
# get UnpickleableException inside the ... | [
"def",
"dump",
"(",
"type",
",",
"exc",
")",
":",
"try",
":",
"return",
"pickle",
".",
"dumps",
"(",
"type",
")",
",",
"pickle",
".",
"dumps",
"(",
"exc",
")",
"except",
"Exception",
":",
"# get UnpickleableException inside the sandbox",
"from",
"setuptools"... | [
98,
4
] | [
108,
48
] | python | en | ['en', 'error', 'th'] | False |
ExceptionSaver.resume | (self) | restore and re-raise any exception | restore and re-raise any exception | def resume(self):
"restore and re-raise any exception"
if '_saved' not in vars(self):
return
type, exc = map(pickle.loads, self._saved)
raise exc.with_traceback(self._tb) | [
"def",
"resume",
"(",
"self",
")",
":",
"if",
"'_saved'",
"not",
"in",
"vars",
"(",
"self",
")",
":",
"return",
"type",
",",
"exc",
"=",
"map",
"(",
"pickle",
".",
"loads",
",",
"self",
".",
"_saved",
")",
"raise",
"exc",
".",
"with_traceback",
"("... | [
131,
4
] | [
138,
42
] | python | en | ['en', 'en', 'en'] | True |
AbstractSandbox.run | (self, func) | Run 'func' under os sandboxing | Run 'func' under os sandboxing | def run(self, func):
"""Run 'func' under os sandboxing"""
with self:
return func() | [
"def",
"run",
"(",
"self",
",",
"func",
")",
":",
"with",
"self",
":",
"return",
"func",
"(",
")"
] | [
289,
4
] | [
292,
25
] | python | es | ['es', 'jv', 'pt'] | False |
AbstractSandbox._validate_path | (self, path) | Called to remap or validate any path, whether input or output | Called to remap or validate any path, whether input or output | def _validate_path(self, path):
"""Called to remap or validate any path, whether input or output"""
return path | [
"def",
"_validate_path",
"(",
"self",
",",
"path",
")",
":",
"return",
"path"
] | [
359,
4
] | [
361,
19
] | python | en | ['en', 'en', 'en'] | True |
AbstractSandbox._remap_input | (self, operation, path, *args, **kw) | Called for path inputs | Called for path inputs | def _remap_input(self, operation, path, *args, **kw):
"""Called for path inputs"""
return self._validate_path(path) | [
"def",
"_remap_input",
"(",
"self",
",",
"operation",
",",
"path",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"return",
"self",
".",
"_validate_path",
"(",
"path",
")"
] | [
363,
4
] | [
365,
40
] | python | en | ['en', 'en', 'en'] | True |
AbstractSandbox._remap_output | (self, operation, path) | Called for path outputs | Called for path outputs | def _remap_output(self, operation, path):
"""Called for path outputs"""
return self._validate_path(path) | [
"def",
"_remap_output",
"(",
"self",
",",
"operation",
",",
"path",
")",
":",
"return",
"self",
".",
"_validate_path",
"(",
"path",
")"
] | [
367,
4
] | [
369,
40
] | python | en | ['en', 'en', 'en'] | True |
AbstractSandbox._remap_pair | (self, operation, src, dst, *args, **kw) | Called for path pairs like rename, link, and symlink operations | Called for path pairs like rename, link, and symlink operations | def _remap_pair(self, operation, src, dst, *args, **kw):
"""Called for path pairs like rename, link, and symlink operations"""
return (
self._remap_input(operation + '-from', src, *args, **kw),
self._remap_input(operation + '-to', dst, *args, **kw)
) | [
"def",
"_remap_pair",
"(",
"self",
",",
"operation",
",",
"src",
",",
"dst",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"return",
"(",
"self",
".",
"_remap_input",
"(",
"operation",
"+",
"'-from'",
",",
"src",
",",
"*",
"args",
",",
"*",
"*... | [
371,
4
] | [
376,
9
] | python | en | ['en', 'en', 'en'] | True |
DirectorySandbox._remap_input | (self, operation, path, *args, **kw) | Called for path inputs | Called for path inputs | def _remap_input(self, operation, path, *args, **kw):
"""Called for path inputs"""
if operation in self.write_ops and not self._ok(path):
self._violation(operation, os.path.realpath(path), *args, **kw)
return path | [
"def",
"_remap_input",
"(",
"self",
",",
"operation",
",",
"path",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"if",
"operation",
"in",
"self",
".",
"write_ops",
"and",
"not",
"self",
".",
"_ok",
"(",
"path",
")",
":",
"self",
".",
"_violation... | [
452,
4
] | [
456,
19
] | python | en | ['en', 'en', 'en'] | True |
DirectorySandbox._remap_pair | (self, operation, src, dst, *args, **kw) | Called for path pairs like rename, link, and symlink operations | Called for path pairs like rename, link, and symlink operations | def _remap_pair(self, operation, src, dst, *args, **kw):
"""Called for path pairs like rename, link, and symlink operations"""
if not self._ok(src) or not self._ok(dst):
self._violation(operation, src, dst, *args, **kw)
return (src, dst) | [
"def",
"_remap_pair",
"(",
"self",
",",
"operation",
",",
"src",
",",
"dst",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"if",
"not",
"self",
".",
"_ok",
"(",
"src",
")",
"or",
"not",
"self",
".",
"_ok",
"(",
"dst",
")",
":",
"self",
"."... | [
458,
4
] | [
462,
25
] | python | en | ['en', 'en', 'en'] | True |
DirectorySandbox.open | (self, file, flags, mode=0o777, *args, **kw) | Called for low-level os.open() | Called for low-level os.open() | def open(self, file, flags, mode=0o777, *args, **kw):
"""Called for low-level os.open()"""
if flags & WRITE_FLAGS and not self._ok(file):
self._violation("os.open", file, flags, mode, *args, **kw)
return _os.open(file, flags, mode, *args, **kw) | [
"def",
"open",
"(",
"self",
",",
"file",
",",
"flags",
",",
"mode",
"=",
"0o777",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"if",
"flags",
"&",
"WRITE_FLAGS",
"and",
"not",
"self",
".",
"_ok",
"(",
"file",
")",
":",
"self",
".",
"_violat... | [
464,
4
] | [
468,
55
] | python | en | ['en', 'en', 'en'] | True |
doom_override_defaults | (env, parser) | RL params specific to Doom envs. | RL params specific to Doom envs. | def doom_override_defaults(env, parser):
"""RL params specific to Doom envs."""
parser.set_defaults(
encoder_type='conv',
encoder_subtype='convnet_simple',
encoder_custom='vizdoom',
hidden_size=512,
ppo_clip_value=0.2, # value used in all experiments in the paper
... | [
"def",
"doom_override_defaults",
"(",
"env",
",",
"parser",
")",
":",
"parser",
".",
"set_defaults",
"(",
"encoder_type",
"=",
"'conv'",
",",
"encoder_subtype",
"=",
"'convnet_simple'",
",",
"encoder_custom",
"=",
"'vizdoom'",
",",
"hidden_size",
"=",
"512",
","... | [
16,
0
] | [
30,
5
] | python | en | ['en', 'en', 'en'] | True |
read | (fname) |
Load content of the file with path relative to where setup.py is.
Args:
fname (str): file name (or path relative to the project root)
Returns:
str: file content
|
Load content of the file with path relative to where setup.py is. | def read(fname):
"""
Load content of the file with path relative to where setup.py is.
Args:
fname (str): file name (or path relative to the project root)
Returns:
str: file content
"""
fpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), fname)
retval = open(fp... | [
"def",
"read",
"(",
"fname",
")",
":",
"fpath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"__file__",
")",
")",
",",
"fname",
")",
"retval",
"=",
"open",
"(",
"fpat... | [
11,
0
] | [
24,
17
] | python | en | ['en', 'error', 'th'] | False |
read_list | (fname) |
Load content of the file and split it into a list of lines.
Args:
fname (str): file name (or path relative to the project root)
Returns:
List[str]: file content (one string per line) with end of lines
characters stripped off and empty lines filtered out
|
Load content of the file and split it into a list of lines. | def read_list(fname):
"""
Load content of the file and split it into a list of lines.
Args:
fname (str): file name (or path relative to the project root)
Returns:
List[str]: file content (one string per line) with end of lines
characters stripped off and empty lines ... | [
"def",
"read_list",
"(",
"fname",
")",
":",
"content",
"=",
"read",
"(",
"fname",
")",
"retval",
"=",
"list",
"(",
"filter",
"(",
"None",
",",
"content",
".",
"split",
"(",
"'\\n'",
")",
")",
")",
"return",
"retval"
] | [
27,
0
] | [
41,
17
] | python | en | ['en', 'error', 'th'] | False |
get_version | (fname) |
Retrieve version from the VERSION file.
Args:
fname (str): file containing only the version
Returns:
str: version with whitespace characters stripped off
|
Retrieve version from the VERSION file. | def get_version(fname):
"""
Retrieve version from the VERSION file.
Args:
fname (str): file containing only the version
Returns:
str: version with whitespace characters stripped off
"""
return read(fname).strip() | [
"def",
"get_version",
"(",
"fname",
")",
":",
"return",
"read",
"(",
"fname",
")",
".",
"strip",
"(",
")"
] | [
44,
0
] | [
54,
30
] | python | en | ['en', 'error', 'th'] | False |
MusicXMLDocument._get_score | (filename) | Given a MusicXML file, return the score as an xml.etree.ElementTree.
Given a MusicXML file, return the score as an xml.etree.ElementTree
If the file is compress (ends in .mxl), uncompress it first
Args:
filename: The path of a MusicXML file
Returns:
The score as an xml.etree.ElementTree... | Given a MusicXML file, return the score as an xml.etree.ElementTree. | def _get_score(filename):
"""Given a MusicXML file, return the score as an xml.etree.ElementTree.
Given a MusicXML file, return the score as an xml.etree.ElementTree
If the file is compress (ends in .mxl), uncompress it first
Args:
filename: The path of a MusicXML file
Returns:
The ... | [
"def",
"_get_score",
"(",
"filename",
")",
":",
"score",
"=",
"None",
"if",
"filename",
".",
"endswith",
"(",
"'.mxl'",
")",
":",
"# Compressed MXL file. Uncompress in memory.",
"try",
":",
"mxlzip",
"=",
"zipfile",
".",
"ZipFile",
"(",
"filename",
")",
"excep... | [
155,
2
] | [
247,
16
] | python | en | ['en', 'en', 'en'] | True |
MusicXMLDocument._parse | (self) | Parse the uncompressed MusicXML document. | Parse the uncompressed MusicXML document. | def _parse(self):
"""Parse the uncompressed MusicXML document."""
# Parse part-list
xml_part_list = self._score.find('part-list')
if xml_part_list is not None:
for element in xml_part_list:
if element.tag == 'score-part':
score_part = ScorePart(element)
self._score_part... | [
"def",
"_parse",
"(",
"self",
")",
":",
"# Parse part-list",
"xml_part_list",
"=",
"self",
".",
"_score",
".",
"find",
"(",
"'part-list'",
")",
"if",
"xml_part_list",
"is",
"not",
"None",
":",
"for",
"element",
"in",
"xml_part_list",
":",
"if",
"element",
... | [
249,
2
] | [
265,
56
] | python | en | ['en', 'en', 'en'] | True |
MusicXMLDocument.get_chord_symbols | (self) | Return a list of all the chord symbols used in this score. | Return a list of all the chord symbols used in this score. | def get_chord_symbols(self):
"""Return a list of all the chord symbols used in this score."""
chord_symbols = []
for part in self.parts:
for measure in part.measures:
for chord_symbol in measure.chord_symbols:
if chord_symbol not in chord_symbols:
# Prevent duplicate chor... | [
"def",
"get_chord_symbols",
"(",
"self",
")",
":",
"chord_symbols",
"=",
"[",
"]",
"for",
"part",
"in",
"self",
".",
"parts",
":",
"for",
"measure",
"in",
"part",
".",
"measures",
":",
"for",
"chord_symbol",
"in",
"measure",
".",
"chord_symbols",
":",
"i... | [
267,
2
] | [
276,
24
] | python | en | ['en', 'en', 'en'] | True |
MusicXMLDocument.get_time_signatures | (self) | Return a list of all the time signatures used in this score.
Does not support polymeter (i.e. assumes all parts have the same
time signature, such as Part 1 having a time signature of 6/8
while Part 2 has a simultaneous time signature of 2/4).
Ignores duplicate time signatures to prevent Magenta dupli... | Return a list of all the time signatures used in this score. | def get_time_signatures(self):
"""Return a list of all the time signatures used in this score.
Does not support polymeter (i.e. assumes all parts have the same
time signature, such as Part 1 having a time signature of 6/8
while Part 2 has a simultaneous time signature of 2/4).
Ignores duplicate ti... | [
"def",
"get_time_signatures",
"(",
"self",
")",
":",
"time_signatures",
"=",
"[",
"]",
"for",
"part",
"in",
"self",
".",
"parts",
":",
"for",
"measure",
"in",
"part",
".",
"measures",
":",
"if",
"measure",
".",
"time_signature",
"is",
"not",
"None",
":",... | [
278,
2
] | [
304,
26
] | python | en | ['en', 'en', 'en'] | True |
MusicXMLDocument.get_key_signatures | (self) | Return a list of all the key signatures used in this score.
Support different key signatures in different parts (score in
written pitch).
Ignores duplicate key signatures to prevent Magenta duplicate key
signature error. This happens when multiple parts have the same
key signature at the same time... | Return a list of all the key signatures used in this score. | def get_key_signatures(self):
"""Return a list of all the key signatures used in this score.
Support different key signatures in different parts (score in
written pitch).
Ignores duplicate key signatures to prevent Magenta duplicate key
signature error. This happens when multiple parts have the sa... | [
"def",
"get_key_signatures",
"(",
"self",
")",
":",
"key_signatures",
"=",
"[",
"]",
"for",
"part",
"in",
"self",
".",
"parts",
":",
"for",
"measure",
"in",
"part",
".",
"measures",
":",
"if",
"measure",
".",
"key_signature",
"is",
"not",
"None",
":",
... | [
306,
2
] | [
342,
25
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.