repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
jmurty/xml4h
xml4h/nodes.py
Node.document
def document(self): """ :return: the :class:`Document` node that contains this node, or ``self`` if this node is the document. """ if self.is_document: return self return self.adapter.wrap_document(self.adapter.impl_document)
python
def document(self): """ :return: the :class:`Document` node that contains this node, or ``self`` if this node is the document. """ if self.is_document: return self return self.adapter.wrap_document(self.adapter.impl_document)
[ "def", "document", "(", "self", ")", ":", "if", "self", ".", "is_document", ":", "return", "self", "return", "self", ".", "adapter", ".", "wrap_document", "(", "self", ".", "adapter", ".", "impl_document", ")" ]
:return: the :class:`Document` node that contains this node, or ``self`` if this node is the document.
[ ":", "return", ":", "the", ":", "class", ":", "Document", "node", "that", "contains", "this", "node", "or", "self", "if", "this", "node", "is", "the", "document", "." ]
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L111-L118
train
jmurty/xml4h
xml4h/nodes.py
Node.root
def root(self): """ :return: the root :class:`Element` node of the document that contains this node, or ``self`` if this node is the root element. """ if self.is_root: return self return self.adapter.wrap_node( self.adapter.impl_root_element, s...
python
def root(self): """ :return: the root :class:`Element` node of the document that contains this node, or ``self`` if this node is the root element. """ if self.is_root: return self return self.adapter.wrap_node( self.adapter.impl_root_element, s...
[ "def", "root", "(", "self", ")", ":", "if", "self", ".", "is_root", ":", "return", "self", "return", "self", ".", "adapter", ".", "wrap_node", "(", "self", ".", "adapter", ".", "impl_root_element", ",", "self", ".", "adapter", ".", "impl_document", ",", ...
:return: the root :class:`Element` node of the document that contains this node, or ``self`` if this node is the root element.
[ ":", "return", ":", "the", "root", ":", "class", ":", "Element", "node", "of", "the", "document", "that", "contains", "this", "node", "or", "self", "if", "this", "node", "is", "the", "root", "element", "." ]
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L121-L130
train
jmurty/xml4h
xml4h/nodes.py
Node._convert_nodelist
def _convert_nodelist(self, impl_nodelist): """ Convert a list of underlying implementation nodes into a list of *xml4h* wrapper nodes. """ nodelist = [ self.adapter.wrap_node(n, self.adapter.impl_document, self.adapter) for n in impl_nodelist] ret...
python
def _convert_nodelist(self, impl_nodelist): """ Convert a list of underlying implementation nodes into a list of *xml4h* wrapper nodes. """ nodelist = [ self.adapter.wrap_node(n, self.adapter.impl_document, self.adapter) for n in impl_nodelist] ret...
[ "def", "_convert_nodelist", "(", "self", ",", "impl_nodelist", ")", ":", "nodelist", "=", "[", "self", ".", "adapter", ".", "wrap_node", "(", "n", ",", "self", ".", "adapter", ".", "impl_document", ",", "self", ".", "adapter", ")", "for", "n", "in", "i...
Convert a list of underlying implementation nodes into a list of *xml4h* wrapper nodes.
[ "Convert", "a", "list", "of", "underlying", "implementation", "nodes", "into", "a", "list", "of", "*", "xml4h", "*", "wrapper", "nodes", "." ]
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L235-L243
train
jmurty/xml4h
xml4h/nodes.py
Node.parent
def parent(self): """ :return: the parent of this node, or *None* of the node has no parent. """ parent_impl_node = self.adapter.get_node_parent(self.impl_node) return self.adapter.wrap_node( parent_impl_node, self.adapter.impl_document, self.adapter)
python
def parent(self): """ :return: the parent of this node, or *None* of the node has no parent. """ parent_impl_node = self.adapter.get_node_parent(self.impl_node) return self.adapter.wrap_node( parent_impl_node, self.adapter.impl_document, self.adapter)
[ "def", "parent", "(", "self", ")", ":", "parent_impl_node", "=", "self", ".", "adapter", ".", "get_node_parent", "(", "self", ".", "impl_node", ")", "return", "self", ".", "adapter", ".", "wrap_node", "(", "parent_impl_node", ",", "self", ".", "adapter", "...
:return: the parent of this node, or *None* of the node has no parent.
[ ":", "return", ":", "the", "parent", "of", "this", "node", "or", "*", "None", "*", "of", "the", "node", "has", "no", "parent", "." ]
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L246-L252
train
jmurty/xml4h
xml4h/nodes.py
Node.children
def children(self): """ :return: a :class:`NodeList` of this node's child nodes. """ impl_nodelist = self.adapter.get_node_children(self.impl_node) return self._convert_nodelist(impl_nodelist)
python
def children(self): """ :return: a :class:`NodeList` of this node's child nodes. """ impl_nodelist = self.adapter.get_node_children(self.impl_node) return self._convert_nodelist(impl_nodelist)
[ "def", "children", "(", "self", ")", ":", "impl_nodelist", "=", "self", ".", "adapter", ".", "get_node_children", "(", "self", ".", "impl_node", ")", "return", "self", ".", "_convert_nodelist", "(", "impl_nodelist", ")" ]
:return: a :class:`NodeList` of this node's child nodes.
[ ":", "return", ":", "a", ":", "class", ":", "NodeList", "of", "this", "node", "s", "child", "nodes", "." ]
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L268-L273
train
jmurty/xml4h
xml4h/nodes.py
Node.child
def child(self, local_name=None, name=None, ns_uri=None, node_type=None, filter_fn=None): """ :return: the first child node matching the given constraints, or \ *None* if there are no matching child nodes. Delegates to :meth:`NodeList.filter`. """ re...
python
def child(self, local_name=None, name=None, ns_uri=None, node_type=None, filter_fn=None): """ :return: the first child node matching the given constraints, or \ *None* if there are no matching child nodes. Delegates to :meth:`NodeList.filter`. """ re...
[ "def", "child", "(", "self", ",", "local_name", "=", "None", ",", "name", "=", "None", ",", "ns_uri", "=", "None", ",", "node_type", "=", "None", ",", "filter_fn", "=", "None", ")", ":", "return", "self", ".", "children", "(", "name", "=", "name", ...
:return: the first child node matching the given constraints, or \ *None* if there are no matching child nodes. Delegates to :meth:`NodeList.filter`.
[ ":", "return", ":", "the", "first", "child", "node", "matching", "the", "given", "constraints", "or", "\\", "*", "None", "*", "if", "there", "are", "no", "matching", "child", "nodes", "." ]
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L275-L284
train
jmurty/xml4h
xml4h/nodes.py
Node.siblings
def siblings(self): """ :return: a list of this node's sibling nodes. :rtype: NodeList """ impl_nodelist = self.adapter.get_node_children(self.parent.impl_node) return self._convert_nodelist( [n for n in impl_nodelist if n != self.impl_node])
python
def siblings(self): """ :return: a list of this node's sibling nodes. :rtype: NodeList """ impl_nodelist = self.adapter.get_node_children(self.parent.impl_node) return self._convert_nodelist( [n for n in impl_nodelist if n != self.impl_node])
[ "def", "siblings", "(", "self", ")", ":", "impl_nodelist", "=", "self", ".", "adapter", ".", "get_node_children", "(", "self", ".", "parent", ".", "impl_node", ")", "return", "self", ".", "_convert_nodelist", "(", "[", "n", "for", "n", "in", "impl_nodelist...
:return: a list of this node's sibling nodes. :rtype: NodeList
[ ":", "return", ":", "a", "list", "of", "this", "node", "s", "sibling", "nodes", ".", ":", "rtype", ":", "NodeList" ]
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L295-L302
train
jmurty/xml4h
xml4h/nodes.py
Node.siblings_before
def siblings_before(self): """ :return: a list of this node's siblings that occur *before* this node in the DOM. """ impl_nodelist = self.adapter.get_node_children(self.parent.impl_node) before_nodelist = [] for n in impl_nodelist: if n == self.imp...
python
def siblings_before(self): """ :return: a list of this node's siblings that occur *before* this node in the DOM. """ impl_nodelist = self.adapter.get_node_children(self.parent.impl_node) before_nodelist = [] for n in impl_nodelist: if n == self.imp...
[ "def", "siblings_before", "(", "self", ")", ":", "impl_nodelist", "=", "self", ".", "adapter", ".", "get_node_children", "(", "self", ".", "parent", ".", "impl_node", ")", "before_nodelist", "=", "[", "]", "for", "n", "in", "impl_nodelist", ":", "if", "n",...
:return: a list of this node's siblings that occur *before* this node in the DOM.
[ ":", "return", ":", "a", "list", "of", "this", "node", "s", "siblings", "that", "occur", "*", "before", "*", "this", "node", "in", "the", "DOM", "." ]
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L305-L316
train
jmurty/xml4h
xml4h/nodes.py
Node.siblings_after
def siblings_after(self): """ :return: a list of this node's siblings that occur *after* this node in the DOM. """ impl_nodelist = self.adapter.get_node_children(self.parent.impl_node) after_nodelist = [] is_after_myself = False for n in impl_nodelist:...
python
def siblings_after(self): """ :return: a list of this node's siblings that occur *after* this node in the DOM. """ impl_nodelist = self.adapter.get_node_children(self.parent.impl_node) after_nodelist = [] is_after_myself = False for n in impl_nodelist:...
[ "def", "siblings_after", "(", "self", ")", ":", "impl_nodelist", "=", "self", ".", "adapter", ".", "get_node_children", "(", "self", ".", "parent", ".", "impl_node", ")", "after_nodelist", "=", "[", "]", "is_after_myself", "=", "False", "for", "n", "in", "...
:return: a list of this node's siblings that occur *after* this node in the DOM.
[ ":", "return", ":", "a", "list", "of", "this", "node", "s", "siblings", "that", "occur", "*", "after", "*", "this", "node", "in", "the", "DOM", "." ]
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L319-L332
train
jmurty/xml4h
xml4h/nodes.py
Node.delete
def delete(self, destroy=True): """ Delete this node from the owning document. :param bool destroy: if True the child node will be destroyed in addition to being removed from the document. :returns: the removed child node, or *None* if the child was destroyed. """ ...
python
def delete(self, destroy=True): """ Delete this node from the owning document. :param bool destroy: if True the child node will be destroyed in addition to being removed from the document. :returns: the removed child node, or *None* if the child was destroyed. """ ...
[ "def", "delete", "(", "self", ",", "destroy", "=", "True", ")", ":", "removed_child", "=", "self", ".", "adapter", ".", "remove_node_child", "(", "self", ".", "adapter", ".", "get_node_parent", "(", "self", ".", "impl_node", ")", ",", "self", ".", "impl_...
Delete this node from the owning document. :param bool destroy: if True the child node will be destroyed in addition to being removed from the document. :returns: the removed child node, or *None* if the child was destroyed.
[ "Delete", "this", "node", "from", "the", "owning", "document", "." ]
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L344-L359
train
jmurty/xml4h
xml4h/nodes.py
Node.clone_node
def clone_node(self, node): """ Clone a node from another document to become a child of this node, by copying the node's data into this document but leaving the node untouched in the source document. The node to be cloned can be a :class:`Node` based on the same underlying XML li...
python
def clone_node(self, node): """ Clone a node from another document to become a child of this node, by copying the node's data into this document but leaving the node untouched in the source document. The node to be cloned can be a :class:`Node` based on the same underlying XML li...
[ "def", "clone_node", "(", "self", ",", "node", ")", ":", "if", "isinstance", "(", "node", ",", "xml4h", ".", "nodes", ".", "Node", ")", ":", "child_impl_node", "=", "node", ".", "impl_node", "else", ":", "child_impl_node", "=", "node", "# Assume it's a val...
Clone a node from another document to become a child of this node, by copying the node's data into this document but leaving the node untouched in the source document. The node to be cloned can be a :class:`Node` based on the same underlying XML library implementation and adapter, or a "...
[ "Clone", "a", "node", "from", "another", "document", "to", "become", "a", "child", "of", "this", "node", "by", "copying", "the", "node", "s", "data", "into", "this", "document", "but", "leaving", "the", "node", "untouched", "in", "the", "source", "document...
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L361-L376
train
jmurty/xml4h
xml4h/nodes.py
Node.transplant_node
def transplant_node(self, node): """ Transplant a node from another document to become a child of this node, removing it from the source document. The node to be transplanted can be a :class:`Node` based on the same underlying XML library implementation and adapter, or a "raw" n...
python
def transplant_node(self, node): """ Transplant a node from another document to become a child of this node, removing it from the source document. The node to be transplanted can be a :class:`Node` based on the same underlying XML library implementation and adapter, or a "raw" n...
[ "def", "transplant_node", "(", "self", ",", "node", ")", ":", "if", "isinstance", "(", "node", ",", "xml4h", ".", "nodes", ".", "Node", ")", ":", "child_impl_node", "=", "node", ".", "impl_node", "original_parent_impl_node", "=", "node", ".", "parent", "."...
Transplant a node from another document to become a child of this node, removing it from the source document. The node to be transplanted can be a :class:`Node` based on the same underlying XML library implementation and adapter, or a "raw" node from that implementation. :param node: t...
[ "Transplant", "a", "node", "from", "another", "document", "to", "become", "a", "child", "of", "this", "node", "removing", "it", "from", "the", "source", "document", ".", "The", "node", "to", "be", "transplanted", "can", "be", "a", ":", "class", ":", "Nod...
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L378-L395
train
jmurty/xml4h
xml4h/nodes.py
Node.find
def find(self, name=None, ns_uri=None, first_only=False): """ Find :class:`Element` node descendants of this node, with optional constraints to limit the results. :param name: limit results to elements with this name. If *None* or ``'*'`` all element names are matched. ...
python
def find(self, name=None, ns_uri=None, first_only=False): """ Find :class:`Element` node descendants of this node, with optional constraints to limit the results. :param name: limit results to elements with this name. If *None* or ``'*'`` all element names are matched. ...
[ "def", "find", "(", "self", ",", "name", "=", "None", ",", "ns_uri", "=", "None", ",", "first_only", "=", "False", ")", ":", "if", "name", "is", "None", ":", "name", "=", "'*'", "# Match all element names", "if", "ns_uri", "is", "None", ":", "ns_uri", ...
Find :class:`Element` node descendants of this node, with optional constraints to limit the results. :param name: limit results to elements with this name. If *None* or ``'*'`` all element names are matched. :type name: string or None :param ns_uri: limit results to elements...
[ "Find", ":", "class", ":", "Element", "node", "descendants", "of", "this", "node", "with", "optional", "constraints", "to", "limit", "the", "results", "." ]
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L397-L426
train
jmurty/xml4h
xml4h/nodes.py
Node.find_first
def find_first(self, name=None, ns_uri=None): """ Find the first :class:`Element` node descendant of this node that matches any optional constraints, or None if there are no matching elements. Delegates to :meth:`find` with ``first_only=True``. """ return self.fi...
python
def find_first(self, name=None, ns_uri=None): """ Find the first :class:`Element` node descendant of this node that matches any optional constraints, or None if there are no matching elements. Delegates to :meth:`find` with ``first_only=True``. """ return self.fi...
[ "def", "find_first", "(", "self", ",", "name", "=", "None", ",", "ns_uri", "=", "None", ")", ":", "return", "self", ".", "find", "(", "name", "=", "name", ",", "ns_uri", "=", "ns_uri", ",", "first_only", "=", "True", ")" ]
Find the first :class:`Element` node descendant of this node that matches any optional constraints, or None if there are no matching elements. Delegates to :meth:`find` with ``first_only=True``.
[ "Find", "the", "first", ":", "class", ":", "Element", "node", "descendant", "of", "this", "node", "that", "matches", "any", "optional", "constraints", "or", "None", "if", "there", "are", "no", "matching", "elements", "." ]
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L428-L436
train
jmurty/xml4h
xml4h/nodes.py
Node.find_doc
def find_doc(self, name=None, ns_uri=None, first_only=False): """ Find :class:`Element` node descendants of the document containing this node, with optional constraints to limit the results. Delegates to :meth:`find` applied to this node's owning document. """ return sel...
python
def find_doc(self, name=None, ns_uri=None, first_only=False): """ Find :class:`Element` node descendants of the document containing this node, with optional constraints to limit the results. Delegates to :meth:`find` applied to this node's owning document. """ return sel...
[ "def", "find_doc", "(", "self", ",", "name", "=", "None", ",", "ns_uri", "=", "None", ",", "first_only", "=", "False", ")", ":", "return", "self", ".", "document", ".", "find", "(", "name", "=", "name", ",", "ns_uri", "=", "ns_uri", ",", "first_only"...
Find :class:`Element` node descendants of the document containing this node, with optional constraints to limit the results. Delegates to :meth:`find` applied to this node's owning document.
[ "Find", ":", "class", ":", "Element", "node", "descendants", "of", "the", "document", "containing", "this", "node", "with", "optional", "constraints", "to", "limit", "the", "results", "." ]
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L438-L446
train
jmurty/xml4h
xml4h/nodes.py
Node.write
def write(self, writer=None, encoding='utf-8', indent=0, newline='', omit_declaration=False, node_depth=0, quote_char='"'): """ Serialize this node and its descendants to text, writing the output to a given *writer* or to stdout. :param writer: an object such as a file or st...
python
def write(self, writer=None, encoding='utf-8', indent=0, newline='', omit_declaration=False, node_depth=0, quote_char='"'): """ Serialize this node and its descendants to text, writing the output to a given *writer* or to stdout. :param writer: an object such as a file or st...
[ "def", "write", "(", "self", ",", "writer", "=", "None", ",", "encoding", "=", "'utf-8'", ",", "indent", "=", "0", ",", "newline", "=", "''", ",", "omit_declaration", "=", "False", ",", "node_depth", "=", "0", ",", "quote_char", "=", "'\"'", ")", ":"...
Serialize this node and its descendants to text, writing the output to a given *writer* or to stdout. :param writer: an object such as a file or stream to which XML text is sent. If *None* text is sent to :attr:`sys.stdout`. :type writer: a file, stream, etc or None :param s...
[ "Serialize", "this", "node", "and", "its", "descendants", "to", "text", "writing", "the", "output", "to", "a", "given", "*", "writer", "*", "or", "to", "stdout", "." ]
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L450-L492
train
jmurty/xml4h
xml4h/nodes.py
Node.xml
def xml(self, indent=4, **kwargs): """ :return: this node as XML text. Delegates to :meth:`write` """ writer = StringIO() self.write(writer, indent=indent, **kwargs) return writer.getvalue()
python
def xml(self, indent=4, **kwargs): """ :return: this node as XML text. Delegates to :meth:`write` """ writer = StringIO() self.write(writer, indent=indent, **kwargs) return writer.getvalue()
[ "def", "xml", "(", "self", ",", "indent", "=", "4", ",", "*", "*", "kwargs", ")", ":", "writer", "=", "StringIO", "(", ")", "self", ".", "write", "(", "writer", ",", "indent", "=", "indent", ",", "*", "*", "kwargs", ")", "return", "writer", ".", ...
:return: this node as XML text. Delegates to :meth:`write`
[ ":", "return", ":", "this", "node", "as", "XML", "text", "." ]
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L503-L511
train
jmurty/xml4h
xml4h/nodes.py
XPathMixin.xpath
def xpath(self, xpath, **kwargs): """ Perform an XPath query on the current node. :param string xpath: XPath query. :param dict kwargs: Optional keyword arguments that are passed through to the underlying XML library implementation. :return: results of the query as ...
python
def xpath(self, xpath, **kwargs): """ Perform an XPath query on the current node. :param string xpath: XPath query. :param dict kwargs: Optional keyword arguments that are passed through to the underlying XML library implementation. :return: results of the query as ...
[ "def", "xpath", "(", "self", ",", "xpath", ",", "*", "*", "kwargs", ")", ":", "result", "=", "self", ".", "adapter", ".", "xpath_on_node", "(", "self", ".", "impl_node", ",", "xpath", ",", "*", "*", "kwargs", ")", "if", "isinstance", "(", "result", ...
Perform an XPath query on the current node. :param string xpath: XPath query. :param dict kwargs: Optional keyword arguments that are passed through to the underlying XML library implementation. :return: results of the query as a list of :class:`Node` objects, or a list...
[ "Perform", "an", "XPath", "query", "on", "the", "current", "node", "." ]
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L595-L611
train
jmurty/xml4h
xml4h/nodes.py
Element.set_attributes
def set_attributes(self, attr_obj=None, ns_uri=None, **attr_dict): """ Add or update this element's attributes, where attributes can be specified in a number of ways. :param attr_obj: a dictionary or list of attribute name/value pairs. :type attr_obj: dict, list, tuple, or None ...
python
def set_attributes(self, attr_obj=None, ns_uri=None, **attr_dict): """ Add or update this element's attributes, where attributes can be specified in a number of ways. :param attr_obj: a dictionary or list of attribute name/value pairs. :type attr_obj: dict, list, tuple, or None ...
[ "def", "set_attributes", "(", "self", ",", "attr_obj", "=", "None", ",", "ns_uri", "=", "None", ",", "*", "*", "attr_dict", ")", ":", "self", ".", "_set_element_attributes", "(", "self", ".", "impl_node", ",", "attr_obj", "=", "attr_obj", ",", "ns_uri", ...
Add or update this element's attributes, where attributes can be specified in a number of ways. :param attr_obj: a dictionary or list of attribute name/value pairs. :type attr_obj: dict, list, tuple, or None :param ns_uri: a URI defining a namespace for the new attributes. :type...
[ "Add", "or", "update", "this", "element", "s", "attributes", "where", "attributes", "can", "be", "specified", "in", "a", "number", "of", "ways", "." ]
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L841-L854
train
jmurty/xml4h
xml4h/nodes.py
Element.attributes
def attributes(self): """ Get or set this element's attributes as name/value pairs. .. note:: Setting element attributes via this accessor will **remove** any existing attributes, as opposed to the :meth:`set_attributes` method which only updates and replaces...
python
def attributes(self): """ Get or set this element's attributes as name/value pairs. .. note:: Setting element attributes via this accessor will **remove** any existing attributes, as opposed to the :meth:`set_attributes` method which only updates and replaces...
[ "def", "attributes", "(", "self", ")", ":", "attr_impl_nodes", "=", "self", ".", "adapter", ".", "get_node_attributes", "(", "self", ".", "impl_node", ")", "return", "AttributeDict", "(", "attr_impl_nodes", ",", "self", ".", "impl_node", ",", "self", ".", "a...
Get or set this element's attributes as name/value pairs. .. note:: Setting element attributes via this accessor will **remove** any existing attributes, as opposed to the :meth:`set_attributes` method which only updates and replaces them.
[ "Get", "or", "set", "this", "element", "s", "attributes", "as", "name", "/", "value", "pairs", "." ]
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L857-L867
train
jmurty/xml4h
xml4h/nodes.py
Element.attribute_nodes
def attribute_nodes(self): """ :return: a list of this element's attributes as :class:`Attribute` nodes. """ impl_attr_nodes = self.adapter.get_node_attributes(self.impl_node) wrapped_attr_nodes = [ self.adapter.wrap_node(a, self.adapter.impl_document, sel...
python
def attribute_nodes(self): """ :return: a list of this element's attributes as :class:`Attribute` nodes. """ impl_attr_nodes = self.adapter.get_node_attributes(self.impl_node) wrapped_attr_nodes = [ self.adapter.wrap_node(a, self.adapter.impl_document, sel...
[ "def", "attribute_nodes", "(", "self", ")", ":", "impl_attr_nodes", "=", "self", ".", "adapter", ".", "get_node_attributes", "(", "self", ".", "impl_node", ")", "wrapped_attr_nodes", "=", "[", "self", ".", "adapter", ".", "wrap_node", "(", "a", ",", "self", ...
:return: a list of this element's attributes as :class:`Attribute` nodes.
[ ":", "return", ":", "a", "list", "of", "this", "element", "s", "attributes", "as", ":", "class", ":", "Attribute", "nodes", "." ]
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L891-L900
train
jmurty/xml4h
xml4h/nodes.py
Element.attribute_node
def attribute_node(self, name, ns_uri=None): """ :param string name: the name of the attribute to return. :param ns_uri: a URI defining a namespace constraint on the attribute. :type ns_uri: string or None :return: this element's attributes that match ``ns_uri`` as :...
python
def attribute_node(self, name, ns_uri=None): """ :param string name: the name of the attribute to return. :param ns_uri: a URI defining a namespace constraint on the attribute. :type ns_uri: string or None :return: this element's attributes that match ``ns_uri`` as :...
[ "def", "attribute_node", "(", "self", ",", "name", ",", "ns_uri", "=", "None", ")", ":", "attr_impl_node", "=", "self", ".", "adapter", ".", "get_node_attribute_node", "(", "self", ".", "impl_node", ",", "name", ",", "ns_uri", ")", "return", "self", ".", ...
:param string name: the name of the attribute to return. :param ns_uri: a URI defining a namespace constraint on the attribute. :type ns_uri: string or None :return: this element's attributes that match ``ns_uri`` as :class:`Attribute` nodes.
[ ":", "param", "string", "name", ":", "the", "name", "of", "the", "attribute", "to", "return", ".", ":", "param", "ns_uri", ":", "a", "URI", "defining", "a", "namespace", "constraint", "on", "the", "attribute", ".", ":", "type", "ns_uri", ":", "string", ...
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L902-L914
train
jmurty/xml4h
xml4h/nodes.py
Element.set_ns_prefix
def set_ns_prefix(self, prefix, ns_uri): """ Define a namespace prefix that will serve as shorthand for the given namespace URI in element names. :param string prefix: prefix that will serve as an alias for a the namespace URI. :param string ns_uri: namespace URI tha...
python
def set_ns_prefix(self, prefix, ns_uri): """ Define a namespace prefix that will serve as shorthand for the given namespace URI in element names. :param string prefix: prefix that will serve as an alias for a the namespace URI. :param string ns_uri: namespace URI tha...
[ "def", "set_ns_prefix", "(", "self", ",", "prefix", ",", "ns_uri", ")", ":", "self", ".", "_add_ns_prefix_attr", "(", "self", ".", "impl_node", ",", "prefix", ",", "ns_uri", ")" ]
Define a namespace prefix that will serve as shorthand for the given namespace URI in element names. :param string prefix: prefix that will serve as an alias for a the namespace URI. :param string ns_uri: namespace URI that will be denoted by the prefix.
[ "Define", "a", "namespace", "prefix", "that", "will", "serve", "as", "shorthand", "for", "the", "given", "namespace", "URI", "in", "element", "names", "." ]
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L925-L935
train
jmurty/xml4h
xml4h/nodes.py
Element.add_element
def add_element(self, name, ns_uri=None, attributes=None, text=None, before_this_element=False): """ Add a new child element to this element, with an optional namespace definition. If no namespace is provided the child will be assigned to the default namespace. :para...
python
def add_element(self, name, ns_uri=None, attributes=None, text=None, before_this_element=False): """ Add a new child element to this element, with an optional namespace definition. If no namespace is provided the child will be assigned to the default namespace. :para...
[ "def", "add_element", "(", "self", ",", "name", ",", "ns_uri", "=", "None", ",", "attributes", "=", "None", ",", "text", "=", "None", ",", "before_this_element", "=", "False", ")", ":", "# Determine local name, namespace and prefix info from tag name", "prefix", "...
Add a new child element to this element, with an optional namespace definition. If no namespace is provided the child will be assigned to the default namespace. :param string name: a name for the child node. The name may be used to apply a namespace to the child by including: ...
[ "Add", "a", "new", "child", "element", "to", "this", "element", "with", "an", "optional", "namespace", "definition", ".", "If", "no", "namespace", "is", "provided", "the", "child", "will", "be", "assigned", "to", "the", "default", "namespace", "." ]
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L937-L1008
train
jmurty/xml4h
xml4h/nodes.py
Element.add_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 ...
python
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", ")", ":", "if", "not", "isinstance", "(", "text", ",", "basestring", ")", ":", "text", "=", "unicode", "(", "text", ")", "self", ".", "_add_text", "(", "self", ".", "impl_node", ",", "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...
[ "Add", "a", "text", "node", "to", "this", "element", "." ]
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L1014-L1027
train
jmurty/xml4h
xml4h/nodes.py
Element.add_instruction
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)
python
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", ")", ":", "self", ".", "_add_instruction", "(", "self", ".", "impl_node", ",", "target", ",", "data", ")" ]
Add an instruction node to this element. :param string text: text content to add as an instruction.
[ "Add", "an", "instruction", "node", "to", "this", "element", "." ]
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L1045-L1051
train
jmurty/xml4h
xml4h/nodes.py
AttributeDict.items
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]
python
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", ")", ":", "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.
[ ":", "return", ":", "a", "list", "of", "name", "/", "value", "attribute", "pairs", "sorted", "by", "attribute", "name", "." ]
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L1135-L1140
train
jmurty/xml4h
xml4h/nodes.py
AttributeDict.namespace_uri
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: ...
python
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", ")", ":", "a_node", "=", "self", ".", "adapter", ".", "get_node_attribute_node", "(", "self", ".", "impl_element", ",", "name", ")", "if", "a_node", "is", "None", ":", "return", "None", "return", "self", ...
:param string name: the name of an attribute to look up. :return: the namespace URI associated with the named attribute, or None.
[ ":", "param", "string", "name", ":", "the", "name", "of", "an", "attribute", "to", "look", "up", "." ]
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L1142-L1152
train
jmurty/xml4h
xml4h/nodes.py
AttributeDict.prefix
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: ...
python
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", ")", ":", "a_node", "=", "self", ".", "adapter", ".", "get_node_attribute_node", "(", "self", ".", "impl_element", ",", "name", ")", "if", "a_node", "is", "None", ":", "return", "None", "return", "a_node", ".", ...
:param string name: the name of an attribute to look up. :return: the prefix component of the named attribute's name, or None.
[ ":", "param", "string", "name", ":", "the", "name", "of", "an", "attribute", "to", "look", "up", "." ]
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L1154-L1164
train
jmurty/xml4h
xml4h/nodes.py
AttributeDict.element
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)
python
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", "self", ".", "adapter", ".", "wrap_node", "(", "self", ".", "impl_element", ",", "self", ".", "adapter", ".", "impl_document", ",", "self", ".", "adapter", ")" ]
:return: the :class:`Element` that contains these attributes.
[ ":", "return", ":", "the", ":", "class", ":", "Element", "that", "contains", "these", "attributes", "." ]
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L1175-L1180
train
jmurty/xml4h
xml4h/nodes.py
NodeList.filter
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 ...
python
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", ")", ":", "# Build our own filter function un...
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. ...
[ "Apply", "filters", "to", "the", "set", "of", "nodes", "in", "this", "list", "." ]
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L1197-L1255
train
redhat-cip/dci-control-server
dci/api/v1/analytics.py
get_all_analytics
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 ...
python
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", ")", ":", "args", "=", "schemas", ".", "args", "(", "flask", ".", "request", ".", "args", ".", "to_dict", "(", ")", ")", "v1_utils", ".", "verify_existence_and_get", "(", "job_id", ",", "models", "....
Get all analytics of a job.
[ "Get", "all", "analytics", "of", "a", "job", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/analytics.py#L53-L70
train
redhat-cip/dci-control-server
dci/api/v1/analytics.py
get_analytic
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...
python
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", ")", ":", "v1_utils", ".", "verify_existence_and_get", "(", "job_id", ",", "models", ".", "JOBS", ")", "analytic", "=", "v1_utils", ".", "verify_existence_and_get", "(", "anc_id", ",", "_TABLE",...
Get an analytic.
[ "Get", "an", "analytic", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/analytics.py#L75-L83
train
jmurty/xml4h
xml4h/writer.py
write_node
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...
python
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 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...
[ "Serialize", "an", "*", "xml4h", "*", "DOM", "node", "and", "its", "descendants", "to", "text", "writing", "the", "output", "to", "a", "given", "*", "writer", "*", "or", "to", "stdout", "." ]
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/writer.py#L12-L182
train
Antidote1911/cryptoshop
cryptoshop/_chunk_engine.py
encry_decry_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: ...
python
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", ")", ":", "engine", "=", "botan", ".", "cipher", "(", "algo", "=", "algo", ",", "encrypt", "=", "bool_encry", ")", "engine", ".", "set_key", "(", "...
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...
[ "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...
0b7ff4a6848f2733f4737606957e8042a4d6ca0b
https://github.com/Antidote1911/cryptoshop/blob/0b7ff4a6848f2733f4737606957e8042a4d6ca0b/cryptoshop/_chunk_engine.py#L39-L64
train
redhat-cip/dci-control-server
dci/trackers/bugzilla.py
Bugzilla.retrieve_info
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('&'): ...
python
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", ")", ":", "scheme", "=", "urlparse", "(", "self", ".", "url", ")", ".", "scheme", "netloc", "=", "urlparse", "(", "self", ".", "url", ")", ".", "netloc", "query", "=", "urlparse", "(", "self", ".", "url", ")", "...
Query Bugzilla API to retrieve the needed infos.
[ "Query", "Bugzilla", "API", "to", "retrieve", "the", "needed", "infos", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/trackers/bugzilla.py#L32-L74
train
smarie/python-valid8
valid8/validation_lib/collections.py
minlen
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...
python
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", ")", ":", "if", "strict", ":", "def", "minlen_", "(", "x", ")", ":", "if", "len", "(", "x", ")", ">", "min_length", ":", "return", "True", "else", ":", "# raise Failure('m...
'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...
[ "Minimum", "length", "validation_function", "generator", ".", "Returns", "a", "validation_function", "to", "check", "that", "len", "(", "x", ")", ">", "=", "min_length", "(", "strict", "=", "False", "default", ")", "or", "len", "(", "x", ")", ">", "min_len...
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/collections.py#L18-L47
train
smarie/python-valid8
valid8/validation_lib/collections.py
maxlen
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...
python
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", ")", ":", "if", "strict", ":", "def", "maxlen_", "(", "x", ")", ":", "if", "len", "(", "x", ")", "<", "max_length", ":", "return", "True", "else", ":", "# raise Failure('m...
'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) ...
[ "Maximum", "length", "validation_function", "generator", ".", "Returns", "a", "validation_function", "to", "check", "that", "len", "(", "x", ")", "<", "=", "max_length", "(", "strict", "=", "False", "default", ")", "or", "len", "(", "x", ")", "<", "max_len...
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/collections.py#L63-L91
train
smarie/python-valid8
valid8/validation_lib/collections.py
has_length
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...
python
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", ")", ":", "def", "has_length_", "(", "x", ")", ":", "if", "len", "(", "x", ")", "==", "ref_length", ":", "return", "True", "else", ":", "raise", "WrongLength", "(", "wrong_value", "=", "x", ",", "ref_length", "="...
'length equals' validation function generator. Returns a validation_function to check that `len(x) == ref_length` :param ref_length: :return:
[ "length", "equals", "validation", "function", "generator", ".", "Returns", "a", "validation_function", "to", "check", "that", "len", "(", "x", ")", "==", "ref_length" ]
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/collections.py#L106-L121
train
smarie/python-valid8
valid8/validation_lib/collections.py
length_between
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 (...
python
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", ")", ":", "if", "open_left", "and", "open_right", ":", "def", "length_between_", "(", "x", ")", ":", "if...
'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...
[ "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...
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/collections.py#L134-L189
train
smarie/python-valid8
valid8/validation_lib/collections.py
is_in
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...
python
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", ")", ":", "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(...
'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:
[ "Values", "in", "validation_function", "generator", ".", "Returns", "a", "validation_function", "to", "check", "that", "x", "is", "in", "the", "provided", "set", "of", "allowed", "values" ]
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/collections.py#L200-L217
train
smarie/python-valid8
valid8/validation_lib/collections.py
is_subset
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 ...
python
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", ")", ":", "def", "is_subset_of", "(", "x", ")", ":", "missing", "=", "x", "-", "reference_set", "if", "len", "(", "missing", ")", "==", "0", ":", "return", "True", "else", ":", "# raise Failure('is_s...
'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:
[ "Is", "subset", "validation_function", "generator", ".", "Returns", "a", "validation_function", "to", "check", "that", "x", "is", "a", "subset", "of", "reference_set" ]
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/collections.py#L228-L248
train
smarie/python-valid8
valid8/validation_lib/collections.py
contains
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: ...
python
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", ")", ":", "def", "contains_ref_value", "(", "x", ")", ":", "if", "ref_value", "in", "x", ":", "return", "True", "else", ":", "raise", "DoesNotContainValue", "(", "wrong_value", "=", "x", ",", "ref_value", "=", "ref_valu...
'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:
[ "Contains", "validation_function", "generator", ".", "Returns", "a", "validation_function", "to", "check", "that", "ref_value", "in", "x" ]
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/collections.py#L259-L274
train
smarie/python-valid8
valid8/validation_lib/collections.py
is_superset
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...
python
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", ")", ":", "def", "is_superset_of", "(", "x", ")", ":", "missing", "=", "reference_set", "-", "x", "if", "len", "(", "missing", ")", "==", "0", ":", "return", "True", "else", ":", "# raise Failure('...
'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:
[ "Is", "superset", "validation_function", "generator", ".", "Returns", "a", "validation_function", "to", "check", "that", "x", "is", "a", "superset", "of", "reference_set" ]
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/collections.py#L285-L305
train
smarie/python-valid8
valid8/validation_lib/collections.py
on_all_
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...
python
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", ")", ":", "# create the validation functions", "validation_function_func", "=", "_process_validation_function_s", "(", "list", "(", "validation_func", ")", ")", "def", "on_all_val", "(", "x", ")", ":", "# validate all eleme...
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...
[ "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...
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/collections.py#L314-L349
train
smarie/python-valid8
valid8/validation_lib/collections.py
on_each_
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...
python
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", ")", ":", "# create a tuple of validation functions.", "validation_function_funcs", "=", "tuple", "(", "_process_validation_function_s", "(", "validation_func", ")", "for", "validation_func", "in", "validation_func...
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...
[ "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"...
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/collections.py#L353-L404
train
redhat-cip/dci-control-server
dci/api/v1/jobs_events.py
get_jobs_events_from_sequence
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...
python
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", ")", ":", "args", "=", "schemas", ".", "args", "(", "flask", ".", "request", ".", "args", ".", "to_dict", "(", ")", ")", "if", "user", ".", "is_not_super_admin", "(", ")", ":", "raise"...
Get all the jobs events from a given sequence number.
[ "Get", "all", "the", "jobs", "events", "from", "a", "given", "sequence", "number", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/jobs_events.py#L37-L63
train
mediawiki-utilities/python-mwxml
mwxml/iteration/dump.py
Dump.from_file
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...
python
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", ")", ":", "element", "=", "ElementIterator", ".", "from_file", "(", "f", ")", "assert", "element", ".", "tag", "==", "\"mediawiki\"", "return", "cls", ".", "from_element", "(", "element", ")" ]
Constructs a :class:`~mwxml.iteration.dump.Dump` from a `file` pointer. :Parameters: f : `file` A plain text file pointer containing XML to process
[ "Constructs", "a", ":", "class", ":", "~mwxml", ".", "iteration", ".", "dump", ".", "Dump", "from", "a", "file", "pointer", "." ]
6a8c18be99cd0bcee9c496e607f08bf4dfe5b510
https://github.com/mediawiki-utilities/python-mwxml/blob/6a8c18be99cd0bcee9c496e607f08bf4dfe5b510/mwxml/iteration/dump.py#L136-L146
train
mediawiki-utilities/python-mwxml
mwxml/iteration/dump.py
Dump.from_page_xml
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 = """ ...
python
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", ")", ":", "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...
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
[ "Constructs", "a", ":", "class", ":", "~mwxml", ".", "iteration", ".", "dump", ".", "Dump", "from", "a", "<page", ">", "block", "." ]
6a8c18be99cd0bcee9c496e607f08bf4dfe5b510
https://github.com/mediawiki-utilities/python-mwxml/blob/6a8c18be99cd0bcee9c496e607f08bf4dfe5b510/mwxml/iteration/dump.py#L149-L170
train
Antidote1911/cryptoshop
cryptoshop/_derivation_engine.py
calc_derivation
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...
python
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", ")", ":", "argonhash", "=", "argon2", ".", "low_level", ".", "hash_secret_raw", "(", "(", "str", ".", "encode", "(", "passphrase", ")", ")", ",", "salt", "=", "salt", ",", "hash_len", "=", "32", ...
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.
[ "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...
0b7ff4a6848f2733f4737606957e8042a4d6ca0b
https://github.com/Antidote1911/cryptoshop/blob/0b7ff4a6848f2733f4737606957e8042a4d6ca0b/cryptoshop/_derivation_engine.py#L29-L39
train
jmurty/xml4h
xml4h/impls/xml_dom_minidom.py
XmlDomImplAdapter.get_node_text
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''...
python
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", ")", ":", "text_children", "=", "[", "n", ".", "nodeValue", "for", "n", "in", "self", ".", "get_node_children", "(", "node", ")", "if", "n", ".", "nodeType", "==", "xml", ".", "dom", ".", "Node", ".",...
Return contatenated value of all text node children of this element
[ "Return", "contatenated", "value", "of", "all", "text", "node", "children", "of", "this", "element" ]
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/impls/xml_dom_minidom.py#L119-L128
train
jmurty/xml4h
xml4h/impls/xml_dom_minidom.py
XmlDomImplAdapter.set_node_text
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:...
python
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", ")", ":", "# Remove any existing Text node children", "for", "child", "in", "self", ".", "get_node_children", "(", "node", ")", ":", "if", "child", ".", "nodeType", "==", "xml", ".", "dom", ".", ...
Set text value as sole Text child node of element; any existing Text nodes are removed
[ "Set", "text", "value", "as", "sole", "Text", "child", "node", "of", "element", ";", "any", "existing", "Text", "nodes", "are", "removed" ]
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/impls/xml_dom_minidom.py#L130-L141
train
inveniosoftware/invenio-assets
invenio_assets/glob.py
GlobBundle._get_contents
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())
python
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", ")", ":", "def", "files", "(", ")", ":", "for", "value", "in", "super", "(", "GlobBundle", ",", "self", ")", ".", "_get_contents", "(", ")", ":", "for", "path", "in", "glob", ".", "glob", "(", "value", ")", ":",...
Create strings from glob strings.
[ "Create", "strings", "from", "glob", "strings", "." ]
836cc75ebe0c179f0d72456bd8b784cdc18394a6
https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/glob.py#L31-L37
train
smarie/python-valid8
valid8/_typing_inspect.py
is_generic_type
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...
python
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", ")", ":", "if", "NEW_TYPING", ":", "return", "(", "isinstance", "(", "tp", ",", "type", ")", "and", "issubclass", "(", "tp", ",", "Generic", ")", "or", "isinstance", "(", "tp", ",", "_GenericAlias", ")", "and", "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(Union[int, T]) == False is_...
[ "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", "::" ]
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/_typing_inspect.py#L39-L62
train
smarie/python-valid8
valid8/_typing_inspect.py
is_union_type
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...
python
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", ")", ":", "if", "NEW_TYPING", ":", "return", "(", "tp", "is", "Union", "or", "isinstance", "(", "tp", ",", "_GenericAlias", ")", "and", "tp", ".", "__origin__", "is", "Union", ")", "try", ":", "from", "typing", "impor...
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
[ "Test", "if", "the", "type", "is", "a", "union", "type", ".", "Examples", "::" ]
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/_typing_inspect.py#L136-L152
train
smarie/python-valid8
valid8/_typing_inspect.py
is_classvar
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 ...
python
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", ")", ":", "if", "NEW_TYPING", ":", "return", "(", "tp", "is", "ClassVar", "or", "isinstance", "(", "tp", ",", "_GenericAlias", ")", "and", "tp", ".", "__origin__", "is", "ClassVar", ")", "try", ":", "from", "typing", "i...
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
[ "Test", "if", "the", "type", "represents", "a", "class", "variable", ".", "Examples", "::" ]
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/_typing_inspect.py#L166-L182
train
jmurty/xml4h
xml4h/__init__.py
parse
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...
python
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", ")", ":", "if", "adapter", "is", "None", ":", "adapter", "=", "best_adapter", "if", "isinstance", "(", "to_parse", ",", "basestring", ")", "and", ...
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...
[ "Parse", "an", "XML", "document", "into", "an", "*", "xml4h", "*", "-", "wrapped", "DOM", "representation", "using", "an", "underlying", "XML", "library", "implementation", "." ]
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/__init__.py#L41-L70
train
jmurty/xml4h
xml4h/__init__.py
build
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 ...
python
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", ")", ":", "if", "adapter", "is", "None", ":", "adapter", "=", "best_adapter", "if", "isinstance", "(", "tagname_or_element", ",", "basestring", ")", ":", "d...
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...
[ "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",...
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/__init__.py#L73-L105
train
smarie/python-valid8
valid8/entry_points.py
get_none_policy_text
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...
python
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", ")", ":", "if", "none_policy", "is", "NonePolicy", ".", "SKIP", ":", "return", "\"accept None without performing validation\"", "if", "verbose", "else", "'S...
Returns a user-friendly description of a NonePolicy taking into account NoneArgPolicy :param none_policy: :param verbose: :return:
[ "Returns", "a", "user", "-", "friendly", "description", "of", "a", "NonePolicy", "taking", "into", "account", "NoneArgPolicy" ]
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points.py#L53-L76
train
smarie/python-valid8
valid8/entry_points.py
_add_none_handler
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: ...
python
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", "if", "none_policy", "is", "NonePolicy", ".", "SKIP", ":", "return", "_none_accepter", "(", "validation_callable", ")", ...
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:
[ "Adds", "a", "wrapper", "or", "nothing", "around", "the", "provided", "validation_callable", "depending", "on", "the", "selected", "policy" ]
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points.py#L79-L100
train
smarie/python-valid8
valid8/entry_points.py
add_base_type_dynamically
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...
python
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", ")", ":", "# the new type created dynamically, with the same name", "class", "new_error_type", "(", "with_metaclass", "(", "MetaReprForValidator", ",", "error_type", ",", "additional_type", ",", "o...
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...
[ "Utility", "method", "to", "create", "a", "new", "type", "dynamically", "inheriting", "from", "both", "error_type", "(", "first", ")", "and", "additional_type", "(", "second", ")", ".", "The", "class", "representation", "(", "repr", "(", "cls", "))", "of", ...
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points.py#L346-L369
train
smarie/python-valid8
valid8/entry_points.py
assert_valid
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 ...
python
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", ")", ":", "error_type", ",", "help_msg", ",", "none_policy", "=", "pop_kwargs", "(", "kwargs", ",", ...
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...
[ "Validates", "value", "value", "using", "validation", "function", "(", "s", ")", "base_validator_s", ".", "As", "opposed", "to", "is_valid", "this", "function", "raises", "a", "ValidationError", "if", "validation", "fails", "." ]
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points.py#L669-L711
train
smarie/python-valid8
valid8/entry_points.py
is_valid
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...
python
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", "none_policy", "=", "pop_kwargs", "(", "kwargs", ",", "[", "(", "'none_policy'", ",", "None", ")", ...
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): .....
[ "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...
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points.py#L724-L757
train
smarie/python-valid8
valid8/entry_points.py
ValidationError.create_manually
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 ...
python
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", "append_details", "=", "T...
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:...
[ "Creates", "an", "instance", "without", "using", "a", "Validator", "." ]
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points.py#L174-L208
train
smarie/python-valid8
valid8/entry_points.py
ValidationError.get_details
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 [...
python
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", ")", ":", "# create the exception main message according to the type of result", "if", "isinstance", "(", "self", ".", "validation_outcome", ",", "Exception", ")", ":", "prefix", "=", "'Validation function [{val}] raised '", "if", "self", ...
The function called to get the details appended to the help message when self.append_details is True
[ "The", "function", "called", "to", "get", "the", "details", "appended", "to", "the", "help", "message", "when", "self", ".", "append_details", "is", "True" ]
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points.py#L282-L303
train
smarie/python-valid8
valid8/entry_points.py
ValidationError.get_variable_str
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: ...
python
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", ")", ":", "if", "self", ".", "var_name", "is", "None", ":", "prefix", "=", "''", "else", ":", "prefix", "=", "self", ".", "var_name", "suffix", "=", "str", "(", "self", ".", "var_value", ")", "if", "len", "(", ...
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:
[ "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" ]
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points.py#L305-L326
train
smarie/python-valid8
valid8/entry_points.py
Validator.assert_valid
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...
python
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", ")", ":", "try", ":", "...
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. ...
[ "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", ...
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points.py#L517-L564
train
smarie/python-valid8
valid8/entry_points.py
Validator._create_validation_error
def _create_validation_error(self, name, # type: str value, # type: Any validation_outcome=None, # type: Any error_type=None, # type: Type[...
python
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[ValidationError]", "help_msg", "=", "None", ",", "# typ...
The function doing the final error raising.
[ "The", "function", "doing", "the", "final", "error", "raising", "." ]
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points.py#L566-L604
train
smarie/python-valid8
valid8/entry_points.py
Validator.is_valid
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...
python
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", "# noinspection PyBroadException", "try", ":", "# perform validation", "res", "=", "self", ".", "main_function", "(", "value", ")", "# return a boolean indicating if success or...
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
[ "Validates", "the", "provided", "value", "and", "returns", "a", "boolean", "indicating", "success", "or", "failure", ".", "Any", "Exception", "happening", "in", "the", "validation", "process", "will", "be", "silently", "caught", "." ]
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points.py#L631-L652
train
redhat-cip/dci-control-server
dci/api/v1/tags.py
create_tags
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...
python
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", ")", ":", "values", "=", "{", "'id'", ":", "utils", ".", "gen_uuid", "(", ")", ",", "'created_at'", ":", "datetime", ".", "datetime", ".", "utcnow", "(", ")", ".", "isoformat", "(", ")", "}", "values", ".", "update"...
Create a tag.
[ "Create", "a", "tag", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/tags.py#L72-L93
train
redhat-cip/dci-control-server
dci/api/v1/tags.py
get_tags
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...
python
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", ")", ":", "args", "=", "schemas", ".", "args", "(", "flask", ".", "request", ".", "args", ".", "to_dict", "(", ")", ")", "query", "=", "v1_utils", ".", "QueryBuilder", "(", "_TABLE", ",", "args", ",", "_T_COLUMNS", ")"...
Get all tags.
[ "Get", "all", "tags", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/tags.py#L98-L105
train
redhat-cip/dci-control-server
dci/api/v1/tags.py
delete_tag_by_id
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...
python
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", ")", ":", "query", "=", "_TABLE", ".", "delete", "(", ")", ".", "where", "(", "_TABLE", ".", "c", ".", "id", "==", "tag_id", ")", "result", "=", "flask", ".", "g", ".", "db_conn", ".", "execute...
Delete a tag.
[ "Delete", "a", "tag", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/tags.py#L110-L118
train
inveniosoftware/invenio-assets
invenio_assets/ext.py
InvenioAssets.init_app
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...
python
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", ")", ":", "self", ".", "init_config", "(", "app", ")", "self", ".", "env", ".", "init_app", "(", "app", ")", "self", ".", "c...
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*.
[ "Initialize", "application", "object", "." ]
836cc75ebe0c179f0d72456bd8b784cdc18394a6
https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/ext.py#L41-L60
train
inveniosoftware/invenio-assets
invenio_assets/ext.py
InvenioAssets.init_config
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...
python
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", ")", ":", "app", ".", "config", ".", "setdefault", "(", "'REQUIREJS_BASEURL'", ",", "app", ".", "static_folder", ")", "app", ".", "config", ".", "setdefault", "(", "'COLLECT_STATIC_ROOT'", ",", "app", ".", "st...
Initialize configuration. :param app: An instance of :class:`~flask.Flask`.
[ "Initialize", "configuration", "." ]
836cc75ebe0c179f0d72456bd8b784cdc18394a6
https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/ext.py#L62-L73
train
inveniosoftware/invenio-assets
invenio_assets/ext.py
InvenioAssets.load_entrypoint
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...
python
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", ")", ":", "for", "ep", "in", "pkg_resources", ".", "iter_entry_points", "(", "entry_point_group", ")", ":", "self", ".", "env", ".", "register", "(", "ep", ".", "name", ",", "ep", ".", "load"...
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*.
[ "Load", "entrypoint", "." ]
836cc75ebe0c179f0d72456bd8b784cdc18394a6
https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/ext.py#L75-L85
train
smarie/python-valid8
valid8/entry_points_inline.py
assert_instance_of
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...
python
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]]", ")", ":", "if", "not", "isinstance", "(", "value", ",", "allowed_types", ")", ":", "try", ":", "# more than 1 ?", "allowed_types", "[", "1", "]", "raise", "HasWron...
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...
[ "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", ...
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_inline.py#L25-L51
train
smarie/python-valid8
valid8/entry_points_inline.py
assert_subclass_of
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. ...
python
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]]", ")", ":", "if", "not", "issubclass", "(", "typ", ",", "allowed_types", ")", ":", "try", ":", "# more than 1 ?", "allowed_types", "[", "1", "]", "raise", "IsWrongType...
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...
[ "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", "...
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_inline.py#L54-L80
train
smarie/python-valid8
valid8/entry_points_inline.py
validate
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...
python
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", "=",...
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: ...
[ "A", "validation", "function", "for", "quick", "inline", "validation", "of", "value", "with", "minimal", "capabilities", ":" ]
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_inline.py#L125-L305
train
smarie/python-valid8
valid8/validation_lib/comparables.py
gt
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...
python
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", ")", ":", "if", "strict", ":", "def", "gt_", "(", "x", ")", ":", "if", "x", ">", "min_value", ":", "return", "True", "else", ":", "# raise Failure('x > ' + str(min_v...
'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) ...
[ "Greater", "than", "validation_function", "generator", ".", "Returns", "a", "validation_function", "to", "check", "that", "x", ">", "=", "min_value", "(", "strict", "=", "False", "default", ")", "or", "x", ">", "min_value", "(", "strict", "=", "True", ")" ]
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/comparables.py#L24-L53
train
smarie/python-valid8
valid8/validation_lib/comparables.py
lt
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...
python
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", ")", ":", "if", "strict", ":", "def", "lt_", "(", "x", ")", ":", "if", "x", "<", "max_value", ":", "return", "True", "else", ":", "# raise Failure('x < ' + str(max_v...
'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) ...
[ "Lesser", "than", "validation_function", "generator", ".", "Returns", "a", "validation_function", "to", "check", "that", "x", "<", "=", "max_value", "(", "strict", "=", "False", "default", ")", "or", "x", "<", "max_value", "(", "strict", "=", "True", ")" ]
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/comparables.py#L70-L99
train
smarie/python-valid8
valid8/validation_lib/comparables.py
between
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...
python
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", ")", ":", "if", "open_left", "and", "open_right", ":", "def", "between_", "(", "x",...
'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...
[ "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...
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/comparables.py#L118-L168
train
BrighterCommand/Brightside
brightside/dispatch.py
_sub_process_main
def _sub_process_main(started_event: Event, channel_name: str, connection: Connection, consumer_configuration: BrightsideConsumerConfiguration, consumer_factory: Callable[[Connection, BrightsideConsumerConfiguration, logging.Logger]...
python
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", "[", "[", "Connectio...
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...
[ "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...
53b2f8323c3972609010a7386130249f3758f5fb
https://github.com/BrighterCommand/Brightside/blob/53b2f8323c3972609010a7386130249f3758f5fb/brightside/dispatch.py#L106-L141
train
redhat-cip/dci-control-server
dci/alembic/env.py
run_migrations_offline
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...
python
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", "(", ")", ":", "app_conf", "=", "dci_config", ".", "generate_conf", "(", ")", "url", "=", "app_conf", "[", "'SQLALCHEMY_DATABASE_URI'", "]", "context", ".", "configure", "(", "url", "=", "url", ",", "target_metadata", "=", "tar...
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.
[ "Run", "migrations", "in", "offline", "mode", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/alembic/env.py#L34-L53
train
redhat-cip/dci-control-server
dci/alembic/env.py
run_migrations_online
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: ...
python
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", "(", ")", ":", "app_conf", "=", "dci_config", ".", "generate_conf", "(", ")", "connectable", "=", "dci_config", ".", "get_engine", "(", "app_conf", ")", "with", "connectable", ".", "connect", "(", ")", "as", "connection", ":", ...
Run migrations in 'online' mode. In this scenario we need to create an Engine and associate a connection with the context.
[ "Run", "migrations", "in", "online", "mode", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/alembic/env.py#L56-L72
train
redhat-cip/dci-control-server
dci/decorators.py
reject
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...
python
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", "(", ")", ":", "auth_message", "=", "(", "'Could not verify your access level for that URL.'", "'Please login with proper credentials.'", ")", "auth_message", "=", "json", ".", "dumps", "(", "{", "'_status'", ":", "'Unauthorized'", ",", "'message'", ":"...
Sends a 401 reject response that enables basic auth.
[ "Sends", "a", "401", "reject", "response", "that", "enables", "basic", "auth", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/decorators.py#L26-L36
train
KennethWilke/PingdomLib
pingdomlib/contact.py
PingdomContact.modify
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...
python
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", ")", ":", "# Warn user about unhandled parameters", "for", "key", "in", "kwargs", ":", "if", "key", "not", "in", "[", "'email'", ",", "'cellphone'", ",", "'countrycode'", ",", "'countryiso'", ",", "'defa...
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 ...
[ "Modify", "a", "contact", "." ]
3ed1e481f9c9d16b032558d62fb05c2166e162ed
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/contact.py#L44-L93
train
BrighterCommand/Brightside
arame/gateway.py
ArameConsumer._establish_connection
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 :...
python
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", ":", "try", ":", "self", ".", "_logger", ".", "debug", "(", "\"Establishing connection.\"", ")", "self", ".", "_conn", "=", "conn", ".", "ensure_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
[ "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"...
53b2f8323c3972609010a7386130249f3758f5fb
https://github.com/BrighterCommand/Brightside/blob/53b2f8323c3972609010a7386130249f3758f5fb/arame/gateway.py#L159-L176
train
BrighterCommand/Brightside
arame/gateway.py
ArameConsumer.run_heartbeat_continuously
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 ...
python
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", ":", "cancellation_event", "=", "threading", ".", "Event", "(", ")", "# Effectively a no-op if we are not actually a long-running thread", "if", "not", "self", ".", "_is_long_running_h...
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...
[ "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...
53b2f8323c3972609010a7386130249f3758f5fb
https://github.com/BrighterCommand/Brightside/blob/53b2f8323c3972609010a7386130249f3758f5fb/arame/gateway.py#L252-L281
train
redhat-cip/dci-control-server
dci/api/v1/export_control.py
_check
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...
python
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 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...
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", "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", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/export_control.py#L21-L38
train
redhat-cip/dci-control-server
dci/stores/files_utils.py
get_stream_or_content_from_request
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...
python
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", ")", ":", "if", "request", ".", "stream", ".", "tell", "(", ")", ":", "logger", ".", "info", "(", "'Request stream already consumed. '", "'Storing file content using in-memory data.'", ")", "return", "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...
[ "Ensure", "the", "proper", "content", "is", "uploaded", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/stores/files_utils.py#L24-L41
train
jmurty/xml4h
xml4h/impls/lxml_etree.py
LXMLAdapter.xpath_on_node
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...
python
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", ")", ":", "if", "isinstance", "(", "node", ",", "etree", ".", "_ElementTree", ")", ":", "# Document node lxml.etree._ElementTree has no nsmap, lookup root", "root", "=", "se...
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...
[ "Return", "result", "of", "performing", "the", "given", "XPath", "query", "on", "the", "given", "node", "." ]
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/impls/lxml_etree.py#L133-L159
train
jmurty/xml4h
xml4h/impls/lxml_etree.py
LXMLAdapter._is_ns_in_ancestor
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...
python
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", ")", ":", "curr_node", "=", "self", ".", "get_node_parent", "(", "node", ")", "while", "curr_node", ".", "__class__", "==", "etree", ".", "_Element", ":", "if", "(", "hasat...
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.
[ "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", ...
adbb45e27a01a869a505aee7bc16bad2f517b511
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/impls/lxml_etree.py#L440-L455
train
coleifer/django-generic-aggregation
generic_aggregation/utils.py
generic_annotate
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...
python
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'", ")", ":", "return", "fallback_generic_annotate", "(", "qs_model", ",", "generic_qs_model", ",", "aggregator", ",", ...
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...
[ "Find", "blog", "entries", "with", "the", "most", "comments", ":", "qs", "=", "generic_annotate", "(", "Entry", ".", "objects", ".", "public", "()", "Comment", ".", "objects", ".", "public", "()", "Count", "(", "comments__id", "))", "for", "entry", "in", ...
67cf89d58176e7df974b2bdb5e397352ad4e16e7
https://github.com/coleifer/django-generic-aggregation/blob/67cf89d58176e7df974b2bdb5e397352ad4e16e7/generic_aggregation/utils.py#L30-L62
train
coleifer/django-generic-aggregation
generic_aggregation/utils.py
generic_aggregate
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...
python
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", ")", ":", "return", "fallback_generic_aggregate", "(", "qs_model", ",", "generic_qs_model", ",", "aggregator", ",", "gfk_field", ")" ]
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,...
[ "Find", "total", "number", "of", "comments", "on", "blog", "entries", ":", "generic_aggregate", "(", "Entry", ".", "objects", ".", "public", "()", "Comment", ".", "objects", ".", "public", "()", "Count", "(", "comments__id", "))", "Find", "the", "average", ...
67cf89d58176e7df974b2bdb5e397352ad4e16e7
https://github.com/coleifer/django-generic-aggregation/blob/67cf89d58176e7df974b2bdb5e397352ad4e16e7/generic_aggregation/utils.py#L65-L93
train
coleifer/django-generic-aggregation
generic_aggregation/utils.py
generic_filter
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...
python
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", ")", ":", "generic_qs", "=", "normalize_qs_model", "(", "generic_qs_model", ")", "filter_qs", "=", "normalize_qs_model", "(", "filter_qs_model", ")", "if", "not"...
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...
[ "Only", "show", "me", "ratings", "made", "on", "foods", "that", "start", "with", "a", ":", "a_foods", "=", "Food", ".", "objects", ".", "filter", "(", "name__startswith", "=", "a", ")", "generic_filter", "(", "Rating", ".", "objects", ".", "all", "()", ...
67cf89d58176e7df974b2bdb5e397352ad4e16e7
https://github.com/coleifer/django-generic-aggregation/blob/67cf89d58176e7df974b2bdb5e397352ad4e16e7/generic_aggregation/utils.py#L96-L125
train
redhat-cip/dci-control-server
dci/common/utils.py
gen_etag
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()
python
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", "(", ")", ":", "my_salt", "=", "gen_uuid", "(", ")", "if", "six", ".", "PY2", ":", "my_salt", "=", "my_salt", ".", "decode", "(", "'utf-8'", ")", "elif", "six", ".", "PY3", ":", "my_salt", "=", "my_salt", ".", "encode", "(", "'ut...
Generate random etag based on MD5.
[ "Generate", "random", "etag", "based", "on", "MD5", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/common/utils.py#L64-L74
train
KennethWilke/PingdomLib
pingdomlib/reports.py
PingdomSharedReport.delete
def delete(self): """Delete this email report""" response = self.pingdom.request('DELETE', 'reports.shared/%s' % self.id) return response.json()['message']
python
def delete(self): """Delete this email report""" response = self.pingdom.request('DELETE', 'reports.shared/%s' % self.id) return response.json()['message']
[ "def", "delete", "(", "self", ")", ":", "response", "=", "self", ".", "pingdom", ".", "request", "(", "'DELETE'", ",", "'reports.shared/%s'", "%", "self", ".", "id", ")", "return", "response", ".", "json", "(", ")", "[", "'message'", "]" ]
Delete this email report
[ "Delete", "this", "email", "report" ]
3ed1e481f9c9d16b032558d62fb05c2166e162ed
https://github.com/KennethWilke/PingdomLib/blob/3ed1e481f9c9d16b032558d62fb05c2166e162ed/pingdomlib/reports.py#L101-L106
train
smarie/python-valid8
valid8/validation_lib/numbers.py
is_multiple_of
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...
python
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", ")", ":", "def", "is_multiple_of_ref", "(", "x", ")", ":", "if", "x", "%", "ref", "==", "0", ":", "return", "True", "else", ":", "raise", "IsNotMultipleOf", "(", "wrong_value", "=", "x", ",", "ref", "=", "ref", ")...
Validates that x is a multiple of the reference (`x % ref == 0`)
[ "Validates", "that", "x", "is", "a", "multiple", "of", "the", "reference", "(", "x", "%", "ref", "==", "0", ")" ]
5e15d1de11602933c5114eb9f73277ad91d97800
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/numbers.py#L42-L52
train
redhat-cip/dci-control-server
dci/api/v1/components.py
get_all_components
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')) ...
python
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", ")", ":", "args", "=", "schemas", ".", "args", "(", "flask", ".", "request", ".", "args", ".", "to_dict", "(", ")", ")", "query", "=", "v1_utils", ".", "QueryBuilder", "(", "_TABLE", ",", "args...
Get all components of a topic.
[ "Get", "all", "components", "of", "a", "topic", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/components.py#L139-L160
train
redhat-cip/dci-control-server
dci/api/v1/components.py
get_component_types_from_topic
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 ...
python
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", ")", ":", "db_conn", "=", "db_conn", "or", "flask", ".", "g", ".", "db_conn", "query", "=", "sql", ".", "select", "(", "[", "models", ".", "TOPICS", "]", ")", ".", "...
Returns the component types of a topic.
[ "Returns", "the", "component", "types", "of", "a", "topic", "." ]
b416cf935ec93e4fdd5741f61a21cabecf8454d2
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/components.py#L340-L347
train