partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
AdvancedTag.getStyleDict
getStyleDict - Gets a dictionary of style attribute/value pairs. @return - OrderedDict of "style" attribute.
AdvancedHTMLParser/Tags.py
def getStyleDict(self): ''' getStyleDict - Gets a dictionary of style attribute/value pairs. @return - OrderedDict of "style" attribute. ''' # TODO: This method is not used and does not appear in any tests. styleStr = (self.getAttribute('style') or '').strip() ...
def getStyleDict(self): ''' getStyleDict - Gets a dictionary of style attribute/value pairs. @return - OrderedDict of "style" attribute. ''' # TODO: This method is not used and does not appear in any tests. styleStr = (self.getAttribute('style') or '').strip() ...
[ "getStyleDict", "-", "Gets", "a", "dictionary", "of", "style", "attribute", "/", "value", "pairs", "." ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L1654-L1675
[ "def", "getStyleDict", "(", "self", ")", ":", "# TODO: This method is not used and does not appear in any tests.", "styleStr", "=", "(", "self", ".", "getAttribute", "(", "'style'", ")", "or", "''", ")", ".", "strip", "(", ")", "styles", "=", "styleStr", ".", "s...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
AdvancedTag.setStyle
setStyle - Sets a style param. Example: "display", "block" If you need to set many styles on an element, use setStyles instead. It takes a dictionary of attribute, value pairs and applies it all in one go (faster) To remove a style, set its value to empty string. ...
AdvancedHTMLParser/Tags.py
def setStyle(self, styleName, styleValue): ''' setStyle - Sets a style param. Example: "display", "block" If you need to set many styles on an element, use setStyles instead. It takes a dictionary of attribute, value pairs and applies it all in one go (faster) ...
def setStyle(self, styleName, styleValue): ''' setStyle - Sets a style param. Example: "display", "block" If you need to set many styles on an element, use setStyles instead. It takes a dictionary of attribute, value pairs and applies it all in one go (faster) ...
[ "setStyle", "-", "Sets", "a", "style", "param", ".", "Example", ":", "display", "block" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L1689-L1709
[ "def", "setStyle", "(", "self", ",", "styleName", ",", "styleValue", ")", ":", "myAttributes", "=", "self", ".", "_attributes", "if", "'style'", "not", "in", "myAttributes", ":", "myAttributes", "[", "'style'", "]", "=", "\"%s: %s\"", "%", "(", "styleName", ...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
AdvancedTag.setStyles
setStyles - Sets one or more style params. This all happens in one shot, so it is much much faster than calling setStyle for every value. To remove a style, set its value to empty string. When all styles are removed, the "style" attribute will be nullified. ...
AdvancedHTMLParser/Tags.py
def setStyles(self, styleUpdatesDict): ''' setStyles - Sets one or more style params. This all happens in one shot, so it is much much faster than calling setStyle for every value. To remove a style, set its value to empty string. When all styles are...
def setStyles(self, styleUpdatesDict): ''' setStyles - Sets one or more style params. This all happens in one shot, so it is much much faster than calling setStyle for every value. To remove a style, set its value to empty string. When all styles are...
[ "setStyles", "-", "Sets", "one", "or", "more", "style", "params", ".", "This", "all", "happens", "in", "one", "shot", "so", "it", "is", "much", "much", "faster", "than", "calling", "setStyle", "for", "every", "value", "." ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L1712-L1728
[ "def", "setStyles", "(", "self", ",", "styleUpdatesDict", ")", ":", "setStyleMethod", "=", "self", ".", "setStyle", "for", "newName", ",", "newValue", "in", "styleUpdatesDict", ".", "items", "(", ")", ":", "setStyleMethod", "(", "newName", ",", "newValue", "...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
AdvancedTag.getElementById
getElementById - Search children of this tag for a tag containing an id @param _id - String of id @return - AdvancedTag or None
AdvancedHTMLParser/Tags.py
def getElementById(self, _id): ''' getElementById - Search children of this tag for a tag containing an id @param _id - String of id @return - AdvancedTag or None ''' for child in self.children: if child.getAttribute('id') == _id: ...
def getElementById(self, _id): ''' getElementById - Search children of this tag for a tag containing an id @param _id - String of id @return - AdvancedTag or None ''' for child in self.children: if child.getAttribute('id') == _id: ...
[ "getElementById", "-", "Search", "children", "of", "this", "tag", "for", "a", "tag", "containing", "an", "id" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L1781-L1795
[ "def", "getElementById", "(", "self", ",", "_id", ")", ":", "for", "child", "in", "self", ".", "children", ":", "if", "child", ".", "getAttribute", "(", "'id'", ")", "==", "_id", ":", "return", "child", "found", "=", "child", ".", "getElementById", "("...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
AdvancedTag.getElementsByAttr
getElementsByAttr - Search children of this tag for tags with an attribute name/value pair @param attrName - Attribute name (lowercase) @param attrValue - Attribute value @return - TagCollection of matching elements
AdvancedHTMLParser/Tags.py
def getElementsByAttr(self, attrName, attrValue): ''' getElementsByAttr - Search children of this tag for tags with an attribute name/value pair @param attrName - Attribute name (lowercase) @param attrValue - Attribute value @return - TagCollection of matching e...
def getElementsByAttr(self, attrName, attrValue): ''' getElementsByAttr - Search children of this tag for tags with an attribute name/value pair @param attrName - Attribute name (lowercase) @param attrValue - Attribute value @return - TagCollection of matching e...
[ "getElementsByAttr", "-", "Search", "children", "of", "this", "tag", "for", "tags", "with", "an", "attribute", "name", "/", "value", "pair" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L1797-L1811
[ "def", "getElementsByAttr", "(", "self", ",", "attrName", ",", "attrValue", ")", ":", "elements", "=", "[", "]", "for", "child", "in", "self", ".", "children", ":", "if", "child", ".", "getAttribute", "(", "attrName", ")", "==", "attrValue", ":", "elemen...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
AdvancedTag.getElementsByClassName
getElementsByClassName - Search children of this tag for tags containing a given class name @param className - Class name @return - TagCollection of matching elements
AdvancedHTMLParser/Tags.py
def getElementsByClassName(self, className): ''' getElementsByClassName - Search children of this tag for tags containing a given class name @param className - Class name @return - TagCollection of matching elements ''' elements = [] for child in sel...
def getElementsByClassName(self, className): ''' getElementsByClassName - Search children of this tag for tags containing a given class name @param className - Class name @return - TagCollection of matching elements ''' elements = [] for child in sel...
[ "getElementsByClassName", "-", "Search", "children", "of", "this", "tag", "for", "tags", "containing", "a", "given", "class", "name" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L1823-L1836
[ "def", "getElementsByClassName", "(", "self", ",", "className", ")", ":", "elements", "=", "[", "]", "for", "child", "in", "self", ".", "children", ":", "if", "child", ".", "hasClass", "(", "className", ")", "is", "True", ":", "elements", ".", "append", ...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
AdvancedTag.getElementsWithAttrValues
getElementsWithAttrValues - Search children of this tag for tags with an attribute name and one of several values @param attrName <lowercase str> - Attribute name (lowercase) @param attrValues set<str> - set of acceptable attribute values @return - TagCollection of matching element...
AdvancedHTMLParser/Tags.py
def getElementsWithAttrValues(self, attrName, attrValues): ''' getElementsWithAttrValues - Search children of this tag for tags with an attribute name and one of several values @param attrName <lowercase str> - Attribute name (lowercase) @param attrValues set<str> - set of a...
def getElementsWithAttrValues(self, attrName, attrValues): ''' getElementsWithAttrValues - Search children of this tag for tags with an attribute name and one of several values @param attrName <lowercase str> - Attribute name (lowercase) @param attrValues set<str> - set of a...
[ "getElementsWithAttrValues", "-", "Search", "children", "of", "this", "tag", "for", "tags", "with", "an", "attribute", "name", "and", "one", "of", "several", "values" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L1838-L1853
[ "def", "getElementsWithAttrValues", "(", "self", ",", "attrName", ",", "attrValues", ")", ":", "elements", "=", "[", "]", "for", "child", "in", "self", ".", "children", ":", "if", "child", ".", "getAttribute", "(", "attrName", ")", "in", "attrValues", ":",...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
AdvancedTag.getElementsCustomFilter
getElementsCustomFilter - Searches children of this tag for those matching a provided user function @param filterFunc <function> - A function or lambda expression that should return "True" if the passed node matches criteria. @return - TagCollection of matching results @see getFir...
AdvancedHTMLParser/Tags.py
def getElementsCustomFilter(self, filterFunc): ''' getElementsCustomFilter - Searches children of this tag for those matching a provided user function @param filterFunc <function> - A function or lambda expression that should return "True" if the passed node matches criteria. ...
def getElementsCustomFilter(self, filterFunc): ''' getElementsCustomFilter - Searches children of this tag for those matching a provided user function @param filterFunc <function> - A function or lambda expression that should return "True" if the passed node matches criteria. ...
[ "getElementsCustomFilter", "-", "Searches", "children", "of", "this", "tag", "for", "those", "matching", "a", "provided", "user", "function" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L1856-L1873
[ "def", "getElementsCustomFilter", "(", "self", ",", "filterFunc", ")", ":", "elements", "=", "[", "]", "for", "child", "in", "self", ".", "children", ":", "if", "filterFunc", "(", "child", ")", "is", "True", ":", "elements", ".", "append", "(", "child", ...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
AdvancedTag.getFirstElementCustomFilter
getFirstElementCustomFilter - Gets the first element which matches a given filter func. Scans first child, to the bottom, then next child to the bottom, etc. Does not include "self" node. @param filterFunc <function> - A function or lambda expression that should return "True" if the passed...
AdvancedHTMLParser/Tags.py
def getFirstElementCustomFilter(self, filterFunc): ''' getFirstElementCustomFilter - Gets the first element which matches a given filter func. Scans first child, to the bottom, then next child to the bottom, etc. Does not include "self" node. @param filterFunc <function...
def getFirstElementCustomFilter(self, filterFunc): ''' getFirstElementCustomFilter - Gets the first element which matches a given filter func. Scans first child, to the bottom, then next child to the bottom, etc. Does not include "self" node. @param filterFunc <function...
[ "getFirstElementCustomFilter", "-", "Gets", "the", "first", "element", "which", "matches", "a", "given", "filter", "func", "." ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L1875-L1896
[ "def", "getFirstElementCustomFilter", "(", "self", ",", "filterFunc", ")", ":", "for", "child", "in", "self", ".", "children", ":", "if", "filterFunc", "(", "child", ")", "is", "True", ":", "return", "child", "childSearchResult", "=", "child", ".", "getFirst...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
AdvancedTag.getParentElementCustomFilter
getParentElementCustomFilter - Runs through parent on up to document root, returning the first tag which filterFunc(tag) returns True. @param filterFunc <function/lambda> - A function or lambda expression that should return "True" if the passed node matche...
AdvancedHTMLParser/Tags.py
def getParentElementCustomFilter(self, filterFunc): ''' getParentElementCustomFilter - Runs through parent on up to document root, returning the first tag which filterFunc(tag) returns True. @param filterFunc <function/lambda> - A funct...
def getParentElementCustomFilter(self, filterFunc): ''' getParentElementCustomFilter - Runs through parent on up to document root, returning the first tag which filterFunc(tag) returns True. @param filterFunc <function/lambda> - A funct...
[ "getParentElementCustomFilter", "-", "Runs", "through", "parent", "on", "up", "to", "document", "root", "returning", "the" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L1898-L1919
[ "def", "getParentElementCustomFilter", "(", "self", ",", "filterFunc", ")", ":", "parentNode", "=", "self", ".", "parentNode", "while", "parentNode", ":", "if", "filterFunc", "(", "parentNode", ")", "is", "True", ":", "return", "parentNode", "parentNode", "=", ...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
AdvancedTag.getPeersCustomFilter
getPeersCustomFilter - Get elements who share a parent with this element and also pass a custom filter check @param filterFunc <lambda/function> - Passed in an element, and returns True if it should be treated as a match, otherwise False. @return <TagCollection> - Resulting peers, or N...
AdvancedHTMLParser/Tags.py
def getPeersCustomFilter(self, filterFunc): ''' getPeersCustomFilter - Get elements who share a parent with this element and also pass a custom filter check @param filterFunc <lambda/function> - Passed in an element, and returns True if it should be treated as a match, otherwise Fal...
def getPeersCustomFilter(self, filterFunc): ''' getPeersCustomFilter - Get elements who share a parent with this element and also pass a custom filter check @param filterFunc <lambda/function> - Passed in an element, and returns True if it should be treated as a match, otherwise Fal...
[ "getPeersCustomFilter", "-", "Get", "elements", "who", "share", "a", "parent", "with", "this", "element", "and", "also", "pass", "a", "custom", "filter", "check" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L1922-L1934
[ "def", "getPeersCustomFilter", "(", "self", ",", "filterFunc", ")", ":", "peers", "=", "self", ".", "peers", "if", "peers", "is", "None", ":", "return", "None", "return", "TagCollection", "(", "[", "peer", "for", "peer", "in", "peers", "if", "filterFunc", ...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
AdvancedTag.getPeersByAttr
getPeersByAttr - Gets peers (elements on same level) which match an attribute/value combination. @param attrName - Name of attribute @param attrValue - Value that must match @return - None if no parent element (error condition), otherwise a TagCollection of peers that matched.
AdvancedHTMLParser/Tags.py
def getPeersByAttr(self, attrName, attrValue): ''' getPeersByAttr - Gets peers (elements on same level) which match an attribute/value combination. @param attrName - Name of attribute @param attrValue - Value that must match @return - None if no parent element (...
def getPeersByAttr(self, attrName, attrValue): ''' getPeersByAttr - Gets peers (elements on same level) which match an attribute/value combination. @param attrName - Name of attribute @param attrValue - Value that must match @return - None if no parent element (...
[ "getPeersByAttr", "-", "Gets", "peers", "(", "elements", "on", "same", "level", ")", "which", "match", "an", "attribute", "/", "value", "combination", "." ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L1937-L1949
[ "def", "getPeersByAttr", "(", "self", ",", "attrName", ",", "attrValue", ")", ":", "peers", "=", "self", ".", "peers", "if", "peers", "is", "None", ":", "return", "None", "return", "TagCollection", "(", "[", "peer", "for", "peer", "in", "peers", "if", ...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
AdvancedTag.getPeersWithAttrValues
getPeersWithAttrValues - Gets peers (elements on same level) whose attribute given by #attrName are in the list of possible vaues #attrValues @param attrName - Name of attribute @param attrValues - List of possible values which will match @return - None if no paren...
AdvancedHTMLParser/Tags.py
def getPeersWithAttrValues(self, attrName, attrValues): ''' getPeersWithAttrValues - Gets peers (elements on same level) whose attribute given by #attrName are in the list of possible vaues #attrValues @param attrName - Name of attribute @param attrValues - ...
def getPeersWithAttrValues(self, attrName, attrValues): ''' getPeersWithAttrValues - Gets peers (elements on same level) whose attribute given by #attrName are in the list of possible vaues #attrValues @param attrName - Name of attribute @param attrValues - ...
[ "getPeersWithAttrValues", "-", "Gets", "peers", "(", "elements", "on", "same", "level", ")", "whose", "attribute", "given", "by", "#attrName", "are", "in", "the", "list", "of", "possible", "vaues", "#attrValues" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L1951-L1964
[ "def", "getPeersWithAttrValues", "(", "self", ",", "attrName", ",", "attrValues", ")", ":", "peers", "=", "self", ".", "peers", "if", "peers", "is", "None", ":", "return", "None", "return", "TagCollection", "(", "[", "peer", "for", "peer", "in", "peers", ...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
AdvancedTag.getPeersByName
getPeersByName - Gets peers (elements on same level) with a given name @param name - Name to match @return - None if no parent element (error condition), otherwise a TagCollection of peers that matched.
AdvancedHTMLParser/Tags.py
def getPeersByName(self, name): ''' getPeersByName - Gets peers (elements on same level) with a given name @param name - Name to match @return - None if no parent element (error condition), otherwise a TagCollection of peers that matched. ''' peers = self.pe...
def getPeersByName(self, name): ''' getPeersByName - Gets peers (elements on same level) with a given name @param name - Name to match @return - None if no parent element (error condition), otherwise a TagCollection of peers that matched. ''' peers = self.pe...
[ "getPeersByName", "-", "Gets", "peers", "(", "elements", "on", "same", "level", ")", "with", "a", "given", "name" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L1966-L1977
[ "def", "getPeersByName", "(", "self", ",", "name", ")", ":", "peers", "=", "self", ".", "peers", "if", "peers", "is", "None", ":", "return", "None", "return", "TagCollection", "(", "[", "peer", "for", "peer", "in", "peers", "if", "peer", ".", "name", ...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
AdvancedTag.getPeersByClassName
getPeersByClassName - Gets peers (elements on same level) with a given class name @param className - classname must contain this name @return - None if no parent element (error condition), otherwise a TagCollection of peers that matched.
AdvancedHTMLParser/Tags.py
def getPeersByClassName(self, className): ''' getPeersByClassName - Gets peers (elements on same level) with a given class name @param className - classname must contain this name @return - None if no parent element (error condition), otherwise a TagCollection of peers that...
def getPeersByClassName(self, className): ''' getPeersByClassName - Gets peers (elements on same level) with a given class name @param className - classname must contain this name @return - None if no parent element (error condition), otherwise a TagCollection of peers that...
[ "getPeersByClassName", "-", "Gets", "peers", "(", "elements", "on", "same", "level", ")", "with", "a", "given", "class", "name" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L1979-L1990
[ "def", "getPeersByClassName", "(", "self", ",", "className", ")", ":", "peers", "=", "self", ".", "peers", "if", "peers", "is", "None", ":", "return", "None", "return", "TagCollection", "(", "[", "peer", "for", "peer", "in", "peers", "if", "peer", ".", ...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
AdvancedTag.isTagEqual
isTagEqual - Compare if a tag contains the same tag name and attributes as another tag, i.e. if everything between < and > parts of this tag are the same. Does NOT compare children, etc. Does NOT compare if these are the same exact tag in the html (use regular == operator for that) ...
AdvancedHTMLParser/Tags.py
def isTagEqual(self, other): ''' isTagEqual - Compare if a tag contains the same tag name and attributes as another tag, i.e. if everything between < and > parts of this tag are the same. Does NOT compare children, etc. Does NOT compare if these are the same exact t...
def isTagEqual(self, other): ''' isTagEqual - Compare if a tag contains the same tag name and attributes as another tag, i.e. if everything between < and > parts of this tag are the same. Does NOT compare children, etc. Does NOT compare if these are the same exact t...
[ "isTagEqual", "-", "Compare", "if", "a", "tag", "contains", "the", "same", "tag", "name", "and", "attributes", "as", "another", "tag" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L2002-L2046
[ "def", "isTagEqual", "(", "self", ",", "other", ")", ":", "# if type(other) != type(self):", "# return False", "# NOTE: Instead of type check,", "# just see if we can get the needed attributes in case subclassing", "try", ":", "if", "self", ".", "ta...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
TagCollection.append
append - Append an item to this tag collection @param tag - an AdvancedTag
AdvancedHTMLParser/Tags.py
def append(self, tag): ''' append - Append an item to this tag collection @param tag - an AdvancedTag ''' list.append(self, tag) self.uids.add(tag.uid)
def append(self, tag): ''' append - Append an item to this tag collection @param tag - an AdvancedTag ''' list.append(self, tag) self.uids.add(tag.uid)
[ "append", "-", "Append", "an", "item", "to", "this", "tag", "collection" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L2241-L2248
[ "def", "append", "(", "self", ",", "tag", ")", ":", "list", ".", "append", "(", "self", ",", "tag", ")", "self", ".", "uids", ".", "add", "(", "tag", ".", "uid", ")" ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
TagCollection.remove
remove - Remove an item from this tag collection @param toRemove - an AdvancedTag
AdvancedHTMLParser/Tags.py
def remove(self, toRemove): ''' remove - Remove an item from this tag collection @param toRemove - an AdvancedTag ''' list.remove(self, toRemove) self.uids.remove(toRemove.uid)
def remove(self, toRemove): ''' remove - Remove an item from this tag collection @param toRemove - an AdvancedTag ''' list.remove(self, toRemove) self.uids.remove(toRemove.uid)
[ "remove", "-", "Remove", "an", "item", "from", "this", "tag", "collection" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L2250-L2257
[ "def", "remove", "(", "self", ",", "toRemove", ")", ":", "list", ".", "remove", "(", "self", ",", "toRemove", ")", "self", ".", "uids", ".", "remove", "(", "toRemove", ".", "uid", ")" ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
TagCollection.filterCollection
filterCollection - Filters only the immediate objects contained within this Collection against a function, not including any children @param filterFunc <function> - A function or lambda expression that returns True to have that element match @return TagCollection<AdvancedTag>
AdvancedHTMLParser/Tags.py
def filterCollection(self, filterFunc): ''' filterCollection - Filters only the immediate objects contained within this Collection against a function, not including any children @param filterFunc <function> - A function or lambda expression that returns True to have that element match ...
def filterCollection(self, filterFunc): ''' filterCollection - Filters only the immediate objects contained within this Collection against a function, not including any children @param filterFunc <function> - A function or lambda expression that returns True to have that element match ...
[ "filterCollection", "-", "Filters", "only", "the", "immediate", "objects", "contained", "within", "this", "Collection", "against", "a", "function", "not", "including", "any", "children" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L2267-L2283
[ "def", "filterCollection", "(", "self", ",", "filterFunc", ")", ":", "ret", "=", "TagCollection", "(", ")", "if", "len", "(", "self", ")", "==", "0", ":", "return", "ret", "for", "tag", "in", "self", ":", "if", "filterFunc", "(", "tag", ")", "is", ...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
TagCollection.getElementsByTagName
getElementsByTagName - Gets elements within this collection having a specific tag name @param tagName - String of tag name @return - TagCollection of unique elements within this collection with given tag name
AdvancedHTMLParser/Tags.py
def getElementsByTagName(self, tagName): ''' getElementsByTagName - Gets elements within this collection having a specific tag name @param tagName - String of tag name @return - TagCollection of unique elements within this collection with given tag name ''' ...
def getElementsByTagName(self, tagName): ''' getElementsByTagName - Gets elements within this collection having a specific tag name @param tagName - String of tag name @return - TagCollection of unique elements within this collection with given tag name ''' ...
[ "getElementsByTagName", "-", "Gets", "elements", "within", "this", "collection", "having", "a", "specific", "tag", "name" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L2285-L2303
[ "def", "getElementsByTagName", "(", "self", ",", "tagName", ")", ":", "ret", "=", "TagCollection", "(", ")", "if", "len", "(", "self", ")", "==", "0", ":", "return", "ret", "tagName", "=", "tagName", ".", "lower", "(", ")", "_cmpFunc", "=", "lambda", ...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
TagCollection.getElementsByName
getElementsByName - Get elements within this collection having a specific name @param name - String of "name" attribute @return - TagCollection of unique elements within this collection with given "name"
AdvancedHTMLParser/Tags.py
def getElementsByName(self, name): ''' getElementsByName - Get elements within this collection having a specific name @param name - String of "name" attribute @return - TagCollection of unique elements within this collection with given "name" ''' ret = TagCo...
def getElementsByName(self, name): ''' getElementsByName - Get elements within this collection having a specific name @param name - String of "name" attribute @return - TagCollection of unique elements within this collection with given "name" ''' ret = TagCo...
[ "getElementsByName", "-", "Get", "elements", "within", "this", "collection", "having", "a", "specific", "name" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L2306-L2321
[ "def", "getElementsByName", "(", "self", ",", "name", ")", ":", "ret", "=", "TagCollection", "(", ")", "if", "len", "(", "self", ")", "==", "0", ":", "return", "ret", "_cmpFunc", "=", "lambda", "tag", ":", "bool", "(", "tag", ".", "name", "==", "na...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
TagCollection.getElementsByClassName
getElementsByClassName - Get elements within this collection containing a specific class name @param className - A single class name @return - TagCollection of unique elements within this collection tagged with a specific class name
AdvancedHTMLParser/Tags.py
def getElementsByClassName(self, className): ''' getElementsByClassName - Get elements within this collection containing a specific class name @param className - A single class name @return - TagCollection of unique elements within this collection tagged with a specific cla...
def getElementsByClassName(self, className): ''' getElementsByClassName - Get elements within this collection containing a specific class name @param className - A single class name @return - TagCollection of unique elements within this collection tagged with a specific cla...
[ "getElementsByClassName", "-", "Get", "elements", "within", "this", "collection", "containing", "a", "specific", "class", "name" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L2323-L2338
[ "def", "getElementsByClassName", "(", "self", ",", "className", ")", ":", "ret", "=", "TagCollection", "(", ")", "if", "len", "(", "self", ")", "==", "0", ":", "return", "ret", "_cmpFunc", "=", "lambda", "tag", ":", "tag", ".", "hasClass", "(", "classN...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
TagCollection.getElementById
getElementById - Gets an element within this collection by id @param _id - string of "id" attribute @return - a single tag matching the id, or None if none found
AdvancedHTMLParser/Tags.py
def getElementById(self, _id): ''' getElementById - Gets an element within this collection by id @param _id - string of "id" attribute @return - a single tag matching the id, or None if none found ''' for tag in self: if tag.id == _id: ...
def getElementById(self, _id): ''' getElementById - Gets an element within this collection by id @param _id - string of "id" attribute @return - a single tag matching the id, or None if none found ''' for tag in self: if tag.id == _id: ...
[ "getElementById", "-", "Gets", "an", "element", "within", "this", "collection", "by", "id" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L2340-L2355
[ "def", "getElementById", "(", "self", ",", "_id", ")", ":", "for", "tag", "in", "self", ":", "if", "tag", ".", "id", "==", "_id", ":", "return", "tag", "for", "subtag", "in", "tag", ".", "children", ":", "tmp", "=", "subtag", ".", "getElementById", ...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
TagCollection.getElementsByAttr
getElementsByAttr - Get elements within this collection posessing a given attribute/value pair @param attr - Attribute name (lowercase) @param value - Matching value @return - TagCollection of all elements matching name/value
AdvancedHTMLParser/Tags.py
def getElementsByAttr(self, attr, value): ''' getElementsByAttr - Get elements within this collection posessing a given attribute/value pair @param attr - Attribute name (lowercase) @param value - Matching value @return - TagCollection of all elements matching n...
def getElementsByAttr(self, attr, value): ''' getElementsByAttr - Get elements within this collection posessing a given attribute/value pair @param attr - Attribute name (lowercase) @param value - Matching value @return - TagCollection of all elements matching n...
[ "getElementsByAttr", "-", "Get", "elements", "within", "this", "collection", "posessing", "a", "given", "attribute", "/", "value", "pair" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L2357-L2375
[ "def", "getElementsByAttr", "(", "self", ",", "attr", ",", "value", ")", ":", "ret", "=", "TagCollection", "(", ")", "if", "len", "(", "self", ")", "==", "0", ":", "return", "ret", "attr", "=", "attr", ".", "lower", "(", ")", "_cmpFunc", "=", "lamb...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
TagCollection.getElementsWithAttrValues
getElementsWithAttrValues - Get elements within this collection possessing an attribute name matching one of several values @param attr <lowercase str> - Attribute name (lowerase) @param values set<str> - Set of possible matching values @return - TagCollection of all elements match...
AdvancedHTMLParser/Tags.py
def getElementsWithAttrValues(self, attr, values): ''' getElementsWithAttrValues - Get elements within this collection possessing an attribute name matching one of several values @param attr <lowercase str> - Attribute name (lowerase) @param values set<str> - Set of possible...
def getElementsWithAttrValues(self, attr, values): ''' getElementsWithAttrValues - Get elements within this collection possessing an attribute name matching one of several values @param attr <lowercase str> - Attribute name (lowerase) @param values set<str> - Set of possible...
[ "getElementsWithAttrValues", "-", "Get", "elements", "within", "this", "collection", "possessing", "an", "attribute", "name", "matching", "one", "of", "several", "values" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L2377-L2398
[ "def", "getElementsWithAttrValues", "(", "self", ",", "attr", ",", "values", ")", ":", "ret", "=", "TagCollection", "(", ")", "if", "len", "(", "self", ")", "==", "0", ":", "return", "ret", "if", "type", "(", "values", ")", "!=", "set", ":", "values"...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
TagCollection.getElementsCustomFilter
getElementsCustomFilter - Get elements within this collection that match a user-provided function. @param filterFunc <function> - A function that returns True if the element matches criteria @return - TagCollection of all elements that matched criteria
AdvancedHTMLParser/Tags.py
def getElementsCustomFilter(self, filterFunc): ''' getElementsCustomFilter - Get elements within this collection that match a user-provided function. @param filterFunc <function> - A function that returns True if the element matches criteria @return - TagCollection of all e...
def getElementsCustomFilter(self, filterFunc): ''' getElementsCustomFilter - Get elements within this collection that match a user-provided function. @param filterFunc <function> - A function that returns True if the element matches criteria @return - TagCollection of all e...
[ "getElementsCustomFilter", "-", "Get", "elements", "within", "this", "collection", "that", "match", "a", "user", "-", "provided", "function", "." ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L2400-L2416
[ "def", "getElementsCustomFilter", "(", "self", ",", "filterFunc", ")", ":", "ret", "=", "TagCollection", "(", ")", "if", "len", "(", "self", ")", "==", "0", ":", "return", "ret", "_cmpFunc", "=", "lambda", "tag", ":", "filterFunc", "(", "tag", ")", "is...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
TagCollection.getAllNodes
getAllNodes - Gets all the nodes, and all their children for every node within this collection
AdvancedHTMLParser/Tags.py
def getAllNodes(self): ''' getAllNodes - Gets all the nodes, and all their children for every node within this collection ''' ret = TagCollection() for tag in self: ret.append(tag) ret += tag.getAllChildNodes() return ret
def getAllNodes(self): ''' getAllNodes - Gets all the nodes, and all their children for every node within this collection ''' ret = TagCollection() for tag in self: ret.append(tag) ret += tag.getAllChildNodes() return ret
[ "getAllNodes", "-", "Gets", "all", "the", "nodes", "and", "all", "their", "children", "for", "every", "node", "within", "this", "collection" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L2418-L2428
[ "def", "getAllNodes", "(", "self", ")", ":", "ret", "=", "TagCollection", "(", ")", "for", "tag", "in", "self", ":", "ret", ".", "append", "(", "tag", ")", "ret", "+=", "tag", ".", "getAllChildNodes", "(", ")", "return", "ret" ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
TagCollection.getAllNodeUids
getAllNodeUids - Gets all the internal uids of all nodes, their children, and all their children so on.. @return set<uuid.UUID>
AdvancedHTMLParser/Tags.py
def getAllNodeUids(self): ''' getAllNodeUids - Gets all the internal uids of all nodes, their children, and all their children so on.. @return set<uuid.UUID> ''' ret = set() for child in self: ret.update(child.getAllNodeUids()) return ret
def getAllNodeUids(self): ''' getAllNodeUids - Gets all the internal uids of all nodes, their children, and all their children so on.. @return set<uuid.UUID> ''' ret = set() for child in self: ret.update(child.getAllNodeUids()) return ret
[ "getAllNodeUids", "-", "Gets", "all", "the", "internal", "uids", "of", "all", "nodes", "their", "children", "and", "all", "their", "children", "so", "on", ".." ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L2430-L2441
[ "def", "getAllNodeUids", "(", "self", ")", ":", "ret", "=", "set", "(", ")", "for", "child", "in", "self", ":", "ret", ".", "update", "(", "child", ".", "getAllNodeUids", "(", ")", ")", "return", "ret" ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
TagCollection.contains
contains - Check if #em occurs within any of the elements within this list, as themselves or as a child, any number of levels down. To check if JUST an element is contained within this list directly, use the "in" operator. @param em <AdvancedTag> - Element of inte...
AdvancedHTMLParser/Tags.py
def contains(self, em): ''' contains - Check if #em occurs within any of the elements within this list, as themselves or as a child, any number of levels down. To check if JUST an element is contained within this list directly, use the "in" operator. ...
def contains(self, em): ''' contains - Check if #em occurs within any of the elements within this list, as themselves or as a child, any number of levels down. To check if JUST an element is contained within this list directly, use the "in" operator. ...
[ "contains", "-", "Check", "if", "#em", "occurs", "within", "any", "of", "the", "elements", "within", "this", "list", "as", "themselves", "or", "as", "a", "child", "any", "number", "of", "levels", "down", "." ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L2443-L2459
[ "def", "contains", "(", "self", ",", "em", ")", ":", "for", "node", "in", "self", ":", "if", "node", ".", "contains", "(", "em", ")", ":", "return", "True", "return", "False" ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
TagCollection.containsUid
containsUid - Check if #uid is the uid (unique internal identifier) of any of the elements within this list, as themselves or as a child, any number of levels down. @param uid <uuid.UUID> - uuid of interest @return <bool> - True if contained, otherwise False
AdvancedHTMLParser/Tags.py
def containsUid(self, uid): ''' containsUid - Check if #uid is the uid (unique internal identifier) of any of the elements within this list, as themselves or as a child, any number of levels down. @param uid <uuid.UUID> - uuid of interest @return <...
def containsUid(self, uid): ''' containsUid - Check if #uid is the uid (unique internal identifier) of any of the elements within this list, as themselves or as a child, any number of levels down. @param uid <uuid.UUID> - uuid of interest @return <...
[ "containsUid", "-", "Check", "if", "#uid", "is", "the", "uid", "(", "unique", "internal", "identifier", ")", "of", "any", "of", "the", "elements", "within", "this", "list", "as", "themselves", "or", "as", "a", "child", "any", "number", "of", "levels", "d...
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L2461-L2475
[ "def", "containsUid", "(", "self", ",", "uid", ")", ":", "for", "node", "in", "self", ":", "if", "node", ".", "containsUid", "(", "uid", ")", ":", "return", "True", "return", "False" ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
TagCollection.filterAll
filterAll aka filterAllAnd - Perform a filter operation on ALL nodes in this collection and all their children. Results must match ALL the filter criteria. for ANY, use the *Or methods For just the nodes in this collection, use "filter" or "filterAnd" on a TagCollection For specia...
AdvancedHTMLParser/Tags.py
def filterAll(self, **kwargs): ''' filterAll aka filterAllAnd - Perform a filter operation on ALL nodes in this collection and all their children. Results must match ALL the filter criteria. for ANY, use the *Or methods For just the nodes in this collection, use "filter" or...
def filterAll(self, **kwargs): ''' filterAll aka filterAllAnd - Perform a filter operation on ALL nodes in this collection and all their children. Results must match ALL the filter criteria. for ANY, use the *Or methods For just the nodes in this collection, use "filter" or...
[ "filterAll", "aka", "filterAllAnd", "-", "Perform", "a", "filter", "operation", "on", "ALL", "nodes", "in", "this", "collection", "and", "all", "their", "children", "." ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L2478-L2503
[ "def", "filterAll", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "canFilterTags", "is", "False", ":", "raise", "NotImplementedError", "(", "'filter methods requires QueryableList installed, it is not. Either install QueryableList, or try the less-robust \"find\" method, ...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
TagCollection.filterAllOr
filterAllOr - Perform a filter operation on ALL nodes in this collection and all their children. Results must match ANY the filter criteria. for ALL, use the *And methods For just the nodes in this collection, use "filterOr" on a TagCollection For special filter keys, @see #Advanc...
AdvancedHTMLParser/Tags.py
def filterAllOr(self, **kwargs): ''' filterAllOr - Perform a filter operation on ALL nodes in this collection and all their children. Results must match ANY the filter criteria. for ALL, use the *And methods For just the nodes in this collection, use "filterOr" on a TagColl...
def filterAllOr(self, **kwargs): ''' filterAllOr - Perform a filter operation on ALL nodes in this collection and all their children. Results must match ANY the filter criteria. for ALL, use the *And methods For just the nodes in this collection, use "filterOr" on a TagColl...
[ "filterAllOr", "-", "Perform", "a", "filter", "operation", "on", "ALL", "nodes", "in", "this", "collection", "and", "all", "their", "children", "." ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L2507-L2533
[ "def", "filterAllOr", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "canFilterTags", "is", "False", ":", "raise", "NotImplementedError", "(", "'filter methods requires QueryableList installed, it is not. Either install QueryableList, or try the less-robust \"find\" method...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
AdvancedHTMLFormatter.handle_starttag
handle_starttag - Internal for parsing
AdvancedHTMLParser/Formatter.py
def handle_starttag(self, tagName, attributeList, isSelfClosing=False): ''' handle_starttag - Internal for parsing ''' tagName = tagName.lower() inTag = self._inTag if isSelfClosing is False and tagName in IMPLICIT_SELF_CLOSING_TAGS: isSelfClosing = True ...
def handle_starttag(self, tagName, attributeList, isSelfClosing=False): ''' handle_starttag - Internal for parsing ''' tagName = tagName.lower() inTag = self._inTag if isSelfClosing is False and tagName in IMPLICIT_SELF_CLOSING_TAGS: isSelfClosing = True ...
[ "handle_starttag", "-", "Internal", "for", "parsing" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Formatter.py#L155-L182
[ "def", "handle_starttag", "(", "self", ",", "tagName", ",", "attributeList", ",", "isSelfClosing", "=", "False", ")", ":", "tagName", "=", "tagName", ".", "lower", "(", ")", "inTag", "=", "self", ".", "_inTag", "if", "isSelfClosing", "is", "False", "and", ...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
AdvancedHTMLFormatter.handle_endtag
handle_endtag - Internal for parsing
AdvancedHTMLParser/Formatter.py
def handle_endtag(self, tagName): ''' handle_endtag - Internal for parsing ''' inTag = self._inTag try: # Handle closing tags which should have been closed but weren't foundIt = False for i in range(len(inTag)): if inTag[i]....
def handle_endtag(self, tagName): ''' handle_endtag - Internal for parsing ''' inTag = self._inTag try: # Handle closing tags which should have been closed but weren't foundIt = False for i in range(len(inTag)): if inTag[i]....
[ "handle_endtag", "-", "Internal", "for", "parsing" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Formatter.py#L191-L221
[ "def", "handle_endtag", "(", "self", ",", "tagName", ")", ":", "inTag", "=", "self", ".", "_inTag", "try", ":", "# Handle closing tags which should have been closed but weren't", "foundIt", "=", "False", "for", "i", "in", "range", "(", "len", "(", "inTag", ")", ...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
AdvancedHTMLFormatter.handle_data
handle_data - Internal for parsing
AdvancedHTMLParser/Formatter.py
def handle_data(self, data): ''' handle_data - Internal for parsing ''' if data: inTag = self._inTag if len(inTag) > 0: if inTag[-1].tagName not in PRESERVE_CONTENTS_TAGS: data = data.replace('\t', ' ').strip('\r\n') ...
def handle_data(self, data): ''' handle_data - Internal for parsing ''' if data: inTag = self._inTag if len(inTag) > 0: if inTag[-1].tagName not in PRESERVE_CONTENTS_TAGS: data = data.replace('\t', ' ').strip('\r\n') ...
[ "handle_data", "-", "Internal", "for", "parsing" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Formatter.py#L223-L239
[ "def", "handle_data", "(", "self", ",", "data", ")", ":", "if", "data", ":", "inTag", "=", "self", ".", "_inTag", "if", "len", "(", "inTag", ")", ">", "0", ":", "if", "inTag", "[", "-", "1", "]", ".", "tagName", "not", "in", "PRESERVE_CONTENTS_TAGS...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
AdvancedTagSlim.getStartTag
getStartTag - Override the end-spacing rules @see AdvancedTag.getStartTag
AdvancedHTMLParser/Formatter.py
def getStartTag(self, *args, **kwargs): ''' getStartTag - Override the end-spacing rules @see AdvancedTag.getStartTag ''' ret = AdvancedTag.getStartTag(self, *args, **kwargs) if ret.endswith(' >'): ret = ret[:-2] + '>' elif object.__getatt...
def getStartTag(self, *args, **kwargs): ''' getStartTag - Override the end-spacing rules @see AdvancedTag.getStartTag ''' ret = AdvancedTag.getStartTag(self, *args, **kwargs) if ret.endswith(' >'): ret = ret[:-2] + '>' elif object.__getatt...
[ "getStartTag", "-", "Override", "the", "end", "-", "spacing", "rules" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Formatter.py#L368-L382
[ "def", "getStartTag", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "ret", "=", "AdvancedTag", ".", "getStartTag", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", "if", "ret", ".", "endswith", "(", "' >'", ")", ":...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
stripIEConditionals
stripIEConditionals - Strips Internet Explorer conditional statements. @param contents <str> - Contents String @param addHtmlIfMissing <bool> - Since these normally encompass the "html" element, optionally add it back if missing.
AdvancedHTMLParser/utils.py
def stripIEConditionals(contents, addHtmlIfMissing=True): ''' stripIEConditionals - Strips Internet Explorer conditional statements. @param contents <str> - Contents String @param addHtmlIfMissing <bool> - Since these normally encompass the "html" element, optionally add it back if missing....
def stripIEConditionals(contents, addHtmlIfMissing=True): ''' stripIEConditionals - Strips Internet Explorer conditional statements. @param contents <str> - Contents String @param addHtmlIfMissing <bool> - Since these normally encompass the "html" element, optionally add it back if missing....
[ "stripIEConditionals", "-", "Strips", "Internet", "Explorer", "conditional", "statements", "." ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/utils.py#L24-L41
[ "def", "stripIEConditionals", "(", "contents", ",", "addHtmlIfMissing", "=", "True", ")", ":", "allMatches", "=", "IE_CONDITIONAL_PATTERN", ".", "findall", "(", "contents", ")", "if", "not", "allMatches", ":", "return", "contents", "for", "match", "in", "allMatc...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
addStartTag
addStartTag - Safetly add a start tag to the document, taking into account the DOCTYPE @param contents <str> - Contents @param startTag <str> - Fully formed tag, i.e. <html>
AdvancedHTMLParser/utils.py
def addStartTag(contents, startTag): ''' addStartTag - Safetly add a start tag to the document, taking into account the DOCTYPE @param contents <str> - Contents @param startTag <str> - Fully formed tag, i.e. <html> ''' matchObj = DOCTYPE_MATCH.match(contents) if matchObj: ...
def addStartTag(contents, startTag): ''' addStartTag - Safetly add a start tag to the document, taking into account the DOCTYPE @param contents <str> - Contents @param startTag <str> - Fully formed tag, i.e. <html> ''' matchObj = DOCTYPE_MATCH.match(contents) if matchObj: ...
[ "addStartTag", "-", "Safetly", "add", "a", "start", "tag", "to", "the", "document", "taking", "into", "account", "the", "DOCTYPE" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/utils.py#L44-L57
[ "def", "addStartTag", "(", "contents", ",", "startTag", ")", ":", "matchObj", "=", "DOCTYPE_MATCH", ".", "match", "(", "contents", ")", "if", "matchObj", ":", "idx", "=", "matchObj", ".", "end", "(", ")", "else", ":", "idx", "=", "0", "return", "\"%s\\...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
ValidatingAdvancedHTMLParser.handle_endtag
Internal for parsing
AdvancedHTMLParser/Validator.py
def handle_endtag(self, tagName): ''' Internal for parsing ''' inTag = self._inTag if len(inTag) == 0: # Attempted to close, but no open tags raise InvalidCloseException(tagName, []) foundIt = False i = len(inTag) - 1 while i >...
def handle_endtag(self, tagName): ''' Internal for parsing ''' inTag = self._inTag if len(inTag) == 0: # Attempted to close, but no open tags raise InvalidCloseException(tagName, []) foundIt = False i = len(inTag) - 1 while i >...
[ "Internal", "for", "parsing" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Validator.py#L20-L44
[ "def", "handle_endtag", "(", "self", ",", "tagName", ")", ":", "inTag", "=", "self", ".", "_inTag", "if", "len", "(", "inTag", ")", "==", "0", ":", "# Attempted to close, but no open tags", "raise", "InvalidCloseException", "(", "tagName", ",", "[", "]", ")"...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
convertToBooleanString
convertToBooleanString - Converts a value to either a string of "true" or "false" @param val <int/str/bool> - Value
AdvancedHTMLParser/conversions.py
def convertToBooleanString(val=None): ''' convertToBooleanString - Converts a value to either a string of "true" or "false" @param val <int/str/bool> - Value ''' if hasattr(val, 'lower'): val = val.lower() # Technically, if you set one of these attributes (like "spellch...
def convertToBooleanString(val=None): ''' convertToBooleanString - Converts a value to either a string of "true" or "false" @param val <int/str/bool> - Value ''' if hasattr(val, 'lower'): val = val.lower() # Technically, if you set one of these attributes (like "spellch...
[ "convertToBooleanString", "-", "Converts", "a", "value", "to", "either", "a", "string", "of", "true", "or", "false" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/conversions.py#L38-L60
[ "def", "convertToBooleanString", "(", "val", "=", "None", ")", ":", "if", "hasattr", "(", "val", ",", "'lower'", ")", ":", "val", "=", "val", ".", "lower", "(", ")", "# Technically, if you set one of these attributes (like \"spellcheck\") to a string of 'false',", "# ...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
convertBooleanStringToBoolean
convertBooleanStringToBoolean - Convert from a boolean attribute (string "true" / "false" ) into a booelan
AdvancedHTMLParser/conversions.py
def convertBooleanStringToBoolean(val=None): ''' convertBooleanStringToBoolean - Convert from a boolean attribute (string "true" / "false" ) into a booelan ''' if not val: return False if hasattr(val, 'lower'): val = val.lower() if val == "false": return False r...
def convertBooleanStringToBoolean(val=None): ''' convertBooleanStringToBoolean - Convert from a boolean attribute (string "true" / "false" ) into a booelan ''' if not val: return False if hasattr(val, 'lower'): val = val.lower() if val == "false": return False r...
[ "convertBooleanStringToBoolean", "-", "Convert", "from", "a", "boolean", "attribute", "(", "string", "true", "/", "false", ")", "into", "a", "booelan" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/conversions.py#L62-L74
[ "def", "convertBooleanStringToBoolean", "(", "val", "=", "None", ")", ":", "if", "not", "val", ":", "return", "False", "if", "hasattr", "(", "val", ",", "'lower'", ")", ":", "val", "=", "val", ".", "lower", "(", ")", "if", "val", "==", "\"false\"", "...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
convertToPositiveInt
convertToPositiveInt - Convert to a positive integer, and if invalid use a given value
AdvancedHTMLParser/conversions.py
def convertToPositiveInt(val=None, invalidDefault=0): ''' convertToPositiveInt - Convert to a positive integer, and if invalid use a given value ''' if val is None: return invalidDefault try: val = int(val) except: return invalidDefault if val < 0: retur...
def convertToPositiveInt(val=None, invalidDefault=0): ''' convertToPositiveInt - Convert to a positive integer, and if invalid use a given value ''' if val is None: return invalidDefault try: val = int(val) except: return invalidDefault if val < 0: retur...
[ "convertToPositiveInt", "-", "Convert", "to", "a", "positive", "integer", "and", "if", "invalid", "use", "a", "given", "value" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/conversions.py#L77-L92
[ "def", "convertToPositiveInt", "(", "val", "=", "None", ",", "invalidDefault", "=", "0", ")", ":", "if", "val", "is", "None", ":", "return", "invalidDefault", "try", ":", "val", "=", "int", "(", "val", ")", "except", ":", "return", "invalidDefault", "if"...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
_handleInvalid
_handleInvalid - Common code for raising / returning an invalid value @param invalidDefault <None/str/Exception> - The value to return if "val" is not empty string/None and "val" is not in #possibleValues If instantiated Excep...
AdvancedHTMLParser/conversions.py
def _handleInvalid(invalidDefault): ''' _handleInvalid - Common code for raising / returning an invalid value @param invalidDefault <None/str/Exception> - The value to return if "val" is not empty string/None and "val" is not in #possib...
def _handleInvalid(invalidDefault): ''' _handleInvalid - Common code for raising / returning an invalid value @param invalidDefault <None/str/Exception> - The value to return if "val" is not empty string/None and "val" is not in #possib...
[ "_handleInvalid", "-", "Common", "code", "for", "raising", "/", "returning", "an", "invalid", "value" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/conversions.py#L94-L127
[ "def", "_handleInvalid", "(", "invalidDefault", ")", ":", "# If not", "# If an instantiated Exception, raise that exception", "try", ":", "isInstantiatedException", "=", "bool", "(", "issubclass", "(", "invalidDefault", ".", "__class__", ",", "Exception", ")", ")", "e...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
convertPossibleValues
convertPossibleValues - Convert input value to one of several possible values, with a default for invalid entries @param val <None/str> - The input value @param possibleValues list<str> - A list of possible values @param invalidDefa...
AdvancedHTMLParser/conversions.py
def convertPossibleValues(val, possibleValues, invalidDefault, emptyValue=''): ''' convertPossibleValues - Convert input value to one of several possible values, with a default for invalid entries @param val <None/str> - The input value ...
def convertPossibleValues(val, possibleValues, invalidDefault, emptyValue=''): ''' convertPossibleValues - Convert input value to one of several possible values, with a default for invalid entries @param val <None/str> - The input value ...
[ "convertPossibleValues", "-", "Convert", "input", "value", "to", "one", "of", "several", "possible", "values", "with", "a", "default", "for", "invalid", "entries" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/conversions.py#L130-L174
[ "def", "convertPossibleValues", "(", "val", ",", "possibleValues", ",", "invalidDefault", ",", "emptyValue", "=", "''", ")", ":", "from", ".", "utils", "import", "tostr", "# If null, retain null", "if", "val", "is", "None", ":", "if", "emptyValue", "is", "EMPT...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
convertToIntRange
converToIntRange - Convert input value to an integer within a certain range @param val <None/str/int/float> - The input value @param minValue <None/int> - The minimum value (inclusive), or None if no minimum @param maxValue <None/int> - The maximum value (inclusive), o...
AdvancedHTMLParser/conversions.py
def convertToIntRange(val, minValue, maxValue, invalidDefault, emptyValue=''): ''' converToIntRange - Convert input value to an integer within a certain range @param val <None/str/int/float> - The input value @param minValue <None/int> - The minimum value (inclusive), o...
def convertToIntRange(val, minValue, maxValue, invalidDefault, emptyValue=''): ''' converToIntRange - Convert input value to an integer within a certain range @param val <None/str/int/float> - The input value @param minValue <None/int> - The minimum value (inclusive), o...
[ "converToIntRange", "-", "Convert", "input", "value", "to", "an", "integer", "within", "a", "certain", "range", "@param", "val", "<None", "/", "str", "/", "int", "/", "float", ">", "-", "The", "input", "value" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/conversions.py#L177-L218
[ "def", "convertToIntRange", "(", "val", ",", "minValue", ",", "maxValue", ",", "invalidDefault", ",", "emptyValue", "=", "''", ")", ":", "from", ".", "utils", "import", "tostr", "# If null, retain null", "if", "val", "is", "None", "or", "val", "==", "''", ...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
SpecialAttributesDict._setTag
_setTag - INTERNAL METHOD. Associated a given AdvancedTag to this attributes dict. If bool(#tag) is True, will set the weakref to that tag. Otherwise, will clear the reference @param tag <AdvancedTag/None> - Either the AdvancedTag to associate, or...
AdvancedHTMLParser/SpecialAttributes.py
def _setTag(self, tag): ''' _setTag - INTERNAL METHOD. Associated a given AdvancedTag to this attributes dict. If bool(#tag) is True, will set the weakref to that tag. Otherwise, will clear the reference @param tag <AdvancedTag...
def _setTag(self, tag): ''' _setTag - INTERNAL METHOD. Associated a given AdvancedTag to this attributes dict. If bool(#tag) is True, will set the weakref to that tag. Otherwise, will clear the reference @param tag <AdvancedTag...
[ "_setTag", "-", "INTERNAL", "METHOD", ".", "Associated", "a", "given", "AdvancedTag", "to", "this", "attributes", "dict", "." ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/SpecialAttributes.py#L46-L59
[ "def", "_setTag", "(", "self", ",", "tag", ")", ":", "if", "tag", ":", "self", ".", "_tagRef", "=", "weakref", ".", "ref", "(", "tag", ")", "else", ":", "self", ".", "_tagRef", "=", "None" ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
SpecialAttributesDict._handleClassAttr
_handleClassAttr - Hack to ensure "class" and "style" show up in attributes when classes are set, and doesn't when no classes are present on associated tag. TODO: I don't like this hack.
AdvancedHTMLParser/SpecialAttributes.py
def _handleClassAttr(self): ''' _handleClassAttr - Hack to ensure "class" and "style" show up in attributes when classes are set, and doesn't when no classes are present on associated tag. TODO: I don't like this hack. ''' if len(self.tag._classNames)...
def _handleClassAttr(self): ''' _handleClassAttr - Hack to ensure "class" and "style" show up in attributes when classes are set, and doesn't when no classes are present on associated tag. TODO: I don't like this hack. ''' if len(self.tag._classNames)...
[ "_handleClassAttr", "-", "Hack", "to", "ensure", "class", "and", "style", "show", "up", "in", "attributes", "when", "classes", "are", "set", "and", "doesn", "t", "when", "no", "classes", "are", "present", "on", "associated", "tag", "." ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/SpecialAttributes.py#L151-L173
[ "def", "_handleClassAttr", "(", "self", ")", ":", "if", "len", "(", "self", ".", "tag", ".", "_classNames", ")", ">", "0", ":", "dict", ".", "__setitem__", "(", "self", ",", "\"class\"", ",", "self", ".", "tag", ".", "className", ")", "else", ":", ...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
SpecialAttributesDict.get
get - Gets an attribute by key with the chance to provide a default value @param key <str> - The key to query @param default <Anything> Default None - The value to return if key is not found @return - The value of attribute at #key, or #default if not present.
AdvancedHTMLParser/SpecialAttributes.py
def get(self, key, default=None): ''' get - Gets an attribute by key with the chance to provide a default value @param key <str> - The key to query @param default <Anything> Default None - The value to return if key is not found @return - The value of ...
def get(self, key, default=None): ''' get - Gets an attribute by key with the chance to provide a default value @param key <str> - The key to query @param default <Anything> Default None - The value to return if key is not found @return - The value of ...
[ "get", "-", "Gets", "an", "attribute", "by", "key", "with", "the", "chance", "to", "provide", "a", "default", "value" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/SpecialAttributes.py#L187-L205
[ "def", "get", "(", "self", ",", "key", ",", "default", "=", "None", ")", ":", "key", "=", "key", ".", "lower", "(", ")", "if", "key", "==", "'class'", ":", "return", "self", ".", "tag", ".", "className", "if", "key", "in", "(", "'style'", ",", ...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
SpecialAttributesDict._direct_set
_direct_set - INTERNAL USE ONLY!!!! Directly sets a value on the underlying dict, without running through the setitem logic
AdvancedHTMLParser/SpecialAttributes.py
def _direct_set(self, key, value): ''' _direct_set - INTERNAL USE ONLY!!!! Directly sets a value on the underlying dict, without running through the setitem logic ''' dict.__setitem__(self, key, value) return value
def _direct_set(self, key, value): ''' _direct_set - INTERNAL USE ONLY!!!! Directly sets a value on the underlying dict, without running through the setitem logic ''' dict.__setitem__(self, key, value) return value
[ "_direct_set", "-", "INTERNAL", "USE", "ONLY!!!!" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/SpecialAttributes.py#L207-L215
[ "def", "_direct_set", "(", "self", ",", "key", ",", "value", ")", ":", "dict", ".", "__setitem__", "(", "self", ",", "key", ",", "value", ")", "return", "value" ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
StyleAttribute.setTag
setTag - Set the tag association for this style. This will handle the underlying weakref to the tag. Call setTag(None) to clear the association, otherwise setTag(tag) to associate this style to that tag. @param tag <AdvancedTag/None> - The new association. If ...
AdvancedHTMLParser/SpecialAttributes.py
def setTag(self, tag): ''' setTag - Set the tag association for this style. This will handle the underlying weakref to the tag. Call setTag(None) to clear the association, otherwise setTag(tag) to associate this style to that tag. @param ta...
def setTag(self, tag): ''' setTag - Set the tag association for this style. This will handle the underlying weakref to the tag. Call setTag(None) to clear the association, otherwise setTag(tag) to associate this style to that tag. @param ta...
[ "setTag", "-", "Set", "the", "tag", "association", "for", "this", "style", ".", "This", "will", "handle", "the", "underlying", "weakref", "to", "the", "tag", "." ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/SpecialAttributes.py#L445-L462
[ "def", "setTag", "(", "self", ",", "tag", ")", ":", "if", "tag", ":", "self", ".", "_tagRef", "=", "weakref", ".", "ref", "(", "tag", ")", "else", ":", "self", ".", "_tagRef", "=", "None" ]
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
StyleAttribute._ensureHtmlAttribute
_ensureHtmlAttribute - INTERNAL METHOD. Ensure the "style" attribute is present in the html attributes when is has a value, and absent when it does not. This requires special linkage.
AdvancedHTMLParser/SpecialAttributes.py
def _ensureHtmlAttribute(self): ''' _ensureHtmlAttribute - INTERNAL METHOD. Ensure the "style" attribute is present in the html attributes when is has a value, and absent when it does not. This requires speci...
def _ensureHtmlAttribute(self): ''' _ensureHtmlAttribute - INTERNAL METHOD. Ensure the "style" attribute is present in the html attributes when is has a value, and absent when it does not. This requires speci...
[ "_ensureHtmlAttribute", "-", "INTERNAL", "METHOD", ".", "Ensure", "the", "style", "attribute", "is", "present", "in", "the", "html", "attributes", "when", "is", "has", "a", "value", "and", "absent", "when", "it", "does", "not", "." ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/SpecialAttributes.py#L519-L542
[ "def", "_ensureHtmlAttribute", "(", "self", ")", ":", "tag", "=", "self", ".", "tag", "if", "tag", ":", "styleDict", "=", "self", ".", "_styleDict", "tagAttributes", "=", "tag", ".", "_attributes", "# If this is called before we have _attributes setup", "if", "not...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
StyleAttribute.setProperty
setProperty - Set a style property to a value. NOTE: To remove a style, use a value of empty string, or None @param name <str> - The style name. NOTE: The dash names are expected here, whereas dot-access expects the camel case names. Example...
AdvancedHTMLParser/SpecialAttributes.py
def setProperty(self, name, value): ''' setProperty - Set a style property to a value. NOTE: To remove a style, use a value of empty string, or None @param name <str> - The style name. NOTE: The dash names are expected here, whereas dot-access ...
def setProperty(self, name, value): ''' setProperty - Set a style property to a value. NOTE: To remove a style, use a value of empty string, or None @param name <str> - The style name. NOTE: The dash names are expected here, whereas dot-access ...
[ "setProperty", "-", "Set", "a", "style", "property", "to", "a", "value", "." ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/SpecialAttributes.py#L555-L577
[ "def", "setProperty", "(", "self", ",", "name", ",", "value", ")", ":", "styleDict", "=", "self", ".", "_styleDict", "if", "value", "in", "(", "''", ",", "None", ")", ":", "try", ":", "del", "styleDict", "[", "name", "]", "except", "KeyError", ":", ...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
StyleAttribute.dashNameToCamelCase
dashNameToCamelCase - Converts a "dash name" (like padding-top) to its camel-case name ( like "paddingTop" ) @param dashName <str> - A name containing dashes NOTE: This method is currently unused, but may be used in the future. kept for completeness. @return <str> - The camel-...
AdvancedHTMLParser/SpecialAttributes.py
def dashNameToCamelCase(dashName): ''' dashNameToCamelCase - Converts a "dash name" (like padding-top) to its camel-case name ( like "paddingTop" ) @param dashName <str> - A name containing dashes NOTE: This method is currently unused, but may be used in the future. kep...
def dashNameToCamelCase(dashName): ''' dashNameToCamelCase - Converts a "dash name" (like padding-top) to its camel-case name ( like "paddingTop" ) @param dashName <str> - A name containing dashes NOTE: This method is currently unused, but may be used in the future. kep...
[ "dashNameToCamelCase", "-", "Converts", "a", "dash", "name", "(", "like", "padding", "-", "top", ")", "to", "its", "camel", "-", "case", "name", "(", "like", "paddingTop", ")" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/SpecialAttributes.py#L598-L612
[ "def", "dashNameToCamelCase", "(", "dashName", ")", ":", "nameParts", "=", "dashName", ".", "split", "(", "'-'", ")", "for", "i", "in", "range", "(", "1", ",", "len", "(", "nameParts", ")", ",", "1", ")", ":", "nameParts", "[", "i", "]", "[", "0", ...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
StyleAttribute.camelCaseToDashName
camelCaseToDashName - Convert a camel case name to a dash-name (like paddingTop to padding-top) @param camelCase <str> - A camel-case string @return <str> - A dash-name
AdvancedHTMLParser/SpecialAttributes.py
def camelCaseToDashName(camelCase): ''' camelCaseToDashName - Convert a camel case name to a dash-name (like paddingTop to padding-top) @param camelCase <str> - A camel-case string @return <str> - A dash-name ''' camelCaseList = list(camelCase) ret...
def camelCaseToDashName(camelCase): ''' camelCaseToDashName - Convert a camel case name to a dash-name (like paddingTop to padding-top) @param camelCase <str> - A camel-case string @return <str> - A dash-name ''' camelCaseList = list(camelCase) ret...
[ "camelCaseToDashName", "-", "Convert", "a", "camel", "case", "name", "to", "a", "dash", "-", "name", "(", "like", "paddingTop", "to", "padding", "-", "top", ")" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/SpecialAttributes.py#L615-L635
[ "def", "camelCaseToDashName", "(", "camelCase", ")", ":", "camelCaseList", "=", "list", "(", "camelCase", ")", "ret", "=", "[", "]", "for", "ch", "in", "camelCaseList", ":", "if", "ch", ".", "isupper", "(", ")", ":", "ret", ".", "append", "(", "'-'", ...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
StyleAttribute.styleToDict
getStyleDict - Gets a dictionary of style attribute/value pairs. NOTE: dash-names (like padding-top) are used here @return - OrderedDict of "style" attribute.
AdvancedHTMLParser/SpecialAttributes.py
def styleToDict(styleStr): ''' getStyleDict - Gets a dictionary of style attribute/value pairs. NOTE: dash-names (like padding-top) are used here @return - OrderedDict of "style" attribute. ''' styleStr = styleStr.strip() styles = styleStr.split(';...
def styleToDict(styleStr): ''' getStyleDict - Gets a dictionary of style attribute/value pairs. NOTE: dash-names (like padding-top) are used here @return - OrderedDict of "style" attribute. ''' styleStr = styleStr.strip() styles = styleStr.split(';...
[ "getStyleDict", "-", "Gets", "a", "dictionary", "of", "style", "attribute", "/", "value", "pairs", "." ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/SpecialAttributes.py#L638-L659
[ "def", "styleToDict", "(", "styleStr", ")", ":", "styleStr", "=", "styleStr", ".", "strip", "(", ")", "styles", "=", "styleStr", ".", "split", "(", "';'", ")", "# Won't work for strings containing semicolon..", "styleDict", "=", "OrderedDict", "(", ")", "for", ...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
StyleAttribute._asStr
_asStr - Get the string representation of this style @return <str> - A string representation of this style (semicolon separated, key: value format)
AdvancedHTMLParser/SpecialAttributes.py
def _asStr(self): ''' _asStr - Get the string representation of this style @return <str> - A string representation of this style (semicolon separated, key: value format) ''' styleDict = self._styleDict if styleDict: return '; '.join([name + ': ' + ...
def _asStr(self): ''' _asStr - Get the string representation of this style @return <str> - A string representation of this style (semicolon separated, key: value format) ''' styleDict = self._styleDict if styleDict: return '; '.join([name + ': ' + ...
[ "_asStr", "-", "Get", "the", "string", "representation", "of", "this", "style" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/SpecialAttributes.py#L738-L748
[ "def", "_asStr", "(", "self", ")", ":", "styleDict", "=", "self", ".", "_styleDict", "if", "styleDict", ":", "return", "'; '", ".", "join", "(", "[", "name", "+", "': '", "+", "value", "for", "name", ",", "value", "in", "styleDict", ".", "items", "("...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
_special_value_rows
_special_value_rows - Handle "rows" special attribute, which differs if tagName is a textarea or frameset
AdvancedHTMLParser/constants.py
def _special_value_rows(em): ''' _special_value_rows - Handle "rows" special attribute, which differs if tagName is a textarea or frameset ''' if em.tagName == 'textarea': return convertToIntRange(em.getAttribute('rows', 2), minValue=1, maxValue=None, invalidDefault=2) else: # fr...
def _special_value_rows(em): ''' _special_value_rows - Handle "rows" special attribute, which differs if tagName is a textarea or frameset ''' if em.tagName == 'textarea': return convertToIntRange(em.getAttribute('rows', 2), minValue=1, maxValue=None, invalidDefault=2) else: # fr...
[ "_special_value_rows", "-", "Handle", "rows", "special", "attribute", "which", "differs", "if", "tagName", "is", "a", "textarea", "or", "frameset" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/constants.py#L248-L256
[ "def", "_special_value_rows", "(", "em", ")", ":", "if", "em", ".", "tagName", "==", "'textarea'", ":", "return", "convertToIntRange", "(", "em", ".", "getAttribute", "(", "'rows'", ",", "2", ")", ",", "minValue", "=", "1", ",", "maxValue", "=", "None", ...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
_special_value_cols
_special_value_cols - Handle "cols" special attribute, which differs if tagName is a textarea or frameset
AdvancedHTMLParser/constants.py
def _special_value_cols(em): ''' _special_value_cols - Handle "cols" special attribute, which differs if tagName is a textarea or frameset ''' if em.tagName == 'textarea': return convertToIntRange(em.getAttribute('cols', 20), minValue=1, maxValue=None, invalidDefault=20) else: # ...
def _special_value_cols(em): ''' _special_value_cols - Handle "cols" special attribute, which differs if tagName is a textarea or frameset ''' if em.tagName == 'textarea': return convertToIntRange(em.getAttribute('cols', 20), minValue=1, maxValue=None, invalidDefault=20) else: # ...
[ "_special_value_cols", "-", "Handle", "cols", "special", "attribute", "which", "differs", "if", "tagName", "is", "a", "textarea", "or", "frameset" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/constants.py#L258-L266
[ "def", "_special_value_cols", "(", "em", ")", ":", "if", "em", ".", "tagName", "==", "'textarea'", ":", "return", "convertToIntRange", "(", "em", ".", "getAttribute", "(", "'cols'", ",", "20", ")", ",", "minValue", "=", "1", ",", "maxValue", "=", "None",...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
_special_value_autocomplete
handle "autocomplete" property, which has different behaviour for form vs input"
AdvancedHTMLParser/constants.py
def _special_value_autocomplete(em): ''' handle "autocomplete" property, which has different behaviour for form vs input" ''' if em.tagName == 'form': return convertPossibleValues(em.getAttribute('autocomplete', 'on'), POSSIBLE_VALUES_ON_OFF, invalidDefault='on', emptyValue=EMPTY_IS_INVALID)...
def _special_value_autocomplete(em): ''' handle "autocomplete" property, which has different behaviour for form vs input" ''' if em.tagName == 'form': return convertPossibleValues(em.getAttribute('autocomplete', 'on'), POSSIBLE_VALUES_ON_OFF, invalidDefault='on', emptyValue=EMPTY_IS_INVALID)...
[ "handle", "autocomplete", "property", "which", "has", "different", "behaviour", "for", "form", "vs", "input" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/constants.py#L268-L275
[ "def", "_special_value_autocomplete", "(", "em", ")", ":", "if", "em", ".", "tagName", "==", "'form'", ":", "return", "convertPossibleValues", "(", "em", ".", "getAttribute", "(", "'autocomplete'", ",", "'on'", ")", ",", "POSSIBLE_VALUES_ON_OFF", ",", "invalidDe...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
_special_value_size
handle "size" property, which has different behaviour for input vs everything else
AdvancedHTMLParser/constants.py
def _special_value_size(em): ''' handle "size" property, which has different behaviour for input vs everything else ''' if em.tagName == 'input': # TODO: "size" on an input is implemented very weirdly. Negative values are treated as invalid, # A value of "0" raises an except...
def _special_value_size(em): ''' handle "size" property, which has different behaviour for input vs everything else ''' if em.tagName == 'input': # TODO: "size" on an input is implemented very weirdly. Negative values are treated as invalid, # A value of "0" raises an except...
[ "handle", "size", "property", "which", "has", "different", "behaviour", "for", "input", "vs", "everything", "else" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/constants.py#L277-L286
[ "def", "_special_value_size", "(", "em", ")", ":", "if", "em", ".", "tagName", "==", "'input'", ":", "# TODO: \"size\" on an input is implemented very weirdly. Negative values are treated as invalid,", "# A value of \"0\" raises an exception (and does not set HTML attribute)", ...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
_special_value_maxLength
_special_value_maxLength - Handle the special "maxLength" property @param em <AdvancedTag> - The tag element @param newValue - Default NOT_PROVIDED, if provided will use that value instead of the current .getAttribute value on the tag. This is because this method can be used f...
AdvancedHTMLParser/constants.py
def _special_value_maxLength(em, newValue=NOT_PROVIDED): ''' _special_value_maxLength - Handle the special "maxLength" property @param em <AdvancedTag> - The tag element @param newValue - Default NOT_PROVIDED, if provided will use that value instead of the current ...
def _special_value_maxLength(em, newValue=NOT_PROVIDED): ''' _special_value_maxLength - Handle the special "maxLength" property @param em <AdvancedTag> - The tag element @param newValue - Default NOT_PROVIDED, if provided will use that value instead of the current ...
[ "_special_value_maxLength", "-", "Handle", "the", "special", "maxLength", "property" ]
kata198/AdvancedHTMLParser
python
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/constants.py#L300-L327
[ "def", "_special_value_maxLength", "(", "em", ",", "newValue", "=", "NOT_PROVIDED", ")", ":", "if", "newValue", "is", "NOT_PROVIDED", ":", "if", "not", "em", ".", "hasAttribute", "(", "'maxlength'", ")", ":", "return", "-", "1", "curValue", "=", "em", ".",...
06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d
train
DataObject.get_by_value
Converts a value into a corresponding data object. For files, this looks up a file DataObject by name, uuid, and/or md5. For other types, it creates a new DataObject.
server/loomengine_server/api/models/data_objects.py
def get_by_value(cls, value, type): """ Converts a value into a corresponding data object. For files, this looks up a file DataObject by name, uuid, and/or md5. For other types, it creates a new DataObject. """ if type == 'file': return cls._get_file_by_value(value) ...
def get_by_value(cls, value, type): """ Converts a value into a corresponding data object. For files, this looks up a file DataObject by name, uuid, and/or md5. For other types, it creates a new DataObject. """ if type == 'file': return cls._get_file_by_value(value) ...
[ "Converts", "a", "value", "into", "a", "corresponding", "data", "object", ".", "For", "files", "this", "looks", "up", "a", "file", "DataObject", "by", "name", "uuid", "and", "/", "or", "md5", ".", "For", "other", "types", "it", "creates", "a", "new", "...
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/server/loomengine_server/api/models/data_objects.py#L55-L67
[ "def", "get_by_value", "(", "cls", ",", "value", ",", "type", ")", ":", "if", "type", "==", "'file'", ":", "return", "cls", ".", "_get_file_by_value", "(", "value", ")", "else", ":", "data_object", "=", "DataObject", "(", "data", "=", "{", "'value'", "...
db2031a1a87124fee1aeb7414a668c03d774a698
train
DataObject._get_file_by_value
Look up a file DataObject by name, uuid, and/or md5.
server/loomengine_server/api/models/data_objects.py
def _get_file_by_value(cls, value): """Look up a file DataObject by name, uuid, and/or md5. """ # Ignore any FileResource with no DataObject. This is a typical state # for a deleted file that has not yet been cleaned up. queryset = FileResource.objects.exclude(data_object__isnull...
def _get_file_by_value(cls, value): """Look up a file DataObject by name, uuid, and/or md5. """ # Ignore any FileResource with no DataObject. This is a typical state # for a deleted file that has not yet been cleaned up. queryset = FileResource.objects.exclude(data_object__isnull...
[ "Look", "up", "a", "file", "DataObject", "by", "name", "uuid", "and", "/", "or", "md5", "." ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/server/loomengine_server/api/models/data_objects.py#L87-L106
[ "def", "_get_file_by_value", "(", "cls", ",", "value", ")", ":", "# Ignore any FileResource with no DataObject. This is a typical state", "# for a deleted file that has not yet been cleaned up.", "queryset", "=", "FileResource", ".", "objects", ".", "exclude", "(", "data_object__...
db2031a1a87124fee1aeb7414a668c03d774a698
train
FileResource._get_run_breadcrumbs
Create a path for a given file, in such a way that files end up being organized and browsable by run
server/loomengine_server/api/models/data_objects.py
def _get_run_breadcrumbs(cls, source_type, data_object, task_attempt): """Create a path for a given file, in such a way that files end up being organized and browsable by run """ # We cannot generate the path unless connect to a TaskAttempt # and a run if not task_attempt...
def _get_run_breadcrumbs(cls, source_type, data_object, task_attempt): """Create a path for a given file, in such a way that files end up being organized and browsable by run """ # We cannot generate the path unless connect to a TaskAttempt # and a run if not task_attempt...
[ "Create", "a", "path", "for", "a", "given", "file", "in", "such", "a", "way", "that", "files", "end", "up", "being", "organized", "and", "browsable", "by", "run" ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/server/loomengine_server/api/models/data_objects.py#L384-L418
[ "def", "_get_run_breadcrumbs", "(", "cls", ",", "source_type", ",", "data_object", ",", "task_attempt", ")", ":", "# We cannot generate the path unless connect to a TaskAttempt", "# and a run", "if", "not", "task_attempt", ":", "return", "[", "]", "# If multiple tasks exist...
db2031a1a87124fee1aeb7414a668c03d774a698
train
FilterHelper.filter_by_name_or_id_or_tag
Find objects that match the identifier of form {name}@{ID}, {name}, or @{ID}, where ID may be truncated
server/loomengine_server/api/models/base.py
def filter_by_name_or_id_or_tag(self, query_string, queryset = None): """Find objects that match the identifier of form {name}@{ID}, {name}, or @{ID}, where ID may be truncated """ assert self.Model.NAME_FIELD, \ 'NAME_FIELD is missing on model %s' % self.Model.__name__ ...
def filter_by_name_or_id_or_tag(self, query_string, queryset = None): """Find objects that match the identifier of form {name}@{ID}, {name}, or @{ID}, where ID may be truncated """ assert self.Model.NAME_FIELD, \ 'NAME_FIELD is missing on model %s' % self.Model.__name__ ...
[ "Find", "objects", "that", "match", "the", "identifier", "of", "form", "{", "name", "}" ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/server/loomengine_server/api/models/base.py#L126-L147
[ "def", "filter_by_name_or_id_or_tag", "(", "self", ",", "query_string", ",", "queryset", "=", "None", ")", ":", "assert", "self", ".", "Model", ".", "NAME_FIELD", ",", "'NAME_FIELD is missing on model %s'", "%", "self", ".", "Model", ".", "__name__", "assert", "...
db2031a1a87124fee1aeb7414a668c03d774a698
train
BaseModel.save
This save method protects against two processesses concurrently modifying the same object. Normally the second save would silently overwrite the changes from the first. Instead we raise a ConcurrentModificationError.
server/loomengine_server/api/models/base.py
def save(self, *args, **kwargs): """ This save method protects against two processesses concurrently modifying the same object. Normally the second save would silently overwrite the changes from the first. Instead we raise a ConcurrentModificationError. """ cls = self.__c...
def save(self, *args, **kwargs): """ This save method protects against two processesses concurrently modifying the same object. Normally the second save would silently overwrite the changes from the first. Instead we raise a ConcurrentModificationError. """ cls = self.__c...
[ "This", "save", "method", "protects", "against", "two", "processesses", "concurrently", "modifying", "the", "same", "object", ".", "Normally", "the", "second", "save", "would", "silently", "overwrite", "the", "changes", "from", "the", "first", ".", "Instead", "w...
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/server/loomengine_server/api/models/base.py#L225-L248
[ "def", "save", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "cls", "=", "self", ".", "__class__", "if", "self", ".", "pk", ":", "rows", "=", "cls", ".", "objects", ".", "filter", "(", "pk", "=", "self", ".", "pk", ",", "_...
db2031a1a87124fee1aeb7414a668c03d774a698
train
BaseModel.setattrs_and_save_with_retries
If the object is being edited by other processes, save may fail due to concurrent modification. This method recovers and retries the edit. assignments is a dict of {attribute: value}
server/loomengine_server/api/models/base.py
def setattrs_and_save_with_retries(self, assignments, max_retries=5): """ If the object is being edited by other processes, save may fail due to concurrent modification. This method recovers and retries the edit. assignments is a dict of {attribute: value} """ co...
def setattrs_and_save_with_retries(self, assignments, max_retries=5): """ If the object is being edited by other processes, save may fail due to concurrent modification. This method recovers and retries the edit. assignments is a dict of {attribute: value} """ co...
[ "If", "the", "object", "is", "being", "edited", "by", "other", "processes", "save", "may", "fail", "due", "to", "concurrent", "modification", ".", "This", "method", "recovers", "and", "retries", "the", "edit", "." ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/server/loomengine_server/api/models/base.py#L250-L275
[ "def", "setattrs_and_save_with_retries", "(", "self", ",", "assignments", ",", "max_retries", "=", "5", ")", ":", "count", "=", "0", "obj", "=", "self", "while", "True", ":", "for", "attribute", ",", "value", "in", "assignments", ".", "iteritems", "(", ")"...
db2031a1a87124fee1aeb7414a668c03d774a698
train
BaseModel.delete
This method implements retries for object deletion.
server/loomengine_server/api/models/base.py
def delete(self, *args, **kwargs): """ This method implements retries for object deletion. """ count = 0 max_retries=3 while True: try: return super(BaseModel, self).delete(*args, **kwargs) except django.db.utils.OperationalError: ...
def delete(self, *args, **kwargs): """ This method implements retries for object deletion. """ count = 0 max_retries=3 while True: try: return super(BaseModel, self).delete(*args, **kwargs) except django.db.utils.OperationalError: ...
[ "This", "method", "implements", "retries", "for", "object", "deletion", "." ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/server/loomengine_server/api/models/base.py#L277-L289
[ "def", "delete", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "count", "=", "0", "max_retries", "=", "3", "while", "True", ":", "try", ":", "return", "super", "(", "BaseModel", ",", "self", ")", ".", "delete", "(", "*", "args...
db2031a1a87124fee1aeb7414a668c03d774a698
train
get_server_type
Checks server.ini for server type.
client/loomengine/common.py
def get_server_type(): """Checks server.ini for server type.""" server_location_file = os.path.expanduser(SERVER_LOCATION_FILE) if not os.path.exists(server_location_file): raise Exception( "%s not found. Please run 'loom server set " "<servertype>' first." % server_location_...
def get_server_type(): """Checks server.ini for server type.""" server_location_file = os.path.expanduser(SERVER_LOCATION_FILE) if not os.path.exists(server_location_file): raise Exception( "%s not found. Please run 'loom server set " "<servertype>' first." % server_location_...
[ "Checks", "server", ".", "ini", "for", "server", "type", "." ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/client/loomengine/common.py#L110-L120
[ "def", "get_server_type", "(", ")", ":", "server_location_file", "=", "os", ".", "path", ".", "expanduser", "(", "SERVER_LOCATION_FILE", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "server_location_file", ")", ":", "raise", "Exception", "(", "\"...
db2031a1a87124fee1aeb7414a668c03d774a698
train
ImportManager._set_upload_status
Set file_data_object.file_resource.upload_status
utils/loomengine_utils/import_manager.py
def _set_upload_status(self, file_data_object, upload_status): """ Set file_data_object.file_resource.upload_status """ uuid = file_data_object['uuid'] return self.connection.update_data_object( uuid, {'uuid': uuid, 'value': { 'upload_status': upload_status}} ...
def _set_upload_status(self, file_data_object, upload_status): """ Set file_data_object.file_resource.upload_status """ uuid = file_data_object['uuid'] return self.connection.update_data_object( uuid, {'uuid': uuid, 'value': { 'upload_status': upload_status}} ...
[ "Set", "file_data_object", ".", "file_resource", ".", "upload_status" ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/utils/loomengine_utils/import_manager.py#L406-L413
[ "def", "_set_upload_status", "(", "self", ",", "file_data_object", ",", "upload_status", ")", ":", "uuid", "=", "file_data_object", "[", "'uuid'", "]", "return", "self", ".", "connection", ".", "update_data_object", "(", "uuid", ",", "{", "'uuid'", ":", "uuid"...
db2031a1a87124fee1aeb7414a668c03d774a698
train
ImportManager._substitute_file_uuids_throughout_template
Anywhere in "template" that refers to a data object but does not give a specific UUID, if a matching file can be found in "file_dependencies", we will change the data object reference to use that UUID. That way templates have a preference to connect to files nested under their ".dependencies" o...
utils/loomengine_utils/import_manager.py
def _substitute_file_uuids_throughout_template(self, template, file_dependencies): """Anywhere in "template" that refers to a data object but does not give a specific UUID, if a matching file can be found in "file_dependencies", we will change the data object reference to use that UUID. That wa...
def _substitute_file_uuids_throughout_template(self, template, file_dependencies): """Anywhere in "template" that refers to a data object but does not give a specific UUID, if a matching file can be found in "file_dependencies", we will change the data object reference to use that UUID. That wa...
[ "Anywhere", "in", "template", "that", "refers", "to", "a", "data", "object", "but", "does", "not", "give", "a", "specific", "UUID", "if", "a", "matching", "file", "can", "be", "found", "in", "file_dependencies", "we", "will", "change", "the", "data", "obje...
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/utils/loomengine_utils/import_manager.py#L614-L627
[ "def", "_substitute_file_uuids_throughout_template", "(", "self", ",", "template", ",", "file_dependencies", ")", ":", "if", "not", "isinstance", "(", "template", ",", "dict", ")", ":", "# Nothing to do if this is a reference to a previously imported template.", "return", "...
db2031a1a87124fee1aeb7414a668c03d774a698
train
RunStart._get_inputs
Converts command line args into a list of template inputs
client/loomengine/run.py
def _get_inputs(self): """Converts command line args into a list of template inputs """ # Convert file inputs to a dict, to make it easier to override # them with commandline inputs file_inputs = self._get_file_inputs() try: jsonschema.validate(file_inputs, fi...
def _get_inputs(self): """Converts command line args into a list of template inputs """ # Convert file inputs to a dict, to make it easier to override # them with commandline inputs file_inputs = self._get_file_inputs() try: jsonschema.validate(file_inputs, fi...
[ "Converts", "command", "line", "args", "into", "a", "list", "of", "template", "inputs" ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/client/loomengine/run.py#L113-L141
[ "def", "_get_inputs", "(", "self", ")", ":", "# Convert file inputs to a dict, to make it easier to override", "# them with commandline inputs", "file_inputs", "=", "self", ".", "_get_file_inputs", "(", ")", "try", ":", "jsonschema", ".", "validate", "(", "file_inputs", "...
db2031a1a87124fee1aeb7414a668c03d774a698
train
RunStart._parse_string_to_nested_lists
e.g., convert "[[a,b,c],[d,e],[f,g]]" into [["a","b","c"],["d","e"],["f","g"]]
client/loomengine/run.py
def _parse_string_to_nested_lists(self, value): """e.g., convert "[[a,b,c],[d,e],[f,g]]" into [["a","b","c"],["d","e"],["f","g"]] """ if not re.match(r'\[.*\]', value.strip()): if '[' in value or ']' in value or ',' in value: raise Exception('Missing outer bra...
def _parse_string_to_nested_lists(self, value): """e.g., convert "[[a,b,c],[d,e],[f,g]]" into [["a","b","c"],["d","e"],["f","g"]] """ if not re.match(r'\[.*\]', value.strip()): if '[' in value or ']' in value or ',' in value: raise Exception('Missing outer bra...
[ "e", ".", "g", ".", "convert", "[[", "a", "b", "c", "]", "[", "d", "e", "]", "[", "f", "g", "]]", "into", "[[", "a", "b", "c", "]", "[", "d", "e", "]", "[", "f", "g", "]]" ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/client/loomengine/run.py#L179-L221
[ "def", "_parse_string_to_nested_lists", "(", "self", ",", "value", ")", ":", "if", "not", "re", ".", "match", "(", "r'\\[.*\\]'", ",", "value", ".", "strip", "(", ")", ")", ":", "if", "'['", "in", "value", "or", "']'", "in", "value", "or", "','", "in...
db2031a1a87124fee1aeb7414a668c03d774a698
train
RunRestart._get_inputs
Converts command line args into a list of template inputs
client/loomengine/run.py
def _get_inputs(self, old_inputs): """Converts command line args into a list of template inputs """ # Convert inputs to dict to facilitate overriding by channel name # Also, drop DataNode ID and keep only contents. input_dict = {} for input in old_inputs: # St...
def _get_inputs(self, old_inputs): """Converts command line args into a list of template inputs """ # Convert inputs to dict to facilitate overriding by channel name # Also, drop DataNode ID and keep only contents. input_dict = {} for input in old_inputs: # St...
[ "Converts", "command", "line", "args", "into", "a", "list", "of", "template", "inputs" ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/client/loomengine/run.py#L285-L316
[ "def", "_get_inputs", "(", "self", ",", "old_inputs", ")", ":", "# Convert inputs to dict to facilitate overriding by channel name", "# Also, drop DataNode ID and keep only contents.", "input_dict", "=", "{", "}", "for", "input", "in", "old_inputs", ":", "# Strip out DataNode U...
db2031a1a87124fee1aeb7414a668c03d774a698
train
CreateWithParentModelSerializer.create
This is a standard method called indirectly by calling 'save' on the serializer. This method expects the 'parent_field' and 'parent_instance' to be included in the Serializer context.
server/loomengine_server/api/serializers/__init__.py
def create(self, validated_data): """ This is a standard method called indirectly by calling 'save' on the serializer. This method expects the 'parent_field' and 'parent_instance' to be included in the Serializer context. """ if self.context.get('parent_field') \ ...
def create(self, validated_data): """ This is a standard method called indirectly by calling 'save' on the serializer. This method expects the 'parent_field' and 'parent_instance' to be included in the Serializer context. """ if self.context.get('parent_field') \ ...
[ "This", "is", "a", "standard", "method", "called", "indirectly", "by", "calling", "save", "on", "the", "serializer", "." ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/server/loomengine_server/api/serializers/__init__.py#L42-L57
[ "def", "create", "(", "self", ",", "validated_data", ")", ":", "if", "self", ".", "context", ".", "get", "(", "'parent_field'", ")", "and", "self", ".", "context", ".", "get", "(", "'parent_instance'", ")", ":", "validated_data", ".", "update", "(", "{",...
db2031a1a87124fee1aeb7414a668c03d774a698
train
disable_insecure_request_warning
Suppress warning about untrusted SSL certificate.
utils/loomengine_utils/connection.py
def disable_insecure_request_warning(): """Suppress warning about untrusted SSL certificate.""" import requests from requests.packages.urllib3.exceptions import InsecureRequestWarning requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
def disable_insecure_request_warning(): """Suppress warning about untrusted SSL certificate.""" import requests from requests.packages.urllib3.exceptions import InsecureRequestWarning requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
[ "Suppress", "warning", "about", "untrusted", "SSL", "certificate", "." ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/utils/loomengine_utils/connection.py#L14-L18
[ "def", "disable_insecure_request_warning", "(", ")", ":", "import", "requests", "from", "requests", ".", "packages", ".", "urllib3", ".", "exceptions", "import", "InsecureRequestWarning", "requests", ".", "packages", ".", "urllib3", ".", "disable_warnings", "(", "In...
db2031a1a87124fee1aeb7414a668c03d774a698
train
Connection._make_request_to_server
Retry sending request until timeout or until receiving a response.
utils/loomengine_utils/connection.py
def _make_request_to_server(self, query_function, raise_for_status=True, time_limit_seconds=2, retry_delay_seconds=0.2): """Retry sending request until timeout or until receiving a response. """ start_time = datetime.datetime.now() while datetime.datetime....
def _make_request_to_server(self, query_function, raise_for_status=True, time_limit_seconds=2, retry_delay_seconds=0.2): """Retry sending request until timeout or until receiving a response. """ start_time = datetime.datetime.now() while datetime.datetime....
[ "Retry", "sending", "request", "until", "timeout", "or", "until", "receiving", "a", "response", "." ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/utils/loomengine_utils/connection.py#L108-L134
[ "def", "_make_request_to_server", "(", "self", ",", "query_function", ",", "raise_for_status", "=", "True", ",", "time_limit_seconds", "=", "2", ",", "retry_delay_seconds", "=", "0.2", ")", ":", "start_time", "=", "datetime", ".", "datetime", ".", "now", "(", ...
db2031a1a87124fee1aeb7414a668c03d774a698
train
Connection._get_resource
Convenience function for retrieving a resource. If resource does not exist, return None.
utils/loomengine_utils/connection.py
def _get_resource(self, relative_url, params=None): """Convenience function for retrieving a resource. If resource does not exist, return None. """ response = self._get(relative_url, params=params, raise_for_status=False) if response.status_code == 404: return None ...
def _get_resource(self, relative_url, params=None): """Convenience function for retrieving a resource. If resource does not exist, return None. """ response = self._get(relative_url, params=params, raise_for_status=False) if response.status_code == 404: return None ...
[ "Convenience", "function", "for", "retrieving", "a", "resource", ".", "If", "resource", "does", "not", "exist", "return", "None", "." ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/utils/loomengine_utils/connection.py#L172-L180
[ "def", "_get_resource", "(", "self", ",", "relative_url", ",", "params", "=", "None", ")", ":", "response", "=", "self", ".", "_get", "(", "relative_url", ",", "params", "=", "params", ",", "raise_for_status", "=", "False", ")", "if", "response", ".", "s...
db2031a1a87124fee1aeb7414a668c03d774a698
train
TaskAttemptInput
Returns the correct Input class for a given data type and gather mode
worker/loomengine_worker/inputs.py
def TaskAttemptInput(input, task_attempt): """Returns the correct Input class for a given data type and gather mode """ (data_type, mode) = _get_input_info(input) if data_type != 'file': return NoOpInput(None, task_attempt) if mode == 'no_gather': return FileInput(input['data'...
def TaskAttemptInput(input, task_attempt): """Returns the correct Input class for a given data type and gather mode """ (data_type, mode) = _get_input_info(input) if data_type != 'file': return NoOpInput(None, task_attempt) if mode == 'no_gather': return FileInput(input['data'...
[ "Returns", "the", "correct", "Input", "class", "for", "a", "given", "data", "type", "and", "gather", "mode" ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/worker/loomengine_worker/inputs.py#L83-L97
[ "def", "TaskAttemptInput", "(", "input", ",", "task_attempt", ")", ":", "(", "data_type", ",", "mode", ")", "=", "_get_input_info", "(", "input", ")", "if", "data_type", "!=", "'file'", ":", "return", "NoOpInput", "(", "None", ",", "task_attempt", ")", "if...
db2031a1a87124fee1aeb7414a668c03d774a698
train
execute
Run a task asynchronously
server/loomengine_server/api/async.py
def execute(task_function, *args, **kwargs): """Run a task asynchronously """ if get_setting('TEST_DISABLE_ASYNC_DELAY'): # Delay disabled, run synchronously logger.debug('Running function "%s" synchronously because '\ 'TEST_DISABLE_ASYNC_DELAY is True' ...
def execute(task_function, *args, **kwargs): """Run a task asynchronously """ if get_setting('TEST_DISABLE_ASYNC_DELAY'): # Delay disabled, run synchronously logger.debug('Running function "%s" synchronously because '\ 'TEST_DISABLE_ASYNC_DELAY is True' ...
[ "Run", "a", "task", "asynchronously" ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/server/loomengine_server/api/async.py#L24-L36
[ "def", "execute", "(", "task_function", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "get_setting", "(", "'TEST_DISABLE_ASYNC_DELAY'", ")", ":", "# Delay disabled, run synchronously", "logger", ".", "debug", "(", "'Running function \"%s\" synchronously b...
db2031a1a87124fee1aeb7414a668c03d774a698
train
execute_with_delay
Run a task asynchronously after at least delay_seconds
server/loomengine_server/api/async.py
def execute_with_delay(task_function, *args, **kwargs): """Run a task asynchronously after at least delay_seconds """ delay = kwargs.pop('delay', 0) if get_setting('TEST_DISABLE_ASYNC_DELAY'): # Delay disabled, run synchronously logger.debug('Running function "%s" synchronously because '...
def execute_with_delay(task_function, *args, **kwargs): """Run a task asynchronously after at least delay_seconds """ delay = kwargs.pop('delay', 0) if get_setting('TEST_DISABLE_ASYNC_DELAY'): # Delay disabled, run synchronously logger.debug('Running function "%s" synchronously because '...
[ "Run", "a", "task", "asynchronously", "after", "at", "least", "delay_seconds" ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/server/loomengine_server/api/async.py#L38-L50
[ "def", "execute_with_delay", "(", "task_function", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "delay", "=", "kwargs", ".", "pop", "(", "'delay'", ",", "0", ")", "if", "get_setting", "(", "'TEST_DISABLE_ASYNC_DELAY'", ")", ":", "# Delay disabled, ru...
db2031a1a87124fee1aeb7414a668c03d774a698
train
check_for_stalled_tasks
Check for tasks that are no longer sending a heartbeat
server/loomengine_server/api/async.py
def check_for_stalled_tasks(): """Check for tasks that are no longer sending a heartbeat """ from api.models.tasks import Task for task in Task.objects.filter(status_is_running=True): if not task.is_responsive(): task.system_error() if task.is_timed_out(): task.ti...
def check_for_stalled_tasks(): """Check for tasks that are no longer sending a heartbeat """ from api.models.tasks import Task for task in Task.objects.filter(status_is_running=True): if not task.is_responsive(): task.system_error() if task.is_timed_out(): task.ti...
[ "Check", "for", "tasks", "that", "are", "no", "longer", "sending", "a", "heartbeat" ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/server/loomengine_server/api/async.py#L55-L63
[ "def", "check_for_stalled_tasks", "(", ")", ":", "from", "api", ".", "models", ".", "tasks", "import", "Task", "for", "task", "in", "Task", ".", "objects", ".", "filter", "(", "status_is_running", "=", "True", ")", ":", "if", "not", "task", ".", "is_resp...
db2031a1a87124fee1aeb7414a668c03d774a698
train
check_for_missed_cleanup
Check for TaskAttempts that were never cleaned up
server/loomengine_server/api/async.py
def check_for_missed_cleanup(): """Check for TaskAttempts that were never cleaned up """ if get_setting('PRESERVE_ALL'): return from api.models.tasks import TaskAttempt if get_setting('PRESERVE_ON_FAILURE'): for task_attempt in TaskAttempt.objects.filter( status_is_ru...
def check_for_missed_cleanup(): """Check for TaskAttempts that were never cleaned up """ if get_setting('PRESERVE_ALL'): return from api.models.tasks import TaskAttempt if get_setting('PRESERVE_ON_FAILURE'): for task_attempt in TaskAttempt.objects.filter( status_is_ru...
[ "Check", "for", "TaskAttempts", "that", "were", "never", "cleaned", "up" ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/server/loomengine_server/api/async.py#L66-L81
[ "def", "check_for_missed_cleanup", "(", ")", ":", "if", "get_setting", "(", "'PRESERVE_ALL'", ")", ":", "return", "from", "api", ".", "models", ".", "tasks", "import", "TaskAttempt", "if", "get_setting", "(", "'PRESERVE_ON_FAILURE'", ")", ":", "for", "task_attem...
db2031a1a87124fee1aeb7414a668c03d774a698
train
execute_with_retries
This attempts to execute "retryable_function" with exponential backoff on delay time. 10 retries adds up to about 34 minutes total delay before the last attempt. "human_readable_action_name" is an option input to customize retry message.
utils/loomengine_utils/__init__.py
def execute_with_retries(retryable_function, retryable_errors, logger, human_readable_action_name='Action', nonretryable_errors=None): """This attempts to execute "retryable_function" with exponential backoff on ...
def execute_with_retries(retryable_function, retryable_errors, logger, human_readable_action_name='Action', nonretryable_errors=None): """This attempts to execute "retryable_function" with exponential backoff on ...
[ "This", "attempts", "to", "execute", "retryable_function", "with", "exponential", "backoff", "on", "delay", "time", ".", "10", "retries", "adds", "up", "to", "about", "34", "minutes", "total", "delay", "before", "the", "last", "attempt", ".", "human_readable_act...
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/utils/loomengine_utils/__init__.py#L18-L48
[ "def", "execute_with_retries", "(", "retryable_function", ",", "retryable_errors", ",", "logger", ",", "human_readable_action_name", "=", "'Action'", ",", "nonretryable_errors", "=", "None", ")", ":", "max_retries", "=", "10", "attempt", "=", "0", "if", "not", "no...
db2031a1a87124fee1aeb7414a668c03d774a698
train
ExportManager.export_file
Export a file from Loom to some file storage location. Default destination_directory is cwd. Default destination_filename is the filename from the file data object associated with the given file_id.
utils/loomengine_utils/export_manager.py
def export_file(self, data_object, destination_directory=None, destination_filename=None, retry=False, export_metadata=False, export_raw_file=True): """Export a file from Loom to some file storage location. Default destination_directory is cwd. Default destination...
def export_file(self, data_object, destination_directory=None, destination_filename=None, retry=False, export_metadata=False, export_raw_file=True): """Export a file from Loom to some file storage location. Default destination_directory is cwd. Default destination...
[ "Export", "a", "file", "from", "Loom", "to", "some", "file", "storage", "location", ".", "Default", "destination_directory", "is", "cwd", ".", "Default", "destination_filename", "is", "the", "filename", "from", "the", "file", "data", "object", "associated", "wit...
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/utils/loomengine_utils/export_manager.py#L47-L101
[ "def", "export_file", "(", "self", ",", "data_object", ",", "destination_directory", "=", "None", ",", "destination_filename", "=", "None", ",", "retry", "=", "False", ",", "export_metadata", "=", "False", ",", "export_raw_file", "=", "True", ")", ":", "if", ...
db2031a1a87124fee1aeb7414a668c03d774a698
train
_urlparse
Like urlparse except it assumes 'file://' if no scheme is specified
utils/loomengine_utils/file_utils.py
def _urlparse(path): """Like urlparse except it assumes 'file://' if no scheme is specified """ url = urlparse.urlparse(path) _validate_url(url) if not url.scheme or url.scheme == 'file://': # Normalize path, and set scheme to "file" if missing path = os.path.abspath( os....
def _urlparse(path): """Like urlparse except it assumes 'file://' if no scheme is specified """ url = urlparse.urlparse(path) _validate_url(url) if not url.scheme or url.scheme == 'file://': # Normalize path, and set scheme to "file" if missing path = os.path.abspath( os....
[ "Like", "urlparse", "except", "it", "assumes", "file", ":", "//", "if", "no", "scheme", "is", "specified" ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/utils/loomengine_utils/file_utils.py#L68-L78
[ "def", "_urlparse", "(", "path", ")", ":", "url", "=", "urlparse", ".", "urlparse", "(", "path", ")", "_validate_url", "(", "url", ")", "if", "not", "url", ".", "scheme", "or", "url", ".", "scheme", "==", "'file://'", ":", "# Normalize path, and set scheme...
db2031a1a87124fee1aeb7414a668c03d774a698
train
FilePattern
Factory method returns LocalFilePattern or GoogleStorageFilePattern
utils/loomengine_utils/file_utils.py
def FilePattern(pattern, settings, **kwargs): """Factory method returns LocalFilePattern or GoogleStorageFilePattern """ url = _urlparse(pattern) if url.scheme == 'gs': return GoogleStorageFilePattern(pattern, settings, **kwargs) else: assert url.scheme == 'file' return Local...
def FilePattern(pattern, settings, **kwargs): """Factory method returns LocalFilePattern or GoogleStorageFilePattern """ url = _urlparse(pattern) if url.scheme == 'gs': return GoogleStorageFilePattern(pattern, settings, **kwargs) else: assert url.scheme == 'file' return Local...
[ "Factory", "method", "returns", "LocalFilePattern", "or", "GoogleStorageFilePattern" ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/utils/loomengine_utils/file_utils.py#L119-L127
[ "def", "FilePattern", "(", "pattern", ",", "settings", ",", "*", "*", "kwargs", ")", ":", "url", "=", "_urlparse", "(", "pattern", ")", "if", "url", ".", "scheme", "==", "'gs'", ":", "return", "GoogleStorageFilePattern", "(", "pattern", ",", "settings", ...
db2031a1a87124fee1aeb7414a668c03d774a698
train
File
Factory method
utils/loomengine_utils/file_utils.py
def File(url, settings, retry=False): """Factory method """ parsed_url = _urlparse(url) if parsed_url.scheme == 'gs': return GoogleStorageFile(url, settings, retry=retry) elif parsed_url.scheme == 'file': if parsed_url.hostname == 'localhost' or parsed_url.hostname is None: ...
def File(url, settings, retry=False): """Factory method """ parsed_url = _urlparse(url) if parsed_url.scheme == 'gs': return GoogleStorageFile(url, settings, retry=retry) elif parsed_url.scheme == 'file': if parsed_url.hostname == 'localhost' or parsed_url.hostname is None: ...
[ "Factory", "method" ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/utils/loomengine_utils/file_utils.py#L291-L307
[ "def", "File", "(", "url", ",", "settings", ",", "retry", "=", "False", ")", ":", "parsed_url", "=", "_urlparse", "(", "url", ")", "if", "parsed_url", ".", "scheme", "==", "'gs'", ":", "return", "GoogleStorageFile", "(", "url", ",", "settings", ",", "r...
db2031a1a87124fee1aeb7414a668c03d774a698
train
Copier
Factory method to select the right copier for a given source and destination.
utils/loomengine_utils/file_utils.py
def Copier(source, destination): """Factory method to select the right copier for a given source and destination. """ if source.type == 'local' and destination.type == 'local': return LocalCopier(source, destination) elif source.type == 'local' and destination.type == 'google_storage': ...
def Copier(source, destination): """Factory method to select the right copier for a given source and destination. """ if source.type == 'local' and destination.type == 'local': return LocalCopier(source, destination) elif source.type == 'local' and destination.type == 'google_storage': ...
[ "Factory", "method", "to", "select", "the", "right", "copier", "for", "a", "given", "source", "and", "destination", "." ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/utils/loomengine_utils/file_utils.py#L496-L510
[ "def", "Copier", "(", "source", ",", "destination", ")", ":", "if", "source", ".", "type", "==", "'local'", "and", "destination", ".", "type", "==", "'local'", ":", "return", "LocalCopier", "(", "source", ",", "destination", ")", "elif", "source", ".", "...
db2031a1a87124fee1aeb7414a668c03d774a698
train
InputSetGeneratorNode.create_from_data_channel
Scan the data tree on the given data_channel to create a corresponding InputSetGenerator tree.
server/loomengine_server/api/models/input_calculator.py
def create_from_data_channel(cls, data_channel): """Scan the data tree on the given data_channel to create a corresponding InputSetGenerator tree. """ gather_depth = cls._get_gather_depth(data_channel) generator = InputSetGeneratorNode() for (data_path, data_node) in dat...
def create_from_data_channel(cls, data_channel): """Scan the data tree on the given data_channel to create a corresponding InputSetGenerator tree. """ gather_depth = cls._get_gather_depth(data_channel) generator = InputSetGeneratorNode() for (data_path, data_node) in dat...
[ "Scan", "the", "data", "tree", "on", "the", "given", "data_channel", "to", "create", "a", "corresponding", "InputSetGenerator", "tree", "." ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/server/loomengine_server/api/models/input_calculator.py#L119-L133
[ "def", "create_from_data_channel", "(", "cls", ",", "data_channel", ")", ":", "gather_depth", "=", "cls", ".", "_get_gather_depth", "(", "data_channel", ")", "generator", "=", "InputSetGeneratorNode", "(", ")", "for", "(", "data_path", ",", "data_node", ")", "in...
db2031a1a87124fee1aeb7414a668c03d774a698
train
TaskAttemptOutput
Returns the correct Output class for a given data type, source type, and scatter mode
worker/loomengine_worker/outputs.py
def TaskAttemptOutput(output, task_attempt): """Returns the correct Output class for a given data type, source type, and scatter mode """ (data_type, mode, source_type) = _get_output_info(output) if data_type == 'file': if mode == 'scatter': assert source_type in ['filenames', ...
def TaskAttemptOutput(output, task_attempt): """Returns the correct Output class for a given data type, source type, and scatter mode """ (data_type, mode, source_type) = _get_output_info(output) if data_type == 'file': if mode == 'scatter': assert source_type in ['filenames', ...
[ "Returns", "the", "correct", "Output", "class", "for", "a", "given", "data", "type", "source", "type", "and", "scatter", "mode" ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/worker/loomengine_worker/outputs.py#L181-L220
[ "def", "TaskAttemptOutput", "(", "output", ",", "task_attempt", ")", ":", "(", "data_type", ",", "mode", ",", "source_type", ")", "=", "_get_output_info", "(", "output", ")", "if", "data_type", "==", "'file'", ":", "if", "mode", "==", "'scatter'", ":", "as...
db2031a1a87124fee1aeb7414a668c03d774a698
train
DataNode.add_leaf
Adds a new leaf node at the given index with the given data_object
server/loomengine_server/api/models/data_nodes.py
def add_leaf(self, index, data_object, save=False): """Adds a new leaf node at the given index with the given data_object """ assert self.type == data_object.type, 'data type mismatch' if self._get_child_by_index(index) is not None: raise NodeAlreadyExistsError( ...
def add_leaf(self, index, data_object, save=False): """Adds a new leaf node at the given index with the given data_object """ assert self.type == data_object.type, 'data type mismatch' if self._get_child_by_index(index) is not None: raise NodeAlreadyExistsError( ...
[ "Adds", "a", "new", "leaf", "node", "at", "the", "given", "index", "with", "the", "given", "data_object" ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/server/loomengine_server/api/models/data_nodes.py#L103-L120
[ "def", "add_leaf", "(", "self", ",", "index", ",", "data_object", ",", "save", "=", "False", ")", ":", "assert", "self", ".", "type", "==", "data_object", ".", "type", ",", "'data type mismatch'", "if", "self", ".", "_get_child_by_index", "(", "index", ")"...
db2031a1a87124fee1aeb7414a668c03d774a698
train
DataNode.get_ready_data_nodes
Returns a list [(path1,data_node1),...] with entries only for existing nodes with DataObjects where is_ready==True. Missing nodes or those with non-ready or non-existing data are ignored.
server/loomengine_server/api/models/data_nodes.py
def get_ready_data_nodes(self, seed_path, gather_depth): """Returns a list [(path1,data_node1),...] with entries only for existing nodes with DataObjects where is_ready==True. Missing nodes or those with non-ready or non-existing data are ignored. """ try: seed_node =...
def get_ready_data_nodes(self, seed_path, gather_depth): """Returns a list [(path1,data_node1),...] with entries only for existing nodes with DataObjects where is_ready==True. Missing nodes or those with non-ready or non-existing data are ignored. """ try: seed_node =...
[ "Returns", "a", "list", "[", "(", "path1", "data_node1", ")", "...", "]", "with", "entries", "only", "for", "existing", "nodes", "with", "DataObjects", "where", "is_ready", "==", "True", ".", "Missing", "nodes", "or", "those", "with", "non", "-", "ready", ...
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/server/loomengine_server/api/models/data_nodes.py#L183-L197
[ "def", "get_ready_data_nodes", "(", "self", ",", "seed_path", ",", "gather_depth", ")", ":", "try", ":", "seed_node", "=", "self", ".", "get_node", "(", "seed_path", ")", "except", "MissingBranchError", ":", "return", "[", "]", "all_paths", "=", "seed_node", ...
db2031a1a87124fee1aeb7414a668c03d774a698
train
DataNode._check_index
Verify that the given index is consistent with the degree of the node.
server/loomengine_server/api/models/data_nodes.py
def _check_index(self, index): """Verify that the given index is consistent with the degree of the node. """ if self.degree is None: raise UnknownDegreeError( 'Cannot access child DataNode on a parent with degree of None. '\ 'Set the degree on the pare...
def _check_index(self, index): """Verify that the given index is consistent with the degree of the node. """ if self.degree is None: raise UnknownDegreeError( 'Cannot access child DataNode on a parent with degree of None. '\ 'Set the degree on the pare...
[ "Verify", "that", "the", "given", "index", "is", "consistent", "with", "the", "degree", "of", "the", "node", "." ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/server/loomengine_server/api/models/data_nodes.py#L328-L339
[ "def", "_check_index", "(", "self", ",", "index", ")", ":", "if", "self", ".", "degree", "is", "None", ":", "raise", "UnknownDegreeError", "(", "'Cannot access child DataNode on a parent with degree of None. '", "'Set the degree on the parent first.'", ")", "if", "index",...
db2031a1a87124fee1aeb7414a668c03d774a698
train
on_gcloud_vm
Determines if we're running on a GCE instance.
client/loomengine/playbooks/files/gcloud_utils.py
def on_gcloud_vm(): """ Determines if we're running on a GCE instance.""" r = None try: r = requests.get('http://metadata.google.internal') except requests.ConnectionError: return False try: if r.headers['Metadata-Flavor'] == 'Google' and \ r.headers['Server'] == ...
def on_gcloud_vm(): """ Determines if we're running on a GCE instance.""" r = None try: r = requests.get('http://metadata.google.internal') except requests.ConnectionError: return False try: if r.headers['Metadata-Flavor'] == 'Google' and \ r.headers['Server'] == ...
[ "Determines", "if", "we", "re", "running", "on", "a", "GCE", "instance", "." ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/client/loomengine/playbooks/files/gcloud_utils.py#L11-L24
[ "def", "on_gcloud_vm", "(", ")", ":", "r", "=", "None", "try", ":", "r", "=", "requests", ".", "get", "(", "'http://metadata.google.internal'", ")", "except", "requests", ".", "ConnectionError", ":", "return", "False", "try", ":", "if", "r", ".", "headers"...
db2031a1a87124fee1aeb7414a668c03d774a698
train
get_cheapest_instance_type
Determine the cheapest instance type given a minimum number of cores and minimum amount of RAM (in GB).
client/loomengine/playbooks/files/gcloud_utils.py
def get_cheapest_instance_type(cores, memory): """Determine the cheapest instance type given a minimum number of cores and minimum amount of RAM (in GB). """ pricelist = get_gcloud_pricelist() # Filter out preemptible, shared-CPU, and non-US instance types us_instance_types = {k: v for k, v in...
def get_cheapest_instance_type(cores, memory): """Determine the cheapest instance type given a minimum number of cores and minimum amount of RAM (in GB). """ pricelist = get_gcloud_pricelist() # Filter out preemptible, shared-CPU, and non-US instance types us_instance_types = {k: v for k, v in...
[ "Determine", "the", "cheapest", "instance", "type", "given", "a", "minimum", "number", "of", "cores", "and", "minimum", "amount", "of", "RAM", "(", "in", "GB", ")", "." ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/client/loomengine/playbooks/files/gcloud_utils.py#L27-L61
[ "def", "get_cheapest_instance_type", "(", "cores", ",", "memory", ")", ":", "pricelist", "=", "get_gcloud_pricelist", "(", ")", "# Filter out preemptible, shared-CPU, and non-US instance types", "us_instance_types", "=", "{", "k", ":", "v", "for", "k", ",", "v", "in",...
db2031a1a87124fee1aeb7414a668c03d774a698
train
get_gcloud_pricelist
Retrieve latest pricelist from Google Cloud, or use cached copy if not reachable.
client/loomengine/playbooks/files/gcloud_utils.py
def get_gcloud_pricelist(): """Retrieve latest pricelist from Google Cloud, or use cached copy if not reachable. """ try: r = requests.get('http://cloudpricingcalculator.appspot.com' '/static/data/pricelist.json') content = json.loads(r.content) except Connec...
def get_gcloud_pricelist(): """Retrieve latest pricelist from Google Cloud, or use cached copy if not reachable. """ try: r = requests.get('http://cloudpricingcalculator.appspot.com' '/static/data/pricelist.json') content = json.loads(r.content) except Connec...
[ "Retrieve", "latest", "pricelist", "from", "Google", "Cloud", "or", "use", "cached", "copy", "if", "not", "reachable", "." ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/client/loomengine/playbooks/files/gcloud_utils.py#L64-L82
[ "def", "get_gcloud_pricelist", "(", ")", ":", "try", ":", "r", "=", "requests", ".", "get", "(", "'http://cloudpricingcalculator.appspot.com'", "'/static/data/pricelist.json'", ")", "content", "=", "json", ".", "loads", "(", "r", ".", "content", ")", "except", "...
db2031a1a87124fee1aeb7414a668c03d774a698
train
_get_base_name
Create a base name for the worker instance that will run the specified task run attempt, from this server. Since hostname and step name will be duplicated across workers (reruns, etc.), ensure that at least MIN_TASK_ID_CHARS are preserved in the instance name. Also, prevent names from ending with dashes...
client/loomengine/playbooks/files/gcloud_utils.py
def _get_base_name(hostname, step_name, attempt_id, max_length): """Create a base name for the worker instance that will run the specified task run attempt, from this server. Since hostname and step name will be duplicated across workers (reruns, etc.), ensure that at least MIN_TASK_ID_CHARS are preserv...
def _get_base_name(hostname, step_name, attempt_id, max_length): """Create a base name for the worker instance that will run the specified task run attempt, from this server. Since hostname and step name will be duplicated across workers (reruns, etc.), ensure that at least MIN_TASK_ID_CHARS are preserv...
[ "Create", "a", "base", "name", "for", "the", "worker", "instance", "that", "will", "run", "the", "specified", "task", "run", "attempt", "from", "this", "server", ".", "Since", "hostname", "and", "step", "name", "will", "be", "duplicated", "across", "workers"...
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/client/loomengine/playbooks/files/gcloud_utils.py#L88-L105
[ "def", "_get_base_name", "(", "hostname", ",", "step_name", ",", "attempt_id", ",", "max_length", ")", ":", "max_length", "=", "int", "(", "max_length", ")", "if", "len", "(", "hostname", ")", "+", "len", "(", "step_name", ")", "+", "MIN_TASK_ID_CHARS", "+...
db2031a1a87124fee1aeb7414a668c03d774a698
train
_sanitize_instance_name
Instance names must start with a lowercase letter. All following characters must be a dash, lowercase letter, or digit.
client/loomengine/playbooks/files/gcloud_utils.py
def _sanitize_instance_name(name, max_length): """Instance names must start with a lowercase letter. All following characters must be a dash, lowercase letter, or digit. """ name = str(name).lower() # make all letters lowercase name = re.sub(r'[^-a-z0-9]', '', name) # remove inva...
def _sanitize_instance_name(name, max_length): """Instance names must start with a lowercase letter. All following characters must be a dash, lowercase letter, or digit. """ name = str(name).lower() # make all letters lowercase name = re.sub(r'[^-a-z0-9]', '', name) # remove inva...
[ "Instance", "names", "must", "start", "with", "a", "lowercase", "letter", ".", "All", "following", "characters", "must", "be", "a", "dash", "lowercase", "letter", "or", "digit", "." ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/client/loomengine/playbooks/files/gcloud_utils.py#L115-L126
[ "def", "_sanitize_instance_name", "(", "name", ",", "max_length", ")", ":", "name", "=", "str", "(", "name", ")", ".", "lower", "(", ")", "# make all letters lowercase", "name", "=", "re", ".", "sub", "(", "r'[^-a-z0-9]'", ",", "''", ",", "name", ")", "#...
db2031a1a87124fee1aeb7414a668c03d774a698
train
CloudInventoryCache.is_valid
Determines if the cache files have expired, or if it is still valid
client/loomengine/playbooks/gce.py
def is_valid(self, max_age=None): ''' Determines if the cache files have expired, or if it is still valid ''' if max_age is None: max_age = self.cache_max_age if os.path.isfile(self.cache_path_cache): mod_time = os.path.getmtime(self.cache_path_cache) curren...
def is_valid(self, max_age=None): ''' Determines if the cache files have expired, or if it is still valid ''' if max_age is None: max_age = self.cache_max_age if os.path.isfile(self.cache_path_cache): mod_time = os.path.getmtime(self.cache_path_cache) curren...
[ "Determines", "if", "the", "cache", "files", "have", "expired", "or", "if", "it", "is", "still", "valid" ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/client/loomengine/playbooks/gce.py#L123-L135
[ "def", "is_valid", "(", "self", ",", "max_age", "=", "None", ")", ":", "if", "max_age", "is", "None", ":", "max_age", "=", "self", ".", "cache_max_age", "if", "os", ".", "path", ".", "isfile", "(", "self", ".", "cache_path_cache", ")", ":", "mod_time",...
db2031a1a87124fee1aeb7414a668c03d774a698