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 | Element.add_text | Add a text node to this element.
Adding text with this method is subtly different from assigning a new
text value with :meth:`text` accessor, because it "appends" to rather
than replacing this element's set of text nodes.
:param text: text content to add to this element.
:param... | xml4h/nodes.py | def add_text(self, text):
"""
Add a text node to this element.
Adding text with this method is subtly different from assigning a new
text value with :meth:`text` accessor, because it "appends" to rather
than replacing this element's set of text nodes.
:param text: text ... | def add_text(self, text):
"""
Add a text node to this element.
Adding text with this method is subtly different from assigning a new
text value with :meth:`text` accessor, because it "appends" to rather
than replacing this element's set of text nodes.
:param text: text ... | [
"Add",
"a",
"text",
"node",
"to",
"this",
"element",
"."
] | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L1014-L1027 | [
"def",
"add_text",
"(",
"self",
",",
"text",
")",
":",
"if",
"not",
"isinstance",
"(",
"text",
",",
"basestring",
")",
":",
"text",
"=",
"unicode",
"(",
"text",
")",
"self",
".",
"_add_text",
"(",
"self",
".",
"impl_node",
",",
"text",
")"
] | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | Element.add_instruction | Add an instruction node to this element.
:param string text: text content to add as an instruction. | xml4h/nodes.py | def add_instruction(self, target, data):
"""
Add an instruction node to this element.
:param string text: text content to add as an instruction.
"""
self._add_instruction(self.impl_node, target, data) | def add_instruction(self, target, data):
"""
Add an instruction node to this element.
:param string text: text content to add as an instruction.
"""
self._add_instruction(self.impl_node, target, data) | [
"Add",
"an",
"instruction",
"node",
"to",
"this",
"element",
"."
] | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L1045-L1051 | [
"def",
"add_instruction",
"(",
"self",
",",
"target",
",",
"data",
")",
":",
"self",
".",
"_add_instruction",
"(",
"self",
".",
"impl_node",
",",
"target",
",",
"data",
")"
] | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | AttributeDict.items | :return: a list of name/value attribute pairs sorted by attribute name. | xml4h/nodes.py | def items(self):
"""
:return: a list of name/value attribute pairs sorted by attribute name.
"""
sorted_keys = sorted(self.keys())
return [(k, self[k]) for k in sorted_keys] | def items(self):
"""
:return: a list of name/value attribute pairs sorted by attribute name.
"""
sorted_keys = sorted(self.keys())
return [(k, self[k]) for k in sorted_keys] | [
":",
"return",
":",
"a",
"list",
"of",
"name",
"/",
"value",
"attribute",
"pairs",
"sorted",
"by",
"attribute",
"name",
"."
] | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L1135-L1140 | [
"def",
"items",
"(",
"self",
")",
":",
"sorted_keys",
"=",
"sorted",
"(",
"self",
".",
"keys",
"(",
")",
")",
"return",
"[",
"(",
"k",
",",
"self",
"[",
"k",
"]",
")",
"for",
"k",
"in",
"sorted_keys",
"]"
] | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | AttributeDict.namespace_uri | :param string name: the name of an attribute to look up.
:return: the namespace URI associated with the named attribute,
or None. | xml4h/nodes.py | def namespace_uri(self, name):
"""
:param string name: the name of an attribute to look up.
:return: the namespace URI associated with the named attribute,
or None.
"""
a_node = self.adapter.get_node_attribute_node(self.impl_element, name)
if a_node is None:
... | def namespace_uri(self, name):
"""
:param string name: the name of an attribute to look up.
:return: the namespace URI associated with the named attribute,
or None.
"""
a_node = self.adapter.get_node_attribute_node(self.impl_element, name)
if a_node is None:
... | [
":",
"param",
"string",
"name",
":",
"the",
"name",
"of",
"an",
"attribute",
"to",
"look",
"up",
"."
] | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L1142-L1152 | [
"def",
"namespace_uri",
"(",
"self",
",",
"name",
")",
":",
"a_node",
"=",
"self",
".",
"adapter",
".",
"get_node_attribute_node",
"(",
"self",
".",
"impl_element",
",",
"name",
")",
"if",
"a_node",
"is",
"None",
":",
"return",
"None",
"return",
"self",
... | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | AttributeDict.prefix | :param string name: the name of an attribute to look up.
:return: the prefix component of the named attribute's name,
or None. | xml4h/nodes.py | def prefix(self, name):
"""
:param string name: the name of an attribute to look up.
:return: the prefix component of the named attribute's name,
or None.
"""
a_node = self.adapter.get_node_attribute_node(self.impl_element, name)
if a_node is None:
... | def prefix(self, name):
"""
:param string name: the name of an attribute to look up.
:return: the prefix component of the named attribute's name,
or None.
"""
a_node = self.adapter.get_node_attribute_node(self.impl_element, name)
if a_node is None:
... | [
":",
"param",
"string",
"name",
":",
"the",
"name",
"of",
"an",
"attribute",
"to",
"look",
"up",
"."
] | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L1154-L1164 | [
"def",
"prefix",
"(",
"self",
",",
"name",
")",
":",
"a_node",
"=",
"self",
".",
"adapter",
".",
"get_node_attribute_node",
"(",
"self",
".",
"impl_element",
",",
"name",
")",
"if",
"a_node",
"is",
"None",
":",
"return",
"None",
"return",
"a_node",
".",
... | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | AttributeDict.element | :return: the :class:`Element` that contains these attributes. | xml4h/nodes.py | def element(self):
"""
:return: the :class:`Element` that contains these attributes.
"""
return self.adapter.wrap_node(
self.impl_element, self.adapter.impl_document, self.adapter) | def element(self):
"""
:return: the :class:`Element` that contains these attributes.
"""
return self.adapter.wrap_node(
self.impl_element, self.adapter.impl_document, self.adapter) | [
":",
"return",
":",
"the",
":",
"class",
":",
"Element",
"that",
"contains",
"these",
"attributes",
"."
] | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L1175-L1180 | [
"def",
"element",
"(",
"self",
")",
":",
"return",
"self",
".",
"adapter",
".",
"wrap_node",
"(",
"self",
".",
"impl_element",
",",
"self",
".",
"adapter",
".",
"impl_document",
",",
"self",
".",
"adapter",
")"
] | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | NodeList.filter | Apply filters to the set of nodes in this list.
:param local_name: a local name used to filter the nodes.
:type local_name: string or None
:param name: a name used to filter the nodes.
:type name: string or None
:param ns_uri: a namespace URI used to filter the nodes.
... | xml4h/nodes.py | def filter(self, local_name=None, name=None, ns_uri=None, node_type=None,
filter_fn=None, first_only=False):
"""
Apply filters to the set of nodes in this list.
:param local_name: a local name used to filter the nodes.
:type local_name: string or None
:param name: a ... | def filter(self, local_name=None, name=None, ns_uri=None, node_type=None,
filter_fn=None, first_only=False):
"""
Apply filters to the set of nodes in this list.
:param local_name: a local name used to filter the nodes.
:type local_name: string or None
:param name: a ... | [
"Apply",
"filters",
"to",
"the",
"set",
"of",
"nodes",
"in",
"this",
"list",
"."
] | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L1197-L1255 | [
"def",
"filter",
"(",
"self",
",",
"local_name",
"=",
"None",
",",
"name",
"=",
"None",
",",
"ns_uri",
"=",
"None",
",",
"node_type",
"=",
"None",
",",
"filter_fn",
"=",
"None",
",",
"first_only",
"=",
"False",
")",
":",
"# Build our own filter function un... | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | get_all_analytics | Get all analytics of a job. | dci/api/v1/analytics.py | def get_all_analytics(user, job_id):
"""Get all analytics of a job."""
args = schemas.args(flask.request.args.to_dict())
v1_utils.verify_existence_and_get(job_id, models.JOBS)
query = v1_utils.QueryBuilder(_TABLE, args, _A_COLUMNS)
# If not admin nor rh employee then restrict the view to the team
... | def get_all_analytics(user, job_id):
"""Get all analytics of a job."""
args = schemas.args(flask.request.args.to_dict())
v1_utils.verify_existence_and_get(job_id, models.JOBS)
query = v1_utils.QueryBuilder(_TABLE, args, _A_COLUMNS)
# If not admin nor rh employee then restrict the view to the team
... | [
"Get",
"all",
"analytics",
"of",
"a",
"job",
"."
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/analytics.py#L53-L70 | [
"def",
"get_all_analytics",
"(",
"user",
",",
"job_id",
")",
":",
"args",
"=",
"schemas",
".",
"args",
"(",
"flask",
".",
"request",
".",
"args",
".",
"to_dict",
"(",
")",
")",
"v1_utils",
".",
"verify_existence_and_get",
"(",
"job_id",
",",
"models",
".... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | get_analytic | Get an analytic. | dci/api/v1/analytics.py | def get_analytic(user, job_id, anc_id):
"""Get an analytic."""
v1_utils.verify_existence_and_get(job_id, models.JOBS)
analytic = v1_utils.verify_existence_and_get(anc_id, _TABLE)
analytic = dict(analytic)
if not user.is_in_team(analytic['team_id']):
raise dci_exc.Unauthorized()
return f... | def get_analytic(user, job_id, anc_id):
"""Get an analytic."""
v1_utils.verify_existence_and_get(job_id, models.JOBS)
analytic = v1_utils.verify_existence_and_get(anc_id, _TABLE)
analytic = dict(analytic)
if not user.is_in_team(analytic['team_id']):
raise dci_exc.Unauthorized()
return f... | [
"Get",
"an",
"analytic",
"."
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/analytics.py#L75-L83 | [
"def",
"get_analytic",
"(",
"user",
",",
"job_id",
",",
"anc_id",
")",
":",
"v1_utils",
".",
"verify_existence_and_get",
"(",
"job_id",
",",
"models",
".",
"JOBS",
")",
"analytic",
"=",
"v1_utils",
".",
"verify_existence_and_get",
"(",
"anc_id",
",",
"_TABLE",... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | write_node | Serialize an *xml4h* DOM node and its descendants to text, writing
the output to a given *writer* or to stdout.
:param node: the DOM node whose content and descendants will
be serialized.
:type node: an :class:`xml4h.nodes.Node` or subclass
:param writer: an object such as a file or stream to w... | xml4h/writer.py | def write_node(node, writer=None, encoding='utf-8', indent=0, newline='',
omit_declaration=False, node_depth=0, quote_char='"'):
"""
Serialize an *xml4h* DOM node and its descendants to text, writing
the output to a given *writer* or to stdout.
:param node: the DOM node whose content and descen... | def write_node(node, writer=None, encoding='utf-8', indent=0, newline='',
omit_declaration=False, node_depth=0, quote_char='"'):
"""
Serialize an *xml4h* DOM node and its descendants to text, writing
the output to a given *writer* or to stdout.
:param node: the DOM node whose content and descen... | [
"Serialize",
"an",
"*",
"xml4h",
"*",
"DOM",
"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/writer.py#L12-L182 | [
"def",
"write_node",
"(",
"node",
",",
"writer",
"=",
"None",
",",
"encoding",
"=",
"'utf-8'",
",",
"indent",
"=",
"0",
",",
"newline",
"=",
"''",
",",
"omit_declaration",
"=",
"False",
",",
"node_depth",
"=",
"0",
",",
"quote_char",
"=",
"'\"'",
")",
... | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | encry_decry_chunk | When bool_encry is True, encrypt a chunk of the file with the key and a randomly generated nonce. When it is False,
the function extract the nonce from the cipherchunk (first 16 bytes), and decrypt the rest of the chunk.
:param chunk: a chunk in bytes to encrypt or decrypt.
:param key: a 32 bytes key in byt... | cryptoshop/_chunk_engine.py | def encry_decry_chunk(chunk, key, algo, bool_encry, assoc_data):
"""
When bool_encry is True, encrypt a chunk of the file with the key and a randomly generated nonce. When it is False,
the function extract the nonce from the cipherchunk (first 16 bytes), and decrypt the rest of the chunk.
:param chunk: ... | def encry_decry_chunk(chunk, key, algo, bool_encry, assoc_data):
"""
When bool_encry is True, encrypt a chunk of the file with the key and a randomly generated nonce. When it is False,
the function extract the nonce from the cipherchunk (first 16 bytes), and decrypt the rest of the chunk.
:param chunk: ... | [
"When",
"bool_encry",
"is",
"True",
"encrypt",
"a",
"chunk",
"of",
"the",
"file",
"with",
"the",
"key",
"and",
"a",
"randomly",
"generated",
"nonce",
".",
"When",
"it",
"is",
"False",
"the",
"function",
"extract",
"the",
"nonce",
"from",
"the",
"cipherchun... | Antidote1911/cryptoshop | python | https://github.com/Antidote1911/cryptoshop/blob/0b7ff4a6848f2733f4737606957e8042a4d6ca0b/cryptoshop/_chunk_engine.py#L39-L64 | [
"def",
"encry_decry_chunk",
"(",
"chunk",
",",
"key",
",",
"algo",
",",
"bool_encry",
",",
"assoc_data",
")",
":",
"engine",
"=",
"botan",
".",
"cipher",
"(",
"algo",
"=",
"algo",
",",
"encrypt",
"=",
"bool_encry",
")",
"engine",
".",
"set_key",
"(",
"... | 0b7ff4a6848f2733f4737606957e8042a4d6ca0b |
train | Bugzilla.retrieve_info | Query Bugzilla API to retrieve the needed infos. | dci/trackers/bugzilla.py | def retrieve_info(self):
"""Query Bugzilla API to retrieve the needed infos."""
scheme = urlparse(self.url).scheme
netloc = urlparse(self.url).netloc
query = urlparse(self.url).query
if scheme not in ('http', 'https'):
return
for item in query.split('&'):
... | def retrieve_info(self):
"""Query Bugzilla API to retrieve the needed infos."""
scheme = urlparse(self.url).scheme
netloc = urlparse(self.url).netloc
query = urlparse(self.url).query
if scheme not in ('http', 'https'):
return
for item in query.split('&'):
... | [
"Query",
"Bugzilla",
"API",
"to",
"retrieve",
"the",
"needed",
"infos",
"."
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/trackers/bugzilla.py#L32-L74 | [
"def",
"retrieve_info",
"(",
"self",
")",
":",
"scheme",
"=",
"urlparse",
"(",
"self",
".",
"url",
")",
".",
"scheme",
"netloc",
"=",
"urlparse",
"(",
"self",
".",
"url",
")",
".",
"netloc",
"query",
"=",
"urlparse",
"(",
"self",
".",
"url",
")",
"... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | minlen | 'Minimum length' validation_function generator.
Returns a validation_function to check that len(x) >= min_length (strict=False, default)
or len(x) > min_length (strict=True)
:param min_length: minimum length for x
:param strict: Boolean flag to switch between len(x) >= min_length (strict=False) and len... | valid8/validation_lib/collections.py | def minlen(min_length,
strict=False # type: bool
):
"""
'Minimum length' validation_function generator.
Returns a validation_function to check that len(x) >= min_length (strict=False, default)
or len(x) > min_length (strict=True)
:param min_length: minimum length for x
:p... | def minlen(min_length,
strict=False # type: bool
):
"""
'Minimum length' validation_function generator.
Returns a validation_function to check that len(x) >= min_length (strict=False, default)
or len(x) > min_length (strict=True)
:param min_length: minimum length for x
:p... | [
"Minimum",
"length",
"validation_function",
"generator",
".",
"Returns",
"a",
"validation_function",
"to",
"check",
"that",
"len",
"(",
"x",
")",
">",
"=",
"min_length",
"(",
"strict",
"=",
"False",
"default",
")",
"or",
"len",
"(",
"x",
")",
">",
"min_len... | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/collections.py#L18-L47 | [
"def",
"minlen",
"(",
"min_length",
",",
"strict",
"=",
"False",
"# type: bool",
")",
":",
"if",
"strict",
":",
"def",
"minlen_",
"(",
"x",
")",
":",
"if",
"len",
"(",
"x",
")",
">",
"min_length",
":",
"return",
"True",
"else",
":",
"# raise Failure('m... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | maxlen | 'Maximum length' validation_function generator.
Returns a validation_function to check that len(x) <= max_length (strict=False, default) or len(x) < max_length (strict=True)
:param max_length: maximum length for x
:param strict: Boolean flag to switch between len(x) <= max_length (strict=False) and len(x) ... | valid8/validation_lib/collections.py | def maxlen(max_length,
strict=False # type: bool
):
"""
'Maximum length' validation_function generator.
Returns a validation_function to check that len(x) <= max_length (strict=False, default) or len(x) < max_length (strict=True)
:param max_length: maximum length for x
:param... | def maxlen(max_length,
strict=False # type: bool
):
"""
'Maximum length' validation_function generator.
Returns a validation_function to check that len(x) <= max_length (strict=False, default) or len(x) < max_length (strict=True)
:param max_length: maximum length for x
:param... | [
"Maximum",
"length",
"validation_function",
"generator",
".",
"Returns",
"a",
"validation_function",
"to",
"check",
"that",
"len",
"(",
"x",
")",
"<",
"=",
"max_length",
"(",
"strict",
"=",
"False",
"default",
")",
"or",
"len",
"(",
"x",
")",
"<",
"max_len... | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/collections.py#L63-L91 | [
"def",
"maxlen",
"(",
"max_length",
",",
"strict",
"=",
"False",
"# type: bool",
")",
":",
"if",
"strict",
":",
"def",
"maxlen_",
"(",
"x",
")",
":",
"if",
"len",
"(",
"x",
")",
"<",
"max_length",
":",
"return",
"True",
"else",
":",
"# raise Failure('m... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | has_length | 'length equals' validation function generator.
Returns a validation_function to check that `len(x) == ref_length`
:param ref_length:
:return: | valid8/validation_lib/collections.py | def has_length(ref_length):
"""
'length equals' validation function generator.
Returns a validation_function to check that `len(x) == ref_length`
:param ref_length:
:return:
"""
def has_length_(x):
if len(x) == ref_length:
return True
else:
raise Wron... | def has_length(ref_length):
"""
'length equals' validation function generator.
Returns a validation_function to check that `len(x) == ref_length`
:param ref_length:
:return:
"""
def has_length_(x):
if len(x) == ref_length:
return True
else:
raise Wron... | [
"length",
"equals",
"validation",
"function",
"generator",
".",
"Returns",
"a",
"validation_function",
"to",
"check",
"that",
"len",
"(",
"x",
")",
"==",
"ref_length"
] | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/collections.py#L106-L121 | [
"def",
"has_length",
"(",
"ref_length",
")",
":",
"def",
"has_length_",
"(",
"x",
")",
":",
"if",
"len",
"(",
"x",
")",
"==",
"ref_length",
":",
"return",
"True",
"else",
":",
"raise",
"WrongLength",
"(",
"wrong_value",
"=",
"x",
",",
"ref_length",
"="... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | length_between | 'Is length between' validation_function generator.
Returns a validation_function to check that `min_len <= len(x) <= max_len (default)`. `open_right` and `open_left`
flags allow to transform each side into strict mode. For example setting `open_left=True` will enforce
`min_len < len(x) <= max_len`.
:pa... | valid8/validation_lib/collections.py | def length_between(min_len,
max_len,
open_left=False, # type: bool
open_right=False # type: bool
):
"""
'Is length between' validation_function generator.
Returns a validation_function to check that `min_len <= len(x) <= max_len (... | def length_between(min_len,
max_len,
open_left=False, # type: bool
open_right=False # type: bool
):
"""
'Is length between' validation_function generator.
Returns a validation_function to check that `min_len <= len(x) <= max_len (... | [
"Is",
"length",
"between",
"validation_function",
"generator",
".",
"Returns",
"a",
"validation_function",
"to",
"check",
"that",
"min_len",
"<",
"=",
"len",
"(",
"x",
")",
"<",
"=",
"max_len",
"(",
"default",
")",
".",
"open_right",
"and",
"open_left",
"fla... | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/collections.py#L134-L189 | [
"def",
"length_between",
"(",
"min_len",
",",
"max_len",
",",
"open_left",
"=",
"False",
",",
"# type: bool",
"open_right",
"=",
"False",
"# type: bool",
")",
":",
"if",
"open_left",
"and",
"open_right",
":",
"def",
"length_between_",
"(",
"x",
")",
":",
"if... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | is_in | 'Values in' validation_function generator.
Returns a validation_function to check that x is in the provided set of allowed values
:param allowed_values: a set of allowed values
:return: | valid8/validation_lib/collections.py | def is_in(allowed_values # type: Set
):
"""
'Values in' validation_function generator.
Returns a validation_function to check that x is in the provided set of allowed values
:param allowed_values: a set of allowed values
:return:
"""
def is_in_allowed_values(x):
if x in a... | def is_in(allowed_values # type: Set
):
"""
'Values in' validation_function generator.
Returns a validation_function to check that x is in the provided set of allowed values
:param allowed_values: a set of allowed values
:return:
"""
def is_in_allowed_values(x):
if x in a... | [
"Values",
"in",
"validation_function",
"generator",
".",
"Returns",
"a",
"validation_function",
"to",
"check",
"that",
"x",
"is",
"in",
"the",
"provided",
"set",
"of",
"allowed",
"values"
] | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/collections.py#L200-L217 | [
"def",
"is_in",
"(",
"allowed_values",
"# type: Set",
")",
":",
"def",
"is_in_allowed_values",
"(",
"x",
")",
":",
"if",
"x",
"in",
"allowed_values",
":",
"return",
"True",
"else",
":",
"# raise Failure('is_in: x in ' + str(allowed_values) + ' does not hold for x=' + str(... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | is_subset | 'Is subset' validation_function generator.
Returns a validation_function to check that x is a subset of reference_set
:param reference_set: the reference set
:return: | valid8/validation_lib/collections.py | def is_subset(reference_set # type: Set
):
"""
'Is subset' validation_function generator.
Returns a validation_function to check that x is a subset of reference_set
:param reference_set: the reference set
:return:
"""
def is_subset_of(x):
missing = x - reference_set
... | def is_subset(reference_set # type: Set
):
"""
'Is subset' validation_function generator.
Returns a validation_function to check that x is a subset of reference_set
:param reference_set: the reference set
:return:
"""
def is_subset_of(x):
missing = x - reference_set
... | [
"Is",
"subset",
"validation_function",
"generator",
".",
"Returns",
"a",
"validation_function",
"to",
"check",
"that",
"x",
"is",
"a",
"subset",
"of",
"reference_set"
] | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/collections.py#L228-L248 | [
"def",
"is_subset",
"(",
"reference_set",
"# type: Set",
")",
":",
"def",
"is_subset_of",
"(",
"x",
")",
":",
"missing",
"=",
"x",
"-",
"reference_set",
"if",
"len",
"(",
"missing",
")",
"==",
"0",
":",
"return",
"True",
"else",
":",
"# raise Failure('is_s... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | contains | 'Contains' validation_function generator.
Returns a validation_function to check that `ref_value in x`
:param ref_value: a value that must be present in x
:return: | valid8/validation_lib/collections.py | def contains(ref_value):
"""
'Contains' validation_function generator.
Returns a validation_function to check that `ref_value in x`
:param ref_value: a value that must be present in x
:return:
"""
def contains_ref_value(x):
if ref_value in x:
return True
else:
... | def contains(ref_value):
"""
'Contains' validation_function generator.
Returns a validation_function to check that `ref_value in x`
:param ref_value: a value that must be present in x
:return:
"""
def contains_ref_value(x):
if ref_value in x:
return True
else:
... | [
"Contains",
"validation_function",
"generator",
".",
"Returns",
"a",
"validation_function",
"to",
"check",
"that",
"ref_value",
"in",
"x"
] | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/collections.py#L259-L274 | [
"def",
"contains",
"(",
"ref_value",
")",
":",
"def",
"contains_ref_value",
"(",
"x",
")",
":",
"if",
"ref_value",
"in",
"x",
":",
"return",
"True",
"else",
":",
"raise",
"DoesNotContainValue",
"(",
"wrong_value",
"=",
"x",
",",
"ref_value",
"=",
"ref_valu... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | is_superset | 'Is superset' validation_function generator.
Returns a validation_function to check that x is a superset of reference_set
:param reference_set: the reference set
:return: | valid8/validation_lib/collections.py | def is_superset(reference_set # type: Set
):
"""
'Is superset' validation_function generator.
Returns a validation_function to check that x is a superset of reference_set
:param reference_set: the reference set
:return:
"""
def is_superset_of(x):
missing = reference... | def is_superset(reference_set # type: Set
):
"""
'Is superset' validation_function generator.
Returns a validation_function to check that x is a superset of reference_set
:param reference_set: the reference set
:return:
"""
def is_superset_of(x):
missing = reference... | [
"Is",
"superset",
"validation_function",
"generator",
".",
"Returns",
"a",
"validation_function",
"to",
"check",
"that",
"x",
"is",
"a",
"superset",
"of",
"reference_set"
] | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/collections.py#L285-L305 | [
"def",
"is_superset",
"(",
"reference_set",
"# type: Set",
")",
":",
"def",
"is_superset_of",
"(",
"x",
")",
":",
"missing",
"=",
"reference_set",
"-",
"x",
"if",
"len",
"(",
"missing",
")",
"==",
"0",
":",
"return",
"True",
"else",
":",
"# raise Failure('... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | on_all_ | Generates a validation_function for collection inputs where each element of the input will be validated against the
validation_functions provided. For convenience, a list of validation_functions can be provided and will be replaced
with an 'and_'.
Note that if you want to apply DIFFERENT validation_functio... | valid8/validation_lib/collections.py | def on_all_(*validation_func):
"""
Generates a validation_function for collection inputs where each element of the input will be validated against the
validation_functions provided. For convenience, a list of validation_functions can be provided and will be replaced
with an 'and_'.
Note that if you... | def on_all_(*validation_func):
"""
Generates a validation_function for collection inputs where each element of the input will be validated against the
validation_functions provided. For convenience, a list of validation_functions can be provided and will be replaced
with an 'and_'.
Note that if you... | [
"Generates",
"a",
"validation_function",
"for",
"collection",
"inputs",
"where",
"each",
"element",
"of",
"the",
"input",
"will",
"be",
"validated",
"against",
"the",
"validation_functions",
"provided",
".",
"For",
"convenience",
"a",
"list",
"of",
"validation_funct... | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/collections.py#L314-L349 | [
"def",
"on_all_",
"(",
"*",
"validation_func",
")",
":",
"# create the validation functions",
"validation_function_func",
"=",
"_process_validation_function_s",
"(",
"list",
"(",
"validation_func",
")",
")",
"def",
"on_all_val",
"(",
"x",
")",
":",
"# validate all eleme... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | on_each_ | Generates a validation_function for collection inputs where each element of the input will be validated against the
corresponding validation_function(s) in the validation_functions_collection. Validators inside the tuple can be
provided as a list for convenience, this will be replaced with an 'and_' operator if... | valid8/validation_lib/collections.py | def on_each_(*validation_functions_collection):
"""
Generates a validation_function for collection inputs where each element of the input will be validated against the
corresponding validation_function(s) in the validation_functions_collection. Validators inside the tuple can be
provided as a list for c... | def on_each_(*validation_functions_collection):
"""
Generates a validation_function for collection inputs where each element of the input will be validated against the
corresponding validation_function(s) in the validation_functions_collection. Validators inside the tuple can be
provided as a list for c... | [
"Generates",
"a",
"validation_function",
"for",
"collection",
"inputs",
"where",
"each",
"element",
"of",
"the",
"input",
"will",
"be",
"validated",
"against",
"the",
"corresponding",
"validation_function",
"(",
"s",
")",
"in",
"the",
"validation_functions_collection"... | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/collections.py#L353-L404 | [
"def",
"on_each_",
"(",
"*",
"validation_functions_collection",
")",
":",
"# create a tuple of validation functions.",
"validation_function_funcs",
"=",
"tuple",
"(",
"_process_validation_function_s",
"(",
"validation_func",
")",
"for",
"validation_func",
"in",
"validation_func... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | get_jobs_events_from_sequence | Get all the jobs events from a given sequence number. | dci/api/v1/jobs_events.py | def get_jobs_events_from_sequence(user, sequence):
"""Get all the jobs events from a given sequence number."""
args = schemas.args(flask.request.args.to_dict())
if user.is_not_super_admin():
raise dci_exc.Unauthorized()
query = sql.select([models.JOBS_EVENTS]). \
select_from(models.JO... | def get_jobs_events_from_sequence(user, sequence):
"""Get all the jobs events from a given sequence number."""
args = schemas.args(flask.request.args.to_dict())
if user.is_not_super_admin():
raise dci_exc.Unauthorized()
query = sql.select([models.JOBS_EVENTS]). \
select_from(models.JO... | [
"Get",
"all",
"the",
"jobs",
"events",
"from",
"a",
"given",
"sequence",
"number",
"."
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/jobs_events.py#L37-L63 | [
"def",
"get_jobs_events_from_sequence",
"(",
"user",
",",
"sequence",
")",
":",
"args",
"=",
"schemas",
".",
"args",
"(",
"flask",
".",
"request",
".",
"args",
".",
"to_dict",
"(",
")",
")",
"if",
"user",
".",
"is_not_super_admin",
"(",
")",
":",
"raise"... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | Dump.from_file | Constructs a :class:`~mwxml.iteration.dump.Dump` from a `file` pointer.
:Parameters:
f : `file`
A plain text file pointer containing XML to process | mwxml/iteration/dump.py | def from_file(cls, f):
"""
Constructs a :class:`~mwxml.iteration.dump.Dump` from a `file` pointer.
:Parameters:
f : `file`
A plain text file pointer containing XML to process
"""
element = ElementIterator.from_file(f)
assert element.tag == "me... | def from_file(cls, f):
"""
Constructs a :class:`~mwxml.iteration.dump.Dump` from a `file` pointer.
:Parameters:
f : `file`
A plain text file pointer containing XML to process
"""
element = ElementIterator.from_file(f)
assert element.tag == "me... | [
"Constructs",
"a",
":",
"class",
":",
"~mwxml",
".",
"iteration",
".",
"dump",
".",
"Dump",
"from",
"a",
"file",
"pointer",
"."
] | mediawiki-utilities/python-mwxml | python | https://github.com/mediawiki-utilities/python-mwxml/blob/6a8c18be99cd0bcee9c496e607f08bf4dfe5b510/mwxml/iteration/dump.py#L136-L146 | [
"def",
"from_file",
"(",
"cls",
",",
"f",
")",
":",
"element",
"=",
"ElementIterator",
".",
"from_file",
"(",
"f",
")",
"assert",
"element",
".",
"tag",
"==",
"\"mediawiki\"",
"return",
"cls",
".",
"from_element",
"(",
"element",
")"
] | 6a8c18be99cd0bcee9c496e607f08bf4dfe5b510 |
train | Dump.from_page_xml | Constructs a :class:`~mwxml.iteration.dump.Dump` from a <page> block.
:Parameters:
page_xml : `str` | `file`
Either a plain string or a file containing <page> block XML to
process | mwxml/iteration/dump.py | def from_page_xml(cls, page_xml):
"""
Constructs a :class:`~mwxml.iteration.dump.Dump` from a <page> block.
:Parameters:
page_xml : `str` | `file`
Either a plain string or a file containing <page> block XML to
process
"""
header = """
... | def from_page_xml(cls, page_xml):
"""
Constructs a :class:`~mwxml.iteration.dump.Dump` from a <page> block.
:Parameters:
page_xml : `str` | `file`
Either a plain string or a file containing <page> block XML to
process
"""
header = """
... | [
"Constructs",
"a",
":",
"class",
":",
"~mwxml",
".",
"iteration",
".",
"dump",
".",
"Dump",
"from",
"a",
"<page",
">",
"block",
"."
] | mediawiki-utilities/python-mwxml | python | https://github.com/mediawiki-utilities/python-mwxml/blob/6a8c18be99cd0bcee9c496e607f08bf4dfe5b510/mwxml/iteration/dump.py#L149-L170 | [
"def",
"from_page_xml",
"(",
"cls",
",",
"page_xml",
")",
":",
"header",
"=",
"\"\"\"\n <mediawiki xmlns=\"http://www.mediawiki.org/xml/export-0.5/\"\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:schemaLocation=\"http://www.mediawiki.o... | 6a8c18be99cd0bcee9c496e607f08bf4dfe5b510 |
train | calc_derivation | Calculate a 32 bytes key derivation with Argon2.
:param passphrase: A string of any length specified by user.
:param salt: 512 bits generated by Botan Random Number Generator.
:return: a 32 bytes keys. | cryptoshop/_derivation_engine.py | def calc_derivation(passphrase, salt):
"""
Calculate a 32 bytes key derivation with Argon2.
:param passphrase: A string of any length specified by user.
:param salt: 512 bits generated by Botan Random Number Generator.
:return: a 32 bytes keys.
"""
argonhash = argon2.low_level.hash_secret_ra... | def calc_derivation(passphrase, salt):
"""
Calculate a 32 bytes key derivation with Argon2.
:param passphrase: A string of any length specified by user.
:param salt: 512 bits generated by Botan Random Number Generator.
:return: a 32 bytes keys.
"""
argonhash = argon2.low_level.hash_secret_ra... | [
"Calculate",
"a",
"32",
"bytes",
"key",
"derivation",
"with",
"Argon2",
".",
":",
"param",
"passphrase",
":",
"A",
"string",
"of",
"any",
"length",
"specified",
"by",
"user",
".",
":",
"param",
"salt",
":",
"512",
"bits",
"generated",
"by",
"Botan",
"Ran... | Antidote1911/cryptoshop | python | https://github.com/Antidote1911/cryptoshop/blob/0b7ff4a6848f2733f4737606957e8042a4d6ca0b/cryptoshop/_derivation_engine.py#L29-L39 | [
"def",
"calc_derivation",
"(",
"passphrase",
",",
"salt",
")",
":",
"argonhash",
"=",
"argon2",
".",
"low_level",
".",
"hash_secret_raw",
"(",
"(",
"str",
".",
"encode",
"(",
"passphrase",
")",
")",
",",
"salt",
"=",
"salt",
",",
"hash_len",
"=",
"32",
... | 0b7ff4a6848f2733f4737606957e8042a4d6ca0b |
train | XmlDomImplAdapter.get_node_text | Return contatenated value of all text node children of this element | xml4h/impls/xml_dom_minidom.py | def get_node_text(self, node):
"""
Return contatenated value of all text node children of this element
"""
text_children = [n.nodeValue for n in self.get_node_children(node)
if n.nodeType == xml.dom.Node.TEXT_NODE]
if text_children:
return u''... | def get_node_text(self, node):
"""
Return contatenated value of all text node children of this element
"""
text_children = [n.nodeValue for n in self.get_node_children(node)
if n.nodeType == xml.dom.Node.TEXT_NODE]
if text_children:
return u''... | [
"Return",
"contatenated",
"value",
"of",
"all",
"text",
"node",
"children",
"of",
"this",
"element"
] | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/impls/xml_dom_minidom.py#L119-L128 | [
"def",
"get_node_text",
"(",
"self",
",",
"node",
")",
":",
"text_children",
"=",
"[",
"n",
".",
"nodeValue",
"for",
"n",
"in",
"self",
".",
"get_node_children",
"(",
"node",
")",
"if",
"n",
".",
"nodeType",
"==",
"xml",
".",
"dom",
".",
"Node",
".",... | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | XmlDomImplAdapter.set_node_text | Set text value as sole Text child node of element; any existing
Text nodes are removed | xml4h/impls/xml_dom_minidom.py | def set_node_text(self, node, text):
"""
Set text value as sole Text child node of element; any existing
Text nodes are removed
"""
# Remove any existing Text node children
for child in self.get_node_children(node):
if child.nodeType == xml.dom.Node.TEXT_NODE:... | def set_node_text(self, node, text):
"""
Set text value as sole Text child node of element; any existing
Text nodes are removed
"""
# Remove any existing Text node children
for child in self.get_node_children(node):
if child.nodeType == xml.dom.Node.TEXT_NODE:... | [
"Set",
"text",
"value",
"as",
"sole",
"Text",
"child",
"node",
"of",
"element",
";",
"any",
"existing",
"Text",
"nodes",
"are",
"removed"
] | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/impls/xml_dom_minidom.py#L130-L141 | [
"def",
"set_node_text",
"(",
"self",
",",
"node",
",",
"text",
")",
":",
"# Remove any existing Text node children",
"for",
"child",
"in",
"self",
".",
"get_node_children",
"(",
"node",
")",
":",
"if",
"child",
".",
"nodeType",
"==",
"xml",
".",
"dom",
".",
... | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | GlobBundle._get_contents | Create strings from glob strings. | invenio_assets/glob.py | def _get_contents(self):
"""Create strings from glob strings."""
def files():
for value in super(GlobBundle, self)._get_contents():
for path in glob.glob(value):
yield path
return list(files()) | def _get_contents(self):
"""Create strings from glob strings."""
def files():
for value in super(GlobBundle, self)._get_contents():
for path in glob.glob(value):
yield path
return list(files()) | [
"Create",
"strings",
"from",
"glob",
"strings",
"."
] | inveniosoftware/invenio-assets | python | https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/glob.py#L31-L37 | [
"def",
"_get_contents",
"(",
"self",
")",
":",
"def",
"files",
"(",
")",
":",
"for",
"value",
"in",
"super",
"(",
"GlobBundle",
",",
"self",
")",
".",
"_get_contents",
"(",
")",
":",
"for",
"path",
"in",
"glob",
".",
"glob",
"(",
"value",
")",
":",... | 836cc75ebe0c179f0d72456bd8b784cdc18394a6 |
train | is_generic_type | Test if the given type is a generic type. This includes Generic itself, but
excludes special typing constructs such as Union, Tuple, Callable, ClassVar.
Examples::
is_generic_type(int) == False
is_generic_type(Union[int, str]) == False
is_generic_type(Union[int, T]) == False
is_... | valid8/_typing_inspect.py | def is_generic_type(tp):
"""Test if the given type is a generic type. This includes Generic itself, but
excludes special typing constructs such as Union, Tuple, Callable, ClassVar.
Examples::
is_generic_type(int) == False
is_generic_type(Union[int, str]) == False
is_generic_type(Uni... | def is_generic_type(tp):
"""Test if the given type is a generic type. This includes Generic itself, but
excludes special typing constructs such as Union, Tuple, Callable, ClassVar.
Examples::
is_generic_type(int) == False
is_generic_type(Union[int, str]) == False
is_generic_type(Uni... | [
"Test",
"if",
"the",
"given",
"type",
"is",
"a",
"generic",
"type",
".",
"This",
"includes",
"Generic",
"itself",
"but",
"excludes",
"special",
"typing",
"constructs",
"such",
"as",
"Union",
"Tuple",
"Callable",
"ClassVar",
".",
"Examples",
"::"
] | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/_typing_inspect.py#L39-L62 | [
"def",
"is_generic_type",
"(",
"tp",
")",
":",
"if",
"NEW_TYPING",
":",
"return",
"(",
"isinstance",
"(",
"tp",
",",
"type",
")",
"and",
"issubclass",
"(",
"tp",
",",
"Generic",
")",
"or",
"isinstance",
"(",
"tp",
",",
"_GenericAlias",
")",
"and",
"tp"... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | is_union_type | Test if the type is a union type. Examples::
is_union_type(int) == False
is_union_type(Union) == True
is_union_type(Union[int, int]) == False
is_union_type(Union[T, int]) == True | valid8/_typing_inspect.py | def is_union_type(tp):
"""Test if the type is a union type. Examples::
is_union_type(int) == False
is_union_type(Union) == True
is_union_type(Union[int, int]) == False
is_union_type(Union[T, int]) == True
"""
if NEW_TYPING:
return (tp is Union or
isin... | def is_union_type(tp):
"""Test if the type is a union type. Examples::
is_union_type(int) == False
is_union_type(Union) == True
is_union_type(Union[int, int]) == False
is_union_type(Union[T, int]) == True
"""
if NEW_TYPING:
return (tp is Union or
isin... | [
"Test",
"if",
"the",
"type",
"is",
"a",
"union",
"type",
".",
"Examples",
"::"
] | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/_typing_inspect.py#L136-L152 | [
"def",
"is_union_type",
"(",
"tp",
")",
":",
"if",
"NEW_TYPING",
":",
"return",
"(",
"tp",
"is",
"Union",
"or",
"isinstance",
"(",
"tp",
",",
"_GenericAlias",
")",
"and",
"tp",
".",
"__origin__",
"is",
"Union",
")",
"try",
":",
"from",
"typing",
"impor... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | is_classvar | Test if the type represents a class variable. Examples::
is_classvar(int) == False
is_classvar(ClassVar) == True
is_classvar(ClassVar[int]) == True
is_classvar(ClassVar[List[T]]) == True | valid8/_typing_inspect.py | def is_classvar(tp):
"""Test if the type represents a class variable. Examples::
is_classvar(int) == False
is_classvar(ClassVar) == True
is_classvar(ClassVar[int]) == True
is_classvar(ClassVar[List[T]]) == True
"""
if NEW_TYPING:
return (tp is ClassVar or
... | def is_classvar(tp):
"""Test if the type represents a class variable. Examples::
is_classvar(int) == False
is_classvar(ClassVar) == True
is_classvar(ClassVar[int]) == True
is_classvar(ClassVar[List[T]]) == True
"""
if NEW_TYPING:
return (tp is ClassVar or
... | [
"Test",
"if",
"the",
"type",
"represents",
"a",
"class",
"variable",
".",
"Examples",
"::"
] | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/_typing_inspect.py#L166-L182 | [
"def",
"is_classvar",
"(",
"tp",
")",
":",
"if",
"NEW_TYPING",
":",
"return",
"(",
"tp",
"is",
"ClassVar",
"or",
"isinstance",
"(",
"tp",
",",
"_GenericAlias",
")",
"and",
"tp",
".",
"__origin__",
"is",
"ClassVar",
")",
"try",
":",
"from",
"typing",
"i... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | parse | Parse an XML document into an *xml4h*-wrapped DOM representation
using an underlying XML library implementation.
:param to_parse: an XML document file, document string, or the
path to an XML file. If a string value is given that contains
a ``<`` character it is treated as literal XML data, othe... | xml4h/__init__.py | def parse(to_parse, ignore_whitespace_text_nodes=True, adapter=None):
"""
Parse an XML document into an *xml4h*-wrapped DOM representation
using an underlying XML library implementation.
:param to_parse: an XML document file, document string, or the
path to an XML file. If a string value is giv... | def parse(to_parse, ignore_whitespace_text_nodes=True, adapter=None):
"""
Parse an XML document into an *xml4h*-wrapped DOM representation
using an underlying XML library implementation.
:param to_parse: an XML document file, document string, or the
path to an XML file. If a string value is giv... | [
"Parse",
"an",
"XML",
"document",
"into",
"an",
"*",
"xml4h",
"*",
"-",
"wrapped",
"DOM",
"representation",
"using",
"an",
"underlying",
"XML",
"library",
"implementation",
"."
] | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/__init__.py#L41-L70 | [
"def",
"parse",
"(",
"to_parse",
",",
"ignore_whitespace_text_nodes",
"=",
"True",
",",
"adapter",
"=",
"None",
")",
":",
"if",
"adapter",
"is",
"None",
":",
"adapter",
"=",
"best_adapter",
"if",
"isinstance",
"(",
"to_parse",
",",
"basestring",
")",
"and",
... | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | build | Return a :class:`~xml4h.builder.Builder` that represents an element in
a new or existing XML DOM and provides "chainable" methods focussed
specifically on adding XML content.
:param tagname_or_element: a string name for the root node of a
new XML document, or an :class:`~xml4h.nodes.Element` node i... | xml4h/__init__.py | def build(tagname_or_element, ns_uri=None, adapter=None):
"""
Return a :class:`~xml4h.builder.Builder` that represents an element in
a new or existing XML DOM and provides "chainable" methods focussed
specifically on adding XML content.
:param tagname_or_element: a string name for the root node of ... | def build(tagname_or_element, ns_uri=None, adapter=None):
"""
Return a :class:`~xml4h.builder.Builder` that represents an element in
a new or existing XML DOM and provides "chainable" methods focussed
specifically on adding XML content.
:param tagname_or_element: a string name for the root node of ... | [
"Return",
"a",
":",
"class",
":",
"~xml4h",
".",
"builder",
".",
"Builder",
"that",
"represents",
"an",
"element",
"in",
"a",
"new",
"or",
"existing",
"XML",
"DOM",
"and",
"provides",
"chainable",
"methods",
"focussed",
"specifically",
"on",
"adding",
"XML",... | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/__init__.py#L73-L105 | [
"def",
"build",
"(",
"tagname_or_element",
",",
"ns_uri",
"=",
"None",
",",
"adapter",
"=",
"None",
")",
":",
"if",
"adapter",
"is",
"None",
":",
"adapter",
"=",
"best_adapter",
"if",
"isinstance",
"(",
"tagname_or_element",
",",
"basestring",
")",
":",
"d... | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | get_none_policy_text | Returns a user-friendly description of a NonePolicy taking into account NoneArgPolicy
:param none_policy:
:param verbose:
:return: | valid8/entry_points.py | def get_none_policy_text(none_policy, # type: int
verbose=False # type: bool
):
"""
Returns a user-friendly description of a NonePolicy taking into account NoneArgPolicy
:param none_policy:
:param verbose:
:return:
"""
if none_policy is N... | def get_none_policy_text(none_policy, # type: int
verbose=False # type: bool
):
"""
Returns a user-friendly description of a NonePolicy taking into account NoneArgPolicy
:param none_policy:
:param verbose:
:return:
"""
if none_policy is N... | [
"Returns",
"a",
"user",
"-",
"friendly",
"description",
"of",
"a",
"NonePolicy",
"taking",
"into",
"account",
"NoneArgPolicy"
] | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points.py#L53-L76 | [
"def",
"get_none_policy_text",
"(",
"none_policy",
",",
"# type: int",
"verbose",
"=",
"False",
"# type: bool",
")",
":",
"if",
"none_policy",
"is",
"NonePolicy",
".",
"SKIP",
":",
"return",
"\"accept None without performing validation\"",
"if",
"verbose",
"else",
"'S... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | _add_none_handler | Adds a wrapper or nothing around the provided validation_callable, depending on the selected policy
:param validation_callable:
:param none_policy: an int representing the None policy, see NonePolicy
:return: | valid8/entry_points.py | def _add_none_handler(validation_callable, # type: Callable
none_policy # type: int
):
# type: (...) -> Callable
"""
Adds a wrapper or nothing around the provided validation_callable, depending on the selected policy
:param validation_callable:
... | def _add_none_handler(validation_callable, # type: Callable
none_policy # type: int
):
# type: (...) -> Callable
"""
Adds a wrapper or nothing around the provided validation_callable, depending on the selected policy
:param validation_callable:
... | [
"Adds",
"a",
"wrapper",
"or",
"nothing",
"around",
"the",
"provided",
"validation_callable",
"depending",
"on",
"the",
"selected",
"policy"
] | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points.py#L79-L100 | [
"def",
"_add_none_handler",
"(",
"validation_callable",
",",
"# type: Callable",
"none_policy",
"# type: int",
")",
":",
"# type: (...) -> Callable",
"if",
"none_policy",
"is",
"NonePolicy",
".",
"SKIP",
":",
"return",
"_none_accepter",
"(",
"validation_callable",
")",
... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | add_base_type_dynamically | Utility method to create a new type dynamically, inheriting from both error_type (first) and additional_type
(second). The class representation (repr(cls)) of the resulting class reflects this by displaying both names
(fully qualified for the first type, __name__ for the second)
For example
```
> n... | valid8/entry_points.py | def add_base_type_dynamically(error_type, additional_type):
"""
Utility method to create a new type dynamically, inheriting from both error_type (first) and additional_type
(second). The class representation (repr(cls)) of the resulting class reflects this by displaying both names
(fully qualified for t... | def add_base_type_dynamically(error_type, additional_type):
"""
Utility method to create a new type dynamically, inheriting from both error_type (first) and additional_type
(second). The class representation (repr(cls)) of the resulting class reflects this by displaying both names
(fully qualified for t... | [
"Utility",
"method",
"to",
"create",
"a",
"new",
"type",
"dynamically",
"inheriting",
"from",
"both",
"error_type",
"(",
"first",
")",
"and",
"additional_type",
"(",
"second",
")",
".",
"The",
"class",
"representation",
"(",
"repr",
"(",
"cls",
"))",
"of",
... | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points.py#L346-L369 | [
"def",
"add_base_type_dynamically",
"(",
"error_type",
",",
"additional_type",
")",
":",
"# the new type created dynamically, with the same name",
"class",
"new_error_type",
"(",
"with_metaclass",
"(",
"MetaReprForValidator",
",",
"error_type",
",",
"additional_type",
",",
"o... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | assert_valid | Validates value `value` using validation function(s) `base_validator_s`.
As opposed to `is_valid`, this function raises a `ValidationError` if validation fails.
It is therefore designed to be used for defensive programming, in an independent statement before the code that you
intent to protect.
```pyt... | valid8/entry_points.py | def assert_valid(name, # type: str
value, # type: Any
*validation_func, # type: ValidationFuncs
**kwargs):
"""
Validates value `value` using validation function(s) `base_validator_s`.
As opposed to `is_valid`, this function raises ... | def assert_valid(name, # type: str
value, # type: Any
*validation_func, # type: ValidationFuncs
**kwargs):
"""
Validates value `value` using validation function(s) `base_validator_s`.
As opposed to `is_valid`, this function raises ... | [
"Validates",
"value",
"value",
"using",
"validation",
"function",
"(",
"s",
")",
"base_validator_s",
".",
"As",
"opposed",
"to",
"is_valid",
"this",
"function",
"raises",
"a",
"ValidationError",
"if",
"validation",
"fails",
"."
] | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points.py#L669-L711 | [
"def",
"assert_valid",
"(",
"name",
",",
"# type: str",
"value",
",",
"# type: Any",
"*",
"validation_func",
",",
"# type: ValidationFuncs",
"*",
"*",
"kwargs",
")",
":",
"error_type",
",",
"help_msg",
",",
"none_policy",
"=",
"pop_kwargs",
"(",
"kwargs",
",",
... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | is_valid | Validates value `value` using validation function(s) `validator_func`.
As opposed to `assert_valid`, this function returns a boolean indicating if validation was a success or a failure.
It is therefore designed to be used within if ... else ... statements:
```python
if is_valid(x, isfinite):
..... | valid8/entry_points.py | def is_valid(value,
*validation_func, # type: Union[Callable, List[Callable]]
**kwargs
):
# type: (...) -> bool
"""
Validates value `value` using validation function(s) `validator_func`.
As opposed to `assert_valid`, this function returns a boolean indicating if v... | def is_valid(value,
*validation_func, # type: Union[Callable, List[Callable]]
**kwargs
):
# type: (...) -> bool
"""
Validates value `value` using validation function(s) `validator_func`.
As opposed to `assert_valid`, this function returns a boolean indicating if v... | [
"Validates",
"value",
"value",
"using",
"validation",
"function",
"(",
"s",
")",
"validator_func",
".",
"As",
"opposed",
"to",
"assert_valid",
"this",
"function",
"returns",
"a",
"boolean",
"indicating",
"if",
"validation",
"was",
"a",
"success",
"or",
"a",
"f... | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points.py#L724-L757 | [
"def",
"is_valid",
"(",
"value",
",",
"*",
"validation_func",
",",
"# type: Union[Callable, List[Callable]]",
"*",
"*",
"kwargs",
")",
":",
"# type: (...) -> bool",
"none_policy",
"=",
"pop_kwargs",
"(",
"kwargs",
",",
"[",
"(",
"'none_policy'",
",",
"None",
")",
... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | ValidationError.create_manually | Creates an instance without using a Validator.
This method is not the primary way that errors are created - they should rather created by the validation entry
points. However it can be handy in rare edge cases.
:param validation_function_name:
:param var_name:
:param var_value:... | valid8/entry_points.py | def create_manually(cls,
validation_function_name, # type: str
var_name, # type: str
var_value,
validation_outcome=None, # type: Any
help_msg=None, # type: str
... | def create_manually(cls,
validation_function_name, # type: str
var_name, # type: str
var_value,
validation_outcome=None, # type: Any
help_msg=None, # type: str
... | [
"Creates",
"an",
"instance",
"without",
"using",
"a",
"Validator",
"."
] | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points.py#L174-L208 | [
"def",
"create_manually",
"(",
"cls",
",",
"validation_function_name",
",",
"# type: str",
"var_name",
",",
"# type: str",
"var_value",
",",
"validation_outcome",
"=",
"None",
",",
"# type: Any",
"help_msg",
"=",
"None",
",",
"# type: str",
"append_details",
"=",
"T... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | ValidationError.get_details | The function called to get the details appended to the help message when self.append_details is True | valid8/entry_points.py | def get_details(self):
""" The function called to get the details appended to the help message when self.append_details is True """
# create the exception main message according to the type of result
if isinstance(self.validation_outcome, Exception):
prefix = 'Validation function [... | def get_details(self):
""" The function called to get the details appended to the help message when self.append_details is True """
# create the exception main message according to the type of result
if isinstance(self.validation_outcome, Exception):
prefix = 'Validation function [... | [
"The",
"function",
"called",
"to",
"get",
"the",
"details",
"appended",
"to",
"the",
"help",
"message",
"when",
"self",
".",
"append_details",
"is",
"True"
] | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points.py#L282-L303 | [
"def",
"get_details",
"(",
"self",
")",
":",
"# create the exception main message according to the type of result",
"if",
"isinstance",
"(",
"self",
".",
"validation_outcome",
",",
"Exception",
")",
":",
"prefix",
"=",
"'Validation function [{val}] raised '",
"if",
"self",
... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | ValidationError.get_variable_str | Utility method to get the variable value or 'var_name=value' if name is not None.
Note that values with large string representations will not get printed
:return: | valid8/entry_points.py | def get_variable_str(self):
"""
Utility method to get the variable value or 'var_name=value' if name is not None.
Note that values with large string representations will not get printed
:return:
"""
if self.var_name is None:
prefix = ''
else:
... | def get_variable_str(self):
"""
Utility method to get the variable value or 'var_name=value' if name is not None.
Note that values with large string representations will not get printed
:return:
"""
if self.var_name is None:
prefix = ''
else:
... | [
"Utility",
"method",
"to",
"get",
"the",
"variable",
"value",
"or",
"var_name",
"=",
"value",
"if",
"name",
"is",
"not",
"None",
".",
"Note",
"that",
"values",
"with",
"large",
"string",
"representations",
"will",
"not",
"get",
"printed"
] | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points.py#L305-L326 | [
"def",
"get_variable_str",
"(",
"self",
")",
":",
"if",
"self",
".",
"var_name",
"is",
"None",
":",
"prefix",
"=",
"''",
"else",
":",
"prefix",
"=",
"self",
".",
"var_name",
"suffix",
"=",
"str",
"(",
"self",
".",
"var_value",
")",
"if",
"len",
"(",
... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | Validator.assert_valid | Asserts that the provided named value is valid with respect to the inner base validation functions. It returns
silently in case of success, and raises a `ValidationError` or a subclass in case of failure. This corresponds
to a 'Defensive programming' (sometimes known as 'Offensive programming') mode.
... | valid8/entry_points.py | def assert_valid(self,
name, # type: str
value, # type: Any
error_type=None, # type: Type[ValidationError]
help_msg=None, # type: str
**kw_context_args):
"""
Asserts that t... | def assert_valid(self,
name, # type: str
value, # type: Any
error_type=None, # type: Type[ValidationError]
help_msg=None, # type: str
**kw_context_args):
"""
Asserts that t... | [
"Asserts",
"that",
"the",
"provided",
"named",
"value",
"is",
"valid",
"with",
"respect",
"to",
"the",
"inner",
"base",
"validation",
"functions",
".",
"It",
"returns",
"silently",
"in",
"case",
"of",
"success",
"and",
"raises",
"a",
"ValidationError",
"or",
... | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points.py#L517-L564 | [
"def",
"assert_valid",
"(",
"self",
",",
"name",
",",
"# type: str",
"value",
",",
"# type: Any",
"error_type",
"=",
"None",
",",
"# type: Type[ValidationError]",
"help_msg",
"=",
"None",
",",
"# type: str",
"*",
"*",
"kw_context_args",
")",
":",
"try",
":",
"... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | Validator._create_validation_error | The function doing the final error raising. | valid8/entry_points.py | def _create_validation_error(self,
name, # type: str
value, # type: Any
validation_outcome=None, # type: Any
error_type=None, # type: Type[... | def _create_validation_error(self,
name, # type: str
value, # type: Any
validation_outcome=None, # type: Any
error_type=None, # type: Type[... | [
"The",
"function",
"doing",
"the",
"final",
"error",
"raising",
"."
] | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points.py#L566-L604 | [
"def",
"_create_validation_error",
"(",
"self",
",",
"name",
",",
"# type: str",
"value",
",",
"# type: Any",
"validation_outcome",
"=",
"None",
",",
"# type: Any",
"error_type",
"=",
"None",
",",
"# type: Type[ValidationError]",
"help_msg",
"=",
"None",
",",
"# typ... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | Validator.is_valid | Validates the provided value and returns a boolean indicating success or failure. Any Exception happening in
the validation process will be silently caught.
:param value: the value to validate
:return: a boolean flag indicating success or failure | valid8/entry_points.py | def is_valid(self,
value # type: Any
):
# type: (...) -> bool
"""
Validates the provided value and returns a boolean indicating success or failure. Any Exception happening in
the validation process will be silently caught.
:param value: the val... | def is_valid(self,
value # type: Any
):
# type: (...) -> bool
"""
Validates the provided value and returns a boolean indicating success or failure. Any Exception happening in
the validation process will be silently caught.
:param value: the val... | [
"Validates",
"the",
"provided",
"value",
"and",
"returns",
"a",
"boolean",
"indicating",
"success",
"or",
"failure",
".",
"Any",
"Exception",
"happening",
"in",
"the",
"validation",
"process",
"will",
"be",
"silently",
"caught",
"."
] | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points.py#L631-L652 | [
"def",
"is_valid",
"(",
"self",
",",
"value",
"# type: Any",
")",
":",
"# type: (...) -> bool",
"# noinspection PyBroadException",
"try",
":",
"# perform validation",
"res",
"=",
"self",
".",
"main_function",
"(",
"value",
")",
"# return a boolean indicating if success or... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | create_tags | Create a tag. | dci/api/v1/tags.py | def create_tags(user):
"""Create a tag."""
values = {
'id': utils.gen_uuid(),
'created_at': datetime.datetime.utcnow().isoformat()
}
values.update(schemas.tag.post(flask.request.json))
with flask.g.db_conn.begin():
where_clause = sql.and_(
_TABLE.c.name == values... | def create_tags(user):
"""Create a tag."""
values = {
'id': utils.gen_uuid(),
'created_at': datetime.datetime.utcnow().isoformat()
}
values.update(schemas.tag.post(flask.request.json))
with flask.g.db_conn.begin():
where_clause = sql.and_(
_TABLE.c.name == values... | [
"Create",
"a",
"tag",
"."
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/tags.py#L72-L93 | [
"def",
"create_tags",
"(",
"user",
")",
":",
"values",
"=",
"{",
"'id'",
":",
"utils",
".",
"gen_uuid",
"(",
")",
",",
"'created_at'",
":",
"datetime",
".",
"datetime",
".",
"utcnow",
"(",
")",
".",
"isoformat",
"(",
")",
"}",
"values",
".",
"update"... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | get_tags | Get all tags. | dci/api/v1/tags.py | def get_tags(user):
"""Get all tags."""
args = schemas.args(flask.request.args.to_dict())
query = v1_utils.QueryBuilder(_TABLE, args, _T_COLUMNS)
nb_rows = query.get_number_of_rows()
rows = query.execute(fetchall=True)
rows = v1_utils.format_result(rows, _TABLE.name)
return flask.jsonify({'t... | def get_tags(user):
"""Get all tags."""
args = schemas.args(flask.request.args.to_dict())
query = v1_utils.QueryBuilder(_TABLE, args, _T_COLUMNS)
nb_rows = query.get_number_of_rows()
rows = query.execute(fetchall=True)
rows = v1_utils.format_result(rows, _TABLE.name)
return flask.jsonify({'t... | [
"Get",
"all",
"tags",
"."
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/tags.py#L98-L105 | [
"def",
"get_tags",
"(",
"user",
")",
":",
"args",
"=",
"schemas",
".",
"args",
"(",
"flask",
".",
"request",
".",
"args",
".",
"to_dict",
"(",
")",
")",
"query",
"=",
"v1_utils",
".",
"QueryBuilder",
"(",
"_TABLE",
",",
"args",
",",
"_T_COLUMNS",
")"... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | delete_tag_by_id | Delete a tag. | dci/api/v1/tags.py | def delete_tag_by_id(user, tag_id):
"""Delete a tag."""
query = _TABLE.delete().where(_TABLE.c.id == tag_id)
result = flask.g.db_conn.execute(query)
if not result.rowcount:
raise dci_exc.DCIConflict('Tag deletion conflict', tag_id)
return flask.Response(None, 204, content_type='application... | def delete_tag_by_id(user, tag_id):
"""Delete a tag."""
query = _TABLE.delete().where(_TABLE.c.id == tag_id)
result = flask.g.db_conn.execute(query)
if not result.rowcount:
raise dci_exc.DCIConflict('Tag deletion conflict', tag_id)
return flask.Response(None, 204, content_type='application... | [
"Delete",
"a",
"tag",
"."
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/tags.py#L110-L118 | [
"def",
"delete_tag_by_id",
"(",
"user",
",",
"tag_id",
")",
":",
"query",
"=",
"_TABLE",
".",
"delete",
"(",
")",
".",
"where",
"(",
"_TABLE",
".",
"c",
".",
"id",
"==",
"tag_id",
")",
"result",
"=",
"flask",
".",
"g",
".",
"db_conn",
".",
"execute... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | InvenioAssets.init_app | Initialize application object.
:param app: An instance of :class:`~flask.Flask`.
:param entry_point_group: A name of entry point group used to load
``webassets`` bundles.
.. versionchanged:: 1.0.0b2
The *entrypoint* has been renamed to *entry_point_group*. | invenio_assets/ext.py | def init_app(self, app, entry_point_group='invenio_assets.bundles',
**kwargs):
"""Initialize application object.
:param app: An instance of :class:`~flask.Flask`.
:param entry_point_group: A name of entry point group used to load
``webassets`` bundles.
.. v... | def init_app(self, app, entry_point_group='invenio_assets.bundles',
**kwargs):
"""Initialize application object.
:param app: An instance of :class:`~flask.Flask`.
:param entry_point_group: A name of entry point group used to load
``webassets`` bundles.
.. v... | [
"Initialize",
"application",
"object",
"."
] | inveniosoftware/invenio-assets | python | https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/ext.py#L41-L60 | [
"def",
"init_app",
"(",
"self",
",",
"app",
",",
"entry_point_group",
"=",
"'invenio_assets.bundles'",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"init_config",
"(",
"app",
")",
"self",
".",
"env",
".",
"init_app",
"(",
"app",
")",
"self",
".",
"c... | 836cc75ebe0c179f0d72456bd8b784cdc18394a6 |
train | InvenioAssets.init_config | Initialize configuration.
:param app: An instance of :class:`~flask.Flask`. | invenio_assets/ext.py | def init_config(self, app):
"""Initialize configuration.
:param app: An instance of :class:`~flask.Flask`.
"""
app.config.setdefault('REQUIREJS_BASEURL', app.static_folder)
app.config.setdefault('COLLECT_STATIC_ROOT', app.static_folder)
app.config.setdefault('COLLECT_STO... | def init_config(self, app):
"""Initialize configuration.
:param app: An instance of :class:`~flask.Flask`.
"""
app.config.setdefault('REQUIREJS_BASEURL', app.static_folder)
app.config.setdefault('COLLECT_STATIC_ROOT', app.static_folder)
app.config.setdefault('COLLECT_STO... | [
"Initialize",
"configuration",
"."
] | inveniosoftware/invenio-assets | python | https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/ext.py#L62-L73 | [
"def",
"init_config",
"(",
"self",
",",
"app",
")",
":",
"app",
".",
"config",
".",
"setdefault",
"(",
"'REQUIREJS_BASEURL'",
",",
"app",
".",
"static_folder",
")",
"app",
".",
"config",
".",
"setdefault",
"(",
"'COLLECT_STATIC_ROOT'",
",",
"app",
".",
"st... | 836cc75ebe0c179f0d72456bd8b784cdc18394a6 |
train | InvenioAssets.load_entrypoint | Load entrypoint.
:param entry_point_group: A name of entry point group used to load
``webassets`` bundles.
.. versionchanged:: 1.0.0b2
The *entrypoint* has been renamed to *entry_point_group*. | invenio_assets/ext.py | def load_entrypoint(self, entry_point_group):
"""Load entrypoint.
:param entry_point_group: A name of entry point group used to load
``webassets`` bundles.
.. versionchanged:: 1.0.0b2
The *entrypoint* has been renamed to *entry_point_group*.
"""
for ep in... | def load_entrypoint(self, entry_point_group):
"""Load entrypoint.
:param entry_point_group: A name of entry point group used to load
``webassets`` bundles.
.. versionchanged:: 1.0.0b2
The *entrypoint* has been renamed to *entry_point_group*.
"""
for ep in... | [
"Load",
"entrypoint",
"."
] | inveniosoftware/invenio-assets | python | https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/ext.py#L75-L85 | [
"def",
"load_entrypoint",
"(",
"self",
",",
"entry_point_group",
")",
":",
"for",
"ep",
"in",
"pkg_resources",
".",
"iter_entry_points",
"(",
"entry_point_group",
")",
":",
"self",
".",
"env",
".",
"register",
"(",
"ep",
".",
"name",
",",
"ep",
".",
"load"... | 836cc75ebe0c179f0d72456bd8b784cdc18394a6 |
train | assert_instance_of | An inlined version of instance_of(var_types)(value) without 'return True': it does not return anything in case of
success, and raises a HasWrongType exception in case of failure.
Used in validate and validation/validator
:param value: the value to check
:param allowed_types: the type(s) to enforce. If... | valid8/entry_points_inline.py | def assert_instance_of(value,
allowed_types # type: Union[Type, Tuple[Type]]
):
"""
An inlined version of instance_of(var_types)(value) without 'return True': it does not return anything in case of
success, and raises a HasWrongType exception in case of failure... | def assert_instance_of(value,
allowed_types # type: Union[Type, Tuple[Type]]
):
"""
An inlined version of instance_of(var_types)(value) without 'return True': it does not return anything in case of
success, and raises a HasWrongType exception in case of failure... | [
"An",
"inlined",
"version",
"of",
"instance_of",
"(",
"var_types",
")",
"(",
"value",
")",
"without",
"return",
"True",
":",
"it",
"does",
"not",
"return",
"anything",
"in",
"case",
"of",
"success",
"and",
"raises",
"a",
"HasWrongType",
"exception",
"in",
... | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_inline.py#L25-L51 | [
"def",
"assert_instance_of",
"(",
"value",
",",
"allowed_types",
"# type: Union[Type, Tuple[Type]]",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"allowed_types",
")",
":",
"try",
":",
"# more than 1 ?",
"allowed_types",
"[",
"1",
"]",
"raise",
"HasWron... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | assert_subclass_of | An inlined version of subclass_of(var_types)(value) without 'return True': it does not return anything in case of
success, and raises a IsWrongType exception in case of failure.
Used in validate and validation/validator
:param typ: the type to check
:param allowed_types: the type(s) to enforce. If a t... | valid8/entry_points_inline.py | def assert_subclass_of(typ,
allowed_types # type: Union[Type, Tuple[Type]]
):
"""
An inlined version of subclass_of(var_types)(value) without 'return True': it does not return anything in case of
success, and raises a IsWrongType exception in case of failure.
... | def assert_subclass_of(typ,
allowed_types # type: Union[Type, Tuple[Type]]
):
"""
An inlined version of subclass_of(var_types)(value) without 'return True': it does not return anything in case of
success, and raises a IsWrongType exception in case of failure.
... | [
"An",
"inlined",
"version",
"of",
"subclass_of",
"(",
"var_types",
")",
"(",
"value",
")",
"without",
"return",
"True",
":",
"it",
"does",
"not",
"return",
"anything",
"in",
"case",
"of",
"success",
"and",
"raises",
"a",
"IsWrongType",
"exception",
"in",
"... | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_inline.py#L54-L80 | [
"def",
"assert_subclass_of",
"(",
"typ",
",",
"allowed_types",
"# type: Union[Type, Tuple[Type]]",
")",
":",
"if",
"not",
"issubclass",
"(",
"typ",
",",
"allowed_types",
")",
":",
"try",
":",
"# more than 1 ?",
"allowed_types",
"[",
"1",
"]",
"raise",
"IsWrongType... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | validate | A validation function for quick inline validation of `value`, with minimal capabilities:
* None handling: reject None (enforce_not_none=True, default), or accept None silently (enforce_not_none=False)
* Type validation: `value` should be an instance of any of `var_types` if provided
* Value validation:
... | valid8/entry_points_inline.py | def validate(name, # type: str
value, # type: Any
enforce_not_none=True, # type: bool
equals=None, # type: Any
instance_of=None, # type: Union[Type, Tuple[Type]]
subclass_of=None, # type: Union[Ty... | def validate(name, # type: str
value, # type: Any
enforce_not_none=True, # type: bool
equals=None, # type: Any
instance_of=None, # type: Union[Type, Tuple[Type]]
subclass_of=None, # type: Union[Ty... | [
"A",
"validation",
"function",
"for",
"quick",
"inline",
"validation",
"of",
"value",
"with",
"minimal",
"capabilities",
":"
] | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_inline.py#L125-L305 | [
"def",
"validate",
"(",
"name",
",",
"# type: str",
"value",
",",
"# type: Any",
"enforce_not_none",
"=",
"True",
",",
"# type: bool",
"equals",
"=",
"None",
",",
"# type: Any",
"instance_of",
"=",
"None",
",",
"# type: Union[Type, Tuple[Type]]",
"subclass_of",
"=",... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | gt | 'Greater than' validation_function generator.
Returns a validation_function to check that x >= min_value (strict=False, default) or x > min_value (strict=True)
:param min_value: minimum value for x
:param strict: Boolean flag to switch between x >= min_value (strict=False) and x > min_value (strict=True)
... | valid8/validation_lib/comparables.py | def gt(min_value, # type: Any
strict=False # type: bool
):
"""
'Greater than' validation_function generator.
Returns a validation_function to check that x >= min_value (strict=False, default) or x > min_value (strict=True)
:param min_value: minimum value for x
:param strict: Boole... | def gt(min_value, # type: Any
strict=False # type: bool
):
"""
'Greater than' validation_function generator.
Returns a validation_function to check that x >= min_value (strict=False, default) or x > min_value (strict=True)
:param min_value: minimum value for x
:param strict: Boole... | [
"Greater",
"than",
"validation_function",
"generator",
".",
"Returns",
"a",
"validation_function",
"to",
"check",
"that",
"x",
">",
"=",
"min_value",
"(",
"strict",
"=",
"False",
"default",
")",
"or",
"x",
">",
"min_value",
"(",
"strict",
"=",
"True",
")"
] | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/comparables.py#L24-L53 | [
"def",
"gt",
"(",
"min_value",
",",
"# type: Any",
"strict",
"=",
"False",
"# type: bool",
")",
":",
"if",
"strict",
":",
"def",
"gt_",
"(",
"x",
")",
":",
"if",
"x",
">",
"min_value",
":",
"return",
"True",
"else",
":",
"# raise Failure('x > ' + str(min_v... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | lt | 'Lesser than' validation_function generator.
Returns a validation_function to check that x <= max_value (strict=False, default) or x < max_value (strict=True)
:param max_value: maximum value for x
:param strict: Boolean flag to switch between x <= max_value (strict=False) and x < max_value (strict=True)
... | valid8/validation_lib/comparables.py | def lt(max_value, # type: Any
strict=False # type: bool
):
"""
'Lesser than' validation_function generator.
Returns a validation_function to check that x <= max_value (strict=False, default) or x < max_value (strict=True)
:param max_value: maximum value for x
:param strict: Boolea... | def lt(max_value, # type: Any
strict=False # type: bool
):
"""
'Lesser than' validation_function generator.
Returns a validation_function to check that x <= max_value (strict=False, default) or x < max_value (strict=True)
:param max_value: maximum value for x
:param strict: Boolea... | [
"Lesser",
"than",
"validation_function",
"generator",
".",
"Returns",
"a",
"validation_function",
"to",
"check",
"that",
"x",
"<",
"=",
"max_value",
"(",
"strict",
"=",
"False",
"default",
")",
"or",
"x",
"<",
"max_value",
"(",
"strict",
"=",
"True",
")"
] | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/comparables.py#L70-L99 | [
"def",
"lt",
"(",
"max_value",
",",
"# type: Any",
"strict",
"=",
"False",
"# type: bool",
")",
":",
"if",
"strict",
":",
"def",
"lt_",
"(",
"x",
")",
":",
"if",
"x",
"<",
"max_value",
":",
"return",
"True",
"else",
":",
"# raise Failure('x < ' + str(max_v... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | between | 'Is between' validation_function generator.
Returns a validation_function to check that min_val <= x <= max_val (default). open_right and open_left flags allow
to transform each side into strict mode. For example setting open_left=True will enforce min_val < x <= max_val
:param min_val: minimum value for x... | valid8/validation_lib/comparables.py | def between(min_val, # type: Any
max_val, # type: Any
open_left=False, # type: bool
open_right=False # type: bool
):
"""
'Is between' validation_function generator.
Returns a validation_function to check that min_val <= x <= max_val (defaul... | def between(min_val, # type: Any
max_val, # type: Any
open_left=False, # type: bool
open_right=False # type: bool
):
"""
'Is between' validation_function generator.
Returns a validation_function to check that min_val <= x <= max_val (defaul... | [
"Is",
"between",
"validation_function",
"generator",
".",
"Returns",
"a",
"validation_function",
"to",
"check",
"that",
"min_val",
"<",
"=",
"x",
"<",
"=",
"max_val",
"(",
"default",
")",
".",
"open_right",
"and",
"open_left",
"flags",
"allow",
"to",
"transfor... | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/comparables.py#L118-L168 | [
"def",
"between",
"(",
"min_val",
",",
"# type: Any",
"max_val",
",",
"# type: Any",
"open_left",
"=",
"False",
",",
"# type: bool",
"open_right",
"=",
"False",
"# type: bool",
")",
":",
"if",
"open_left",
"and",
"open_right",
":",
"def",
"between_",
"(",
"x",... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | _sub_process_main | This is the main method for the sub=process, everything we need to create the message pump and
channel it needs to be passed in as parameters that can be pickled as when we run they will be serialized
into this process. The data should be value types, not reference types as we will receive a copy of the origina... | brightside/dispatch.py | def _sub_process_main(started_event: Event,
channel_name: str,
connection: Connection,
consumer_configuration: BrightsideConsumerConfiguration,
consumer_factory: Callable[[Connection, BrightsideConsumerConfiguration, logging.Logger]... | def _sub_process_main(started_event: Event,
channel_name: str,
connection: Connection,
consumer_configuration: BrightsideConsumerConfiguration,
consumer_factory: Callable[[Connection, BrightsideConsumerConfiguration, logging.Logger]... | [
"This",
"is",
"the",
"main",
"method",
"for",
"the",
"sub",
"=",
"process",
"everything",
"we",
"need",
"to",
"create",
"the",
"message",
"pump",
"and",
"channel",
"it",
"needs",
"to",
"be",
"passed",
"in",
"as",
"parameters",
"that",
"can",
"be",
"pickl... | BrighterCommand/Brightside | python | https://github.com/BrighterCommand/Brightside/blob/53b2f8323c3972609010a7386130249f3758f5fb/brightside/dispatch.py#L106-L141 | [
"def",
"_sub_process_main",
"(",
"started_event",
":",
"Event",
",",
"channel_name",
":",
"str",
",",
"connection",
":",
"Connection",
",",
"consumer_configuration",
":",
"BrightsideConsumerConfiguration",
",",
"consumer_factory",
":",
"Callable",
"[",
"[",
"Connectio... | 53b2f8323c3972609010a7386130249f3758f5fb |
train | run_migrations_offline | Run migrations in 'offline' mode.
This configures the context with just a URL
and not an Engine, though an Engine is acceptable
here as well. By skipping the Engine creation
we don't even need a DBAPI to be available.
Calls to context.execute() here emit the given string to the
script output. | dci/alembic/env.py | def run_migrations_offline():
"""Run migrations in 'offline' mode.
This configures the context with just a URL
and not an Engine, though an Engine is acceptable
here as well. By skipping the Engine creation
we don't even need a DBAPI to be available.
Calls to context.execute() here emit the g... | def run_migrations_offline():
"""Run migrations in 'offline' mode.
This configures the context with just a URL
and not an Engine, though an Engine is acceptable
here as well. By skipping the Engine creation
we don't even need a DBAPI to be available.
Calls to context.execute() here emit the g... | [
"Run",
"migrations",
"in",
"offline",
"mode",
"."
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/alembic/env.py#L34-L53 | [
"def",
"run_migrations_offline",
"(",
")",
":",
"app_conf",
"=",
"dci_config",
".",
"generate_conf",
"(",
")",
"url",
"=",
"app_conf",
"[",
"'SQLALCHEMY_DATABASE_URI'",
"]",
"context",
".",
"configure",
"(",
"url",
"=",
"url",
",",
"target_metadata",
"=",
"tar... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | run_migrations_online | Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context. | dci/alembic/env.py | def run_migrations_online():
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
"""
app_conf = dci_config.generate_conf()
connectable = dci_config.get_engine(app_conf)
with connectable.connect() as connection:
... | def run_migrations_online():
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
"""
app_conf = dci_config.generate_conf()
connectable = dci_config.get_engine(app_conf)
with connectable.connect() as connection:
... | [
"Run",
"migrations",
"in",
"online",
"mode",
"."
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/alembic/env.py#L56-L72 | [
"def",
"run_migrations_online",
"(",
")",
":",
"app_conf",
"=",
"dci_config",
".",
"generate_conf",
"(",
")",
"connectable",
"=",
"dci_config",
".",
"get_engine",
"(",
"app_conf",
")",
"with",
"connectable",
".",
"connect",
"(",
")",
"as",
"connection",
":",
... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | reject | Sends a 401 reject response that enables basic auth. | dci/decorators.py | def reject():
"""Sends a 401 reject response that enables basic auth."""
auth_message = ('Could not verify your access level for that URL.'
'Please login with proper credentials.')
auth_message = json.dumps({'_status': 'Unauthorized',
'message': auth_messa... | def reject():
"""Sends a 401 reject response that enables basic auth."""
auth_message = ('Could not verify your access level for that URL.'
'Please login with proper credentials.')
auth_message = json.dumps({'_status': 'Unauthorized',
'message': auth_messa... | [
"Sends",
"a",
"401",
"reject",
"response",
"that",
"enables",
"basic",
"auth",
"."
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/decorators.py#L26-L36 | [
"def",
"reject",
"(",
")",
":",
"auth_message",
"=",
"(",
"'Could not verify your access level for that URL.'",
"'Please login with proper credentials.'",
")",
"auth_message",
"=",
"json",
".",
"dumps",
"(",
"{",
"'_status'",
":",
"'Unauthorized'",
",",
"'message'",
":"... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | PingdomContact.modify | Modify a contact.
Returns status message
Optional Parameters:
* name -- Contact name
Type: String
* email -- Contact email address
Type: String
* cellphone -- Cellphone number, without the country code part. In
... | pingdomlib/contact.py | def modify(self, **kwargs):
"""Modify a contact.
Returns status message
Optional Parameters:
* name -- Contact name
Type: String
* email -- Contact email address
Type: String
* cellphone -- Cellphone number, without... | def modify(self, **kwargs):
"""Modify a contact.
Returns status message
Optional Parameters:
* name -- Contact name
Type: String
* email -- Contact email address
Type: String
* cellphone -- Cellphone number, without... | [
"Modify",
"a",
"contact",
"."
] | KennethWilke/PingdomLib | python | https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/contact.py#L44-L93 | [
"def",
"modify",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# Warn user about unhandled parameters",
"for",
"key",
"in",
"kwargs",
":",
"if",
"key",
"not",
"in",
"[",
"'email'",
",",
"'cellphone'",
",",
"'countrycode'",
",",
"'countryiso'",
",",
"'defa... | 3ed1e481f9c9d16b032558d62fb05c2166e162ed |
train | ArameConsumer._establish_connection | We don't use a pool here. We only have one consumer connection per process, so
we get no value from a pool, and we want to use a heartbeat to keep the consumer
collection alive, which does not work with a pool
:return: the connection to the transport | arame/gateway.py | def _establish_connection(self, conn: BrokerConnection) -> None:
"""
We don't use a pool here. We only have one consumer connection per process, so
we get no value from a pool, and we want to use a heartbeat to keep the consumer
collection alive, which does not work with a pool
:... | def _establish_connection(self, conn: BrokerConnection) -> None:
"""
We don't use a pool here. We only have one consumer connection per process, so
we get no value from a pool, and we want to use a heartbeat to keep the consumer
collection alive, which does not work with a pool
:... | [
"We",
"don",
"t",
"use",
"a",
"pool",
"here",
".",
"We",
"only",
"have",
"one",
"consumer",
"connection",
"per",
"process",
"so",
"we",
"get",
"no",
"value",
"from",
"a",
"pool",
"and",
"we",
"want",
"to",
"use",
"a",
"heartbeat",
"to",
"keep",
"the"... | BrighterCommand/Brightside | python | https://github.com/BrighterCommand/Brightside/blob/53b2f8323c3972609010a7386130249f3758f5fb/arame/gateway.py#L159-L176 | [
"def",
"_establish_connection",
"(",
"self",
",",
"conn",
":",
"BrokerConnection",
")",
"->",
"None",
":",
"try",
":",
"self",
".",
"_logger",
".",
"debug",
"(",
"\"Establishing connection.\"",
")",
"self",
".",
"_conn",
"=",
"conn",
".",
"ensure_connection",
... | 53b2f8323c3972609010a7386130249f3758f5fb |
train | ArameConsumer.run_heartbeat_continuously | For a long runing handler, there is a danger that we do not send a heartbeat message or activity on the
connection whilst we are running the handler. With a default heartbeat of 30s, for example, there is a risk
that a handler which takes more than 15s will fail to send the heartbeat in time and then th... | arame/gateway.py | def run_heartbeat_continuously(self) -> threading.Event:
"""
For a long runing handler, there is a danger that we do not send a heartbeat message or activity on the
connection whilst we are running the handler. With a default heartbeat of 30s, for example, there is a risk
that a handler ... | def run_heartbeat_continuously(self) -> threading.Event:
"""
For a long runing handler, there is a danger that we do not send a heartbeat message or activity on the
connection whilst we are running the handler. With a default heartbeat of 30s, for example, there is a risk
that a handler ... | [
"For",
"a",
"long",
"runing",
"handler",
"there",
"is",
"a",
"danger",
"that",
"we",
"do",
"not",
"send",
"a",
"heartbeat",
"message",
"or",
"activity",
"on",
"the",
"connection",
"whilst",
"we",
"are",
"running",
"the",
"handler",
".",
"With",
"a",
"def... | BrighterCommand/Brightside | python | https://github.com/BrighterCommand/Brightside/blob/53b2f8323c3972609010a7386130249f3758f5fb/arame/gateway.py#L252-L281 | [
"def",
"run_heartbeat_continuously",
"(",
"self",
")",
"->",
"threading",
".",
"Event",
":",
"cancellation_event",
"=",
"threading",
".",
"Event",
"(",
")",
"# Effectively a no-op if we are not actually a long-running thread",
"if",
"not",
"self",
".",
"_is_long_running_h... | 53b2f8323c3972609010a7386130249f3758f5fb |
train | _check | If the topic has it's export_control set to True then all the teams
under the product team can access to the topic's resources.
:param user:
:param topic:
:return: True if check is ok, False otherwise | dci/api/v1/export_control.py | def _check(user, topic):
"""If the topic has it's export_control set to True then all the teams
under the product team can access to the topic's resources.
:param user:
:param topic:
:return: True if check is ok, False otherwise
"""
# if export_control then check the team is associated to t... | def _check(user, topic):
"""If the topic has it's export_control set to True then all the teams
under the product team can access to the topic's resources.
:param user:
:param topic:
:return: True if check is ok, False otherwise
"""
# if export_control then check the team is associated to t... | [
"If",
"the",
"topic",
"has",
"it",
"s",
"export_control",
"set",
"to",
"True",
"then",
"all",
"the",
"teams",
"under",
"the",
"product",
"team",
"can",
"access",
"to",
"the",
"topic",
"s",
"resources",
"."
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/export_control.py#L21-L38 | [
"def",
"_check",
"(",
"user",
",",
"topic",
")",
":",
"# if export_control then check the team is associated to the product, ie.:",
"# - the current user belongs to the product's team",
"# OR",
"# - the product's team belongs to the user's parents teams",
"if",
"topic",
"[",
"'ex... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | get_stream_or_content_from_request | Ensure the proper content is uploaded.
Stream might be already consumed by authentication process.
Hence flask.request.stream might not be readable and return improper value.
This methods checks if the stream has already been consumed and if so
retrieve the data from flask.request.data where it has be... | dci/stores/files_utils.py | def get_stream_or_content_from_request(request):
"""Ensure the proper content is uploaded.
Stream might be already consumed by authentication process.
Hence flask.request.stream might not be readable and return improper value.
This methods checks if the stream has already been consumed and if so
r... | def get_stream_or_content_from_request(request):
"""Ensure the proper content is uploaded.
Stream might be already consumed by authentication process.
Hence flask.request.stream might not be readable and return improper value.
This methods checks if the stream has already been consumed and if so
r... | [
"Ensure",
"the",
"proper",
"content",
"is",
"uploaded",
"."
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/stores/files_utils.py#L24-L41 | [
"def",
"get_stream_or_content_from_request",
"(",
"request",
")",
":",
"if",
"request",
".",
"stream",
".",
"tell",
"(",
")",
":",
"logger",
".",
"info",
"(",
"'Request stream already consumed. '",
"'Storing file content using in-memory data.'",
")",
"return",
"request"... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | LXMLAdapter.xpath_on_node | Return result of performing the given XPath query on the given node.
All known namespace prefix-to-URI mappings in the document are
automatically included in the XPath invocation.
If an empty/default namespace (i.e. None) is defined, this is
converted to the prefix name '_' so it can b... | xml4h/impls/lxml_etree.py | def xpath_on_node(self, node, xpath, **kwargs):
"""
Return result of performing the given XPath query on the given node.
All known namespace prefix-to-URI mappings in the document are
automatically included in the XPath invocation.
If an empty/default namespace (i.e. None) is d... | def xpath_on_node(self, node, xpath, **kwargs):
"""
Return result of performing the given XPath query on the given node.
All known namespace prefix-to-URI mappings in the document are
automatically included in the XPath invocation.
If an empty/default namespace (i.e. None) is d... | [
"Return",
"result",
"of",
"performing",
"the",
"given",
"XPath",
"query",
"on",
"the",
"given",
"node",
"."
] | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/impls/lxml_etree.py#L133-L159 | [
"def",
"xpath_on_node",
"(",
"self",
",",
"node",
",",
"xpath",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"node",
",",
"etree",
".",
"_ElementTree",
")",
":",
"# Document node lxml.etree._ElementTree has no nsmap, lookup root",
"root",
"=",
"se... | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | LXMLAdapter._is_ns_in_ancestor | Return True if the given namespace name/value is defined in an
ancestor of the given node, meaning that the given node need not
have its own attributes to apply that namespacing. | xml4h/impls/lxml_etree.py | def _is_ns_in_ancestor(self, node, name, value):
"""
Return True if the given namespace name/value is defined in an
ancestor of the given node, meaning that the given node need not
have its own attributes to apply that namespacing.
"""
curr_node = self.get_node_parent(nod... | def _is_ns_in_ancestor(self, node, name, value):
"""
Return True if the given namespace name/value is defined in an
ancestor of the given node, meaning that the given node need not
have its own attributes to apply that namespacing.
"""
curr_node = self.get_node_parent(nod... | [
"Return",
"True",
"if",
"the",
"given",
"namespace",
"name",
"/",
"value",
"is",
"defined",
"in",
"an",
"ancestor",
"of",
"the",
"given",
"node",
"meaning",
"that",
"the",
"given",
"node",
"need",
"not",
"have",
"its",
"own",
"attributes",
"to",
"apply",
... | jmurty/xml4h | python | https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/impls/lxml_etree.py#L440-L455 | [
"def",
"_is_ns_in_ancestor",
"(",
"self",
",",
"node",
",",
"name",
",",
"value",
")",
":",
"curr_node",
"=",
"self",
".",
"get_node_parent",
"(",
"node",
")",
"while",
"curr_node",
".",
"__class__",
"==",
"etree",
".",
"_Element",
":",
"if",
"(",
"hasat... | adbb45e27a01a869a505aee7bc16bad2f517b511 |
train | generic_annotate | Find blog entries with the most comments:
qs = generic_annotate(Entry.objects.public(), Comment.objects.public(), Count('comments__id'))
for entry in qs:
print entry.title, entry.score
Find the highest rated foods:
generic_annotate(Food, Rating, Avg('ratings__ratin... | generic_aggregation/utils.py | def generic_annotate(qs_model, generic_qs_model, aggregator, gfk_field=None, alias='score'):
"""
Find blog entries with the most comments:
qs = generic_annotate(Entry.objects.public(), Comment.objects.public(), Count('comments__id'))
for entry in qs:
print entry.title, entry.sco... | def generic_annotate(qs_model, generic_qs_model, aggregator, gfk_field=None, alias='score'):
"""
Find blog entries with the most comments:
qs = generic_annotate(Entry.objects.public(), Comment.objects.public(), Count('comments__id'))
for entry in qs:
print entry.title, entry.sco... | [
"Find",
"blog",
"entries",
"with",
"the",
"most",
"comments",
":",
"qs",
"=",
"generic_annotate",
"(",
"Entry",
".",
"objects",
".",
"public",
"()",
"Comment",
".",
"objects",
".",
"public",
"()",
"Count",
"(",
"comments__id",
"))",
"for",
"entry",
"in",
... | coleifer/django-generic-aggregation | python | https://github.com/coleifer/django-generic-aggregation/blob/67cf89d58176e7df974b2bdb5e397352ad4e16e7/generic_aggregation/utils.py#L30-L62 | [
"def",
"generic_annotate",
"(",
"qs_model",
",",
"generic_qs_model",
",",
"aggregator",
",",
"gfk_field",
"=",
"None",
",",
"alias",
"=",
"'score'",
")",
":",
"return",
"fallback_generic_annotate",
"(",
"qs_model",
",",
"generic_qs_model",
",",
"aggregator",
",",
... | 67cf89d58176e7df974b2bdb5e397352ad4e16e7 |
train | generic_aggregate | Find total number of comments on blog entries:
generic_aggregate(Entry.objects.public(), Comment.objects.public(), Count('comments__id'))
Find the average rating for foods starting with 'a':
a_foods = Food.objects.filter(name__startswith='a')
generic_aggregate(a_foods, Rating,... | generic_aggregation/utils.py | def generic_aggregate(qs_model, generic_qs_model, aggregator, gfk_field=None):
"""
Find total number of comments on blog entries:
generic_aggregate(Entry.objects.public(), Comment.objects.public(), Count('comments__id'))
Find the average rating for foods starting with 'a':
a_f... | def generic_aggregate(qs_model, generic_qs_model, aggregator, gfk_field=None):
"""
Find total number of comments on blog entries:
generic_aggregate(Entry.objects.public(), Comment.objects.public(), Count('comments__id'))
Find the average rating for foods starting with 'a':
a_f... | [
"Find",
"total",
"number",
"of",
"comments",
"on",
"blog",
"entries",
":",
"generic_aggregate",
"(",
"Entry",
".",
"objects",
".",
"public",
"()",
"Comment",
".",
"objects",
".",
"public",
"()",
"Count",
"(",
"comments__id",
"))",
"Find",
"the",
"average",
... | coleifer/django-generic-aggregation | python | https://github.com/coleifer/django-generic-aggregation/blob/67cf89d58176e7df974b2bdb5e397352ad4e16e7/generic_aggregation/utils.py#L65-L93 | [
"def",
"generic_aggregate",
"(",
"qs_model",
",",
"generic_qs_model",
",",
"aggregator",
",",
"gfk_field",
"=",
"None",
")",
":",
"return",
"fallback_generic_aggregate",
"(",
"qs_model",
",",
"generic_qs_model",
",",
"aggregator",
",",
"gfk_field",
")"
] | 67cf89d58176e7df974b2bdb5e397352ad4e16e7 |
train | generic_filter | Only show me ratings made on foods that start with "a":
a_foods = Food.objects.filter(name__startswith='a')
generic_filter(Rating.objects.all(), a_foods)
Only show me comments from entries that are marked as public:
generic_filter(Comment.objects.public(), Entry.objects.public... | generic_aggregation/utils.py | def generic_filter(generic_qs_model, filter_qs_model, gfk_field=None):
"""
Only show me ratings made on foods that start with "a":
a_foods = Food.objects.filter(name__startswith='a')
generic_filter(Rating.objects.all(), a_foods)
Only show me comments from entries that are marked as... | def generic_filter(generic_qs_model, filter_qs_model, gfk_field=None):
"""
Only show me ratings made on foods that start with "a":
a_foods = Food.objects.filter(name__startswith='a')
generic_filter(Rating.objects.all(), a_foods)
Only show me comments from entries that are marked as... | [
"Only",
"show",
"me",
"ratings",
"made",
"on",
"foods",
"that",
"start",
"with",
"a",
":",
"a_foods",
"=",
"Food",
".",
"objects",
".",
"filter",
"(",
"name__startswith",
"=",
"a",
")",
"generic_filter",
"(",
"Rating",
".",
"objects",
".",
"all",
"()",
... | coleifer/django-generic-aggregation | python | https://github.com/coleifer/django-generic-aggregation/blob/67cf89d58176e7df974b2bdb5e397352ad4e16e7/generic_aggregation/utils.py#L96-L125 | [
"def",
"generic_filter",
"(",
"generic_qs_model",
",",
"filter_qs_model",
",",
"gfk_field",
"=",
"None",
")",
":",
"generic_qs",
"=",
"normalize_qs_model",
"(",
"generic_qs_model",
")",
"filter_qs",
"=",
"normalize_qs_model",
"(",
"filter_qs_model",
")",
"if",
"not"... | 67cf89d58176e7df974b2bdb5e397352ad4e16e7 |
train | gen_etag | Generate random etag based on MD5. | dci/common/utils.py | def gen_etag():
"""Generate random etag based on MD5."""
my_salt = gen_uuid()
if six.PY2:
my_salt = my_salt.decode('utf-8')
elif six.PY3:
my_salt = my_salt.encode('utf-8')
md5 = hashlib.md5()
md5.update(my_salt)
return md5.hexdigest() | def gen_etag():
"""Generate random etag based on MD5."""
my_salt = gen_uuid()
if six.PY2:
my_salt = my_salt.decode('utf-8')
elif six.PY3:
my_salt = my_salt.encode('utf-8')
md5 = hashlib.md5()
md5.update(my_salt)
return md5.hexdigest() | [
"Generate",
"random",
"etag",
"based",
"on",
"MD5",
"."
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/common/utils.py#L64-L74 | [
"def",
"gen_etag",
"(",
")",
":",
"my_salt",
"=",
"gen_uuid",
"(",
")",
"if",
"six",
".",
"PY2",
":",
"my_salt",
"=",
"my_salt",
".",
"decode",
"(",
"'utf-8'",
")",
"elif",
"six",
".",
"PY3",
":",
"my_salt",
"=",
"my_salt",
".",
"encode",
"(",
"'ut... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | PingdomSharedReport.delete | Delete this email report | pingdomlib/reports.py | def delete(self):
"""Delete this email report"""
response = self.pingdom.request('DELETE',
'reports.shared/%s' % self.id)
return response.json()['message'] | def delete(self):
"""Delete this email report"""
response = self.pingdom.request('DELETE',
'reports.shared/%s' % self.id)
return response.json()['message'] | [
"Delete",
"this",
"email",
"report"
] | KennethWilke/PingdomLib | python | https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/reports.py#L101-L106 | [
"def",
"delete",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"pingdom",
".",
"request",
"(",
"'DELETE'",
",",
"'reports.shared/%s'",
"%",
"self",
".",
"id",
")",
"return",
"response",
".",
"json",
"(",
")",
"[",
"'message'",
"]"
] | 3ed1e481f9c9d16b032558d62fb05c2166e162ed |
train | is_multiple_of | Validates that x is a multiple of the reference (`x % ref == 0`) | valid8/validation_lib/numbers.py | def is_multiple_of(ref):
""" Validates that x is a multiple of the reference (`x % ref == 0`) """
def is_multiple_of_ref(x):
if x % ref == 0:
return True
else:
raise IsNotMultipleOf(wrong_value=x, ref=ref)
# raise Failure('x % {ref} == 0 does not hold for x={v... | def is_multiple_of(ref):
""" Validates that x is a multiple of the reference (`x % ref == 0`) """
def is_multiple_of_ref(x):
if x % ref == 0:
return True
else:
raise IsNotMultipleOf(wrong_value=x, ref=ref)
# raise Failure('x % {ref} == 0 does not hold for x={v... | [
"Validates",
"that",
"x",
"is",
"a",
"multiple",
"of",
"the",
"reference",
"(",
"x",
"%",
"ref",
"==",
"0",
")"
] | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/numbers.py#L42-L52 | [
"def",
"is_multiple_of",
"(",
"ref",
")",
":",
"def",
"is_multiple_of_ref",
"(",
"x",
")",
":",
"if",
"x",
"%",
"ref",
"==",
"0",
":",
"return",
"True",
"else",
":",
"raise",
"IsNotMultipleOf",
"(",
"wrong_value",
"=",
"x",
",",
"ref",
"=",
"ref",
")... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | get_all_components | Get all components of a topic. | dci/api/v1/components.py | def get_all_components(user, topic_id):
"""Get all components of a topic."""
args = schemas.args(flask.request.args.to_dict())
query = v1_utils.QueryBuilder(_TABLE, args, _C_COLUMNS)
query.add_extra_condition(sql.and_(
_TABLE.c.topic_id == topic_id,
_TABLE.c.state != 'archived'))
... | def get_all_components(user, topic_id):
"""Get all components of a topic."""
args = schemas.args(flask.request.args.to_dict())
query = v1_utils.QueryBuilder(_TABLE, args, _C_COLUMNS)
query.add_extra_condition(sql.and_(
_TABLE.c.topic_id == topic_id,
_TABLE.c.state != 'archived'))
... | [
"Get",
"all",
"components",
"of",
"a",
"topic",
"."
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/components.py#L139-L160 | [
"def",
"get_all_components",
"(",
"user",
",",
"topic_id",
")",
":",
"args",
"=",
"schemas",
".",
"args",
"(",
"flask",
".",
"request",
".",
"args",
".",
"to_dict",
"(",
")",
")",
"query",
"=",
"v1_utils",
".",
"QueryBuilder",
"(",
"_TABLE",
",",
"args... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | get_component_types_from_topic | Returns the component types of a topic. | dci/api/v1/components.py | def get_component_types_from_topic(topic_id, db_conn=None):
"""Returns the component types of a topic."""
db_conn = db_conn or flask.g.db_conn
query = sql.select([models.TOPICS]).\
where(models.TOPICS.c.id == topic_id)
topic = db_conn.execute(query).fetchone()
topic = dict(topic)
return ... | def get_component_types_from_topic(topic_id, db_conn=None):
"""Returns the component types of a topic."""
db_conn = db_conn or flask.g.db_conn
query = sql.select([models.TOPICS]).\
where(models.TOPICS.c.id == topic_id)
topic = db_conn.execute(query).fetchone()
topic = dict(topic)
return ... | [
"Returns",
"the",
"component",
"types",
"of",
"a",
"topic",
"."
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/components.py#L340-L347 | [
"def",
"get_component_types_from_topic",
"(",
"topic_id",
",",
"db_conn",
"=",
"None",
")",
":",
"db_conn",
"=",
"db_conn",
"or",
"flask",
".",
"g",
".",
"db_conn",
"query",
"=",
"sql",
".",
"select",
"(",
"[",
"models",
".",
"TOPICS",
"]",
")",
".",
"... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | get_component_types | Returns either the topic component types or the rconfigration's
component types. | dci/api/v1/components.py | def get_component_types(topic_id, remoteci_id, db_conn=None):
"""Returns either the topic component types or the rconfigration's
component types."""
db_conn = db_conn or flask.g.db_conn
rconfiguration = remotecis.get_remoteci_configuration(topic_id,
... | def get_component_types(topic_id, remoteci_id, db_conn=None):
"""Returns either the topic component types or the rconfigration's
component types."""
db_conn = db_conn or flask.g.db_conn
rconfiguration = remotecis.get_remoteci_configuration(topic_id,
... | [
"Returns",
"either",
"the",
"topic",
"component",
"types",
"or",
"the",
"rconfigration",
"s",
"component",
"types",
"."
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/components.py#L350-L368 | [
"def",
"get_component_types",
"(",
"topic_id",
",",
"remoteci_id",
",",
"db_conn",
"=",
"None",
")",
":",
"db_conn",
"=",
"db_conn",
"or",
"flask",
".",
"g",
".",
"db_conn",
"rconfiguration",
"=",
"remotecis",
".",
"get_remoteci_configuration",
"(",
"topic_id",
... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | get_last_components_by_type | For each component type of a topic, get the last one. | dci/api/v1/components.py | def get_last_components_by_type(component_types, topic_id, db_conn=None):
"""For each component type of a topic, get the last one."""
db_conn = db_conn or flask.g.db_conn
schedule_components_ids = []
for ct in component_types:
where_clause = sql.and_(models.COMPONENTS.c.type == ct,
... | def get_last_components_by_type(component_types, topic_id, db_conn=None):
"""For each component type of a topic, get the last one."""
db_conn = db_conn or flask.g.db_conn
schedule_components_ids = []
for ct in component_types:
where_clause = sql.and_(models.COMPONENTS.c.type == ct,
... | [
"For",
"each",
"component",
"type",
"of",
"a",
"topic",
"get",
"the",
"last",
"one",
"."
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/components.py#L371-L395 | [
"def",
"get_last_components_by_type",
"(",
"component_types",
",",
"topic_id",
",",
"db_conn",
"=",
"None",
")",
":",
"db_conn",
"=",
"db_conn",
"or",
"flask",
".",
"g",
".",
"db_conn",
"schedule_components_ids",
"=",
"[",
"]",
"for",
"ct",
"in",
"component_ty... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | verify_and_get_components_ids | Process some verifications of the provided components ids. | dci/api/v1/components.py | def verify_and_get_components_ids(topic_id, components_ids, component_types,
db_conn=None):
"""Process some verifications of the provided components ids."""
db_conn = db_conn or flask.g.db_conn
if len(components_ids) != len(component_types):
msg = 'The number of com... | def verify_and_get_components_ids(topic_id, components_ids, component_types,
db_conn=None):
"""Process some verifications of the provided components ids."""
db_conn = db_conn or flask.g.db_conn
if len(components_ids) != len(component_types):
msg = 'The number of com... | [
"Process",
"some",
"verifications",
"of",
"the",
"provided",
"components",
"ids",
"."
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/components.py#L398-L428 | [
"def",
"verify_and_get_components_ids",
"(",
"topic_id",
",",
"components_ids",
",",
"component_types",
",",
"db_conn",
"=",
"None",
")",
":",
"db_conn",
"=",
"db_conn",
"or",
"flask",
".",
"g",
".",
"db_conn",
"if",
"len",
"(",
"components_ids",
")",
"!=",
... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | retrieve_tags_from_component | Retrieve all tags attached to a component. | dci/api/v1/components.py | def retrieve_tags_from_component(user, c_id):
"""Retrieve all tags attached to a component."""
JCT = models.JOIN_COMPONENTS_TAGS
query = (sql.select([models.TAGS])
.select_from(JCT.join(models.TAGS))
.where(JCT.c.component_id == c_id))
rows = flask.g.db_conn.execute(query)
... | def retrieve_tags_from_component(user, c_id):
"""Retrieve all tags attached to a component."""
JCT = models.JOIN_COMPONENTS_TAGS
query = (sql.select([models.TAGS])
.select_from(JCT.join(models.TAGS))
.where(JCT.c.component_id == c_id))
rows = flask.g.db_conn.execute(query)
... | [
"Retrieve",
"all",
"tags",
"attached",
"to",
"a",
"component",
"."
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/components.py#L464-L472 | [
"def",
"retrieve_tags_from_component",
"(",
"user",
",",
"c_id",
")",
":",
"JCT",
"=",
"models",
".",
"JOIN_COMPONENTS_TAGS",
"query",
"=",
"(",
"sql",
".",
"select",
"(",
"[",
"models",
".",
"TAGS",
"]",
")",
".",
"select_from",
"(",
"JCT",
".",
"join",... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | add_tag_for_component | Add a tag on a specific component. | dci/api/v1/components.py | def add_tag_for_component(user, c_id):
"""Add a tag on a specific component."""
v1_utils.verify_existence_and_get(c_id, _TABLE)
values = {
'component_id': c_id
}
component_tagged = tags.add_tag_to_resource(values,
models.JOIN_COMPONENTS_TAGS... | def add_tag_for_component(user, c_id):
"""Add a tag on a specific component."""
v1_utils.verify_existence_and_get(c_id, _TABLE)
values = {
'component_id': c_id
}
component_tagged = tags.add_tag_to_resource(values,
models.JOIN_COMPONENTS_TAGS... | [
"Add",
"a",
"tag",
"on",
"a",
"specific",
"component",
"."
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/components.py#L477-L490 | [
"def",
"add_tag_for_component",
"(",
"user",
",",
"c_id",
")",
":",
"v1_utils",
".",
"verify_existence_and_get",
"(",
"c_id",
",",
"_TABLE",
")",
"values",
"=",
"{",
"'component_id'",
":",
"c_id",
"}",
"component_tagged",
"=",
"tags",
".",
"add_tag_to_resource",... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | delete_tag_for_component | Delete a tag on a specific component. | dci/api/v1/components.py | def delete_tag_for_component(user, c_id, tag_id):
"""Delete a tag on a specific component."""
# Todo : check c_id and tag_id exist in db
query = _TABLE_TAGS.delete().where(_TABLE_TAGS.c.tag_id == tag_id and
_TABLE_TAGS.c.component_id == c_id)
try:
flask.g... | def delete_tag_for_component(user, c_id, tag_id):
"""Delete a tag on a specific component."""
# Todo : check c_id and tag_id exist in db
query = _TABLE_TAGS.delete().where(_TABLE_TAGS.c.tag_id == tag_id and
_TABLE_TAGS.c.component_id == c_id)
try:
flask.g... | [
"Delete",
"a",
"tag",
"on",
"a",
"specific",
"component",
"."
] | redhat-cip/dci-control-server | python | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/components.py#L495-L507 | [
"def",
"delete_tag_for_component",
"(",
"user",
",",
"c_id",
",",
"tag_id",
")",
":",
"# Todo : check c_id and tag_id exist in db",
"query",
"=",
"_TABLE_TAGS",
".",
"delete",
"(",
")",
".",
"where",
"(",
"_TABLE_TAGS",
".",
"c",
".",
"tag_id",
"==",
"tag_id",
... | b416cf935ec93e4fdd5741f61a21cabecf8454d2 |
train | should_be_hidden_as_cause | Used everywhere to decide if some exception type should be displayed or hidden as the casue of an error | valid8/base.py | def should_be_hidden_as_cause(exc):
""" Used everywhere to decide if some exception type should be displayed or hidden as the casue of an error """
# reduced traceback in case of HasWrongType (instance_of checks)
from valid8.validation_lib.types import HasWrongType, IsWrongType
return isinstance(exc, (H... | def should_be_hidden_as_cause(exc):
""" Used everywhere to decide if some exception type should be displayed or hidden as the casue of an error """
# reduced traceback in case of HasWrongType (instance_of checks)
from valid8.validation_lib.types import HasWrongType, IsWrongType
return isinstance(exc, (H... | [
"Used",
"everywhere",
"to",
"decide",
"if",
"some",
"exception",
"type",
"should",
"be",
"displayed",
"or",
"hidden",
"as",
"the",
"casue",
"of",
"an",
"error"
] | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/base.py#L59-L63 | [
"def",
"should_be_hidden_as_cause",
"(",
"exc",
")",
":",
"# reduced traceback in case of HasWrongType (instance_of checks)",
"from",
"valid8",
".",
"validation_lib",
".",
"types",
"import",
"HasWrongType",
",",
"IsWrongType",
"return",
"isinstance",
"(",
"exc",
",",
"(",... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | is_error_of_type | Helper function to determine if some exception is of some type, by also looking at its declared __cause__
:param exc:
:param ref_type:
:return: | valid8/base.py | def is_error_of_type(exc, ref_type):
"""
Helper function to determine if some exception is of some type, by also looking at its declared __cause__
:param exc:
:param ref_type:
:return:
"""
if isinstance(exc, ref_type):
return True
elif hasattr(exc, '__cause__') and exc.__cause__... | def is_error_of_type(exc, ref_type):
"""
Helper function to determine if some exception is of some type, by also looking at its declared __cause__
:param exc:
:param ref_type:
:return:
"""
if isinstance(exc, ref_type):
return True
elif hasattr(exc, '__cause__') and exc.__cause__... | [
"Helper",
"function",
"to",
"determine",
"if",
"some",
"exception",
"is",
"of",
"some",
"type",
"by",
"also",
"looking",
"at",
"its",
"declared",
"__cause__"
] | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/base.py#L103-L114 | [
"def",
"is_error_of_type",
"(",
"exc",
",",
"ref_type",
")",
":",
"if",
"isinstance",
"(",
"exc",
",",
"ref_type",
")",
":",
"return",
"True",
"elif",
"hasattr",
"(",
"exc",
",",
"'__cause__'",
")",
"and",
"exc",
".",
"__cause__",
"is",
"not",
"None",
... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | _failure_raiser | Wraps the provided validation function so that in case of failure it raises the given failure_type or a WrappingFailure
with the given help message.
:param validation_callable:
:param failure_type: an optional subclass of `WrappingFailure` that should be raised in case of failure, instead of
`WrappingF... | valid8/base.py | def _failure_raiser(validation_callable, # type: Callable
failure_type=None, # type: Type[WrappingFailure]
help_msg=None, # type: str
**kw_context_args):
# type: (...) -> Callable
"""
Wraps the provided validation function so that in ... | def _failure_raiser(validation_callable, # type: Callable
failure_type=None, # type: Type[WrappingFailure]
help_msg=None, # type: str
**kw_context_args):
# type: (...) -> Callable
"""
Wraps the provided validation function so that in ... | [
"Wraps",
"the",
"provided",
"validation",
"function",
"so",
"that",
"in",
"case",
"of",
"failure",
"it",
"raises",
"the",
"given",
"failure_type",
"or",
"a",
"WrappingFailure",
"with",
"the",
"given",
"help",
"message",
"."
] | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/base.py#L413-L477 | [
"def",
"_failure_raiser",
"(",
"validation_callable",
",",
"# type: Callable",
"failure_type",
"=",
"None",
",",
"# type: Type[WrappingFailure]",
"help_msg",
"=",
"None",
",",
"# type: str",
"*",
"*",
"kw_context_args",
")",
":",
"# type: (...) -> Callable",
"# check fail... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | _none_accepter | Wraps the given validation callable to accept None values silently. When a None value is received by the wrapper,
it is not passed to the validation_callable and instead this function will return True. When any other value is
received the validation_callable is called as usual.
Note: the created wrapper ha... | valid8/base.py | def _none_accepter(validation_callable # type: Callable
):
# type: (...) -> Callable
"""
Wraps the given validation callable to accept None values silently. When a None value is received by the wrapper,
it is not passed to the validation_callable and instead this function will return... | def _none_accepter(validation_callable # type: Callable
):
# type: (...) -> Callable
"""
Wraps the given validation callable to accept None values silently. When a None value is received by the wrapper,
it is not passed to the validation_callable and instead this function will return... | [
"Wraps",
"the",
"given",
"validation",
"callable",
"to",
"accept",
"None",
"values",
"silently",
".",
"When",
"a",
"None",
"value",
"is",
"received",
"by",
"the",
"wrapper",
"it",
"is",
"not",
"passed",
"to",
"the",
"validation_callable",
"and",
"instead",
"... | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/base.py#L484-L512 | [
"def",
"_none_accepter",
"(",
"validation_callable",
"# type: Callable",
")",
":",
"# type: (...) -> Callable",
"# option (a) use the `decorate()` helper method to preserve name and signature of the inner object",
"# ==> NO, we want to support also non-function callable objects",
"# option (b) s... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | _none_rejecter | Wraps the given validation callable to reject None values. When a None value is received by the wrapper,
it is not passed to the validation_callable and instead this function will raise a WrappingFailure. When any other value is
received the validation_callable is called as usual.
:param validation_callabl... | valid8/base.py | def _none_rejecter(validation_callable # type: Callable
):
# type: (...) -> Callable
"""
Wraps the given validation callable to reject None values. When a None value is received by the wrapper,
it is not passed to the validation_callable and instead this function will raise a Wrappin... | def _none_rejecter(validation_callable # type: Callable
):
# type: (...) -> Callable
"""
Wraps the given validation callable to reject None values. When a None value is received by the wrapper,
it is not passed to the validation_callable and instead this function will raise a Wrappin... | [
"Wraps",
"the",
"given",
"validation",
"callable",
"to",
"reject",
"None",
"values",
".",
"When",
"a",
"None",
"value",
"is",
"received",
"by",
"the",
"wrapper",
"it",
"is",
"not",
"passed",
"to",
"the",
"validation_callable",
"and",
"instead",
"this",
"func... | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/base.py#L515-L539 | [
"def",
"_none_rejecter",
"(",
"validation_callable",
"# type: Callable",
")",
":",
"# type: (...) -> Callable",
"# option (a) use the `decorate()` helper method to preserve name and signature of the inner object",
"# ==> NO, we want to support also non-function callable objects",
"# option (b) s... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | HelpMsgMixIn.get_help_msg | The method used to get the formatted help message according to kwargs. By default it returns the 'help_msg'
attribute, whether it is defined at the instance level or at the class level.
The help message is formatted according to help_msg.format(**kwargs), and may be terminated with a dot
and a ... | valid8/base.py | def get_help_msg(self,
dotspace_ending=False, # type: bool
**kwargs):
# type: (...) -> str
"""
The method used to get the formatted help message according to kwargs. By default it returns the 'help_msg'
attribute, whether it is defined at the in... | def get_help_msg(self,
dotspace_ending=False, # type: bool
**kwargs):
# type: (...) -> str
"""
The method used to get the formatted help message according to kwargs. By default it returns the 'help_msg'
attribute, whether it is defined at the in... | [
"The",
"method",
"used",
"to",
"get",
"the",
"formatted",
"help",
"message",
"according",
"to",
"kwargs",
".",
"By",
"default",
"it",
"returns",
"the",
"help_msg",
"attribute",
"whether",
"it",
"is",
"defined",
"at",
"the",
"instance",
"level",
"or",
"at",
... | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/base.py#L156-L201 | [
"def",
"get_help_msg",
"(",
"self",
",",
"dotspace_ending",
"=",
"False",
",",
"# type: bool",
"*",
"*",
"kwargs",
")",
":",
"# type: (...) -> str",
"context",
"=",
"self",
".",
"get_context_for_help_msgs",
"(",
"kwargs",
")",
"if",
"self",
".",
"help_msg",
"i... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | Failure.get_details | The function called to get the details appended to the help message when self.append_details is True | valid8/base.py | def get_details(self):
""" The function called to get the details appended to the help message when self.append_details is True """
strval = str(self.wrong_value)
if len(strval) > self.__max_str_length_displayed__:
return '(Actual value is too big to be printed in this message)'
... | def get_details(self):
""" The function called to get the details appended to the help message when self.append_details is True """
strval = str(self.wrong_value)
if len(strval) > self.__max_str_length_displayed__:
return '(Actual value is too big to be printed in this message)'
... | [
"The",
"function",
"called",
"to",
"get",
"the",
"details",
"appended",
"to",
"the",
"help",
"message",
"when",
"self",
".",
"append_details",
"is",
"True"
] | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/base.py#L308-L314 | [
"def",
"get_details",
"(",
"self",
")",
":",
"strval",
"=",
"str",
"(",
"self",
".",
"wrong_value",
")",
"if",
"len",
"(",
"strval",
")",
">",
"self",
".",
"__max_str_length_displayed__",
":",
"return",
"'(Actual value is too big to be printed in this message)'",
... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | WrappingFailure.get_details | Overrides the method in Failure so as to add a few details about the wrapped function and outcome | valid8/base.py | def get_details(self):
""" Overrides the method in Failure so as to add a few details about the wrapped function and outcome """
if isinstance(self.validation_outcome, Exception):
if isinstance(self.validation_outcome, Failure):
# do not say again what was the value, it is a... | def get_details(self):
""" Overrides the method in Failure so as to add a few details about the wrapped function and outcome """
if isinstance(self.validation_outcome, Exception):
if isinstance(self.validation_outcome, Failure):
# do not say again what was the value, it is a... | [
"Overrides",
"the",
"method",
"in",
"Failure",
"so",
"as",
"to",
"add",
"a",
"few",
"details",
"about",
"the",
"wrapped",
"function",
"and",
"outcome"
] | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/base.py#L385-L404 | [
"def",
"get_details",
"(",
"self",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"validation_outcome",
",",
"Exception",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"validation_outcome",
",",
"Failure",
")",
":",
"# do not say again what was the value, it is... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | WrappingFailure.get_context_for_help_msgs | We override this method from HelpMsgMixIn to replace wrapped_func with its name | valid8/base.py | def get_context_for_help_msgs(self, context_dict):
""" We override this method from HelpMsgMixIn to replace wrapped_func with its name """
context_dict = copy(context_dict)
context_dict['wrapped_func'] = get_callable_name(context_dict['wrapped_func'])
return context_dict | def get_context_for_help_msgs(self, context_dict):
""" We override this method from HelpMsgMixIn to replace wrapped_func with its name """
context_dict = copy(context_dict)
context_dict['wrapped_func'] = get_callable_name(context_dict['wrapped_func'])
return context_dict | [
"We",
"override",
"this",
"method",
"from",
"HelpMsgMixIn",
"to",
"replace",
"wrapped_func",
"with",
"its",
"name"
] | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/base.py#L406-L410 | [
"def",
"get_context_for_help_msgs",
"(",
"self",
",",
"context_dict",
")",
":",
"context_dict",
"=",
"copy",
"(",
"context_dict",
")",
"context_dict",
"[",
"'wrapped_func'",
"]",
"=",
"get_callable_name",
"(",
"context_dict",
"[",
"'wrapped_func'",
"]",
")",
"retu... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | validate_field | A class decorator. It goes through all class variables and for all of those that are descriptors with a __set__,
it wraps the descriptors' setter function with a `validate_arg` annotation
:param field_name:
:param validation_func:
:param help_msg:
:param error_type:
:param none_policy:
:par... | valid8/entry_points_annotations.py | def validate_field(cls,
field_name,
*validation_func, # type: ValidationFuncs
**kwargs):
# type: (...) -> Callable
"""
A class decorator. It goes through all class variables and for all of those that are descriptors with a __set__,
it wraps the d... | def validate_field(cls,
field_name,
*validation_func, # type: ValidationFuncs
**kwargs):
# type: (...) -> Callable
"""
A class decorator. It goes through all class variables and for all of those that are descriptors with a __set__,
it wraps the d... | [
"A",
"class",
"decorator",
".",
"It",
"goes",
"through",
"all",
"class",
"variables",
"and",
"for",
"all",
"of",
"those",
"that",
"are",
"descriptors",
"with",
"a",
"__set__",
"it",
"wraps",
"the",
"descriptors",
"setter",
"function",
"with",
"a",
"validate_... | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_annotations.py#L352-L369 | [
"def",
"validate_field",
"(",
"cls",
",",
"field_name",
",",
"*",
"validation_func",
",",
"# type: ValidationFuncs",
"*",
"*",
"kwargs",
")",
":",
"# type: (...) -> Callable",
"return",
"decorate_cls_with_validation",
"(",
"cls",
",",
"field_name",
",",
"*",
"valida... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | validate_io | A function decorator to add input validation prior to the function execution. It should be called with named
arguments: for each function arg name, provide a single validation function or a list of validation functions to
apply. If validation fails, it will raise an InputValidationError with details about the f... | valid8/entry_points_annotations.py | def validate_io(f=DECORATED,
none_policy=None, # type: int
_out_=None, # type: ValidationFuncs
**kw_validation_funcs # type: ValidationFuncs
):
"""
A function decorator to add input validation prior to the function execution. It sh... | def validate_io(f=DECORATED,
none_policy=None, # type: int
_out_=None, # type: ValidationFuncs
**kw_validation_funcs # type: ValidationFuncs
):
"""
A function decorator to add input validation prior to the function execution. It sh... | [
"A",
"function",
"decorator",
"to",
"add",
"input",
"validation",
"prior",
"to",
"the",
"function",
"execution",
".",
"It",
"should",
"be",
"called",
"with",
"named",
"arguments",
":",
"for",
"each",
"function",
"arg",
"name",
"provide",
"a",
"single",
"vali... | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_annotations.py#L373-L424 | [
"def",
"validate_io",
"(",
"f",
"=",
"DECORATED",
",",
"none_policy",
"=",
"None",
",",
"# type: int",
"_out_",
"=",
"None",
",",
"# type: ValidationFuncs",
"*",
"*",
"kw_validation_funcs",
"# type: ValidationFuncs",
")",
":",
"return",
"decorate_several_with_validati... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | validate_arg | A decorator to apply function input validation for the given argument name, with the provided base validation
function(s). You may use several such decorators on a given function as long as they are stacked on top of each
other (no external decorator in the middle)
:param arg_name:
:param validation_fu... | valid8/entry_points_annotations.py | def validate_arg(f,
arg_name,
*validation_func, # type: ValidationFuncs
**kwargs
):
# type: (...) -> Callable
"""
A decorator to apply function input validation for the given argument name, with the provided base validation
function(s)... | def validate_arg(f,
arg_name,
*validation_func, # type: ValidationFuncs
**kwargs
):
# type: (...) -> Callable
"""
A decorator to apply function input validation for the given argument name, with the provided base validation
function(s)... | [
"A",
"decorator",
"to",
"apply",
"function",
"input",
"validation",
"for",
"the",
"given",
"argument",
"name",
"with",
"the",
"provided",
"base",
"validation",
"function",
"(",
"s",
")",
".",
"You",
"may",
"use",
"several",
"such",
"decorators",
"on",
"a",
... | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_annotations.py#L442-L469 | [
"def",
"validate_arg",
"(",
"f",
",",
"arg_name",
",",
"*",
"validation_func",
",",
"# type: ValidationFuncs",
"*",
"*",
"kwargs",
")",
":",
"# type: (...) -> Callable",
"return",
"decorate_with_validation",
"(",
"f",
",",
"arg_name",
",",
"*",
"validation_func",
... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | validate_out | A decorator to apply function output validation to this function's output, with the provided base validation
function(s). You may use several such decorators on a given function as long as they are stacked on top of each
other (no external decorator in the middle)
:param validation_func: the base validatio... | valid8/entry_points_annotations.py | def validate_out(*validation_func, # type: ValidationFuncs
**kwargs):
# type: (...) -> Callable
"""
A decorator to apply function output validation to this function's output, with the provided base validation
function(s). You may use several such decorators on a given function as long ... | def validate_out(*validation_func, # type: ValidationFuncs
**kwargs):
# type: (...) -> Callable
"""
A decorator to apply function output validation to this function's output, with the provided base validation
function(s). You may use several such decorators on a given function as long ... | [
"A",
"decorator",
"to",
"apply",
"function",
"output",
"validation",
"to",
"this",
"function",
"s",
"output",
"with",
"the",
"provided",
"base",
"validation",
"function",
"(",
"s",
")",
".",
"You",
"may",
"use",
"several",
"such",
"decorators",
"on",
"a",
... | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_annotations.py#L484-L504 | [
"def",
"validate_out",
"(",
"*",
"validation_func",
",",
"# type: ValidationFuncs",
"*",
"*",
"kwargs",
")",
":",
"# type: (...) -> Callable",
"def",
"decorate",
"(",
"f",
")",
":",
"return",
"decorate_with_validation",
"(",
"f",
",",
"_OUT_KEY",
",",
"*",
"vali... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | decorate_cls_with_validation | This method is equivalent to decorating a class with the `@validate_field` decorator but can be used a posteriori.
:param cls: the class to decorate
:param field_name: the name of the argument to validate or _OUT_KEY for output validation
:param validation_func: the validation function or
list of v... | valid8/entry_points_annotations.py | def decorate_cls_with_validation(cls,
field_name, # type: str
*validation_func, # type: ValidationFuncs
**kwargs):
# type: (...) -> Type[Any]
"""
This method is equivalent to decorating a class with th... | def decorate_cls_with_validation(cls,
field_name, # type: str
*validation_func, # type: ValidationFuncs
**kwargs):
# type: (...) -> Type[Any]
"""
This method is equivalent to decorating a class with th... | [
"This",
"method",
"is",
"equivalent",
"to",
"decorating",
"a",
"class",
"with",
"the",
"@validate_field",
"decorator",
"but",
"can",
"be",
"used",
"a",
"posteriori",
"."
] | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_annotations.py#L525-L663 | [
"def",
"decorate_cls_with_validation",
"(",
"cls",
",",
"field_name",
",",
"# type: str",
"*",
"validation_func",
",",
"# type: ValidationFuncs",
"*",
"*",
"kwargs",
")",
":",
"# type: (...) -> Type[Any]",
"error_type",
",",
"help_msg",
",",
"none_policy",
"=",
"pop_k... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | decorate_several_with_validation | This method is equivalent to applying `decorate_with_validation` once for each of the provided arguments of
the function `func` as well as output `_out_`. validation_funcs keyword arguments are validation functions for each
arg name.
Note that this method is less flexible than decorate_with_validation sinc... | valid8/entry_points_annotations.py | def decorate_several_with_validation(func,
_out_=None, # type: ValidationFuncs
none_policy=None, # type: int
**validation_funcs # type: ValidationFuncs
):
# ... | def decorate_several_with_validation(func,
_out_=None, # type: ValidationFuncs
none_policy=None, # type: int
**validation_funcs # type: ValidationFuncs
):
# ... | [
"This",
"method",
"is",
"equivalent",
"to",
"applying",
"decorate_with_validation",
"once",
"for",
"each",
"of",
"the",
"provided",
"arguments",
"of",
"the",
"function",
"func",
"as",
"well",
"as",
"output",
"_out_",
".",
"validation_funcs",
"keyword",
"arguments"... | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_annotations.py#L666-L696 | [
"def",
"decorate_several_with_validation",
"(",
"func",
",",
"_out_",
"=",
"None",
",",
"# type: ValidationFuncs",
"none_policy",
"=",
"None",
",",
"# type: int",
"*",
"*",
"validation_funcs",
"# type: ValidationFuncs",
")",
":",
"# type: (...) -> Callable",
"# add valida... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | decorate_with_validation | This method is the inner method used in `@validate_io`, `@validate_arg` and `@validate_out`.
It can be used if you with to perform decoration manually without a decorator.
:param func:
:param arg_name: the name of the argument to validate or _OUT_KEY for output validation
:param validation_func: the va... | valid8/entry_points_annotations.py | def decorate_with_validation(func,
arg_name, # type: str
*validation_func, # type: ValidationFuncs
**kwargs):
# type: (...) -> Callable
"""
This method is the inner method used in `@validate_io`, `@validate_arg`... | def decorate_with_validation(func,
arg_name, # type: str
*validation_func, # type: ValidationFuncs
**kwargs):
# type: (...) -> Callable
"""
This method is the inner method used in `@validate_io`, `@validate_arg`... | [
"This",
"method",
"is",
"the",
"inner",
"method",
"used",
"in",
"@validate_io",
"@validate_arg",
"and",
"@validate_out",
".",
"It",
"can",
"be",
"used",
"if",
"you",
"with",
"to",
"perform",
"decoration",
"manually",
"without",
"a",
"decorator",
"."
] | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_annotations.py#L714-L769 | [
"def",
"decorate_with_validation",
"(",
"func",
",",
"arg_name",
",",
"# type: str",
"*",
"validation_func",
",",
"# type: ValidationFuncs",
"*",
"*",
"kwargs",
")",
":",
"# type: (...) -> Callable",
"error_type",
",",
"help_msg",
",",
"none_policy",
",",
"_constructo... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | _get_final_none_policy_for_validator | Depending on none_policy and of the fact that the target parameter is nonable or not, returns a corresponding
NonePolicy
:param is_nonable:
:param none_policy:
:return: | valid8/entry_points_annotations.py | def _get_final_none_policy_for_validator(is_nonable, # type: bool
none_policy # type: NoneArgPolicy
):
"""
Depending on none_policy and of the fact that the target parameter is nonable or not, returns a corresponding
NoneP... | def _get_final_none_policy_for_validator(is_nonable, # type: bool
none_policy # type: NoneArgPolicy
):
"""
Depending on none_policy and of the fact that the target parameter is nonable or not, returns a corresponding
NoneP... | [
"Depending",
"on",
"none_policy",
"and",
"of",
"the",
"fact",
"that",
"the",
"target",
"parameter",
"is",
"nonable",
"or",
"not",
"returns",
"a",
"corresponding",
"NonePolicy"
] | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_annotations.py#L772-L794 | [
"def",
"_get_final_none_policy_for_validator",
"(",
"is_nonable",
",",
"# type: bool",
"none_policy",
"# type: NoneArgPolicy",
")",
":",
"if",
"none_policy",
"in",
"{",
"NonePolicy",
".",
"VALIDATE",
",",
"NonePolicy",
".",
"SKIP",
",",
"NonePolicy",
".",
"FAIL",
"}... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
train | decorate_with_validators | Utility method to decorate the provided function with the provided input and output Validator objects. Since this
method takes Validator objects as argument, it is for advanced users.
:param func: the function to decorate. It might already be decorated, this method will check it and wont create
another wra... | valid8/entry_points_annotations.py | def decorate_with_validators(func,
func_signature=None, # type: Signature
**validators # type: Validator
):
"""
Utility method to decorate the provided function with the provided input and output Validator objects. ... | def decorate_with_validators(func,
func_signature=None, # type: Signature
**validators # type: Validator
):
"""
Utility method to decorate the provided function with the provided input and output Validator objects. ... | [
"Utility",
"method",
"to",
"decorate",
"the",
"provided",
"function",
"with",
"the",
"provided",
"input",
"and",
"output",
"Validator",
"objects",
".",
"Since",
"this",
"method",
"takes",
"Validator",
"objects",
"as",
"argument",
"it",
"is",
"for",
"advanced",
... | smarie/python-valid8 | python | https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_annotations.py#L872-L942 | [
"def",
"decorate_with_validators",
"(",
"func",
",",
"func_signature",
"=",
"None",
",",
"# type: Signature",
"*",
"*",
"validators",
"# type: Validator",
")",
":",
"# first turn the dictionary values into lists only",
"for",
"arg_name",
",",
"validator",
"in",
"validator... | 5e15d1de11602933c5114eb9f73277ad91d97800 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.