partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | Step.download | Download a file into the correct cache directory. | sets/core/step.py | def download(cls, url, filename=None):
"""
Download a file into the correct cache directory.
"""
return utility.download(url, cls.directory(), filename) | def download(cls, url, filename=None):
"""
Download a file into the correct cache directory.
"""
return utility.download(url, cls.directory(), filename) | [
"Download",
"a",
"file",
"into",
"the",
"correct",
"cache",
"directory",
"."
] | danijar/sets | python | https://github.com/danijar/sets/blob/2542c28f43d0af18932cb5b82f54ffb6ae557d12/sets/core/step.py#L24-L28 | [
"def",
"download",
"(",
"cls",
",",
"url",
",",
"filename",
"=",
"None",
")",
":",
"return",
"utility",
".",
"download",
"(",
"url",
",",
"cls",
".",
"directory",
"(",
")",
",",
"filename",
")"
] | 2542c28f43d0af18932cb5b82f54ffb6ae557d12 |
train | Step.directory | Path that should be used for caching. Different for all subclasses. | sets/core/step.py | def directory(cls, prefix=None):
"""
Path that should be used for caching. Different for all subclasses.
"""
prefix = prefix or utility.read_config().directory
name = cls.__name__.lower()
directory = os.path.expanduser(os.path.join(prefix, name))
utility.ensure_di... | def directory(cls, prefix=None):
"""
Path that should be used for caching. Different for all subclasses.
"""
prefix = prefix or utility.read_config().directory
name = cls.__name__.lower()
directory = os.path.expanduser(os.path.join(prefix, name))
utility.ensure_di... | [
"Path",
"that",
"should",
"be",
"used",
"for",
"caching",
".",
"Different",
"for",
"all",
"subclasses",
"."
] | danijar/sets | python | https://github.com/danijar/sets/blob/2542c28f43d0af18932cb5b82f54ffb6ae557d12/sets/core/step.py#L31-L39 | [
"def",
"directory",
"(",
"cls",
",",
"prefix",
"=",
"None",
")",
":",
"prefix",
"=",
"prefix",
"or",
"utility",
".",
"read_config",
"(",
")",
".",
"directory",
"name",
"=",
"cls",
".",
"__name__",
".",
"lower",
"(",
")",
"directory",
"=",
"os",
".",
... | 2542c28f43d0af18932cb5b82f54ffb6ae557d12 |
train | get_last_rconfiguration_id | Get the rconfiguration_id of the last job run by the remoteci.
:param topic_id: the topic
:param remoteci_id: the remoteci id
:return: last rconfiguration_id of the remoteci | dci/api/v1/remotecis.py | def get_last_rconfiguration_id(topic_id, remoteci_id, db_conn=None):
"""Get the rconfiguration_id of the last job run by the remoteci.
:param topic_id: the topic
:param remoteci_id: the remoteci id
:return: last rconfiguration_id of the remoteci
"""
db_conn = db_conn or flask.g.db_conn
__TA... | def get_last_rconfiguration_id(topic_id, remoteci_id, db_conn=None):
"""Get the rconfiguration_id of the last job run by the remoteci.
:param topic_id: the topic
:param remoteci_id: the remoteci id
:return: last rconfiguration_id of the remoteci
"""
db_conn = db_conn or flask.g.db_conn
__TA... | [
"Get",
"the",
"rconfiguration_id",
"of",
"the",
"last",
"job",
"run",
"by",
"the",
"remoteci",
"."
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/remotecis.py#L409-L427 | [
"def",
"get_last_rconfiguration_id",
"(",
"topic_id",
",",
"remoteci_id",
",",
"db_conn",
"=",
"None",
")",
":",
"db_conn",
"=",
"db_conn",
"or",
"flask",
".",
"g",
".",
"db_conn",
"__TABLE",
"=",
"models",
".",
"JOBS",
"query",
"=",
"sql",
".",
"select",
... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | get_remoteci_configuration | Get a remoteci configuration. This will iterate over each
configuration in a round robin manner depending on the last
rconfiguration used by the remoteci. | dci/api/v1/remotecis.py | def get_remoteci_configuration(topic_id, remoteci_id, db_conn=None):
"""Get a remoteci configuration. This will iterate over each
configuration in a round robin manner depending on the last
rconfiguration used by the remoteci."""
db_conn = db_conn or flask.g.db_conn
last_rconfiguration_id = get_las... | def get_remoteci_configuration(topic_id, remoteci_id, db_conn=None):
"""Get a remoteci configuration. This will iterate over each
configuration in a round robin manner depending on the last
rconfiguration used by the remoteci."""
db_conn = db_conn or flask.g.db_conn
last_rconfiguration_id = get_las... | [
"Get",
"a",
"remoteci",
"configuration",
".",
"This",
"will",
"iterate",
"over",
"each",
"configuration",
"in",
"a",
"round",
"robin",
"manner",
"depending",
"on",
"the",
"last",
"rconfiguration",
"used",
"by",
"the",
"remoteci",
"."
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/remotecis.py#L430-L457 | [
"def",
"get_remoteci_configuration",
"(",
"topic_id",
",",
"remoteci_id",
",",
"db_conn",
"=",
"None",
")",
":",
"db_conn",
"=",
"db_conn",
"or",
"flask",
".",
"g",
".",
"db_conn",
"last_rconfiguration_id",
"=",
"get_last_rconfiguration_id",
"(",
"topic_id",
",",
... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | CommandProcessor.send | Dispatches a request. Expects one and one only target handler
:param request: The request to dispatch
:return: None, will throw a ConfigurationException if more than one handler factor is registered for the command | brightside/command_processor.py | def send(self, request: Request) -> None:
"""
Dispatches a request. Expects one and one only target handler
:param request: The request to dispatch
:return: None, will throw a ConfigurationException if more than one handler factor is registered for the command
"""
handle... | def send(self, request: Request) -> None:
"""
Dispatches a request. Expects one and one only target handler
:param request: The request to dispatch
:return: None, will throw a ConfigurationException if more than one handler factor is registered for the command
"""
handle... | [
"Dispatches",
"a",
"request",
".",
"Expects",
"one",
"and",
"one",
"only",
"target",
"handler",
":",
"param",
"request",
":",
"The",
"request",
"to",
"dispatch",
":",
"return",
":",
"None",
"will",
"throw",
"a",
"ConfigurationException",
"if",
"more",
"than"... | BrighterCommand/Brightside | python | https://github.com/BrighterCommand/Brightside/blob/53b2f8323c3972609010a7386130249f3758f5fb/brightside/command_processor.py#L54-L65 | [
"def",
"send",
"(",
"self",
",",
"request",
":",
"Request",
")",
"->",
"None",
":",
"handler_factories",
"=",
"self",
".",
"_registry",
".",
"lookup",
"(",
"request",
")",
"if",
"len",
"(",
"handler_factories",
")",
"!=",
"1",
":",
"raise",
"Configuratio... | 53b2f8323c3972609010a7386130249f3758f5fb |
train | CommandProcessor.publish | Dispatches a request. Expects zero or more target handlers
:param request: The request to dispatch
:return: None. | brightside/command_processor.py | def publish(self, request: Request) -> None:
"""
Dispatches a request. Expects zero or more target handlers
:param request: The request to dispatch
:return: None.
"""
handler_factories = self._registry.lookup(request)
for factory in handler_factories:
... | def publish(self, request: Request) -> None:
"""
Dispatches a request. Expects zero or more target handlers
:param request: The request to dispatch
:return: None.
"""
handler_factories = self._registry.lookup(request)
for factory in handler_factories:
... | [
"Dispatches",
"a",
"request",
".",
"Expects",
"zero",
"or",
"more",
"target",
"handlers",
":",
"param",
"request",
":",
"The",
"request",
"to",
"dispatch",
":",
"return",
":",
"None",
"."
] | BrighterCommand/Brightside | python | https://github.com/BrighterCommand/Brightside/blob/53b2f8323c3972609010a7386130249f3758f5fb/brightside/command_processor.py#L67-L76 | [
"def",
"publish",
"(",
"self",
",",
"request",
":",
"Request",
")",
"->",
"None",
":",
"handler_factories",
"=",
"self",
".",
"_registry",
".",
"lookup",
"(",
"request",
")",
"for",
"factory",
"in",
"handler_factories",
":",
"handler",
"=",
"factory",
"(",... | 53b2f8323c3972609010a7386130249f3758f5fb |
train | CommandProcessor.post | Dispatches a request over middleware. Returns when message put onto outgoing channel by producer,
does not wait for response from a consuming application i.e. is fire-and-forget
:param request: The request to dispatch
:return: None | brightside/command_processor.py | def post(self, request: Request) -> None:
"""
Dispatches a request over middleware. Returns when message put onto outgoing channel by producer,
does not wait for response from a consuming application i.e. is fire-and-forget
:param request: The request to dispatch
:return: None
... | def post(self, request: Request) -> None:
"""
Dispatches a request over middleware. Returns when message put onto outgoing channel by producer,
does not wait for response from a consuming application i.e. is fire-and-forget
:param request: The request to dispatch
:return: None
... | [
"Dispatches",
"a",
"request",
"over",
"middleware",
".",
"Returns",
"when",
"message",
"put",
"onto",
"outgoing",
"channel",
"by",
"producer",
"does",
"not",
"wait",
"for",
"response",
"from",
"a",
"consuming",
"application",
"i",
".",
"e",
".",
"is",
"fire"... | BrighterCommand/Brightside | python | https://github.com/BrighterCommand/Brightside/blob/53b2f8323c3972609010a7386130249f3758f5fb/brightside/command_processor.py#L78-L94 | [
"def",
"post",
"(",
"self",
",",
"request",
":",
"Request",
")",
"->",
"None",
":",
"if",
"self",
".",
"_producer",
"is",
"None",
":",
"raise",
"ConfigurationException",
"(",
"\"Command Processor requires a BrightsideProducer to post to a Broker\"",
")",
"if",
"self... | 53b2f8323c3972609010a7386130249f3758f5fb |
train | XmlImplAdapter.ignore_whitespace_text_nodes | Find and delete any text nodes containing nothing but whitespace in
in the given node and its descendents.
This is useful for cleaning up excess low-value text nodes in a
document DOM after parsing a pretty-printed XML document. | xml4h/impls/interface.py | def ignore_whitespace_text_nodes(cls, wrapped_node):
"""
Find and delete any text nodes containing nothing but whitespace in
in the given node and its descendents.
This is useful for cleaning up excess low-value text nodes in a
document DOM after parsing a pretty-printed XML doc... | def ignore_whitespace_text_nodes(cls, wrapped_node):
"""
Find and delete any text nodes containing nothing but whitespace in
in the given node and its descendents.
This is useful for cleaning up excess low-value text nodes in a
document DOM after parsing a pretty-printed XML doc... | [
"Find",
"and",
"delete",
"any",
"text",
"nodes",
"containing",
"nothing",
"but",
"whitespace",
"in",
"in",
"the",
"given",
"node",
"and",
"its",
"descendents",
"."
] | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/impls/interface.py#L32-L44 | [
"def",
"ignore_whitespace_text_nodes",
"(",
"cls",
",",
"wrapped_node",
")",
":",
"for",
"child",
"in",
"wrapped_node",
".",
"children",
":",
"if",
"child",
".",
"is_text",
"and",
"child",
".",
"value",
".",
"strip",
"(",
")",
"==",
"''",
":",
"child",
"... | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | XmlImplAdapter.get_ns_info_from_node_name | Return a three-element tuple with the prefix, local name, and namespace
URI for the given element/attribute name (in the context of the given
node's hierarchy). If the name has no associated prefix or namespace
information, None is return for those tuple members. | xml4h/impls/interface.py | def get_ns_info_from_node_name(self, name, impl_node):
"""
Return a three-element tuple with the prefix, local name, and namespace
URI for the given element/attribute name (in the context of the given
node's hierarchy). If the name has no associated prefix or namespace
informatio... | def get_ns_info_from_node_name(self, name, impl_node):
"""
Return a three-element tuple with the prefix, local name, and namespace
URI for the given element/attribute name (in the context of the given
node's hierarchy). If the name has no associated prefix or namespace
informatio... | [
"Return",
"a",
"three",
"-",
"element",
"tuple",
"with",
"the",
"prefix",
"local",
"name",
"and",
"namespace",
"URI",
"for",
"the",
"given",
"element",
"/",
"attribute",
"name",
"(",
"in",
"the",
"context",
"of",
"the",
"given",
"node",
"s",
"hierarchy",
... | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/impls/interface.py#L141-L161 | [
"def",
"get_ns_info_from_node_name",
"(",
"self",
",",
"name",
",",
"impl_node",
")",
":",
"if",
"'}'",
"in",
"name",
":",
"ns_uri",
",",
"name",
"=",
"name",
".",
"split",
"(",
"'}'",
")",
"ns_uri",
"=",
"ns_uri",
"[",
"1",
":",
"]",
"prefix",
"=",
... | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | Builder.up | :return: a builder representing an ancestor of the current element,
by default the parent element.
:param count: return the n'th ancestor element; defaults to 1 which
means the immediate parent. If *count* is greater than the number
of number of ancestors return the doc... | xml4h/builder.py | def up(self, count=1, to_name=None):
"""
:return: a builder representing an ancestor of the current element,
by default the parent element.
:param count: return the n'th ancestor element; defaults to 1 which
means the immediate parent. If *count* is greater than the... | def up(self, count=1, to_name=None):
"""
:return: a builder representing an ancestor of the current element,
by default the parent element.
:param count: return the n'th ancestor element; defaults to 1 which
means the immediate parent. If *count* is greater than the... | [
":",
"return",
":",
"a",
"builder",
"representing",
"an",
"ancestor",
"of",
"the",
"current",
"element",
"by",
"default",
"the",
"parent",
"element",
"."
] | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/builder.py#L103-L131 | [
"def",
"up",
"(",
"self",
",",
"count",
"=",
"1",
",",
"to_name",
"=",
"None",
")",
":",
"elem",
"=",
"self",
".",
"_element",
"up_count",
"=",
"0",
"while",
"True",
":",
"# Don't go up beyond the document root",
"if",
"elem",
".",
"is_root",
"or",
"elem... | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | Builder.element | Add a child element to the :class:`xml4h.nodes.Element` node
represented by this Builder.
:return: a new Builder that represents the child element.
Delegates to :meth:`xml4h.nodes.Element.add_element`. | xml4h/builder.py | def element(self, *args, **kwargs):
"""
Add a child element to the :class:`xml4h.nodes.Element` node
represented by this Builder.
:return: a new Builder that represents the child element.
Delegates to :meth:`xml4h.nodes.Element.add_element`.
"""
child_element = ... | def element(self, *args, **kwargs):
"""
Add a child element to the :class:`xml4h.nodes.Element` node
represented by this Builder.
:return: a new Builder that represents the child element.
Delegates to :meth:`xml4h.nodes.Element.add_element`.
"""
child_element = ... | [
"Add",
"a",
"child",
"element",
"to",
"the",
":",
"class",
":",
"xml4h",
".",
"nodes",
".",
"Element",
"node",
"represented",
"by",
"this",
"Builder",
"."
] | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/builder.py#L159-L169 | [
"def",
"element",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"child_element",
"=",
"self",
".",
"_element",
".",
"add_element",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"return",
"Builder",
"(",
"child_element",
")"
] | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | Builder.attributes | Add one or more attributes to the :class:`xml4h.nodes.Element` node
represented by this Builder.
:return: the current Builder.
Delegates to :meth:`xml4h.nodes.Element.set_attributes`. | xml4h/builder.py | def attributes(self, *args, **kwargs):
"""
Add one or more attributes to the :class:`xml4h.nodes.Element` node
represented by this Builder.
:return: the current Builder.
Delegates to :meth:`xml4h.nodes.Element.set_attributes`.
"""
self._element.set_attributes(*a... | def attributes(self, *args, **kwargs):
"""
Add one or more attributes to the :class:`xml4h.nodes.Element` node
represented by this Builder.
:return: the current Builder.
Delegates to :meth:`xml4h.nodes.Element.set_attributes`.
"""
self._element.set_attributes(*a... | [
"Add",
"one",
"or",
"more",
"attributes",
"to",
"the",
":",
"class",
":",
"xml4h",
".",
"nodes",
".",
"Element",
"node",
"represented",
"by",
"this",
"Builder",
"."
] | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/builder.py#L177-L187 | [
"def",
"attributes",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_element",
".",
"set_attributes",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"return",
"self"
] | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | Builder.processing_instruction | Add a processing instruction node to the :class:`xml4h.nodes.Element`
node represented by this Builder.
:return: the current Builder.
Delegates to :meth:`xml4h.nodes.Element.add_instruction`. | xml4h/builder.py | def processing_instruction(self, target, data):
"""
Add a processing instruction node to the :class:`xml4h.nodes.Element`
node represented by this Builder.
:return: the current Builder.
Delegates to :meth:`xml4h.nodes.Element.add_instruction`.
"""
self._element.... | def processing_instruction(self, target, data):
"""
Add a processing instruction node to the :class:`xml4h.nodes.Element`
node represented by this Builder.
:return: the current Builder.
Delegates to :meth:`xml4h.nodes.Element.add_instruction`.
"""
self._element.... | [
"Add",
"a",
"processing",
"instruction",
"node",
"to",
"the",
":",
"class",
":",
"xml4h",
".",
"nodes",
".",
"Element",
"node",
"represented",
"by",
"this",
"Builder",
"."
] | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/builder.py#L225-L235 | [
"def",
"processing_instruction",
"(",
"self",
",",
"target",
",",
"data",
")",
":",
"self",
".",
"_element",
".",
"add_instruction",
"(",
"target",
",",
"data",
")",
"return",
"self"
] | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | Builder.ns_prefix | Set the namespace prefix of the :class:`xml4h.nodes.Element` node
represented by this Builder.
:return: the current Builder.
Delegates to :meth:`xml4h.nodes.Element.set_ns_prefix`. | xml4h/builder.py | def ns_prefix(self, prefix, ns_uri):
"""
Set the namespace prefix of the :class:`xml4h.nodes.Element` node
represented by this Builder.
:return: the current Builder.
Delegates to :meth:`xml4h.nodes.Element.set_ns_prefix`.
"""
self._element.set_ns_prefix(prefix, ... | def ns_prefix(self, prefix, ns_uri):
"""
Set the namespace prefix of the :class:`xml4h.nodes.Element` node
represented by this Builder.
:return: the current Builder.
Delegates to :meth:`xml4h.nodes.Element.set_ns_prefix`.
"""
self._element.set_ns_prefix(prefix, ... | [
"Set",
"the",
"namespace",
"prefix",
"of",
"the",
":",
"class",
":",
"xml4h",
".",
"nodes",
".",
"Element",
"node",
"represented",
"by",
"this",
"Builder",
"."
] | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/builder.py#L261-L271 | [
"def",
"ns_prefix",
"(",
"self",
",",
"prefix",
",",
"ns_uri",
")",
":",
"self",
".",
"_element",
".",
"set_ns_prefix",
"(",
"prefix",
",",
"ns_uri",
")",
"return",
"self"
] | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | createCertRequest | Create a certificate request.
Arguments: pkey - The key to associate with the request
digest - Digestion method to use for signing, default is sha256
**name - The name of the subject of the request, possible
arguments are:
C - Cou... | dci/api/v1/utils.py | def createCertRequest(pkey, digest="sha256"):
"""
Create a certificate request.
Arguments: pkey - The key to associate with the request
digest - Digestion method to use for signing, default is sha256
**name - The name of the subject of the request, possible
... | def createCertRequest(pkey, digest="sha256"):
"""
Create a certificate request.
Arguments: pkey - The key to associate with the request
digest - Digestion method to use for signing, default is sha256
**name - The name of the subject of the request, possible
... | [
"Create",
"a",
"certificate",
"request",
".",
"Arguments",
":",
"pkey",
"-",
"The",
"key",
"to",
"associate",
"with",
"the",
"request",
"digest",
"-",
"Digestion",
"method",
"to",
"use",
"for",
"signing",
"default",
"is",
"sha256",
"**",
"name",
"-",
"The"... | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/utils.py#L41-L68 | [
"def",
"createCertRequest",
"(",
"pkey",
",",
"digest",
"=",
"\"sha256\"",
")",
":",
"req",
"=",
"crypto",
".",
"X509Req",
"(",
")",
"req",
".",
"get_subject",
"(",
")",
".",
"C",
"=",
"\"FR\"",
"req",
".",
"get_subject",
"(",
")",
".",
"ST",
"=",
... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | verify_existence_and_get | Verify the existence of a resource in the database and then
return it if it exists, according to the condition, or raise an
exception.
:param id: id of the resource
:param table: the table object
:param name: the name of the row to look for
:param get_id: if True, return only the ID
:return... | dci/api/v1/utils.py | def verify_existence_and_get(id, table, name=None, get_id=False):
"""Verify the existence of a resource in the database and then
return it if it exists, according to the condition, or raise an
exception.
:param id: id of the resource
:param table: the table object
:param name: the name of the r... | def verify_existence_and_get(id, table, name=None, get_id=False):
"""Verify the existence of a resource in the database and then
return it if it exists, according to the condition, or raise an
exception.
:param id: id of the resource
:param table: the table object
:param name: the name of the r... | [
"Verify",
"the",
"existence",
"of",
"a",
"resource",
"in",
"the",
"database",
"and",
"then",
"return",
"it",
"if",
"it",
"exists",
"according",
"to",
"the",
"condition",
"or",
"raise",
"an",
"exception",
"."
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/utils.py#L91-L118 | [
"def",
"verify_existence_and_get",
"(",
"id",
",",
"table",
",",
"name",
"=",
"None",
",",
"get_id",
"=",
"False",
")",
":",
"where_clause",
"=",
"table",
".",
"c",
".",
"id",
"==",
"id",
"if",
"name",
":",
"where_clause",
"=",
"table",
".",
"c",
"."... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | user_topic_ids | Retrieve the list of topics IDs a user has access to. | dci/api/v1/utils.py | def user_topic_ids(user):
"""Retrieve the list of topics IDs a user has access to."""
if user.is_super_admin() or user.is_read_only_user():
query = sql.select([models.TOPICS])
else:
query = (sql.select([models.JOINS_TOPICS_TEAMS.c.topic_id])
.select_from(
... | def user_topic_ids(user):
"""Retrieve the list of topics IDs a user has access to."""
if user.is_super_admin() or user.is_read_only_user():
query = sql.select([models.TOPICS])
else:
query = (sql.select([models.JOINS_TOPICS_TEAMS.c.topic_id])
.select_from(
... | [
"Retrieve",
"the",
"list",
"of",
"topics",
"IDs",
"a",
"user",
"has",
"access",
"to",
"."
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/utils.py#L121-L137 | [
"def",
"user_topic_ids",
"(",
"user",
")",
":",
"if",
"user",
".",
"is_super_admin",
"(",
")",
"or",
"user",
".",
"is_read_only_user",
"(",
")",
":",
"query",
"=",
"sql",
".",
"select",
"(",
"[",
"models",
".",
"TOPICS",
"]",
")",
"else",
":",
"query... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | verify_team_in_topic | Verify that the user's team does belongs to the given topic. If
the user is an admin or read only user then it belongs to all topics. | dci/api/v1/utils.py | def verify_team_in_topic(user, topic_id):
"""Verify that the user's team does belongs to the given topic. If
the user is an admin or read only user then it belongs to all topics.
"""
if user.is_super_admin() or user.is_read_only_user():
return
if str(topic_id) not in user_topic_ids(user):
... | def verify_team_in_topic(user, topic_id):
"""Verify that the user's team does belongs to the given topic. If
the user is an admin or read only user then it belongs to all topics.
"""
if user.is_super_admin() or user.is_read_only_user():
return
if str(topic_id) not in user_topic_ids(user):
... | [
"Verify",
"that",
"the",
"user",
"s",
"team",
"does",
"belongs",
"to",
"the",
"given",
"topic",
".",
"If",
"the",
"user",
"is",
"an",
"admin",
"or",
"read",
"only",
"user",
"then",
"it",
"belongs",
"to",
"all",
"topics",
"."
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/utils.py#L140-L147 | [
"def",
"verify_team_in_topic",
"(",
"user",
",",
"topic_id",
")",
":",
"if",
"user",
".",
"is_super_admin",
"(",
")",
"or",
"user",
".",
"is_read_only_user",
"(",
")",
":",
"return",
"if",
"str",
"(",
"topic_id",
")",
"not",
"in",
"user_topic_ids",
"(",
... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | _format_level_1 | Transform sqlalchemy source:
[{'a_id' : 'id1',
'a_name' : 'name1,
'b_id' : 'id2',
'b_name' : 'name2},
{'a_id' : 'id3',
'a_name' : 'name3,
'b_id' : 'id4',
'b_name' : 'name4}
]
to
[{'id' : 'id1',
'name': 'name2',
'b' : {'id': 'id2', 'name': 'name2'},
... | dci/api/v1/utils.py | def _format_level_1(rows, root_table_name):
"""
Transform sqlalchemy source:
[{'a_id' : 'id1',
'a_name' : 'name1,
'b_id' : 'id2',
'b_name' : 'name2},
{'a_id' : 'id3',
'a_name' : 'name3,
'b_id' : 'id4',
'b_name' : 'name4}
]
to
[{'id' : 'id1',
'name':... | def _format_level_1(rows, root_table_name):
"""
Transform sqlalchemy source:
[{'a_id' : 'id1',
'a_name' : 'name1,
'b_id' : 'id2',
'b_name' : 'name2},
{'a_id' : 'id3',
'a_name' : 'name3,
'b_id' : 'id4',
'b_name' : 'name4}
]
to
[{'id' : 'id1',
'name':... | [
"Transform",
"sqlalchemy",
"source",
":",
"[",
"{",
"a_id",
":",
"id1",
"a_name",
":",
"name1",
"b_id",
":",
"id2",
"b_name",
":",
"name2",
"}",
"{",
"a_id",
":",
"id3",
"a_name",
":",
"name3",
"b_id",
":",
"id4",
"b_name",
":",
"name4",
"}",
"]",
... | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/utils.py#L417-L463 | [
"def",
"_format_level_1",
"(",
"rows",
",",
"root_table_name",
")",
":",
"result_rows",
"=",
"[",
"]",
"for",
"row",
"in",
"rows",
":",
"row",
"=",
"dict",
"(",
"row",
")",
"result_row",
"=",
"{",
"}",
"prefixes_to_remove",
"=",
"[",
"]",
"for",
"field... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | _format_level_2 | From the _format_level_1 function we have a list of rows. Because of using
joins, we have as many rows as join result.
For example:
[{'id' : 'id1',
'name' : 'name1,
'b' : {'id': 'id2,
'name': 'name2'}
}
{'id' : 'id1',
'name' : 'name1,
'b' : {'id' : 'id4',
... | dci/api/v1/utils.py | def _format_level_2(rows, list_embeds, embed_many):
"""
From the _format_level_1 function we have a list of rows. Because of using
joins, we have as many rows as join result.
For example:
[{'id' : 'id1',
'name' : 'name1,
'b' : {'id': 'id2,
'name': 'name2'}
}
{'id'... | def _format_level_2(rows, list_embeds, embed_many):
"""
From the _format_level_1 function we have a list of rows. Because of using
joins, we have as many rows as join result.
For example:
[{'id' : 'id1',
'name' : 'name1,
'b' : {'id': 'id2,
'name': 'name2'}
}
{'id'... | [
"From",
"the",
"_format_level_1",
"function",
"we",
"have",
"a",
"list",
"of",
"rows",
".",
"Because",
"of",
"using",
"joins",
"we",
"have",
"as",
"many",
"rows",
"as",
"join",
"result",
"."
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/utils.py#L466-L575 | [
"def",
"_format_level_2",
"(",
"rows",
",",
"list_embeds",
",",
"embed_many",
")",
":",
"def",
"_uniqify_list",
"(",
"list_of_dicts",
")",
":",
"# list() for py34",
"result",
"=",
"[",
"]",
"set_ids",
"=",
"set",
"(",
")",
"for",
"v",
"in",
"list_of_dicts",
... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | common_values_dict | Build a basic values object used in every create method.
All our resources contain a same subset of value. Instead of
redoing this code everytime, this method ensures it is done only at
one place. | dci/api/v1/utils.py | def common_values_dict():
"""Build a basic values object used in every create method.
All our resources contain a same subset of value. Instead of
redoing this code everytime, this method ensures it is done only at
one place.
"""
now = datetime.datetime.utcnow().isoformat()
etag = ... | def common_values_dict():
"""Build a basic values object used in every create method.
All our resources contain a same subset of value. Instead of
redoing this code everytime, this method ensures it is done only at
one place.
"""
now = datetime.datetime.utcnow().isoformat()
etag = ... | [
"Build",
"a",
"basic",
"values",
"object",
"used",
"in",
"every",
"create",
"method",
"."
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/utils.py#L586-L602 | [
"def",
"common_values_dict",
"(",
")",
":",
"now",
"=",
"datetime",
".",
"datetime",
".",
"utcnow",
"(",
")",
".",
"isoformat",
"(",
")",
"etag",
"=",
"utils",
".",
"gen_etag",
"(",
")",
"values",
"=",
"{",
"'id'",
":",
"utils",
".",
"gen_uuid",
"(",... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | QueryBuilder.execute | :param fetchall: get all rows
:param fetchone: get only one row
:param use_labels: prefix row columns names by the table name
:return: | dci/api/v1/utils.py | def execute(self, fetchall=False, fetchone=False, use_labels=True):
"""
:param fetchall: get all rows
:param fetchone: get only one row
:param use_labels: prefix row columns names by the table name
:return:
"""
query = self.get_query(use_labels=use_labels)
... | def execute(self, fetchall=False, fetchone=False, use_labels=True):
"""
:param fetchall: get all rows
:param fetchone: get only one row
:param use_labels: prefix row columns names by the table name
:return:
"""
query = self.get_query(use_labels=use_labels)
... | [
":",
"param",
"fetchall",
":",
"get",
"all",
"rows",
":",
"param",
"fetchone",
":",
"get",
"only",
"one",
"row",
":",
"param",
"use_labels",
":",
"prefix",
"row",
"columns",
"names",
"by",
"the",
"table",
"name",
":",
"return",
":"
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/utils.py#L399-L410 | [
"def",
"execute",
"(",
"self",
",",
"fetchall",
"=",
"False",
",",
"fetchone",
"=",
"False",
",",
"use_labels",
"=",
"True",
")",
":",
"query",
"=",
"self",
".",
"get_query",
"(",
"use_labels",
"=",
"use_labels",
")",
"if",
"fetchall",
":",
"return",
"... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | get_identity | Returns some information about the currently authenticated identity | dci/api/v1/identity.py | def get_identity(identity):
"""Returns some information about the currently authenticated identity"""
return flask.Response(
json.dumps(
{
'identity': {
'id': identity.id,
'etag': identity.etag,
'name': identity.name... | def get_identity(identity):
"""Returns some information about the currently authenticated identity"""
return flask.Response(
json.dumps(
{
'identity': {
'id': identity.id,
'etag': identity.etag,
'name': identity.name... | [
"Returns",
"some",
"information",
"about",
"the",
"currently",
"authenticated",
"identity"
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/identity.py#L36-L54 | [
"def",
"get_identity",
"(",
"identity",
")",
":",
"return",
"flask",
".",
"Response",
"(",
"json",
".",
"dumps",
"(",
"{",
"'identity'",
":",
"{",
"'id'",
":",
"identity",
".",
"id",
",",
"'etag'",
":",
"identity",
".",
"etag",
",",
"'name'",
":",
"i... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | get_issues_by_resource | Get all issues for a specific job. | dci/api/v1/issues.py | def get_issues_by_resource(resource_id, table):
"""Get all issues for a specific job."""
v1_utils.verify_existence_and_get(resource_id, table)
# When retrieving the issues for a job, we actually retrieve
# the issues attach to the job itself + the issues attached to
# the components the job has be... | def get_issues_by_resource(resource_id, table):
"""Get all issues for a specific job."""
v1_utils.verify_existence_and_get(resource_id, table)
# When retrieving the issues for a job, we actually retrieve
# the issues attach to the job itself + the issues attached to
# the components the job has be... | [
"Get",
"all",
"issues",
"for",
"a",
"specific",
"job",
"."
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/issues.py#L63-L127 | [
"def",
"get_issues_by_resource",
"(",
"resource_id",
",",
"table",
")",
":",
"v1_utils",
".",
"verify_existence_and_get",
"(",
"resource_id",
",",
"table",
")",
"# When retrieving the issues for a job, we actually retrieve",
"# the issues attach to the job itself + the issues attac... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | unattach_issue | Unattach an issue from a specific job. | dci/api/v1/issues.py | def unattach_issue(resource_id, issue_id, table):
"""Unattach an issue from a specific job."""
v1_utils.verify_existence_and_get(issue_id, _TABLE)
if table.name == 'jobs':
join_table = models.JOIN_JOBS_ISSUES
where_clause = sql.and_(join_table.c.job_id == resource_id,
... | def unattach_issue(resource_id, issue_id, table):
"""Unattach an issue from a specific job."""
v1_utils.verify_existence_and_get(issue_id, _TABLE)
if table.name == 'jobs':
join_table = models.JOIN_JOBS_ISSUES
where_clause = sql.and_(join_table.c.job_id == resource_id,
... | [
"Unattach",
"an",
"issue",
"from",
"a",
"specific",
"job",
"."
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/issues.py#L130-L149 | [
"def",
"unattach_issue",
"(",
"resource_id",
",",
"issue_id",
",",
"table",
")",
":",
"v1_utils",
".",
"verify_existence_and_get",
"(",
"issue_id",
",",
"_TABLE",
")",
"if",
"table",
".",
"name",
"==",
"'jobs'",
":",
"join_table",
"=",
"models",
".",
"JOIN_J... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | attach_issue | Attach an issue to a specific job. | dci/api/v1/issues.py | def attach_issue(resource_id, table, user_id):
"""Attach an issue to a specific job."""
data = schemas.issue.post(flask.request.json)
issue = _get_or_create_issue(data)
# Second, insert a join record in the JOIN_JOBS_ISSUES or
# JOIN_COMPONENTS_ISSUES database.
if table.name == 'jobs':
... | def attach_issue(resource_id, table, user_id):
"""Attach an issue to a specific job."""
data = schemas.issue.post(flask.request.json)
issue = _get_or_create_issue(data)
# Second, insert a join record in the JOIN_JOBS_ISSUES or
# JOIN_COMPONENTS_ISSUES database.
if table.name == 'jobs':
... | [
"Attach",
"an",
"issue",
"to",
"a",
"specific",
"job",
"."
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/issues.py#L152-L178 | [
"def",
"attach_issue",
"(",
"resource_id",
",",
"table",
",",
"user_id",
")",
":",
"data",
"=",
"schemas",
".",
"issue",
".",
"post",
"(",
"flask",
".",
"request",
".",
"json",
")",
"issue",
"=",
"_get_or_create_issue",
"(",
"data",
")",
"# Second, insert ... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | collect_staticroot_removal | Remove collect's static root folder from list. | invenio_assets/collect.py | def collect_staticroot_removal(app, blueprints):
"""Remove collect's static root folder from list."""
collect_root = app.extensions['collect'].static_root
return [bp for bp in blueprints if (
bp.has_static_folder and bp.static_folder != collect_root)] | def collect_staticroot_removal(app, blueprints):
"""Remove collect's static root folder from list."""
collect_root = app.extensions['collect'].static_root
return [bp for bp in blueprints if (
bp.has_static_folder and bp.static_folder != collect_root)] | [
"Remove",
"collect",
"s",
"static",
"root",
"folder",
"from",
"list",
"."
] | inveniosoftware/invenio-assets | python | https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/collect.py#L14-L18 | [
"def",
"collect_staticroot_removal",
"(",
"app",
",",
"blueprints",
")",
":",
"collect_root",
"=",
"app",
".",
"extensions",
"[",
"'collect'",
"]",
".",
"static_root",
"return",
"[",
"bp",
"for",
"bp",
"in",
"blueprints",
"if",
"(",
"bp",
".",
"has_static_fo... | 836cc75ebe0c179f0d72456bd8b784cdc18394a6 |
train | get_all_jobstates | Get all jobstates. | dci/api/v1/jobstates.py | def get_all_jobstates(user, job_id):
"""Get all jobstates.
"""
args = schemas.args(flask.request.args.to_dict())
job = v1_utils.verify_existence_and_get(job_id, models.JOBS)
if user.is_not_super_admin() and user.is_not_read_only_user():
if (job['team_id'] not in user.teams_ids and
... | def get_all_jobstates(user, job_id):
"""Get all jobstates.
"""
args = schemas.args(flask.request.args.to_dict())
job = v1_utils.verify_existence_and_get(job_id, models.JOBS)
if user.is_not_super_admin() and user.is_not_read_only_user():
if (job['team_id'] not in user.teams_ids and
... | [
"Get",
"all",
"jobstates",
"."
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/jobstates.py#L100-L118 | [
"def",
"get_all_jobstates",
"(",
"user",
",",
"job_id",
")",
":",
"args",
"=",
"schemas",
".",
"args",
"(",
"flask",
".",
"request",
".",
"args",
".",
"to_dict",
"(",
")",
")",
"job",
"=",
"v1_utils",
".",
"verify_existence_and_get",
"(",
"job_id",
",",
... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | create_client | Create the dci client in the master realm. | bin/keycloak-provision.py | def create_client(access_token):
"""Create the dci client in the master realm."""
url = 'http://keycloak:8080/auth/admin/realms/dci-test/clients'
r = requests.post(url,
data=json.dumps(client_data),
headers=get_auth_headers(access_token))
if r.status_code in (... | def create_client(access_token):
"""Create the dci client in the master realm."""
url = 'http://keycloak:8080/auth/admin/realms/dci-test/clients'
r = requests.post(url,
data=json.dumps(client_data),
headers=get_auth_headers(access_token))
if r.status_code in (... | [
"Create",
"the",
"dci",
"client",
"in",
"the",
"master",
"realm",
"."
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/bin/keycloak-provision.py#L193-L205 | [
"def",
"create_client",
"(",
"access_token",
")",
":",
"url",
"=",
"'http://keycloak:8080/auth/admin/realms/dci-test/clients'",
"r",
"=",
"requests",
".",
"post",
"(",
"url",
",",
"data",
"=",
"json",
".",
"dumps",
"(",
"client_data",
")",
",",
"headers",
"=",
... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | create_user_dci | Create the a dci user.
username=dci, password=dci, email=dci@distributed-ci.io | bin/keycloak-provision.py | def create_user_dci(access_token):
"""Create the a dci user.
username=dci, password=dci, email=dci@distributed-ci.io"""
user_data = {'username': 'dci',
'email': 'dci@distributed-ci.io',
'enabled': True,
'emailVerified': True,
'credentials':... | def create_user_dci(access_token):
"""Create the a dci user.
username=dci, password=dci, email=dci@distributed-ci.io"""
user_data = {'username': 'dci',
'email': 'dci@distributed-ci.io',
'enabled': True,
'emailVerified': True,
'credentials':... | [
"Create",
"the",
"a",
"dci",
"user",
".",
"username",
"=",
"dci",
"password",
"=",
"dci",
"email",
"=",
"dci"
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/bin/keycloak-provision.py#L208-L224 | [
"def",
"create_user_dci",
"(",
"access_token",
")",
":",
"user_data",
"=",
"{",
"'username'",
":",
"'dci'",
",",
"'email'",
":",
"'dci@distributed-ci.io'",
",",
"'enabled'",
":",
"True",
",",
"'emailVerified'",
":",
"True",
",",
"'credentials'",
":",
"[",
"{",... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | SiteInfo.initialize | The name of the site. : str | `None` | mwxml/iteration/site_info.py | def initialize(self, name=None, dbname=None, base=None, generator=None,
case=None, namespaces=None):
self.name = none_or(name, str)
"""
The name of the site. : str | `None`
"""
self.dbname = none_or(dbname, str)
"""
The dbname of the site. : s... | def initialize(self, name=None, dbname=None, base=None, generator=None,
case=None, namespaces=None):
self.name = none_or(name, str)
"""
The name of the site. : str | `None`
"""
self.dbname = none_or(dbname, str)
"""
The dbname of the site. : s... | [
"The",
"name",
"of",
"the",
"site",
".",
":",
"str",
"|",
"None"
] | mediawiki-utilities/python-mwxml | python | https://github.com/mediawiki-utilities/python-mwxml/blob/6a8c18be99cd0bcee9c496e607f08bf4dfe5b510/mwxml/iteration/site_info.py#L32-L63 | [
"def",
"initialize",
"(",
"self",
",",
"name",
"=",
"None",
",",
"dbname",
"=",
"None",
",",
"base",
"=",
"None",
",",
"generator",
"=",
"None",
",",
"case",
"=",
"None",
",",
"namespaces",
"=",
"None",
")",
":",
"self",
".",
"name",
"=",
"none_or"... | 6a8c18be99cd0bcee9c496e607f08bf4dfe5b510 |
train | Pingdom._serializeBooleans | Convert all booleans to lowercase strings | pingdomlib/pingdom.py | def _serializeBooleans(params):
""""Convert all booleans to lowercase strings"""
serialized = {}
for name, value in params.items():
if value is True:
value = 'true'
elif value is False:
value = 'false'
serialized[name] = value
... | def _serializeBooleans(params):
""""Convert all booleans to lowercase strings"""
serialized = {}
for name, value in params.items():
if value is True:
value = 'true'
elif value is False:
value = 'false'
serialized[name] = value
... | [
"Convert",
"all",
"booleans",
"to",
"lowercase",
"strings"
] | KennethWilke/PingdomLib | python | https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L37-L50 | [
"def",
"_serializeBooleans",
"(",
"params",
")",
":",
"serialized",
"=",
"{",
"}",
"for",
"name",
",",
"value",
"in",
"params",
".",
"items",
"(",
")",
":",
"if",
"value",
"is",
"True",
":",
"value",
"=",
"'true'",
"elif",
"value",
"is",
"False",
":"... | 3ed1e481f9c9d16b032558d62fb05c2166e162ed |
train | Pingdom.request | Requests wrapper function | pingdomlib/pingdom.py | def request(self, method, url, parameters=dict()):
"""Requests wrapper function"""
# The requests library uses urllib, which serializes to "True"/"False" while Pingdom requires lowercase
parameters = self._serializeBooleans(parameters)
headers = {'App-Key': self.apikey}
if self... | def request(self, method, url, parameters=dict()):
"""Requests wrapper function"""
# The requests library uses urllib, which serializes to "True"/"False" while Pingdom requires lowercase
parameters = self._serializeBooleans(parameters)
headers = {'App-Key': self.apikey}
if self... | [
"Requests",
"wrapper",
"function"
] | KennethWilke/PingdomLib | python | https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L52-L97 | [
"def",
"request",
"(",
"self",
",",
"method",
",",
"url",
",",
"parameters",
"=",
"dict",
"(",
")",
")",
":",
"# The requests library uses urllib, which serializes to \"True\"/\"False\" while Pingdom requires lowercase",
"parameters",
"=",
"self",
".",
"_serializeBooleans",... | 3ed1e481f9c9d16b032558d62fb05c2166e162ed |
train | Pingdom.actions | Returns a list of actions (alerts) that have been generated for
your account.
Optional Parameters:
* from -- Only include actions generated later than this timestamp.
Format is UNIX time.
Type: Integer
Default: None
*... | pingdomlib/pingdom.py | def actions(self, **parameters):
"""Returns a list of actions (alerts) that have been generated for
your account.
Optional Parameters:
* from -- Only include actions generated later than this timestamp.
Format is UNIX time.
Type: Integer
... | def actions(self, **parameters):
"""Returns a list of actions (alerts) that have been generated for
your account.
Optional Parameters:
* from -- Only include actions generated later than this timestamp.
Format is UNIX time.
Type: Integer
... | [
"Returns",
"a",
"list",
"of",
"actions",
"(",
"alerts",
")",
"that",
"have",
"been",
"generated",
"for",
"your",
"account",
"."
] | KennethWilke/PingdomLib | python | https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L99-L183 | [
"def",
"actions",
"(",
"self",
",",
"*",
"*",
"parameters",
")",
":",
"# Warn user about unhandled parameters",
"for",
"key",
"in",
"parameters",
":",
"if",
"key",
"not",
"in",
"[",
"'from'",
",",
"'to'",
",",
"'limit'",
",",
"'offset'",
",",
"'checkids'",
... | 3ed1e481f9c9d16b032558d62fb05c2166e162ed |
train | Pingdom.getChecks | Pulls all checks from pingdom
Optional Parameters:
* limit -- Limits the number of returned probes to the
specified quantity.
Type: Integer (max 25000)
Default: 25000
* offset -- Offset for listing (requires limit.)
... | pingdomlib/pingdom.py | def getChecks(self, **parameters):
"""Pulls all checks from pingdom
Optional Parameters:
* limit -- Limits the number of returned probes to the
specified quantity.
Type: Integer (max 25000)
Default: 25000
* offset -- Offs... | def getChecks(self, **parameters):
"""Pulls all checks from pingdom
Optional Parameters:
* limit -- Limits the number of returned probes to the
specified quantity.
Type: Integer (max 25000)
Default: 25000
* offset -- Offs... | [
"Pulls",
"all",
"checks",
"from",
"pingdom"
] | KennethWilke/PingdomLib | python | https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L191-L219 | [
"def",
"getChecks",
"(",
"self",
",",
"*",
"*",
"parameters",
")",
":",
"# Warn user about unhandled parameters",
"for",
"key",
"in",
"parameters",
":",
"if",
"key",
"not",
"in",
"[",
"'limit'",
",",
"'offset'",
",",
"'tags'",
"]",
":",
"sys",
".",
"stderr... | 3ed1e481f9c9d16b032558d62fb05c2166e162ed |
train | Pingdom.getCheck | Returns a detailed description of a specified check. | pingdomlib/pingdom.py | def getCheck(self, checkid):
"""Returns a detailed description of a specified check."""
check = PingdomCheck(self, {'id': checkid})
check.getDetails()
return check | def getCheck(self, checkid):
"""Returns a detailed description of a specified check."""
check = PingdomCheck(self, {'id': checkid})
check.getDetails()
return check | [
"Returns",
"a",
"detailed",
"description",
"of",
"a",
"specified",
"check",
"."
] | KennethWilke/PingdomLib | python | https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L221-L226 | [
"def",
"getCheck",
"(",
"self",
",",
"checkid",
")",
":",
"check",
"=",
"PingdomCheck",
"(",
"self",
",",
"{",
"'id'",
":",
"checkid",
"}",
")",
"check",
".",
"getDetails",
"(",
")",
"return",
"check"
] | 3ed1e481f9c9d16b032558d62fb05c2166e162ed |
train | Pingdom.probes | Returns a list of all Pingdom probe servers
Parameters:
* limit -- Limits the number of returned probes to the specified
quantity
Type: Integer
* offset -- Offset for listing (requires limit).
Type: Integer
De... | pingdomlib/pingdom.py | def probes(self, **kwargs):
"""Returns a list of all Pingdom probe servers
Parameters:
* limit -- Limits the number of returned probes to the specified
quantity
Type: Integer
* offset -- Offset for listing (requires limit).
... | def probes(self, **kwargs):
"""Returns a list of all Pingdom probe servers
Parameters:
* limit -- Limits the number of returned probes to the specified
quantity
Type: Integer
* offset -- Offset for listing (requires limit).
... | [
"Returns",
"a",
"list",
"of",
"all",
"Pingdom",
"probe",
"servers"
] | KennethWilke/PingdomLib | python | https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L621-L664 | [
"def",
"probes",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# Warn user about unhandled parameters",
"for",
"key",
"in",
"kwargs",
":",
"if",
"key",
"not",
"in",
"[",
"'limit'",
",",
"'offset'",
",",
"'onlyactive'",
",",
"'includedeleted'",
"]",
":",
... | 3ed1e481f9c9d16b032558d62fb05c2166e162ed |
train | Pingdom.traceroute | Perform a traceroute to a specified target from a specified Pingdom
probe.
Provide hostname to check and probeid to check from
Returned structure:
{
'result' : <String> Traceroute output
'probeid' : <Integer> Probe identifier
... | pingdomlib/pingdom.py | def traceroute(self, host, probeid):
"""Perform a traceroute to a specified target from a specified Pingdom
probe.
Provide hostname to check and probeid to check from
Returned structure:
{
'result' : <String> Traceroute output
'probeid'... | def traceroute(self, host, probeid):
"""Perform a traceroute to a specified target from a specified Pingdom
probe.
Provide hostname to check and probeid to check from
Returned structure:
{
'result' : <String> Traceroute output
'probeid'... | [
"Perform",
"a",
"traceroute",
"to",
"a",
"specified",
"target",
"from",
"a",
"specified",
"Pingdom",
"probe",
"."
] | KennethWilke/PingdomLib | python | https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L733-L749 | [
"def",
"traceroute",
"(",
"self",
",",
"host",
",",
"probeid",
")",
":",
"response",
"=",
"self",
".",
"request",
"(",
"'GET'",
",",
"'traceroute'",
",",
"{",
"'host'",
":",
"host",
",",
"'probeid'",
":",
"probeid",
"}",
")",
"return",
"response",
".",... | 3ed1e481f9c9d16b032558d62fb05c2166e162ed |
train | Pingdom.getContacts | Returns a list of all contacts.
Optional Parameters:
* limit -- Limits the number of returned contacts to the specified
quantity.
Type: Integer
Default: 100
* offset -- Offset for listing (requires limit.)
Typ... | pingdomlib/pingdom.py | def getContacts(self, **kwargs):
"""Returns a list of all contacts.
Optional Parameters:
* limit -- Limits the number of returned contacts to the specified
quantity.
Type: Integer
Default: 100
* offset -- Offset for listi... | def getContacts(self, **kwargs):
"""Returns a list of all contacts.
Optional Parameters:
* limit -- Limits the number of returned contacts to the specified
quantity.
Type: Integer
Default: 100
* offset -- Offset for listi... | [
"Returns",
"a",
"list",
"of",
"all",
"contacts",
"."
] | KennethWilke/PingdomLib | python | https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L756-L793 | [
"def",
"getContacts",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# Warn user about unhandled parameters",
"for",
"key",
"in",
"kwargs",
":",
"if",
"key",
"not",
"in",
"[",
"'limit'",
",",
"'offset'",
"]",
":",
"sys",
".",
"stderr",
".",
"write",
"(... | 3ed1e481f9c9d16b032558d62fb05c2166e162ed |
train | Pingdom.newContact | Create a new contact.
Provide new contact name and any optional arguments. Returns new
PingdomContact instance
Optional Parameters:
* email -- Contact email address
Type: String
* cellphone -- Cellphone number, without the country code part. In... | pingdomlib/pingdom.py | def newContact(self, name, **kwargs):
"""Create a new contact.
Provide new contact name and any optional arguments. Returns new
PingdomContact instance
Optional Parameters:
* email -- Contact email address
Type: String
* cellphone -- Ce... | def newContact(self, name, **kwargs):
"""Create a new contact.
Provide new contact name and any optional arguments. Returns new
PingdomContact instance
Optional Parameters:
* email -- Contact email address
Type: String
* cellphone -- Ce... | [
"Create",
"a",
"new",
"contact",
"."
] | KennethWilke/PingdomLib | python | https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L795-L844 | [
"def",
"newContact",
"(",
"self",
",",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"# Warn user about unhandled parameters",
"for",
"key",
"in",
"kwargs",
":",
"if",
"key",
"not",
"in",
"[",
"'email'",
",",
"'cellphone'",
",",
"'countrycode'",
",",
"'countryi... | 3ed1e481f9c9d16b032558d62fb05c2166e162ed |
train | Pingdom.modifyContacts | Modifies a list of contacts.
Provide comma separated list of contact ids and desired paused state
Returns status message | pingdomlib/pingdom.py | def modifyContacts(self, contactids, paused):
"""Modifies a list of contacts.
Provide comma separated list of contact ids and desired paused state
Returns status message
"""
response = self.request("PUT", "notification_contacts", {'contactids': contactids,
... | def modifyContacts(self, contactids, paused):
"""Modifies a list of contacts.
Provide comma separated list of contact ids and desired paused state
Returns status message
"""
response = self.request("PUT", "notification_contacts", {'contactids': contactids,
... | [
"Modifies",
"a",
"list",
"of",
"contacts",
"."
] | KennethWilke/PingdomLib | python | https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L846-L856 | [
"def",
"modifyContacts",
"(",
"self",
",",
"contactids",
",",
"paused",
")",
":",
"response",
"=",
"self",
".",
"request",
"(",
"\"PUT\"",
",",
"\"notification_contacts\"",
",",
"{",
"'contactids'",
":",
"contactids",
",",
"'paused'",
":",
"paused",
"}",
")"... | 3ed1e481f9c9d16b032558d62fb05c2166e162ed |
train | Pingdom.getEmailReports | Returns a list of PingdomEmailReport instances. | pingdomlib/pingdom.py | def getEmailReports(self):
"""Returns a list of PingdomEmailReport instances."""
reports = [PingdomEmailReport(self, x) for x in
self.request('GET',
'reports.email').json()['subscriptions']]
return reports | def getEmailReports(self):
"""Returns a list of PingdomEmailReport instances."""
reports = [PingdomEmailReport(self, x) for x in
self.request('GET',
'reports.email').json()['subscriptions']]
return reports | [
"Returns",
"a",
"list",
"of",
"PingdomEmailReport",
"instances",
"."
] | KennethWilke/PingdomLib | python | https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L1170-L1177 | [
"def",
"getEmailReports",
"(",
"self",
")",
":",
"reports",
"=",
"[",
"PingdomEmailReport",
"(",
"self",
",",
"x",
")",
"for",
"x",
"in",
"self",
".",
"request",
"(",
"'GET'",
",",
"'reports.email'",
")",
".",
"json",
"(",
")",
"[",
"'subscriptions'",
... | 3ed1e481f9c9d16b032558d62fb05c2166e162ed |
train | Pingdom.newEmailReport | Creates a new email report
Returns status message for operation
Optional parameters:
* checkid -- Check identifier. If omitted, this will be an
overview report
Type: Integer
* frequency -- Report frequency
Type: String [... | pingdomlib/pingdom.py | def newEmailReport(self, name, **kwargs):
"""Creates a new email report
Returns status message for operation
Optional parameters:
* checkid -- Check identifier. If omitted, this will be an
overview report
Type: Integer
* frequency -... | def newEmailReport(self, name, **kwargs):
"""Creates a new email report
Returns status message for operation
Optional parameters:
* checkid -- Check identifier. If omitted, this will be an
overview report
Type: Integer
* frequency -... | [
"Creates",
"a",
"new",
"email",
"report"
] | KennethWilke/PingdomLib | python | https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L1179-L1214 | [
"def",
"newEmailReport",
"(",
"self",
",",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"# Warn user about unhandled parameters",
"for",
"key",
"in",
"kwargs",
":",
"if",
"key",
"not",
"in",
"[",
"'checkid'",
",",
"'frequency'",
",",
"'contactids'",
",",
"'add... | 3ed1e481f9c9d16b032558d62fb05c2166e162ed |
train | Pingdom.getSharedReports | Returns a list of PingdomSharedReport instances | pingdomlib/pingdom.py | def getSharedReports(self):
"""Returns a list of PingdomSharedReport instances"""
response = self.request('GET',
'reports.shared').json()['shared']['banners']
reports = [PingdomSharedReport(self, x) for x in response]
return reports | def getSharedReports(self):
"""Returns a list of PingdomSharedReport instances"""
response = self.request('GET',
'reports.shared').json()['shared']['banners']
reports = [PingdomSharedReport(self, x) for x in response]
return reports | [
"Returns",
"a",
"list",
"of",
"PingdomSharedReport",
"instances"
] | KennethWilke/PingdomLib | python | https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L1232-L1239 | [
"def",
"getSharedReports",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"request",
"(",
"'GET'",
",",
"'reports.shared'",
")",
".",
"json",
"(",
")",
"[",
"'shared'",
"]",
"[",
"'banners'",
"]",
"reports",
"=",
"[",
"PingdomSharedReport",
"(",
"s... | 3ed1e481f9c9d16b032558d62fb05c2166e162ed |
train | Pingdom.newSharedReport | Create a shared report (banner).
Returns status message for operation
Optional parameters:
* auto -- Automatic period (If false, requires: fromyear,
frommonth, fromday, toyear, tomonth, today)
Type: Boolean
* type -- Banner type
... | pingdomlib/pingdom.py | def newSharedReport(self, checkid, **kwargs):
"""Create a shared report (banner).
Returns status message for operation
Optional parameters:
* auto -- Automatic period (If false, requires: fromyear,
frommonth, fromday, toyear, tomonth, today)
Typ... | def newSharedReport(self, checkid, **kwargs):
"""Create a shared report (banner).
Returns status message for operation
Optional parameters:
* auto -- Automatic period (If false, requires: fromyear,
frommonth, fromday, toyear, tomonth, today)
Typ... | [
"Create",
"a",
"shared",
"report",
"(",
"banner",
")",
"."
] | KennethWilke/PingdomLib | python | https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/pingdom.py#L1241-L1286 | [
"def",
"newSharedReport",
"(",
"self",
",",
"checkid",
",",
"*",
"*",
"kwargs",
")",
":",
"# Warn user about unhandled parameters",
"for",
"key",
"in",
"kwargs",
":",
"if",
"key",
"not",
"in",
"[",
"'auto'",
",",
"'type'",
",",
"'fromyear'",
",",
"'frommonth... | 3ed1e481f9c9d16b032558d62fb05c2166e162ed |
train | encry_decry_cascade | When bool_encry is True, encrypt the data with master key. When it is False, the function extract the three nonce
from the encrypted data (first 3*21 bytes), and decrypt the data.
:param data: the data to encrypt or decrypt.
:param masterkey: a 32 bytes key in bytes.
:param bool_encry: if bool_encry is ... | cryptoshop/_cascade_engine.py | def encry_decry_cascade(data, masterkey, bool_encry, assoc_data):
"""
When bool_encry is True, encrypt the data with master key. When it is False, the function extract the three nonce
from the encrypted data (first 3*21 bytes), and decrypt the data.
:param data: the data to encrypt or decrypt.
:para... | def encry_decry_cascade(data, masterkey, bool_encry, assoc_data):
"""
When bool_encry is True, encrypt the data with master key. When it is False, the function extract the three nonce
from the encrypted data (first 3*21 bytes), and decrypt the data.
:param data: the data to encrypt or decrypt.
:para... | [
"When",
"bool_encry",
"is",
"True",
"encrypt",
"the",
"data",
"with",
"master",
"key",
".",
"When",
"it",
"is",
"False",
"the",
"function",
"extract",
"the",
"three",
"nonce",
"from",
"the",
"encrypted",
"data",
"(",
"first",
"3",
"*",
"21",
"bytes",
")"... | Antidote1911/cryptoshop | python | https://github.com/Antidote1911/cryptoshop/blob/0b7ff4a6848f2733f4737606957e8042a4d6ca0b/cryptoshop/_cascade_engine.py#L39-L104 | [
"def",
"encry_decry_cascade",
"(",
"data",
",",
"masterkey",
",",
"bool_encry",
",",
"assoc_data",
")",
":",
"engine1",
"=",
"botan",
".",
"cipher",
"(",
"algo",
"=",
"\"Serpent/GCM\"",
",",
"encrypt",
"=",
"bool_encry",
")",
"engine2",
"=",
"botan",
".",
... | 0b7ff4a6848f2733f4737606957e8042a4d6ca0b |
train | Registry.register | Register the handler for the command
:param request_class: The command or event to dispatch. It must implement getKey()
:param handler_factory: A factory method to create the handler to dispatch to
:return: | brightside/registry.py | def register(self, request_class: Request, handler_factory: Callable[[], Handler]) -> None:
"""
Register the handler for the command
:param request_class: The command or event to dispatch. It must implement getKey()
:param handler_factory: A factory method to create the handler to dispat... | def register(self, request_class: Request, handler_factory: Callable[[], Handler]) -> None:
"""
Register the handler for the command
:param request_class: The command or event to dispatch. It must implement getKey()
:param handler_factory: A factory method to create the handler to dispat... | [
"Register",
"the",
"handler",
"for",
"the",
"command",
":",
"param",
"request_class",
":",
"The",
"command",
"or",
"event",
"to",
"dispatch",
".",
"It",
"must",
"implement",
"getKey",
"()",
":",
"param",
"handler_factory",
":",
"A",
"factory",
"method",
"to"... | BrighterCommand/Brightside | python | https://github.com/BrighterCommand/Brightside/blob/53b2f8323c3972609010a7386130249f3758f5fb/brightside/registry.py#L45-L61 | [
"def",
"register",
"(",
"self",
",",
"request_class",
":",
"Request",
",",
"handler_factory",
":",
"Callable",
"[",
"[",
"]",
",",
"Handler",
"]",
")",
"->",
"None",
":",
"key",
"=",
"request_class",
".",
"__name__",
"is_command",
"=",
"request_class",
"."... | 53b2f8323c3972609010a7386130249f3758f5fb |
train | Registry.lookup | Looks up the handler associated with a request - matches the key on the request to a registered handler
:param request: The request we want to find a handler for
:return: | brightside/registry.py | def lookup(self, request: Request) -> List[Callable[[], Handler]]:
"""
Looks up the handler associated with a request - matches the key on the request to a registered handler
:param request: The request we want to find a handler for
:return:
"""
key = request.__class__.__... | def lookup(self, request: Request) -> List[Callable[[], Handler]]:
"""
Looks up the handler associated with a request - matches the key on the request to a registered handler
:param request: The request we want to find a handler for
:return:
"""
key = request.__class__.__... | [
"Looks",
"up",
"the",
"handler",
"associated",
"with",
"a",
"request",
"-",
"matches",
"the",
"key",
"on",
"the",
"request",
"to",
"a",
"registered",
"handler",
":",
"param",
"request",
":",
"The",
"request",
"we",
"want",
"to",
"find",
"a",
"handler",
"... | BrighterCommand/Brightside | python | https://github.com/BrighterCommand/Brightside/blob/53b2f8323c3972609010a7386130249f3758f5fb/brightside/registry.py#L63-L76 | [
"def",
"lookup",
"(",
"self",
",",
"request",
":",
"Request",
")",
"->",
"List",
"[",
"Callable",
"[",
"[",
"]",
",",
"Handler",
"]",
"]",
":",
"key",
"=",
"request",
".",
"__class__",
".",
"__name__",
"if",
"key",
"not",
"in",
"self",
".",
"_regis... | 53b2f8323c3972609010a7386130249f3758f5fb |
train | MessageMapperRegistry.register | Adds a message mapper to a factory, using the requests key
:param mapper_func: A callback that creates a BrightsideMessage from a Request
:param request_class: A request type | brightside/registry.py | def register(self, request_class: Request, mapper_func: Callable[[Request], BrightsideMessage]) -> None:
"""Adds a message mapper to a factory, using the requests key
:param mapper_func: A callback that creates a BrightsideMessage from a Request
:param request_class: A request type
"""
... | def register(self, request_class: Request, mapper_func: Callable[[Request], BrightsideMessage]) -> None:
"""Adds a message mapper to a factory, using the requests key
:param mapper_func: A callback that creates a BrightsideMessage from a Request
:param request_class: A request type
"""
... | [
"Adds",
"a",
"message",
"mapper",
"to",
"a",
"factory",
"using",
"the",
"requests",
"key",
":",
"param",
"mapper_func",
":",
"A",
"callback",
"that",
"creates",
"a",
"BrightsideMessage",
"from",
"a",
"Request",
":",
"param",
"request_class",
":",
"A",
"reque... | BrighterCommand/Brightside | python | https://github.com/BrighterCommand/Brightside/blob/53b2f8323c3972609010a7386130249f3758f5fb/brightside/registry.py#L89-L99 | [
"def",
"register",
"(",
"self",
",",
"request_class",
":",
"Request",
",",
"mapper_func",
":",
"Callable",
"[",
"[",
"Request",
"]",
",",
"BrightsideMessage",
"]",
")",
"->",
"None",
":",
"key",
"=",
"request_class",
".",
"__name__",
"if",
"key",
"not",
... | 53b2f8323c3972609010a7386130249f3758f5fb |
train | MessageMapperRegistry.lookup | Looks up the message mapper function associated with this class. Function should take in a Request derived class
and return a BrightsideMessage derived class, for sending on the wire
:param request_class:
:return: | brightside/registry.py | def lookup(self, request_class: Request) -> Callable[[Request], BrightsideMessage]:
"""
Looks up the message mapper function associated with this class. Function should take in a Request derived class
and return a BrightsideMessage derived class, for sending on the wire
:param request_c... | def lookup(self, request_class: Request) -> Callable[[Request], BrightsideMessage]:
"""
Looks up the message mapper function associated with this class. Function should take in a Request derived class
and return a BrightsideMessage derived class, for sending on the wire
:param request_c... | [
"Looks",
"up",
"the",
"message",
"mapper",
"function",
"associated",
"with",
"this",
"class",
".",
"Function",
"should",
"take",
"in",
"a",
"Request",
"derived",
"class",
"and",
"return",
"a",
"BrightsideMessage",
"derived",
"class",
"for",
"sending",
"on",
"t... | BrighterCommand/Brightside | python | https://github.com/BrighterCommand/Brightside/blob/53b2f8323c3972609010a7386130249f3758f5fb/brightside/registry.py#L101-L112 | [
"def",
"lookup",
"(",
"self",
",",
"request_class",
":",
"Request",
")",
"->",
"Callable",
"[",
"[",
"Request",
"]",
",",
"BrightsideMessage",
"]",
":",
"key",
"=",
"request_class",
".",
"__class__",
".",
"__name__",
"if",
"key",
"not",
"in",
"self",
"."... | 53b2f8323c3972609010a7386130249f3758f5fb |
train | instance_of | This type validation function can be used in two modes:
* providing two arguments (x, ref_type), it returns `True` if isinstance(x, ref_type) and raises a HasWrongType
error if not. If ref_type is a set of types, any match with one of the included types will do
* providing a single argument (ref_type), t... | valid8/validation_lib/types.py | def instance_of(*args):
"""
This type validation function can be used in two modes:
* providing two arguments (x, ref_type), it returns `True` if isinstance(x, ref_type) and raises a HasWrongType
error if not. If ref_type is a set of types, any match with one of the included types will do
* provi... | def instance_of(*args):
"""
This type validation function can be used in two modes:
* providing two arguments (x, ref_type), it returns `True` if isinstance(x, ref_type) and raises a HasWrongType
error if not. If ref_type is a set of types, any match with one of the included types will do
* provi... | [
"This",
"type",
"validation",
"function",
"can",
"be",
"used",
"in",
"two",
"modes",
":",
"*",
"providing",
"two",
"arguments",
"(",
"x",
"ref_type",
")",
"it",
"returns",
"True",
"if",
"isinstance",
"(",
"x",
"ref_type",
")",
"and",
"raises",
"a",
"HasW... | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/types.py#L15-L78 | [
"def",
"instance_of",
"(",
"*",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
"==",
"2",
":",
"# Standard mode",
"value",
",",
"ref_type",
"=",
"args",
"if",
"not",
"isinstance",
"(",
"ref_type",
",",
"set",
")",
":",
"# ref_type is a single type",
"i... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | subclass_of | This type validation function can be used in two modes:
* providing two arguments (c, ref_type), it returns `True` if issubclass(c, ref_type) and raises a IsWrongType
error if not. If ref_type is a set of types, any match with one of the included types will do
* providing a single argument (ref_type), th... | valid8/validation_lib/types.py | def subclass_of(*args):
"""
This type validation function can be used in two modes:
* providing two arguments (c, ref_type), it returns `True` if issubclass(c, ref_type) and raises a IsWrongType
error if not. If ref_type is a set of types, any match with one of the included types will do
* provid... | def subclass_of(*args):
"""
This type validation function can be used in two modes:
* providing two arguments (c, ref_type), it returns `True` if issubclass(c, ref_type) and raises a IsWrongType
error if not. If ref_type is a set of types, any match with one of the included types will do
* provid... | [
"This",
"type",
"validation",
"function",
"can",
"be",
"used",
"in",
"two",
"modes",
":",
"*",
"providing",
"two",
"arguments",
"(",
"c",
"ref_type",
")",
"it",
"returns",
"True",
"if",
"issubclass",
"(",
"c",
"ref_type",
")",
"and",
"raises",
"a",
"IsWr... | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/types.py#L92-L153 | [
"def",
"subclass_of",
"(",
"*",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
"==",
"2",
":",
"# Standard mode",
"typ",
",",
"ref_type",
"=",
"args",
"if",
"not",
"isinstance",
"(",
"ref_type",
",",
"set",
")",
":",
"# ref_type is a single type",
"if"... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | disk_cache | Function decorator for caching pickleable return values on disk. Uses a
hash computed from the function arguments for invalidation. If 'method',
skip the first argument, usually being self or cls. The cache filepath is
'directory/basename-hash.pickle'. | sets/utility.py | def disk_cache(basename, directory, method=False):
"""
Function decorator for caching pickleable return values on disk. Uses a
hash computed from the function arguments for invalidation. If 'method',
skip the first argument, usually being self or cls. The cache filepath is
'directory/basename-hash.p... | def disk_cache(basename, directory, method=False):
"""
Function decorator for caching pickleable return values on disk. Uses a
hash computed from the function arguments for invalidation. If 'method',
skip the first argument, usually being self or cls. The cache filepath is
'directory/basename-hash.p... | [
"Function",
"decorator",
"for",
"caching",
"pickleable",
"return",
"values",
"on",
"disk",
".",
"Uses",
"a",
"hash",
"computed",
"from",
"the",
"function",
"arguments",
"for",
"invalidation",
".",
"If",
"method",
"skip",
"the",
"first",
"argument",
"usually",
... | danijar/sets | python | https://github.com/danijar/sets/blob/2542c28f43d0af18932cb5b82f54ffb6ae557d12/sets/utility.py#L23-L51 | [
"def",
"disk_cache",
"(",
"basename",
",",
"directory",
",",
"method",
"=",
"False",
")",
":",
"directory",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"directory",
")",
"ensure_directory",
"(",
"directory",
")",
"def",
"wrapper",
"(",
"func",
")",
"... | 2542c28f43d0af18932cb5b82f54ffb6ae557d12 |
train | download | Download a file and return its filename on the local file system. If the
file is already there, it will not be downloaded again. The filename is
derived from the url if not provided. Return the filepath. | sets/utility.py | def download(url, directory, filename=None):
"""
Download a file and return its filename on the local file system. If the
file is already there, it will not be downloaded again. The filename is
derived from the url if not provided. Return the filepath.
"""
if not filename:
_, filename = ... | def download(url, directory, filename=None):
"""
Download a file and return its filename on the local file system. If the
file is already there, it will not be downloaded again. The filename is
derived from the url if not provided. Return the filepath.
"""
if not filename:
_, filename = ... | [
"Download",
"a",
"file",
"and",
"return",
"its",
"filename",
"on",
"the",
"local",
"file",
"system",
".",
"If",
"the",
"file",
"is",
"already",
"there",
"it",
"will",
"not",
"be",
"downloaded",
"again",
".",
"The",
"filename",
"is",
"derived",
"from",
"t... | danijar/sets | python | https://github.com/danijar/sets/blob/2542c28f43d0af18932cb5b82f54ffb6ae557d12/sets/utility.py#L53-L69 | [
"def",
"download",
"(",
"url",
",",
"directory",
",",
"filename",
"=",
"None",
")",
":",
"if",
"not",
"filename",
":",
"_",
",",
"filename",
"=",
"os",
".",
"path",
".",
"split",
"(",
"url",
")",
"directory",
"=",
"os",
".",
"path",
".",
"expanduse... | 2542c28f43d0af18932cb5b82f54ffb6ae557d12 |
train | ensure_directory | Create the directories along the provided directory path that do not exist. | sets/utility.py | def ensure_directory(directory):
"""
Create the directories along the provided directory path that do not exist.
"""
directory = os.path.expanduser(directory)
try:
os.makedirs(directory)
except OSError as e:
if e.errno != errno.EEXIST:
raise e | def ensure_directory(directory):
"""
Create the directories along the provided directory path that do not exist.
"""
directory = os.path.expanduser(directory)
try:
os.makedirs(directory)
except OSError as e:
if e.errno != errno.EEXIST:
raise e | [
"Create",
"the",
"directories",
"along",
"the",
"provided",
"directory",
"path",
"that",
"do",
"not",
"exist",
"."
] | danijar/sets | python | https://github.com/danijar/sets/blob/2542c28f43d0af18932cb5b82f54ffb6ae557d12/sets/utility.py#L71-L80 | [
"def",
"ensure_directory",
"(",
"directory",
")",
":",
"directory",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"directory",
")",
"try",
":",
"os",
".",
"makedirs",
"(",
"directory",
")",
"except",
"OSError",
"as",
"e",
":",
"if",
"e",
".",
"errno"... | 2542c28f43d0af18932cb5b82f54ffb6ae557d12 |
train | _process_validation_function_s | This function handles the various ways that users may enter 'validation functions', so as to output a single
callable method. Setting "auto_and_wrapper" to False allows callers to get a list of callables instead.
valid8 supports the following expressions for 'validation functions'
* <ValidationFunc>
... | valid8/composition.py | def _process_validation_function_s(validation_func, # type: ValidationFuncs
auto_and_wrapper=True # type: bool
):
# type: (...) -> Union[Callable, List[Callable]]
"""
This function handles the various ways that users may enter 'val... | def _process_validation_function_s(validation_func, # type: ValidationFuncs
auto_and_wrapper=True # type: bool
):
# type: (...) -> Union[Callable, List[Callable]]
"""
This function handles the various ways that users may enter 'val... | [
"This",
"function",
"handles",
"the",
"various",
"ways",
"that",
"users",
"may",
"enter",
"validation",
"functions",
"so",
"as",
"to",
"output",
"a",
"single",
"callable",
"method",
".",
"Setting",
"auto_and_wrapper",
"to",
"False",
"allows",
"callers",
"to",
... | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/composition.py#L43-L125 | [
"def",
"_process_validation_function_s",
"(",
"validation_func",
",",
"# type: ValidationFuncs",
"auto_and_wrapper",
"=",
"True",
"# type: bool",
")",
":",
"# type: (...) -> Union[Callable, List[Callable]]",
"# handle the case where validation_func is not yet a list or is empty or none",
... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | and_ | An 'and' validator: it returns `True` if all of the provided validators return `True`, or raises a
`AtLeastOneFailed` failure on the first `False` received or `Exception` caught.
Note that an implicit `and_` is performed if you provide a list of validators to any of the entry points
(`validate`, `validatio... | valid8/composition.py | def and_(*validation_func # type: ValidationFuncs
):
# type: (...) -> Callable
"""
An 'and' validator: it returns `True` if all of the provided validators return `True`, or raises a
`AtLeastOneFailed` failure on the first `False` received or `Exception` caught.
Note that an implicit `and_... | def and_(*validation_func # type: ValidationFuncs
):
# type: (...) -> Callable
"""
An 'and' validator: it returns `True` if all of the provided validators return `True`, or raises a
`AtLeastOneFailed` failure on the first `False` received or `Exception` caught.
Note that an implicit `and_... | [
"An",
"and",
"validator",
":",
"it",
"returns",
"True",
"if",
"all",
"of",
"the",
"provided",
"validators",
"return",
"True",
"or",
"raises",
"a",
"AtLeastOneFailed",
"failure",
"on",
"the",
"first",
"False",
"received",
"or",
"Exception",
"caught",
"."
] | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/composition.py#L229-L266 | [
"def",
"and_",
"(",
"*",
"validation_func",
"# type: ValidationFuncs",
")",
":",
"# type: (...) -> Callable",
"validation_func",
"=",
"_process_validation_function_s",
"(",
"list",
"(",
"validation_func",
")",
",",
"auto_and_wrapper",
"=",
"False",
")",
"if",
"len",
"... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | not_ | Generates the inverse of the provided validation functions: when the validator returns `False` or raises a
`Failure`, this function returns `True`. Otherwise it raises a `DidNotFail` failure.
By default, exceptions of types other than `Failure` are not caught and therefore fail the validation
(`catch_all=F... | valid8/composition.py | def not_(validation_func, # type: ValidationFuncs
catch_all=False # type: bool
):
# type: (...) -> Callable
"""
Generates the inverse of the provided validation functions: when the validator returns `False` or raises a
`Failure`, this function returns `True`. Otherwise it raises a `... | def not_(validation_func, # type: ValidationFuncs
catch_all=False # type: bool
):
# type: (...) -> Callable
"""
Generates the inverse of the provided validation functions: when the validator returns `False` or raises a
`Failure`, this function returns `True`. Otherwise it raises a `... | [
"Generates",
"the",
"inverse",
"of",
"the",
"provided",
"validation",
"functions",
":",
"when",
"the",
"validator",
"returns",
"False",
"or",
"raises",
"a",
"Failure",
"this",
"function",
"returns",
"True",
".",
"Otherwise",
"it",
"raises",
"a",
"DidNotFail",
... | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/composition.py#L274-L319 | [
"def",
"not_",
"(",
"validation_func",
",",
"# type: ValidationFuncs",
"catch_all",
"=",
"False",
"# type: bool",
")",
":",
"# type: (...) -> Callable",
"def",
"not_v_",
"(",
"x",
")",
":",
"try",
":",
"res",
"=",
"validation_func",
"(",
"x",
")",
"if",
"not",... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | or_ | An 'or' validator: returns `True` if at least one of the provided validators returns `True`. All exceptions will be
silently caught. In case of failure, a global `AllValidatorsFailed` failure will be raised, together with details
about all validation results.
:param validation_func: the base validation fun... | valid8/composition.py | def or_(*validation_func # type: ValidationFuncs
):
# type: (...) -> Callable
"""
An 'or' validator: returns `True` if at least one of the provided validators returns `True`. All exceptions will be
silently caught. In case of failure, a global `AllValidatorsFailed` failure will be raised, toget... | def or_(*validation_func # type: ValidationFuncs
):
# type: (...) -> Callable
"""
An 'or' validator: returns `True` if at least one of the provided validators returns `True`. All exceptions will be
silently caught. In case of failure, a global `AllValidatorsFailed` failure will be raised, toget... | [
"An",
"or",
"validator",
":",
"returns",
"True",
"if",
"at",
"least",
"one",
"of",
"the",
"provided",
"validators",
"returns",
"True",
".",
"All",
"exceptions",
"will",
"be",
"silently",
"caught",
".",
"In",
"case",
"of",
"failure",
"a",
"global",
"AllVali... | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/composition.py#L330-L367 | [
"def",
"or_",
"(",
"*",
"validation_func",
"# type: ValidationFuncs",
")",
":",
"# type: (...) -> Callable",
"validation_func",
"=",
"_process_validation_function_s",
"(",
"list",
"(",
"validation_func",
")",
",",
"auto_and_wrapper",
"=",
"False",
")",
"if",
"len",
"(... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | xor_ | A 'xor' validation function: returns `True` if exactly one of the provided validators returns `True`. All exceptions
will be silently caught. In case of failure, a global `XorTooManySuccess` or `AllValidatorsFailed` will be raised,
together with details about the various validation results.
:param validati... | valid8/composition.py | def xor_(*validation_func # type: ValidationFuncs
):
# type: (...) -> Callable
"""
A 'xor' validation function: returns `True` if exactly one of the provided validators returns `True`. All exceptions
will be silently caught. In case of failure, a global `XorTooManySuccess` or `AllValidatorsFai... | def xor_(*validation_func # type: ValidationFuncs
):
# type: (...) -> Callable
"""
A 'xor' validation function: returns `True` if exactly one of the provided validators returns `True`. All exceptions
will be silently caught. In case of failure, a global `XorTooManySuccess` or `AllValidatorsFai... | [
"A",
"xor",
"validation",
"function",
":",
"returns",
"True",
"if",
"exactly",
"one",
"of",
"the",
"provided",
"validators",
"returns",
"True",
".",
"All",
"exceptions",
"will",
"be",
"silently",
"caught",
".",
"In",
"case",
"of",
"failure",
"a",
"global",
... | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/composition.py#L378-L424 | [
"def",
"xor_",
"(",
"*",
"validation_func",
"# type: ValidationFuncs",
")",
":",
"# type: (...) -> Callable",
"validation_func",
"=",
"_process_validation_function_s",
"(",
"list",
"(",
"validation_func",
")",
",",
"auto_and_wrapper",
"=",
"False",
")",
"if",
"len",
"... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | not_all | An alias for not_(and_(validators)).
:param validation_func: the base validation function or list of base validation functions to use. A callable, a
tuple(callable, help_msg_str), a tuple(callable, failure_type), or a list of several such elements. Nested lists
are supported and indicate an implici... | valid8/composition.py | def not_all(*validation_func, # type: ValidationFuncs
**kwargs
):
# type: (...) -> Callable
"""
An alias for not_(and_(validators)).
:param validation_func: the base validation function or list of base validation functions to use. A callable, a
tuple(callable, help_msg_... | def not_all(*validation_func, # type: ValidationFuncs
**kwargs
):
# type: (...) -> Callable
"""
An alias for not_(and_(validators)).
:param validation_func: the base validation function or list of base validation functions to use. A callable, a
tuple(callable, help_msg_... | [
"An",
"alias",
"for",
"not_",
"(",
"and_",
"(",
"validators",
"))",
"."
] | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/composition.py#L436-L458 | [
"def",
"not_all",
"(",
"*",
"validation_func",
",",
"# type: ValidationFuncs",
"*",
"*",
"kwargs",
")",
":",
"# type: (...) -> Callable",
"catch_all",
"=",
"pop_kwargs",
"(",
"kwargs",
",",
"[",
"(",
"'catch_all'",
",",
"False",
")",
"]",
")",
"# in case this is... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | failure_raiser | This function is automatically used if you provide a tuple `(<function>, <msg>_or_<Failure_type>)`, to any of the
methods in this page or to one of the `valid8` decorators. It transforms the provided `<function>` into a failure
raiser, raising a subclass of `Failure` in case of failure (either not returning `Tr... | valid8/composition.py | def failure_raiser(*validation_func, # type: ValidationFuncs
**kwargs
):
# type: (...) -> Callable
"""
This function is automatically used if you provide a tuple `(<function>, <msg>_or_<Failure_type>)`, to any of the
methods in this page or to one of the `valid8` ... | def failure_raiser(*validation_func, # type: ValidationFuncs
**kwargs
):
# type: (...) -> Callable
"""
This function is automatically used if you provide a tuple `(<function>, <msg>_or_<Failure_type>)`, to any of the
methods in this page or to one of the `valid8` ... | [
"This",
"function",
"is",
"automatically",
"used",
"if",
"you",
"provide",
"a",
"tuple",
"(",
"<function",
">",
"<msg",
">",
"_or_<Failure_type",
">",
")",
"to",
"any",
"of",
"the",
"methods",
"in",
"this",
"page",
"or",
"to",
"one",
"of",
"the",
"valid8... | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/composition.py#L473-L498 | [
"def",
"failure_raiser",
"(",
"*",
"validation_func",
",",
"# type: ValidationFuncs",
"*",
"*",
"kwargs",
")",
":",
"# type: (...) -> Callable",
"failure_type",
",",
"help_msg",
"=",
"pop_kwargs",
"(",
"kwargs",
",",
"[",
"(",
"'failure_type'",
",",
"None",
")",
... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | pop_kwargs | Internal utility method to extract optional arguments from kwargs.
:param kwargs:
:param names_with_defaults:
:param allow_others: if False (default) then an error will be raised if kwargs still contains something at the end.
:return: | valid8/composition.py | def pop_kwargs(kwargs,
names_with_defaults, # type: List[Tuple[str, Any]]
allow_others=False
):
"""
Internal utility method to extract optional arguments from kwargs.
:param kwargs:
:param names_with_defaults:
:param allow_others: if False (default) the... | def pop_kwargs(kwargs,
names_with_defaults, # type: List[Tuple[str, Any]]
allow_others=False
):
"""
Internal utility method to extract optional arguments from kwargs.
:param kwargs:
:param names_with_defaults:
:param allow_others: if False (default) the... | [
"Internal",
"utility",
"method",
"to",
"extract",
"optional",
"arguments",
"from",
"kwargs",
"."
] | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/composition.py#L539-L565 | [
"def",
"pop_kwargs",
"(",
"kwargs",
",",
"names_with_defaults",
",",
"# type: List[Tuple[str, Any]]",
"allow_others",
"=",
"False",
")",
":",
"all_arguments",
"=",
"[",
"]",
"for",
"name",
",",
"default_",
"in",
"names_with_defaults",
":",
"try",
":",
"val",
"="... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | CompositionFailure.get_details | Overrides the base method in order to give details on the various successes and failures | valid8/composition.py | def get_details(self):
""" Overrides the base method in order to give details on the various successes and failures """
# transform the dictionary of failures into a printable form
need_to_print_value = True
failures_for_print = OrderedDict()
for validator, failure in self.failu... | def get_details(self):
""" Overrides the base method in order to give details on the various successes and failures """
# transform the dictionary of failures into a printable form
need_to_print_value = True
failures_for_print = OrderedDict()
for validator, failure in self.failu... | [
"Overrides",
"the",
"base",
"method",
"in",
"order",
"to",
"give",
"details",
"on",
"the",
"various",
"successes",
"and",
"failures"
] | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/composition.py#L160-L189 | [
"def",
"get_details",
"(",
"self",
")",
":",
"# transform the dictionary of failures into a printable form",
"need_to_print_value",
"=",
"True",
"failures_for_print",
"=",
"OrderedDict",
"(",
")",
"for",
"validator",
",",
"failure",
"in",
"self",
".",
"failures",
".",
... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | CompositionFailure.play_all_validators | Utility method to play all the provided validators on the provided value and output the
:param validators:
:param value:
:return: | valid8/composition.py | def play_all_validators(self, validators, value):
"""
Utility method to play all the provided validators on the provided value and output the
:param validators:
:param value:
:return:
"""
successes = list()
failures = OrderedDict()
for validator i... | def play_all_validators(self, validators, value):
"""
Utility method to play all the provided validators on the provided value and output the
:param validators:
:param value:
:return:
"""
successes = list()
failures = OrderedDict()
for validator i... | [
"Utility",
"method",
"to",
"play",
"all",
"the",
"provided",
"validators",
"on",
"the",
"provided",
"value",
"and",
"output",
"the"
] | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/composition.py#L191-L213 | [
"def",
"play_all_validators",
"(",
"self",
",",
"validators",
",",
"value",
")",
":",
"successes",
"=",
"list",
"(",
")",
"failures",
"=",
"OrderedDict",
"(",
")",
"for",
"validator",
"in",
"validators",
":",
"name",
"=",
"get_callable_name",
"(",
"validator... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | gen_secret | Generates a secret of given length | dci/common/signature.py | def gen_secret(length=64):
""" Generates a secret of given length
"""
charset = string.ascii_letters + string.digits
return ''.join(random.SystemRandom().choice(charset)
for _ in range(length)) | def gen_secret(length=64):
""" Generates a secret of given length
"""
charset = string.ascii_letters + string.digits
return ''.join(random.SystemRandom().choice(charset)
for _ in range(length)) | [
"Generates",
"a",
"secret",
"of",
"given",
"length"
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/common/signature.py#L21-L26 | [
"def",
"gen_secret",
"(",
"length",
"=",
"64",
")",
":",
"charset",
"=",
"string",
".",
"ascii_letters",
"+",
"string",
".",
"digits",
"return",
"''",
".",
"join",
"(",
"random",
".",
"SystemRandom",
"(",
")",
".",
"choice",
"(",
"charset",
")",
"for",... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | encryptfile | Encrypt a file and write it with .cryptoshop extension.
:param filename: a string with the path to the file to encrypt.
:param passphrase: a string with the user passphrase.
:param algo: a string with the algorithm. Can be srp, aes, twf. Default is srp.
:return: a string with "successfully encrypted" or... | cryptoshop/cryptoshop.py | def encryptfile(filename, passphrase, algo='srp'):
"""
Encrypt a file and write it with .cryptoshop extension.
:param filename: a string with the path to the file to encrypt.
:param passphrase: a string with the user passphrase.
:param algo: a string with the algorithm. Can be srp, aes, twf. Default... | def encryptfile(filename, passphrase, algo='srp'):
"""
Encrypt a file and write it with .cryptoshop extension.
:param filename: a string with the path to the file to encrypt.
:param passphrase: a string with the user passphrase.
:param algo: a string with the algorithm. Can be srp, aes, twf. Default... | [
"Encrypt",
"a",
"file",
"and",
"write",
"it",
"with",
".",
"cryptoshop",
"extension",
".",
":",
"param",
"filename",
":",
"a",
"string",
"with",
"the",
"path",
"to",
"the",
"file",
"to",
"encrypt",
".",
":",
"param",
"passphrase",
":",
"a",
"string",
"... | Antidote1911/cryptoshop | python | https://github.com/Antidote1911/cryptoshop/blob/0b7ff4a6848f2733f4737606957e8042a4d6ca0b/cryptoshop/cryptoshop.py#L104-L161 | [
"def",
"encryptfile",
"(",
"filename",
",",
"passphrase",
",",
"algo",
"=",
"'srp'",
")",
":",
"try",
":",
"if",
"algo",
"==",
"\"srp\"",
":",
"header",
"=",
"b\"Cryptoshop srp \"",
"+",
"b_version",
"crypto_algo",
"=",
"\"Serpent/GCM\"",
"if",
"algo",
"==",... | 0b7ff4a6848f2733f4737606957e8042a4d6ca0b |
train | decryptfile | Decrypt a file and write corresponding decrypted file. We remove the .cryptoshop extension.
:param filename: a string with the path to the file to decrypt.
:param passphrase: a string with the user passphrase.
:return: a string with "successfully decrypted" or error. | cryptoshop/cryptoshop.py | def decryptfile(filename, passphrase):
"""
Decrypt a file and write corresponding decrypted file. We remove the .cryptoshop extension.
:param filename: a string with the path to the file to decrypt.
:param passphrase: a string with the user passphrase.
:return: a string with "successfully decrypted"... | def decryptfile(filename, passphrase):
"""
Decrypt a file and write corresponding decrypted file. We remove the .cryptoshop extension.
:param filename: a string with the path to the file to decrypt.
:param passphrase: a string with the user passphrase.
:return: a string with "successfully decrypted"... | [
"Decrypt",
"a",
"file",
"and",
"write",
"corresponding",
"decrypted",
"file",
".",
"We",
"remove",
"the",
".",
"cryptoshop",
"extension",
".",
":",
"param",
"filename",
":",
"a",
"string",
"with",
"the",
"path",
"to",
"the",
"file",
"to",
"decrypt",
".",
... | Antidote1911/cryptoshop | python | https://github.com/Antidote1911/cryptoshop/blob/0b7ff4a6848f2733f4737606957e8042a4d6ca0b/cryptoshop/cryptoshop.py#L164-L225 | [
"def",
"decryptfile",
"(",
"filename",
",",
"passphrase",
")",
":",
"try",
":",
"outname",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"filename",
")",
"[",
"0",
"]",
".",
"split",
"(",
"\"_\"",
")",
"[",
"-",
"1",
"]",
"# create a string file name w... | 0b7ff4a6848f2733f4737606957e8042a4d6ca0b |
train | Tokenize._tokenize | Split a sentence while preserving tags. | sets/process/tokenize.py | def _tokenize(cls, sentence):
"""
Split a sentence while preserving tags.
"""
while True:
match = cls._regex_tag.search(sentence)
if not match:
yield from cls._split(sentence)
return
chunk = sentence[:match.start()]
... | def _tokenize(cls, sentence):
"""
Split a sentence while preserving tags.
"""
while True:
match = cls._regex_tag.search(sentence)
if not match:
yield from cls._split(sentence)
return
chunk = sentence[:match.start()]
... | [
"Split",
"a",
"sentence",
"while",
"preserving",
"tags",
"."
] | danijar/sets | python | https://github.com/danijar/sets/blob/2542c28f43d0af18932cb5b82f54ffb6ae557d12/sets/process/tokenize.py#L22-L35 | [
"def",
"_tokenize",
"(",
"cls",
",",
"sentence",
")",
":",
"while",
"True",
":",
"match",
"=",
"cls",
".",
"_regex_tag",
".",
"search",
"(",
"sentence",
")",
"if",
"not",
"match",
":",
"yield",
"from",
"cls",
".",
"_split",
"(",
"sentence",
")",
"ret... | 2542c28f43d0af18932cb5b82f54ffb6ae557d12 |
train | map | Implements a distributed stategy for processing XML files. This
function constructs a set of py:mod:`multiprocessing` threads (spread over
multiple cores) and uses an internal queue to aggregate outputs. To use
this function, implement a `process()` function that takes two arguments
-- a :class:`mwxml... | mwxml/map/map.py | def map(process, paths, threads=None):
"""
Implements a distributed stategy for processing XML files. This
function constructs a set of py:mod:`multiprocessing` threads (spread over
multiple cores) and uses an internal queue to aggregate outputs. To use
this function, implement a `process()` funct... | def map(process, paths, threads=None):
"""
Implements a distributed stategy for processing XML files. This
function constructs a set of py:mod:`multiprocessing` threads (spread over
multiple cores) and uses an internal queue to aggregate outputs. To use
this function, implement a `process()` funct... | [
"Implements",
"a",
"distributed",
"stategy",
"for",
"processing",
"XML",
"files",
".",
"This",
"function",
"constructs",
"a",
"set",
"of",
"py",
":",
"mod",
":",
"multiprocessing",
"threads",
"(",
"spread",
"over",
"multiple",
"cores",
")",
"and",
"uses",
"a... | mediawiki-utilities/python-mwxml | python | https://github.com/mediawiki-utilities/python-mwxml/blob/6a8c18be99cd0bcee9c496e607f08bf4dfe5b510/mwxml/map/map.py#L11-L49 | [
"def",
"map",
"(",
"process",
",",
"paths",
",",
"threads",
"=",
"None",
")",
":",
"paths",
"=",
"[",
"mwtypes",
".",
"files",
".",
"normalize_path",
"(",
"path",
")",
"for",
"path",
"in",
"paths",
"]",
"def",
"process_path",
"(",
"path",
")",
":",
... | 6a8c18be99cd0bcee9c496e607f08bf4dfe5b510 |
train | Tracker.dump | Return the object itself. | dci/trackers/__init__.py | def dump(self):
"""Return the object itself."""
return {
'title': self.title,
'issue_id': self.issue_id,
'reporter': self.reporter,
'assignee': self.assignee,
'status': self.status,
'product': self.product,
'component':... | def dump(self):
"""Return the object itself."""
return {
'title': self.title,
'issue_id': self.issue_id,
'reporter': self.reporter,
'assignee': self.assignee,
'status': self.status,
'product': self.product,
'component':... | [
"Return",
"the",
"object",
"itself",
"."
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/trackers/__init__.py#L39-L54 | [
"def",
"dump",
"(",
"self",
")",
":",
"return",
"{",
"'title'",
":",
"self",
".",
"title",
",",
"'issue_id'",
":",
"self",
".",
"issue_id",
",",
"'reporter'",
":",
"self",
".",
"reporter",
",",
"'assignee'",
":",
"self",
".",
"assignee",
",",
"'status'... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | apply_on_each_func_args_sig | Applies func_to_apply on each argument of func according to what's received in current call (cur_args, cur_kwargs).
For each argument of func named 'att' in its signature, the following method is called:
`func_to_apply(cur_att_value, func_to_apply_paramers_dict[att], func, att_name)`
:param func:
:par... | valid8/utils_decoration.py | def apply_on_each_func_args_sig(func,
cur_args,
cur_kwargs,
sig, # type: Signature
func_to_apply,
func_to_apply_params_dict):
"""
Applies func_to_apply... | def apply_on_each_func_args_sig(func,
cur_args,
cur_kwargs,
sig, # type: Signature
func_to_apply,
func_to_apply_params_dict):
"""
Applies func_to_apply... | [
"Applies",
"func_to_apply",
"on",
"each",
"argument",
"of",
"func",
"according",
"to",
"what",
"s",
"received",
"in",
"current",
"call",
"(",
"cur_args",
"cur_kwargs",
")",
".",
"For",
"each",
"argument",
"of",
"func",
"named",
"att",
"in",
"its",
"signature... | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/utils_decoration.py#L15-L45 | [
"def",
"apply_on_each_func_args_sig",
"(",
"func",
",",
"cur_args",
",",
"cur_kwargs",
",",
"sig",
",",
"# type: Signature",
"func_to_apply",
",",
"func_to_apply_params_dict",
")",
":",
"# match the received arguments with the signature to know who is who",
"bound_values",
"=",... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | Identity.is_product_owner | Ensure the user is a PRODUCT_OWNER. | dci/identity.py | def is_product_owner(self, team_id):
"""Ensure the user is a PRODUCT_OWNER."""
if self.is_super_admin():
return True
team_id = uuid.UUID(str(team_id))
return team_id in self.child_teams_ids | def is_product_owner(self, team_id):
"""Ensure the user is a PRODUCT_OWNER."""
if self.is_super_admin():
return True
team_id = uuid.UUID(str(team_id))
return team_id in self.child_teams_ids | [
"Ensure",
"the",
"user",
"is",
"a",
"PRODUCT_OWNER",
"."
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/identity.py#L71-L77 | [
"def",
"is_product_owner",
"(",
"self",
",",
"team_id",
")",
":",
"if",
"self",
".",
"is_super_admin",
"(",
")",
":",
"return",
"True",
"team_id",
"=",
"uuid",
".",
"UUID",
"(",
"str",
"(",
"team_id",
")",
")",
"return",
"team_id",
"in",
"self",
".",
... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | Identity.is_in_team | Test if user is in team | dci/identity.py | def is_in_team(self, team_id):
"""Test if user is in team"""
if self.is_super_admin():
return True
team_id = uuid.UUID(str(team_id))
return team_id in self.teams or team_id in self.child_teams_ids | def is_in_team(self, team_id):
"""Test if user is in team"""
if self.is_super_admin():
return True
team_id = uuid.UUID(str(team_id))
return team_id in self.teams or team_id in self.child_teams_ids | [
"Test",
"if",
"user",
"is",
"in",
"team"
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/identity.py#L96-L102 | [
"def",
"is_in_team",
"(",
"self",
",",
"team_id",
")",
":",
"if",
"self",
".",
"is_super_admin",
"(",
")",
":",
"return",
"True",
"team_id",
"=",
"uuid",
".",
"UUID",
"(",
"str",
"(",
"team_id",
")",
")",
"return",
"team_id",
"in",
"self",
".",
"team... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | Identity.is_remoteci | Ensure ther resource has the role REMOTECI. | dci/identity.py | def is_remoteci(self, team_id=None):
"""Ensure ther resource has the role REMOTECI."""
if team_id is None:
return self._is_remoteci
team_id = uuid.UUID(str(team_id))
if team_id not in self.teams_ids:
return False
return self.teams[team_id]['role'] == 'REMO... | def is_remoteci(self, team_id=None):
"""Ensure ther resource has the role REMOTECI."""
if team_id is None:
return self._is_remoteci
team_id = uuid.UUID(str(team_id))
if team_id not in self.teams_ids:
return False
return self.teams[team_id]['role'] == 'REMO... | [
"Ensure",
"ther",
"resource",
"has",
"the",
"role",
"REMOTECI",
"."
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/identity.py#L112-L119 | [
"def",
"is_remoteci",
"(",
"self",
",",
"team_id",
"=",
"None",
")",
":",
"if",
"team_id",
"is",
"None",
":",
"return",
"self",
".",
"_is_remoteci",
"team_id",
"=",
"uuid",
".",
"UUID",
"(",
"str",
"(",
"team_id",
")",
")",
"if",
"team_id",
"not",
"i... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | Identity.is_feeder | Ensure ther resource has the role FEEDER. | dci/identity.py | def is_feeder(self, team_id=None):
"""Ensure ther resource has the role FEEDER."""
if team_id is None:
return self._is_feeder
team_id = uuid.UUID(str(team_id))
if team_id not in self.teams_ids:
return False
return self.teams[team_id]['role'] == 'FEEDER' | def is_feeder(self, team_id=None):
"""Ensure ther resource has the role FEEDER."""
if team_id is None:
return self._is_feeder
team_id = uuid.UUID(str(team_id))
if team_id not in self.teams_ids:
return False
return self.teams[team_id]['role'] == 'FEEDER' | [
"Ensure",
"ther",
"resource",
"has",
"the",
"role",
"FEEDER",
"."
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/identity.py#L121-L128 | [
"def",
"is_feeder",
"(",
"self",
",",
"team_id",
"=",
"None",
")",
":",
"if",
"team_id",
"is",
"None",
":",
"return",
"self",
".",
"_is_feeder",
"team_id",
"=",
"uuid",
".",
"UUID",
"(",
"str",
"(",
"team_id",
")",
")",
"if",
"team_id",
"not",
"in",
... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | Node.document | :return: the :class:`Document` node that contains this node,
or ``self`` if this node is the document. | xml4h/nodes.py | def document(self):
"""
:return: the :class:`Document` node that contains this node,
or ``self`` if this node is the document.
"""
if self.is_document:
return self
return self.adapter.wrap_document(self.adapter.impl_document) | def document(self):
"""
:return: the :class:`Document` node that contains this node,
or ``self`` if this node is the document.
"""
if self.is_document:
return self
return self.adapter.wrap_document(self.adapter.impl_document) | [
":",
"return",
":",
"the",
":",
"class",
":",
"Document",
"node",
"that",
"contains",
"this",
"node",
"or",
"self",
"if",
"this",
"node",
"is",
"the",
"document",
"."
] | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L111-L118 | [
"def",
"document",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_document",
":",
"return",
"self",
"return",
"self",
".",
"adapter",
".",
"wrap_document",
"(",
"self",
".",
"adapter",
".",
"impl_document",
")"
] | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | Node.root | :return: the root :class:`Element` node of the document that
contains this node, or ``self`` if this node is the root element. | xml4h/nodes.py | def root(self):
"""
:return: the root :class:`Element` node of the document that
contains this node, or ``self`` if this node is the root element.
"""
if self.is_root:
return self
return self.adapter.wrap_node(
self.adapter.impl_root_element, s... | def root(self):
"""
:return: the root :class:`Element` node of the document that
contains this node, or ``self`` if this node is the root element.
"""
if self.is_root:
return self
return self.adapter.wrap_node(
self.adapter.impl_root_element, s... | [
":",
"return",
":",
"the",
"root",
":",
"class",
":",
"Element",
"node",
"of",
"the",
"document",
"that",
"contains",
"this",
"node",
"or",
"self",
"if",
"this",
"node",
"is",
"the",
"root",
"element",
"."
] | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L121-L130 | [
"def",
"root",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_root",
":",
"return",
"self",
"return",
"self",
".",
"adapter",
".",
"wrap_node",
"(",
"self",
".",
"adapter",
".",
"impl_root_element",
",",
"self",
".",
"adapter",
".",
"impl_document",
",",
... | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | Node._convert_nodelist | Convert a list of underlying implementation nodes into a list of
*xml4h* wrapper nodes. | xml4h/nodes.py | def _convert_nodelist(self, impl_nodelist):
"""
Convert a list of underlying implementation nodes into a list of
*xml4h* wrapper nodes.
"""
nodelist = [
self.adapter.wrap_node(n, self.adapter.impl_document, self.adapter)
for n in impl_nodelist]
ret... | def _convert_nodelist(self, impl_nodelist):
"""
Convert a list of underlying implementation nodes into a list of
*xml4h* wrapper nodes.
"""
nodelist = [
self.adapter.wrap_node(n, self.adapter.impl_document, self.adapter)
for n in impl_nodelist]
ret... | [
"Convert",
"a",
"list",
"of",
"underlying",
"implementation",
"nodes",
"into",
"a",
"list",
"of",
"*",
"xml4h",
"*",
"wrapper",
"nodes",
"."
] | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L235-L243 | [
"def",
"_convert_nodelist",
"(",
"self",
",",
"impl_nodelist",
")",
":",
"nodelist",
"=",
"[",
"self",
".",
"adapter",
".",
"wrap_node",
"(",
"n",
",",
"self",
".",
"adapter",
".",
"impl_document",
",",
"self",
".",
"adapter",
")",
"for",
"n",
"in",
"i... | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | Node.parent | :return: the parent of this node, or *None* of the node has no parent. | xml4h/nodes.py | def parent(self):
"""
:return: the parent of this node, or *None* of the node has no parent.
"""
parent_impl_node = self.adapter.get_node_parent(self.impl_node)
return self.adapter.wrap_node(
parent_impl_node, self.adapter.impl_document, self.adapter) | def parent(self):
"""
:return: the parent of this node, or *None* of the node has no parent.
"""
parent_impl_node = self.adapter.get_node_parent(self.impl_node)
return self.adapter.wrap_node(
parent_impl_node, self.adapter.impl_document, self.adapter) | [
":",
"return",
":",
"the",
"parent",
"of",
"this",
"node",
"or",
"*",
"None",
"*",
"of",
"the",
"node",
"has",
"no",
"parent",
"."
] | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L246-L252 | [
"def",
"parent",
"(",
"self",
")",
":",
"parent_impl_node",
"=",
"self",
".",
"adapter",
".",
"get_node_parent",
"(",
"self",
".",
"impl_node",
")",
"return",
"self",
".",
"adapter",
".",
"wrap_node",
"(",
"parent_impl_node",
",",
"self",
".",
"adapter",
"... | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | Node.children | :return: a :class:`NodeList` of this node's child nodes. | xml4h/nodes.py | def children(self):
"""
:return: a :class:`NodeList` of this node's child nodes.
"""
impl_nodelist = self.adapter.get_node_children(self.impl_node)
return self._convert_nodelist(impl_nodelist) | def children(self):
"""
:return: a :class:`NodeList` of this node's child nodes.
"""
impl_nodelist = self.adapter.get_node_children(self.impl_node)
return self._convert_nodelist(impl_nodelist) | [
":",
"return",
":",
"a",
":",
"class",
":",
"NodeList",
"of",
"this",
"node",
"s",
"child",
"nodes",
"."
] | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L268-L273 | [
"def",
"children",
"(",
"self",
")",
":",
"impl_nodelist",
"=",
"self",
".",
"adapter",
".",
"get_node_children",
"(",
"self",
".",
"impl_node",
")",
"return",
"self",
".",
"_convert_nodelist",
"(",
"impl_nodelist",
")"
] | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | Node.child | :return: the first child node matching the given constraints, or \
*None* if there are no matching child nodes.
Delegates to :meth:`NodeList.filter`. | xml4h/nodes.py | def child(self, local_name=None, name=None, ns_uri=None, node_type=None,
filter_fn=None):
"""
:return: the first child node matching the given constraints, or \
*None* if there are no matching child nodes.
Delegates to :meth:`NodeList.filter`.
"""
re... | def child(self, local_name=None, name=None, ns_uri=None, node_type=None,
filter_fn=None):
"""
:return: the first child node matching the given constraints, or \
*None* if there are no matching child nodes.
Delegates to :meth:`NodeList.filter`.
"""
re... | [
":",
"return",
":",
"the",
"first",
"child",
"node",
"matching",
"the",
"given",
"constraints",
"or",
"\\",
"*",
"None",
"*",
"if",
"there",
"are",
"no",
"matching",
"child",
"nodes",
"."
] | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L275-L284 | [
"def",
"child",
"(",
"self",
",",
"local_name",
"=",
"None",
",",
"name",
"=",
"None",
",",
"ns_uri",
"=",
"None",
",",
"node_type",
"=",
"None",
",",
"filter_fn",
"=",
"None",
")",
":",
"return",
"self",
".",
"children",
"(",
"name",
"=",
"name",
... | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | Node.siblings | :return: a list of this node's sibling nodes.
:rtype: NodeList | xml4h/nodes.py | def siblings(self):
"""
:return: a list of this node's sibling nodes.
:rtype: NodeList
"""
impl_nodelist = self.adapter.get_node_children(self.parent.impl_node)
return self._convert_nodelist(
[n for n in impl_nodelist if n != self.impl_node]) | def siblings(self):
"""
:return: a list of this node's sibling nodes.
:rtype: NodeList
"""
impl_nodelist = self.adapter.get_node_children(self.parent.impl_node)
return self._convert_nodelist(
[n for n in impl_nodelist if n != self.impl_node]) | [
":",
"return",
":",
"a",
"list",
"of",
"this",
"node",
"s",
"sibling",
"nodes",
".",
":",
"rtype",
":",
"NodeList"
] | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L295-L302 | [
"def",
"siblings",
"(",
"self",
")",
":",
"impl_nodelist",
"=",
"self",
".",
"adapter",
".",
"get_node_children",
"(",
"self",
".",
"parent",
".",
"impl_node",
")",
"return",
"self",
".",
"_convert_nodelist",
"(",
"[",
"n",
"for",
"n",
"in",
"impl_nodelist... | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | Node.siblings_before | :return: a list of this node's siblings that occur *before* this
node in the DOM. | xml4h/nodes.py | def siblings_before(self):
"""
:return: a list of this node's siblings that occur *before* this
node in the DOM.
"""
impl_nodelist = self.adapter.get_node_children(self.parent.impl_node)
before_nodelist = []
for n in impl_nodelist:
if n == self.imp... | def siblings_before(self):
"""
:return: a list of this node's siblings that occur *before* this
node in the DOM.
"""
impl_nodelist = self.adapter.get_node_children(self.parent.impl_node)
before_nodelist = []
for n in impl_nodelist:
if n == self.imp... | [
":",
"return",
":",
"a",
"list",
"of",
"this",
"node",
"s",
"siblings",
"that",
"occur",
"*",
"before",
"*",
"this",
"node",
"in",
"the",
"DOM",
"."
] | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L305-L316 | [
"def",
"siblings_before",
"(",
"self",
")",
":",
"impl_nodelist",
"=",
"self",
".",
"adapter",
".",
"get_node_children",
"(",
"self",
".",
"parent",
".",
"impl_node",
")",
"before_nodelist",
"=",
"[",
"]",
"for",
"n",
"in",
"impl_nodelist",
":",
"if",
"n",... | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | Node.siblings_after | :return: a list of this node's siblings that occur *after* this
node in the DOM. | xml4h/nodes.py | def siblings_after(self):
"""
:return: a list of this node's siblings that occur *after* this
node in the DOM.
"""
impl_nodelist = self.adapter.get_node_children(self.parent.impl_node)
after_nodelist = []
is_after_myself = False
for n in impl_nodelist:... | def siblings_after(self):
"""
:return: a list of this node's siblings that occur *after* this
node in the DOM.
"""
impl_nodelist = self.adapter.get_node_children(self.parent.impl_node)
after_nodelist = []
is_after_myself = False
for n in impl_nodelist:... | [
":",
"return",
":",
"a",
"list",
"of",
"this",
"node",
"s",
"siblings",
"that",
"occur",
"*",
"after",
"*",
"this",
"node",
"in",
"the",
"DOM",
"."
] | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L319-L332 | [
"def",
"siblings_after",
"(",
"self",
")",
":",
"impl_nodelist",
"=",
"self",
".",
"adapter",
".",
"get_node_children",
"(",
"self",
".",
"parent",
".",
"impl_node",
")",
"after_nodelist",
"=",
"[",
"]",
"is_after_myself",
"=",
"False",
"for",
"n",
"in",
"... | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | Node.delete | Delete this node from the owning document.
:param bool destroy: if True the child node will be destroyed in
addition to being removed from the document.
:returns: the removed child node, or *None* if the child was destroyed. | xml4h/nodes.py | def delete(self, destroy=True):
"""
Delete this node from the owning document.
:param bool destroy: if True the child node will be destroyed in
addition to being removed from the document.
:returns: the removed child node, or *None* if the child was destroyed.
"""
... | def delete(self, destroy=True):
"""
Delete this node from the owning document.
:param bool destroy: if True the child node will be destroyed in
addition to being removed from the document.
:returns: the removed child node, or *None* if the child was destroyed.
"""
... | [
"Delete",
"this",
"node",
"from",
"the",
"owning",
"document",
"."
] | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L344-L359 | [
"def",
"delete",
"(",
"self",
",",
"destroy",
"=",
"True",
")",
":",
"removed_child",
"=",
"self",
".",
"adapter",
".",
"remove_node_child",
"(",
"self",
".",
"adapter",
".",
"get_node_parent",
"(",
"self",
".",
"impl_node",
")",
",",
"self",
".",
"impl_... | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | Node.clone_node | Clone a node from another document to become a child of this node, by
copying the node's data into this document but leaving the node
untouched in the source document. The node to be cloned can be
a :class:`Node` based on the same underlying XML library implementation
and adapter, or a "... | xml4h/nodes.py | def clone_node(self, node):
"""
Clone a node from another document to become a child of this node, by
copying the node's data into this document but leaving the node
untouched in the source document. The node to be cloned can be
a :class:`Node` based on the same underlying XML li... | def clone_node(self, node):
"""
Clone a node from another document to become a child of this node, by
copying the node's data into this document but leaving the node
untouched in the source document. The node to be cloned can be
a :class:`Node` based on the same underlying XML li... | [
"Clone",
"a",
"node",
"from",
"another",
"document",
"to",
"become",
"a",
"child",
"of",
"this",
"node",
"by",
"copying",
"the",
"node",
"s",
"data",
"into",
"this",
"document",
"but",
"leaving",
"the",
"node",
"untouched",
"in",
"the",
"source",
"document... | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L361-L376 | [
"def",
"clone_node",
"(",
"self",
",",
"node",
")",
":",
"if",
"isinstance",
"(",
"node",
",",
"xml4h",
".",
"nodes",
".",
"Node",
")",
":",
"child_impl_node",
"=",
"node",
".",
"impl_node",
"else",
":",
"child_impl_node",
"=",
"node",
"# Assume it's a val... | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | Node.transplant_node | Transplant a node from another document to become a child of this node,
removing it from the source document. The node to be transplanted can
be a :class:`Node` based on the same underlying XML library
implementation and adapter, or a "raw" node from that implementation.
:param node: t... | xml4h/nodes.py | def transplant_node(self, node):
"""
Transplant a node from another document to become a child of this node,
removing it from the source document. The node to be transplanted can
be a :class:`Node` based on the same underlying XML library
implementation and adapter, or a "raw" n... | def transplant_node(self, node):
"""
Transplant a node from another document to become a child of this node,
removing it from the source document. The node to be transplanted can
be a :class:`Node` based on the same underlying XML library
implementation and adapter, or a "raw" n... | [
"Transplant",
"a",
"node",
"from",
"another",
"document",
"to",
"become",
"a",
"child",
"of",
"this",
"node",
"removing",
"it",
"from",
"the",
"source",
"document",
".",
"The",
"node",
"to",
"be",
"transplanted",
"can",
"be",
"a",
":",
"class",
":",
"Nod... | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L378-L395 | [
"def",
"transplant_node",
"(",
"self",
",",
"node",
")",
":",
"if",
"isinstance",
"(",
"node",
",",
"xml4h",
".",
"nodes",
".",
"Node",
")",
":",
"child_impl_node",
"=",
"node",
".",
"impl_node",
"original_parent_impl_node",
"=",
"node",
".",
"parent",
"."... | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | Node.find | Find :class:`Element` node descendants of this node, with optional
constraints to limit the results.
:param name: limit results to elements with this name.
If *None* or ``'*'`` all element names are matched.
:type name: string or None
:param ns_uri: limit results to elements... | xml4h/nodes.py | def find(self, name=None, ns_uri=None, first_only=False):
"""
Find :class:`Element` node descendants of this node, with optional
constraints to limit the results.
:param name: limit results to elements with this name.
If *None* or ``'*'`` all element names are matched.
... | def find(self, name=None, ns_uri=None, first_only=False):
"""
Find :class:`Element` node descendants of this node, with optional
constraints to limit the results.
:param name: limit results to elements with this name.
If *None* or ``'*'`` all element names are matched.
... | [
"Find",
":",
"class",
":",
"Element",
"node",
"descendants",
"of",
"this",
"node",
"with",
"optional",
"constraints",
"to",
"limit",
"the",
"results",
"."
] | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L397-L426 | [
"def",
"find",
"(",
"self",
",",
"name",
"=",
"None",
",",
"ns_uri",
"=",
"None",
",",
"first_only",
"=",
"False",
")",
":",
"if",
"name",
"is",
"None",
":",
"name",
"=",
"'*'",
"# Match all element names",
"if",
"ns_uri",
"is",
"None",
":",
"ns_uri",
... | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | Node.find_first | Find the first :class:`Element` node descendant of this node that
matches any optional constraints, or None if there are no matching
elements.
Delegates to :meth:`find` with ``first_only=True``. | xml4h/nodes.py | def find_first(self, name=None, ns_uri=None):
"""
Find the first :class:`Element` node descendant of this node that
matches any optional constraints, or None if there are no matching
elements.
Delegates to :meth:`find` with ``first_only=True``.
"""
return self.fi... | def find_first(self, name=None, ns_uri=None):
"""
Find the first :class:`Element` node descendant of this node that
matches any optional constraints, or None if there are no matching
elements.
Delegates to :meth:`find` with ``first_only=True``.
"""
return self.fi... | [
"Find",
"the",
"first",
":",
"class",
":",
"Element",
"node",
"descendant",
"of",
"this",
"node",
"that",
"matches",
"any",
"optional",
"constraints",
"or",
"None",
"if",
"there",
"are",
"no",
"matching",
"elements",
"."
] | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L428-L436 | [
"def",
"find_first",
"(",
"self",
",",
"name",
"=",
"None",
",",
"ns_uri",
"=",
"None",
")",
":",
"return",
"self",
".",
"find",
"(",
"name",
"=",
"name",
",",
"ns_uri",
"=",
"ns_uri",
",",
"first_only",
"=",
"True",
")"
] | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | Node.find_doc | Find :class:`Element` node descendants of the document containing
this node, with optional constraints to limit the results.
Delegates to :meth:`find` applied to this node's owning document. | xml4h/nodes.py | def find_doc(self, name=None, ns_uri=None, first_only=False):
"""
Find :class:`Element` node descendants of the document containing
this node, with optional constraints to limit the results.
Delegates to :meth:`find` applied to this node's owning document.
"""
return sel... | def find_doc(self, name=None, ns_uri=None, first_only=False):
"""
Find :class:`Element` node descendants of the document containing
this node, with optional constraints to limit the results.
Delegates to :meth:`find` applied to this node's owning document.
"""
return sel... | [
"Find",
":",
"class",
":",
"Element",
"node",
"descendants",
"of",
"the",
"document",
"containing",
"this",
"node",
"with",
"optional",
"constraints",
"to",
"limit",
"the",
"results",
"."
] | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L438-L446 | [
"def",
"find_doc",
"(",
"self",
",",
"name",
"=",
"None",
",",
"ns_uri",
"=",
"None",
",",
"first_only",
"=",
"False",
")",
":",
"return",
"self",
".",
"document",
".",
"find",
"(",
"name",
"=",
"name",
",",
"ns_uri",
"=",
"ns_uri",
",",
"first_only"... | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | Node.write | Serialize this node and its descendants to text, writing
the output to a given *writer* or to stdout.
:param writer: an object such as a file or stream to which XML text
is sent. If *None* text is sent to :attr:`sys.stdout`.
:type writer: a file, stream, etc or None
:param s... | xml4h/nodes.py | def write(self, writer=None, encoding='utf-8', indent=0, newline='',
omit_declaration=False, node_depth=0, quote_char='"'):
"""
Serialize this node and its descendants to text, writing
the output to a given *writer* or to stdout.
:param writer: an object such as a file or st... | def write(self, writer=None, encoding='utf-8', indent=0, newline='',
omit_declaration=False, node_depth=0, quote_char='"'):
"""
Serialize this node and its descendants to text, writing
the output to a given *writer* or to stdout.
:param writer: an object such as a file or st... | [
"Serialize",
"this",
"node",
"and",
"its",
"descendants",
"to",
"text",
"writing",
"the",
"output",
"to",
"a",
"given",
"*",
"writer",
"*",
"or",
"to",
"stdout",
"."
] | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L450-L492 | [
"def",
"write",
"(",
"self",
",",
"writer",
"=",
"None",
",",
"encoding",
"=",
"'utf-8'",
",",
"indent",
"=",
"0",
",",
"newline",
"=",
"''",
",",
"omit_declaration",
"=",
"False",
",",
"node_depth",
"=",
"0",
",",
"quote_char",
"=",
"'\"'",
")",
":"... | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | Node.xml | :return: this node as XML text.
Delegates to :meth:`write` | xml4h/nodes.py | def xml(self, indent=4, **kwargs):
"""
:return: this node as XML text.
Delegates to :meth:`write`
"""
writer = StringIO()
self.write(writer, indent=indent, **kwargs)
return writer.getvalue() | def xml(self, indent=4, **kwargs):
"""
:return: this node as XML text.
Delegates to :meth:`write`
"""
writer = StringIO()
self.write(writer, indent=indent, **kwargs)
return writer.getvalue() | [
":",
"return",
":",
"this",
"node",
"as",
"XML",
"text",
"."
] | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L503-L511 | [
"def",
"xml",
"(",
"self",
",",
"indent",
"=",
"4",
",",
"*",
"*",
"kwargs",
")",
":",
"writer",
"=",
"StringIO",
"(",
")",
"self",
".",
"write",
"(",
"writer",
",",
"indent",
"=",
"indent",
",",
"*",
"*",
"kwargs",
")",
"return",
"writer",
".",
... | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | XPathMixin.xpath | Perform an XPath query on the current node.
:param string xpath: XPath query.
:param dict kwargs: Optional keyword arguments that are passed through
to the underlying XML library implementation.
:return: results of the query as a list of :class:`Node` objects, or
a list... | xml4h/nodes.py | def xpath(self, xpath, **kwargs):
"""
Perform an XPath query on the current node.
:param string xpath: XPath query.
:param dict kwargs: Optional keyword arguments that are passed through
to the underlying XML library implementation.
:return: results of the query as ... | def xpath(self, xpath, **kwargs):
"""
Perform an XPath query on the current node.
:param string xpath: XPath query.
:param dict kwargs: Optional keyword arguments that are passed through
to the underlying XML library implementation.
:return: results of the query as ... | [
"Perform",
"an",
"XPath",
"query",
"on",
"the",
"current",
"node",
"."
] | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L595-L611 | [
"def",
"xpath",
"(",
"self",
",",
"xpath",
",",
"*",
"*",
"kwargs",
")",
":",
"result",
"=",
"self",
".",
"adapter",
".",
"xpath_on_node",
"(",
"self",
".",
"impl_node",
",",
"xpath",
",",
"*",
"*",
"kwargs",
")",
"if",
"isinstance",
"(",
"result",
... | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | Element.set_attributes | Add or update this element's attributes, where attributes can be
specified in a number of ways.
:param attr_obj: a dictionary or list of attribute name/value pairs.
:type attr_obj: dict, list, tuple, or None
:param ns_uri: a URI defining a namespace for the new attributes.
:type... | xml4h/nodes.py | def set_attributes(self, attr_obj=None, ns_uri=None, **attr_dict):
"""
Add or update this element's attributes, where attributes can be
specified in a number of ways.
:param attr_obj: a dictionary or list of attribute name/value pairs.
:type attr_obj: dict, list, tuple, or None
... | def set_attributes(self, attr_obj=None, ns_uri=None, **attr_dict):
"""
Add or update this element's attributes, where attributes can be
specified in a number of ways.
:param attr_obj: a dictionary or list of attribute name/value pairs.
:type attr_obj: dict, list, tuple, or None
... | [
"Add",
"or",
"update",
"this",
"element",
"s",
"attributes",
"where",
"attributes",
"can",
"be",
"specified",
"in",
"a",
"number",
"of",
"ways",
"."
] | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L841-L854 | [
"def",
"set_attributes",
"(",
"self",
",",
"attr_obj",
"=",
"None",
",",
"ns_uri",
"=",
"None",
",",
"*",
"*",
"attr_dict",
")",
":",
"self",
".",
"_set_element_attributes",
"(",
"self",
".",
"impl_node",
",",
"attr_obj",
"=",
"attr_obj",
",",
"ns_uri",
... | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | Element.attributes | Get or set this element's attributes as name/value pairs.
.. note::
Setting element attributes via this accessor will **remove**
any existing attributes, as opposed to the :meth:`set_attributes`
method which only updates and replaces them. | xml4h/nodes.py | def attributes(self):
"""
Get or set this element's attributes as name/value pairs.
.. note::
Setting element attributes via this accessor will **remove**
any existing attributes, as opposed to the :meth:`set_attributes`
method which only updates and replaces... | def attributes(self):
"""
Get or set this element's attributes as name/value pairs.
.. note::
Setting element attributes via this accessor will **remove**
any existing attributes, as opposed to the :meth:`set_attributes`
method which only updates and replaces... | [
"Get",
"or",
"set",
"this",
"element",
"s",
"attributes",
"as",
"name",
"/",
"value",
"pairs",
"."
] | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L857-L867 | [
"def",
"attributes",
"(",
"self",
")",
":",
"attr_impl_nodes",
"=",
"self",
".",
"adapter",
".",
"get_node_attributes",
"(",
"self",
".",
"impl_node",
")",
"return",
"AttributeDict",
"(",
"attr_impl_nodes",
",",
"self",
".",
"impl_node",
",",
"self",
".",
"a... | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | Element.attribute_nodes | :return: a list of this element's attributes as
:class:`Attribute` nodes. | xml4h/nodes.py | def attribute_nodes(self):
"""
:return: a list of this element's attributes as
:class:`Attribute` nodes.
"""
impl_attr_nodes = self.adapter.get_node_attributes(self.impl_node)
wrapped_attr_nodes = [
self.adapter.wrap_node(a, self.adapter.impl_document, sel... | def attribute_nodes(self):
"""
:return: a list of this element's attributes as
:class:`Attribute` nodes.
"""
impl_attr_nodes = self.adapter.get_node_attributes(self.impl_node)
wrapped_attr_nodes = [
self.adapter.wrap_node(a, self.adapter.impl_document, sel... | [
":",
"return",
":",
"a",
"list",
"of",
"this",
"element",
"s",
"attributes",
"as",
":",
"class",
":",
"Attribute",
"nodes",
"."
] | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L891-L900 | [
"def",
"attribute_nodes",
"(",
"self",
")",
":",
"impl_attr_nodes",
"=",
"self",
".",
"adapter",
".",
"get_node_attributes",
"(",
"self",
".",
"impl_node",
")",
"wrapped_attr_nodes",
"=",
"[",
"self",
".",
"adapter",
".",
"wrap_node",
"(",
"a",
",",
"self",
... | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | Element.attribute_node | :param string name: the name of the attribute to return.
:param ns_uri: a URI defining a namespace constraint on the attribute.
:type ns_uri: string or None
:return: this element's attributes that match ``ns_uri`` as
:class:`Attribute` nodes. | xml4h/nodes.py | def attribute_node(self, name, ns_uri=None):
"""
:param string name: the name of the attribute to return.
:param ns_uri: a URI defining a namespace constraint on the attribute.
:type ns_uri: string or None
:return: this element's attributes that match ``ns_uri`` as
:... | def attribute_node(self, name, ns_uri=None):
"""
:param string name: the name of the attribute to return.
:param ns_uri: a URI defining a namespace constraint on the attribute.
:type ns_uri: string or None
:return: this element's attributes that match ``ns_uri`` as
:... | [
":",
"param",
"string",
"name",
":",
"the",
"name",
"of",
"the",
"attribute",
"to",
"return",
".",
":",
"param",
"ns_uri",
":",
"a",
"URI",
"defining",
"a",
"namespace",
"constraint",
"on",
"the",
"attribute",
".",
":",
"type",
"ns_uri",
":",
"string",
... | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L902-L914 | [
"def",
"attribute_node",
"(",
"self",
",",
"name",
",",
"ns_uri",
"=",
"None",
")",
":",
"attr_impl_node",
"=",
"self",
".",
"adapter",
".",
"get_node_attribute_node",
"(",
"self",
".",
"impl_node",
",",
"name",
",",
"ns_uri",
")",
"return",
"self",
".",
... | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | Element.set_ns_prefix | Define a namespace prefix that will serve as shorthand for the given
namespace URI in element names.
:param string prefix: prefix that will serve as an alias for a
the namespace URI.
:param string ns_uri: namespace URI that will be denoted by the
prefix. | xml4h/nodes.py | def set_ns_prefix(self, prefix, ns_uri):
"""
Define a namespace prefix that will serve as shorthand for the given
namespace URI in element names.
:param string prefix: prefix that will serve as an alias for a
the namespace URI.
:param string ns_uri: namespace URI tha... | def set_ns_prefix(self, prefix, ns_uri):
"""
Define a namespace prefix that will serve as shorthand for the given
namespace URI in element names.
:param string prefix: prefix that will serve as an alias for a
the namespace URI.
:param string ns_uri: namespace URI tha... | [
"Define",
"a",
"namespace",
"prefix",
"that",
"will",
"serve",
"as",
"shorthand",
"for",
"the",
"given",
"namespace",
"URI",
"in",
"element",
"names",
"."
] | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L925-L935 | [
"def",
"set_ns_prefix",
"(",
"self",
",",
"prefix",
",",
"ns_uri",
")",
":",
"self",
".",
"_add_ns_prefix_attr",
"(",
"self",
".",
"impl_node",
",",
"prefix",
",",
"ns_uri",
")"
] | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | Element.add_element | Add a new child element to this element, with an optional namespace
definition. If no namespace is provided the child will be assigned
to the default namespace.
:param string name: a name for the child node. The name may be used
to apply a namespace to the child by including:
... | xml4h/nodes.py | def add_element(self, name, ns_uri=None, attributes=None,
text=None, before_this_element=False):
"""
Add a new child element to this element, with an optional namespace
definition. If no namespace is provided the child will be assigned
to the default namespace.
:para... | def add_element(self, name, ns_uri=None, attributes=None,
text=None, before_this_element=False):
"""
Add a new child element to this element, with an optional namespace
definition. If no namespace is provided the child will be assigned
to the default namespace.
:para... | [
"Add",
"a",
"new",
"child",
"element",
"to",
"this",
"element",
"with",
"an",
"optional",
"namespace",
"definition",
".",
"If",
"no",
"namespace",
"is",
"provided",
"the",
"child",
"will",
"be",
"assigned",
"to",
"the",
"default",
"namespace",
"."
] | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L937-L1008 | [
"def",
"add_element",
"(",
"self",
",",
"name",
",",
"ns_uri",
"=",
"None",
",",
"attributes",
"=",
"None",
",",
"text",
"=",
"None",
",",
"before_this_element",
"=",
"False",
")",
":",
"# Determine local name, namespace and prefix info from tag name",
"prefix",
"... | adbb45e27a01a869a505aee7bc16bad2f517b511 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.