repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
scour-project/scour
scour/scour.py
removeUnreferencedIDs
def removeUnreferencedIDs(referencedIDs, identifiedElements): """ Removes the unreferenced ID attributes. Returns the number of ID attributes removed """ global _num_ids_removed keepTags = ['font'] num = 0 for id in identifiedElements: node = identifiedElements[id] if id...
python
def removeUnreferencedIDs(referencedIDs, identifiedElements): """ Removes the unreferenced ID attributes. Returns the number of ID attributes removed """ global _num_ids_removed keepTags = ['font'] num = 0 for id in identifiedElements: node = identifiedElements[id] if id...
[ "def", "removeUnreferencedIDs", "(", "referencedIDs", ",", "identifiedElements", ")", ":", "global", "_num_ids_removed", "keepTags", "=", "[", "'font'", "]", "num", "=", "0", "for", "id", "in", "identifiedElements", ":", "node", "=", "identifiedElements", "[", "...
Removes the unreferenced ID attributes. Returns the number of ID attributes removed
[ "Removes", "the", "unreferenced", "ID", "attributes", "." ]
train
https://github.com/scour-project/scour/blob/049264eba6b1a54ae5ba1d6a5077d8e7b80e8835/scour/scour.py#L857-L872
scour-project/scour
scour/scour.py
removeNestedGroups
def removeNestedGroups(node): """ This walks further and further down the tree, removing groups which do not have any attributes or a title/desc child and promoting their children up one level """ global _num_elements_removed num = 0 groupsToRemove = [] # Only consider <g> elements ...
python
def removeNestedGroups(node): """ This walks further and further down the tree, removing groups which do not have any attributes or a title/desc child and promoting their children up one level """ global _num_elements_removed num = 0 groupsToRemove = [] # Only consider <g> elements ...
[ "def", "removeNestedGroups", "(", "node", ")", ":", "global", "_num_elements_removed", "num", "=", "0", "groupsToRemove", "=", "[", "]", "# Only consider <g> elements for promotion if this element isn't a <switch>.", "# (partial fix for bug 594930, required by the SVG spec however)",...
This walks further and further down the tree, removing groups which do not have any attributes or a title/desc child and promoting their children up one level
[ "This", "walks", "further", "and", "further", "down", "the", "tree", "removing", "groups", "which", "do", "not", "have", "any", "attributes", "or", "a", "title", "/", "desc", "child", "and", "promoting", "their", "children", "up", "one", "level" ]
train
https://github.com/scour-project/scour/blob/049264eba6b1a54ae5ba1d6a5077d8e7b80e8835/scour/scour.py#L946-L980
scour-project/scour
scour/scour.py
moveCommonAttributesToParentGroup
def moveCommonAttributesToParentGroup(elem, referencedElements): """ This recursively calls this function on all children of the passed in element and then iterates over all child elements and removes common inheritable attributes from the children and places them in the parent group. But only if the p...
python
def moveCommonAttributesToParentGroup(elem, referencedElements): """ This recursively calls this function on all children of the passed in element and then iterates over all child elements and removes common inheritable attributes from the children and places them in the parent group. But only if the p...
[ "def", "moveCommonAttributesToParentGroup", "(", "elem", ",", "referencedElements", ")", ":", "num", "=", "0", "childElements", "=", "[", "]", "# recurse first into the children (depth-first)", "for", "child", "in", "elem", ".", "childNodes", ":", "if", "child", "."...
This recursively calls this function on all children of the passed in element and then iterates over all child elements and removes common inheritable attributes from the children and places them in the parent group. But only if the parent contains nothing but element children and whitespace. The attribut...
[ "This", "recursively", "calls", "this", "function", "on", "all", "children", "of", "the", "passed", "in", "element", "and", "then", "iterates", "over", "all", "child", "elements", "and", "removes", "common", "inheritable", "attributes", "from", "the", "children"...
train
https://github.com/scour-project/scour/blob/049264eba6b1a54ae5ba1d6a5077d8e7b80e8835/scour/scour.py#L983-L1063
scour-project/scour
scour/scour.py
createGroupsForCommonAttributes
def createGroupsForCommonAttributes(elem): """ Creates <g> elements to contain runs of 3 or more consecutive child elements having at least one common attribute. Common attributes are not promoted to the <g> by this function. This is handled by moveCommonAttributesToParentGroup. If all childre...
python
def createGroupsForCommonAttributes(elem): """ Creates <g> elements to contain runs of 3 or more consecutive child elements having at least one common attribute. Common attributes are not promoted to the <g> by this function. This is handled by moveCommonAttributesToParentGroup. If all childre...
[ "def", "createGroupsForCommonAttributes", "(", "elem", ")", ":", "num", "=", "0", "global", "_num_elements_removed", "# TODO perhaps all of the Presentation attributes in http://www.w3.org/TR/SVG/struct.html#GElement", "# could be added here", "# Cyn: These attributes are the same as in mo...
Creates <g> elements to contain runs of 3 or more consecutive child elements having at least one common attribute. Common attributes are not promoted to the <g> by this function. This is handled by moveCommonAttributesToParentGroup. If all children have a common attribute, an extra <g> is not created....
[ "Creates", "<g", ">", "elements", "to", "contain", "runs", "of", "3", "or", "more", "consecutive", "child", "elements", "having", "at", "least", "one", "common", "attribute", "." ]
train
https://github.com/scour-project/scour/blob/049264eba6b1a54ae5ba1d6a5077d8e7b80e8835/scour/scour.py#L1066-L1192
scour-project/scour
scour/scour.py
removeUnusedAttributesOnParent
def removeUnusedAttributesOnParent(elem): """ This recursively calls this function on all children of the element passed in, then removes any unused attributes on this elem if none of the children inherit it """ num = 0 childElements = [] # recurse first into the children (depth-first) ...
python
def removeUnusedAttributesOnParent(elem): """ This recursively calls this function on all children of the element passed in, then removes any unused attributes on this elem if none of the children inherit it """ num = 0 childElements = [] # recurse first into the children (depth-first) ...
[ "def", "removeUnusedAttributesOnParent", "(", "elem", ")", ":", "num", "=", "0", "childElements", "=", "[", "]", "# recurse first into the children (depth-first)", "for", "child", "in", "elem", ".", "childNodes", ":", "if", "child", ".", "nodeType", "==", "Node", ...
This recursively calls this function on all children of the element passed in, then removes any unused attributes on this elem if none of the children inherit it
[ "This", "recursively", "calls", "this", "function", "on", "all", "children", "of", "the", "element", "passed", "in", "then", "removes", "any", "unused", "attributes", "on", "this", "elem", "if", "none", "of", "the", "children", "inherit", "it" ]
train
https://github.com/scour-project/scour/blob/049264eba6b1a54ae5ba1d6a5077d8e7b80e8835/scour/scour.py#L1195-L1247
scour-project/scour
scour/scour.py
_getStyle
def _getStyle(node): u"""Returns the style attribute of a node as a dictionary.""" if node.nodeType == Node.ELEMENT_NODE and len(node.getAttribute('style')) > 0: styleMap = {} rawStyles = node.getAttribute('style').split(';') for style in rawStyles: propval = style.split(':')...
python
def _getStyle(node): u"""Returns the style attribute of a node as a dictionary.""" if node.nodeType == Node.ELEMENT_NODE and len(node.getAttribute('style')) > 0: styleMap = {} rawStyles = node.getAttribute('style').split(';') for style in rawStyles: propval = style.split(':')...
[ "def", "_getStyle", "(", "node", ")", ":", "if", "node", ".", "nodeType", "==", "Node", ".", "ELEMENT_NODE", "and", "len", "(", "node", ".", "getAttribute", "(", "'style'", ")", ")", ">", "0", ":", "styleMap", "=", "{", "}", "rawStyles", "=", "node",...
u"""Returns the style attribute of a node as a dictionary.
[ "u", "Returns", "the", "style", "attribute", "of", "a", "node", "as", "a", "dictionary", "." ]
train
https://github.com/scour-project/scour/blob/049264eba6b1a54ae5ba1d6a5077d8e7b80e8835/scour/scour.py#L1443-L1454
scour-project/scour
scour/scour.py
_setStyle
def _setStyle(node, styleMap): u"""Sets the style attribute of a node to the dictionary ``styleMap``.""" fixedStyle = ';'.join([prop + ':' + styleMap[prop] for prop in styleMap]) if fixedStyle != '': node.setAttribute('style', fixedStyle) elif node.getAttribute('style'): node.removeAttri...
python
def _setStyle(node, styleMap): u"""Sets the style attribute of a node to the dictionary ``styleMap``.""" fixedStyle = ';'.join([prop + ':' + styleMap[prop] for prop in styleMap]) if fixedStyle != '': node.setAttribute('style', fixedStyle) elif node.getAttribute('style'): node.removeAttri...
[ "def", "_setStyle", "(", "node", ",", "styleMap", ")", ":", "fixedStyle", "=", "';'", ".", "join", "(", "[", "prop", "+", "':'", "+", "styleMap", "[", "prop", "]", "for", "prop", "in", "styleMap", "]", ")", "if", "fixedStyle", "!=", "''", ":", "nod...
u"""Sets the style attribute of a node to the dictionary ``styleMap``.
[ "u", "Sets", "the", "style", "attribute", "of", "a", "node", "to", "the", "dictionary", "styleMap", "." ]
train
https://github.com/scour-project/scour/blob/049264eba6b1a54ae5ba1d6a5077d8e7b80e8835/scour/scour.py#L1457-L1464
scour-project/scour
scour/scour.py
styleInheritedFromParent
def styleInheritedFromParent(node, style): """ Returns the value of 'style' that is inherited from the parents of the passed-in node Warning: This method only considers presentation attributes and inline styles, any style sheets are ignored! """ parentNode = node.parentNode # retu...
python
def styleInheritedFromParent(node, style): """ Returns the value of 'style' that is inherited from the parents of the passed-in node Warning: This method only considers presentation attributes and inline styles, any style sheets are ignored! """ parentNode = node.parentNode # retu...
[ "def", "styleInheritedFromParent", "(", "node", ",", "style", ")", ":", "parentNode", "=", "node", ".", "parentNode", "# return None if we reached the Document element", "if", "parentNode", ".", "nodeType", "==", "Node", ".", "DOCUMENT_NODE", ":", "return", "None", ...
Returns the value of 'style' that is inherited from the parents of the passed-in node Warning: This method only considers presentation attributes and inline styles, any style sheets are ignored!
[ "Returns", "the", "value", "of", "style", "that", "is", "inherited", "from", "the", "parents", "of", "the", "passed", "-", "in", "node" ]
train
https://github.com/scour-project/scour/blob/049264eba6b1a54ae5ba1d6a5077d8e7b80e8835/scour/scour.py#L1601-L1627
scour-project/scour
scour/scour.py
styleInheritedByChild
def styleInheritedByChild(node, style, nodeIsChild=False): """ Returns whether 'style' is inherited by any children of the passed-in node If False is returned, it is guaranteed that 'style' can safely be removed from the passed-in node without influencing visual output of it's children If True is ...
python
def styleInheritedByChild(node, style, nodeIsChild=False): """ Returns whether 'style' is inherited by any children of the passed-in node If False is returned, it is guaranteed that 'style' can safely be removed from the passed-in node without influencing visual output of it's children If True is ...
[ "def", "styleInheritedByChild", "(", "node", ",", "style", ",", "nodeIsChild", "=", "False", ")", ":", "# Comment, text and CDATA nodes don't have attributes and aren't containers so they can't inherit attributes", "if", "node", ".", "nodeType", "!=", "Node", ".", "ELEMENT_NO...
Returns whether 'style' is inherited by any children of the passed-in node If False is returned, it is guaranteed that 'style' can safely be removed from the passed-in node without influencing visual output of it's children If True is returned, the passed-in node should not have its text-based attribu...
[ "Returns", "whether", "style", "is", "inherited", "by", "any", "children", "of", "the", "passed", "-", "in", "node" ]
train
https://github.com/scour-project/scour/blob/049264eba6b1a54ae5ba1d6a5077d8e7b80e8835/scour/scour.py#L1630-L1677
scour-project/scour
scour/scour.py
mayContainTextNodes
def mayContainTextNodes(node): """ Returns True if the passed-in node is probably a text element, or at least one of its descendants is probably a text element. If False is returned, it is guaranteed that the passed-in node has no business having text-based attributes. If True is returned, the...
python
def mayContainTextNodes(node): """ Returns True if the passed-in node is probably a text element, or at least one of its descendants is probably a text element. If False is returned, it is guaranteed that the passed-in node has no business having text-based attributes. If True is returned, the...
[ "def", "mayContainTextNodes", "(", "node", ")", ":", "# Cached result of a prior call?", "try", ":", "return", "node", ".", "mayContainTextNodes", "except", "AttributeError", ":", "pass", "result", "=", "True", "# Default value", "# Comment, text and CDATA nodes don't have ...
Returns True if the passed-in node is probably a text element, or at least one of its descendants is probably a text element. If False is returned, it is guaranteed that the passed-in node has no business having text-based attributes. If True is returned, the passed-in node should not have its text-ba...
[ "Returns", "True", "if", "the", "passed", "-", "in", "node", "is", "probably", "a", "text", "element", "or", "at", "least", "one", "of", "its", "descendants", "is", "probably", "a", "text", "element", "." ]
train
https://github.com/scour-project/scour/blob/049264eba6b1a54ae5ba1d6a5077d8e7b80e8835/scour/scour.py#L1680-L1720
scour-project/scour
scour/scour.py
taint
def taint(taintedSet, taintedAttribute): u"""Adds an attribute to a set of attributes. Related attributes are also included.""" taintedSet.add(taintedAttribute) if taintedAttribute == 'marker': taintedSet |= set(['marker-start', 'marker-mid', 'marker-end']) if taintedAttribute in ['marker-s...
python
def taint(taintedSet, taintedAttribute): u"""Adds an attribute to a set of attributes. Related attributes are also included.""" taintedSet.add(taintedAttribute) if taintedAttribute == 'marker': taintedSet |= set(['marker-start', 'marker-mid', 'marker-end']) if taintedAttribute in ['marker-s...
[ "def", "taint", "(", "taintedSet", ",", "taintedAttribute", ")", ":", "taintedSet", ".", "add", "(", "taintedAttribute", ")", "if", "taintedAttribute", "==", "'marker'", ":", "taintedSet", "|=", "set", "(", "[", "'marker-start'", ",", "'marker-mid'", ",", "'ma...
u"""Adds an attribute to a set of attributes. Related attributes are also included.
[ "u", "Adds", "an", "attribute", "to", "a", "set", "of", "attributes", "." ]
train
https://github.com/scour-project/scour/blob/049264eba6b1a54ae5ba1d6a5077d8e7b80e8835/scour/scour.py#L1885-L1894
scour-project/scour
scour/scour.py
removeDefaultAttributeValue
def removeDefaultAttributeValue(node, attribute): """ Removes the DefaultAttribute 'attribute' from 'node' if specified conditions are fulfilled Warning: Does NOT check if the attribute is actually valid for the passed element type for increased preformance! """ if not node.hasAttribute(attribute.n...
python
def removeDefaultAttributeValue(node, attribute): """ Removes the DefaultAttribute 'attribute' from 'node' if specified conditions are fulfilled Warning: Does NOT check if the attribute is actually valid for the passed element type for increased preformance! """ if not node.hasAttribute(attribute.n...
[ "def", "removeDefaultAttributeValue", "(", "node", ",", "attribute", ")", ":", "if", "not", "node", ".", "hasAttribute", "(", "attribute", ".", "name", ")", ":", "return", "0", "# differentiate between text and numeric values", "if", "isinstance", "(", "attribute", ...
Removes the DefaultAttribute 'attribute' from 'node' if specified conditions are fulfilled Warning: Does NOT check if the attribute is actually valid for the passed element type for increased preformance!
[ "Removes", "the", "DefaultAttribute", "attribute", "from", "node", "if", "specified", "conditions", "are", "fulfilled" ]
train
https://github.com/scour-project/scour/blob/049264eba6b1a54ae5ba1d6a5077d8e7b80e8835/scour/scour.py#L1897-L1923
scour-project/scour
scour/scour.py
removeDefaultAttributeValues
def removeDefaultAttributeValues(node, options, tainted=set()): u"""'tainted' keeps a set of attributes defined in parent nodes. For such attributes, we don't delete attributes with default values.""" num = 0 if node.nodeType != Node.ELEMENT_NODE: return 0 # Conditionally remove all defaul...
python
def removeDefaultAttributeValues(node, options, tainted=set()): u"""'tainted' keeps a set of attributes defined in parent nodes. For such attributes, we don't delete attributes with default values.""" num = 0 if node.nodeType != Node.ELEMENT_NODE: return 0 # Conditionally remove all defaul...
[ "def", "removeDefaultAttributeValues", "(", "node", ",", "options", ",", "tainted", "=", "set", "(", ")", ")", ":", "num", "=", "0", "if", "node", ".", "nodeType", "!=", "Node", ".", "ELEMENT_NODE", ":", "return", "0", "# Conditionally remove all default attri...
u"""'tainted' keeps a set of attributes defined in parent nodes. For such attributes, we don't delete attributes with default values.
[ "u", "tainted", "keeps", "a", "set", "of", "attributes", "defined", "in", "parent", "nodes", "." ]
train
https://github.com/scour-project/scour/blob/049264eba6b1a54ae5ba1d6a5077d8e7b80e8835/scour/scour.py#L1926-L1971
scour-project/scour
scour/scour.py
convertColor
def convertColor(value): """ Converts the input color string and returns a #RRGGBB (or #RGB if possible) string """ s = value if s in colors: s = colors[s] rgbpMatch = rgbp.match(s) if rgbpMatch is not None: r = int(float(rgbpMatch.group(1)) * 255.0 / 100.0) g = ...
python
def convertColor(value): """ Converts the input color string and returns a #RRGGBB (or #RGB if possible) string """ s = value if s in colors: s = colors[s] rgbpMatch = rgbp.match(s) if rgbpMatch is not None: r = int(float(rgbpMatch.group(1)) * 255.0 / 100.0) g = ...
[ "def", "convertColor", "(", "value", ")", ":", "s", "=", "value", "if", "s", "in", "colors", ":", "s", "=", "colors", "[", "s", "]", "rgbpMatch", "=", "rgbp", ".", "match", "(", "s", ")", "if", "rgbpMatch", "is", "not", "None", ":", "r", "=", "...
Converts the input color string and returns a #RRGGBB (or #RGB if possible) string
[ "Converts", "the", "input", "color", "string", "and", "returns", "a", "#RRGGBB", "(", "or", "#RGB", "if", "possible", ")", "string" ]
train
https://github.com/scour-project/scour/blob/049264eba6b1a54ae5ba1d6a5077d8e7b80e8835/scour/scour.py#L1978-L2006
scour-project/scour
scour/scour.py
convertColors
def convertColors(element): """ Recursively converts all color properties into #RRGGBB format if shorter """ numBytes = 0 if element.nodeType != Node.ELEMENT_NODE: return 0 # set up list of color attributes for each element type attrsToConvert = [] if element.nodeName in ['r...
python
def convertColors(element): """ Recursively converts all color properties into #RRGGBB format if shorter """ numBytes = 0 if element.nodeType != Node.ELEMENT_NODE: return 0 # set up list of color attributes for each element type attrsToConvert = [] if element.nodeName in ['r...
[ "def", "convertColors", "(", "element", ")", ":", "numBytes", "=", "0", "if", "element", ".", "nodeType", "!=", "Node", ".", "ELEMENT_NODE", ":", "return", "0", "# set up list of color attributes for each element type", "attrsToConvert", "=", "[", "]", "if", "elem...
Recursively converts all color properties into #RRGGBB format if shorter
[ "Recursively", "converts", "all", "color", "properties", "into", "#RRGGBB", "format", "if", "shorter" ]
train
https://github.com/scour-project/scour/blob/049264eba6b1a54ae5ba1d6a5077d8e7b80e8835/scour/scour.py#L2009-L2054
scour-project/scour
scour/scour.py
cleanPath
def cleanPath(element, options): """ Cleans the path string (d attribute) of the element """ global _num_bytes_saved_in_path_data global _num_path_segments_removed # this gets the parser object from svg_regex.py oldPathStr = element.getAttribute('d') path = svg_parser.parse(oldPathSt...
python
def cleanPath(element, options): """ Cleans the path string (d attribute) of the element """ global _num_bytes_saved_in_path_data global _num_path_segments_removed # this gets the parser object from svg_regex.py oldPathStr = element.getAttribute('d') path = svg_parser.parse(oldPathSt...
[ "def", "cleanPath", "(", "element", ",", "options", ")", ":", "global", "_num_bytes_saved_in_path_data", "global", "_num_path_segments_removed", "# this gets the parser object from svg_regex.py", "oldPathStr", "=", "element", ".", "getAttribute", "(", "'d'", ")", "path", ...
Cleans the path string (d attribute) of the element
[ "Cleans", "the", "path", "string", "(", "d", "attribute", ")", "of", "the", "element" ]
train
https://github.com/scour-project/scour/blob/049264eba6b1a54ae5ba1d6a5077d8e7b80e8835/scour/scour.py#L2061-L2555
scour-project/scour
scour/scour.py
parseListOfPoints
def parseListOfPoints(s): """ Parse string into a list of points. Returns a list containing an even number of coordinate strings """ i = 0 # (wsp)? comma-or-wsp-separated coordinate pairs (wsp)? # coordinate-pair = coordinate comma-or-wsp coordinate # coordinate = sign? integer ...
python
def parseListOfPoints(s): """ Parse string into a list of points. Returns a list containing an even number of coordinate strings """ i = 0 # (wsp)? comma-or-wsp-separated coordinate pairs (wsp)? # coordinate-pair = coordinate comma-or-wsp coordinate # coordinate = sign? integer ...
[ "def", "parseListOfPoints", "(", "s", ")", ":", "i", "=", "0", "# (wsp)? comma-or-wsp-separated coordinate pairs (wsp)?", "# coordinate-pair = coordinate comma-or-wsp coordinate", "# coordinate = sign? integer", "# comma-wsp: (wsp+ comma? wsp*) | (comma wsp*)", "ws_nums", "=", "re", ...
Parse string into a list of points. Returns a list containing an even number of coordinate strings
[ "Parse", "string", "into", "a", "list", "of", "points", "." ]
train
https://github.com/scour-project/scour/blob/049264eba6b1a54ae5ba1d6a5077d8e7b80e8835/scour/scour.py#L2558-L2615
scour-project/scour
scour/scour.py
cleanPolygon
def cleanPolygon(elem, options): """ Remove unnecessary closing point of polygon points attribute """ global _num_points_removed_from_polygon pts = parseListOfPoints(elem.getAttribute('points')) N = len(pts) / 2 if N >= 2: (startx, starty) = pts[:2] (endx, endy) = pts[-2:...
python
def cleanPolygon(elem, options): """ Remove unnecessary closing point of polygon points attribute """ global _num_points_removed_from_polygon pts = parseListOfPoints(elem.getAttribute('points')) N = len(pts) / 2 if N >= 2: (startx, starty) = pts[:2] (endx, endy) = pts[-2:...
[ "def", "cleanPolygon", "(", "elem", ",", "options", ")", ":", "global", "_num_points_removed_from_polygon", "pts", "=", "parseListOfPoints", "(", "elem", ".", "getAttribute", "(", "'points'", ")", ")", "N", "=", "len", "(", "pts", ")", "/", "2", "if", "N",...
Remove unnecessary closing point of polygon points attribute
[ "Remove", "unnecessary", "closing", "point", "of", "polygon", "points", "attribute" ]
train
https://github.com/scour-project/scour/blob/049264eba6b1a54ae5ba1d6a5077d8e7b80e8835/scour/scour.py#L2618-L2632
scour-project/scour
scour/scour.py
cleanPolyline
def cleanPolyline(elem, options): """ Scour the polyline points attribute """ pts = parseListOfPoints(elem.getAttribute('points')) elem.setAttribute('points', scourCoordinates(pts, options, True))
python
def cleanPolyline(elem, options): """ Scour the polyline points attribute """ pts = parseListOfPoints(elem.getAttribute('points')) elem.setAttribute('points', scourCoordinates(pts, options, True))
[ "def", "cleanPolyline", "(", "elem", ",", "options", ")", ":", "pts", "=", "parseListOfPoints", "(", "elem", ".", "getAttribute", "(", "'points'", ")", ")", "elem", ".", "setAttribute", "(", "'points'", ",", "scourCoordinates", "(", "pts", ",", "options", ...
Scour the polyline points attribute
[ "Scour", "the", "polyline", "points", "attribute" ]
train
https://github.com/scour-project/scour/blob/049264eba6b1a54ae5ba1d6a5077d8e7b80e8835/scour/scour.py#L2635-L2640
scour-project/scour
scour/scour.py
controlPoints
def controlPoints(cmd, data): """ Checks if there are control points in the path data Returns the indices of all values in the path data which are control points """ cmd = cmd.lower() if cmd in ['c', 's', 'q']: indices = range(len(data)) if cmd == 'c': # c: (x1 y1 x2 y2 x...
python
def controlPoints(cmd, data): """ Checks if there are control points in the path data Returns the indices of all values in the path data which are control points """ cmd = cmd.lower() if cmd in ['c', 's', 'q']: indices = range(len(data)) if cmd == 'c': # c: (x1 y1 x2 y2 x...
[ "def", "controlPoints", "(", "cmd", ",", "data", ")", ":", "cmd", "=", "cmd", ".", "lower", "(", ")", "if", "cmd", "in", "[", "'c'", ",", "'s'", ",", "'q'", "]", ":", "indices", "=", "range", "(", "len", "(", "data", ")", ")", "if", "cmd", "=...
Checks if there are control points in the path data Returns the indices of all values in the path data which are control points
[ "Checks", "if", "there", "are", "control", "points", "in", "the", "path", "data" ]
train
https://github.com/scour-project/scour/blob/049264eba6b1a54ae5ba1d6a5077d8e7b80e8835/scour/scour.py#L2643-L2657
scour-project/scour
scour/scour.py
flags
def flags(cmd, data): """ Checks if there are flags in the path data Returns the indices of all values in the path data which are flags """ if cmd.lower() == 'a': # a: (rx ry x-axis-rotation large-arc-flag sweep-flag x y)+ indices = range(len(data)) return [index for index in...
python
def flags(cmd, data): """ Checks if there are flags in the path data Returns the indices of all values in the path data which are flags """ if cmd.lower() == 'a': # a: (rx ry x-axis-rotation large-arc-flag sweep-flag x y)+ indices = range(len(data)) return [index for index in...
[ "def", "flags", "(", "cmd", ",", "data", ")", ":", "if", "cmd", ".", "lower", "(", ")", "==", "'a'", ":", "# a: (rx ry x-axis-rotation large-arc-flag sweep-flag x y)+", "indices", "=", "range", "(", "len", "(", "data", ")", ")", "return", "[", "index", "fo...
Checks if there are flags in the path data Returns the indices of all values in the path data which are flags
[ "Checks", "if", "there", "are", "flags", "in", "the", "path", "data" ]
train
https://github.com/scour-project/scour/blob/049264eba6b1a54ae5ba1d6a5077d8e7b80e8835/scour/scour.py#L2660-L2670
scour-project/scour
scour/scour.py
serializePath
def serializePath(pathObj, options): """ Reserializes the path data with some cleanups. """ # elliptical arc commands must have comma/wsp separating the coordinates # this fixes an issue outlined in Fix https://bugs.launchpad.net/scour/+bug/412754 return ''.join([cmd + scourCoordinates(data, ...
python
def serializePath(pathObj, options): """ Reserializes the path data with some cleanups. """ # elliptical arc commands must have comma/wsp separating the coordinates # this fixes an issue outlined in Fix https://bugs.launchpad.net/scour/+bug/412754 return ''.join([cmd + scourCoordinates(data, ...
[ "def", "serializePath", "(", "pathObj", ",", "options", ")", ":", "# elliptical arc commands must have comma/wsp separating the coordinates", "# this fixes an issue outlined in Fix https://bugs.launchpad.net/scour/+bug/412754", "return", "''", ".", "join", "(", "[", "cmd", "+", "...
Reserializes the path data with some cleanups.
[ "Reserializes", "the", "path", "data", "with", "some", "cleanups", "." ]
train
https://github.com/scour-project/scour/blob/049264eba6b1a54ae5ba1d6a5077d8e7b80e8835/scour/scour.py#L2673-L2682
scour-project/scour
scour/scour.py
serializeTransform
def serializeTransform(transformObj): """ Reserializes the transform data with some cleanups. """ return ' '.join([command + '(' + ' '.join([scourUnitlessLength(number) for number in numbers]) + ')' for command, numbers in transformObj])
python
def serializeTransform(transformObj): """ Reserializes the transform data with some cleanups. """ return ' '.join([command + '(' + ' '.join([scourUnitlessLength(number) for number in numbers]) + ')' for command, numbers in transformObj])
[ "def", "serializeTransform", "(", "transformObj", ")", ":", "return", "' '", ".", "join", "(", "[", "command", "+", "'('", "+", "' '", ".", "join", "(", "[", "scourUnitlessLength", "(", "number", ")", "for", "number", "in", "numbers", "]", ")", "+", "'...
Reserializes the transform data with some cleanups.
[ "Reserializes", "the", "transform", "data", "with", "some", "cleanups", "." ]
train
https://github.com/scour-project/scour/blob/049264eba6b1a54ae5ba1d6a5077d8e7b80e8835/scour/scour.py#L2685-L2690
scour-project/scour
scour/scour.py
scourCoordinates
def scourCoordinates(data, options, force_whitespace=False, control_points=[], flags=[]): """ Serializes coordinate data with some cleanups: - removes all trailing zeros after the decimal - integerize coordinates if possible - removes extraneous whitespace - adds space...
python
def scourCoordinates(data, options, force_whitespace=False, control_points=[], flags=[]): """ Serializes coordinate data with some cleanups: - removes all trailing zeros after the decimal - integerize coordinates if possible - removes extraneous whitespace - adds space...
[ "def", "scourCoordinates", "(", "data", ",", "options", ",", "force_whitespace", "=", "False", ",", "control_points", "=", "[", "]", ",", "flags", "=", "[", "]", ")", ":", "if", "data", "is", "not", "None", ":", "newData", "=", "[", "]", "c", "=", ...
Serializes coordinate data with some cleanups: - removes all trailing zeros after the decimal - integerize coordinates if possible - removes extraneous whitespace - adds spaces between values in a subcommand if required (or if force_whitespace is True)
[ "Serializes", "coordinate", "data", "with", "some", "cleanups", ":", "-", "removes", "all", "trailing", "zeros", "after", "the", "decimal", "-", "integerize", "coordinates", "if", "possible", "-", "removes", "extraneous", "whitespace", "-", "adds", "spaces", "be...
train
https://github.com/scour-project/scour/blob/049264eba6b1a54ae5ba1d6a5077d8e7b80e8835/scour/scour.py#L2693-L2742
scour-project/scour
scour/scour.py
scourLength
def scourLength(length): """ Scours a length. Accepts units. """ length = SVGLength(length) return scourUnitlessLength(length.value) + Unit.str(length.units)
python
def scourLength(length): """ Scours a length. Accepts units. """ length = SVGLength(length) return scourUnitlessLength(length.value) + Unit.str(length.units)
[ "def", "scourLength", "(", "length", ")", ":", "length", "=", "SVGLength", "(", "length", ")", "return", "scourUnitlessLength", "(", "length", ".", "value", ")", "+", "Unit", ".", "str", "(", "length", ".", "units", ")" ]
Scours a length. Accepts units.
[ "Scours", "a", "length", ".", "Accepts", "units", "." ]
train
https://github.com/scour-project/scour/blob/049264eba6b1a54ae5ba1d6a5077d8e7b80e8835/scour/scour.py#L2745-L2751
scour-project/scour
scour/scour.py
scourUnitlessLength
def scourUnitlessLength(length, renderer_workaround=False, is_control_point=False): # length is of a numeric type """ Scours the numeric part of a length only. Does not accept units. This is faster than scourLength on elements guaranteed not to contain units. """ if not isinstance(length, Deci...
python
def scourUnitlessLength(length, renderer_workaround=False, is_control_point=False): # length is of a numeric type """ Scours the numeric part of a length only. Does not accept units. This is faster than scourLength on elements guaranteed not to contain units. """ if not isinstance(length, Deci...
[ "def", "scourUnitlessLength", "(", "length", ",", "renderer_workaround", "=", "False", ",", "is_control_point", "=", "False", ")", ":", "# length is of a numeric type", "if", "not", "isinstance", "(", "length", ",", "Decimal", ")", ":", "length", "=", "getcontext"...
Scours the numeric part of a length only. Does not accept units. This is faster than scourLength on elements guaranteed not to contain units.
[ "Scours", "the", "numeric", "part", "of", "a", "length", "only", ".", "Does", "not", "accept", "units", "." ]
train
https://github.com/scour-project/scour/blob/049264eba6b1a54ae5ba1d6a5077d8e7b80e8835/scour/scour.py#L2754-L2804
scour-project/scour
scour/scour.py
reducePrecision
def reducePrecision(element): """ Because opacities, letter spacings, stroke widths and all that don't need to be preserved in SVG files with 9 digits of precision. Takes all of these attributes, in the given element node and its children, and reduces their precision to the current Decimal context'...
python
def reducePrecision(element): """ Because opacities, letter spacings, stroke widths and all that don't need to be preserved in SVG files with 9 digits of precision. Takes all of these attributes, in the given element node and its children, and reduces their precision to the current Decimal context'...
[ "def", "reducePrecision", "(", "element", ")", ":", "num", "=", "0", "styles", "=", "_getStyle", "(", "element", ")", "for", "lengthAttr", "in", "[", "'opacity'", ",", "'flood-opacity'", ",", "'fill-opacity'", ",", "'stroke-opacity'", ",", "'stop-opacity'", ",...
Because opacities, letter spacings, stroke widths and all that don't need to be preserved in SVG files with 9 digits of precision. Takes all of these attributes, in the given element node and its children, and reduces their precision to the current Decimal context's precision. Also checks for the attri...
[ "Because", "opacities", "letter", "spacings", "stroke", "widths", "and", "all", "that", "don", "t", "need", "to", "be", "preserved", "in", "SVG", "files", "with", "9", "digits", "of", "precision", "." ]
train
https://github.com/scour-project/scour/blob/049264eba6b1a54ae5ba1d6a5077d8e7b80e8835/scour/scour.py#L2807-L2850
scour-project/scour
scour/scour.py
optimizeAngle
def optimizeAngle(angle): """ Because any rotation can be expressed within 360 degrees of any given number, and since negative angles sometimes are one character longer than corresponding positive angle, we shorten the number to one in the range to [-90, 270[. """ # First, we put the new ang...
python
def optimizeAngle(angle): """ Because any rotation can be expressed within 360 degrees of any given number, and since negative angles sometimes are one character longer than corresponding positive angle, we shorten the number to one in the range to [-90, 270[. """ # First, we put the new ang...
[ "def", "optimizeAngle", "(", "angle", ")", ":", "# First, we put the new angle in the range ]-360, 360[.", "# The modulo operator yields results with the sign of the", "# divisor, so for negative dividends, we preserve the sign", "# of the angle.", "if", "angle", "<", "0", ":", "angle"...
Because any rotation can be expressed within 360 degrees of any given number, and since negative angles sometimes are one character longer than corresponding positive angle, we shorten the number to one in the range to [-90, 270[.
[ "Because", "any", "rotation", "can", "be", "expressed", "within", "360", "degrees", "of", "any", "given", "number", "and", "since", "negative", "angles", "sometimes", "are", "one", "character", "longer", "than", "corresponding", "positive", "angle", "we", "short...
train
https://github.com/scour-project/scour/blob/049264eba6b1a54ae5ba1d6a5077d8e7b80e8835/scour/scour.py#L2853-L2876
scour-project/scour
scour/scour.py
optimizeTransform
def optimizeTransform(transform): """ Optimises a series of transformations parsed from a single transform="" attribute. The transformation list is modified in-place. """ # FIXME: reordering these would optimize even more cases: # first: Fold consecutive runs of the same transformation ...
python
def optimizeTransform(transform): """ Optimises a series of transformations parsed from a single transform="" attribute. The transformation list is modified in-place. """ # FIXME: reordering these would optimize even more cases: # first: Fold consecutive runs of the same transformation ...
[ "def", "optimizeTransform", "(", "transform", ")", ":", "# FIXME: reordering these would optimize even more cases:", "# first: Fold consecutive runs of the same transformation", "# extra: Attempt to cast between types to create sameness:", "# \"matrix(0 1 -1 0 0 0) rotate(180) scale(-...
Optimises a series of transformations parsed from a single transform="" attribute. The transformation list is modified in-place.
[ "Optimises", "a", "series", "of", "transformations", "parsed", "from", "a", "single", "transform", "=", "attribute", "." ]
train
https://github.com/scour-project/scour/blob/049264eba6b1a54ae5ba1d6a5077d8e7b80e8835/scour/scour.py#L2879-L3038
scour-project/scour
scour/scour.py
optimizeTransforms
def optimizeTransforms(element, options): """ Attempts to optimise transform specifications on the given node and its children. Returns the number of bytes saved after performing these reductions. """ num = 0 for transformAttr in ['transform', 'patternTransform', 'gradientTransform']: ...
python
def optimizeTransforms(element, options): """ Attempts to optimise transform specifications on the given node and its children. Returns the number of bytes saved after performing these reductions. """ num = 0 for transformAttr in ['transform', 'patternTransform', 'gradientTransform']: ...
[ "def", "optimizeTransforms", "(", "element", ",", "options", ")", ":", "num", "=", "0", "for", "transformAttr", "in", "[", "'transform'", ",", "'patternTransform'", ",", "'gradientTransform'", "]", ":", "val", "=", "element", ".", "getAttribute", "(", "transfo...
Attempts to optimise transform specifications on the given node and its children. Returns the number of bytes saved after performing these reductions.
[ "Attempts", "to", "optimise", "transform", "specifications", "on", "the", "given", "node", "and", "its", "children", "." ]
train
https://github.com/scour-project/scour/blob/049264eba6b1a54ae5ba1d6a5077d8e7b80e8835/scour/scour.py#L3041-L3069
scour-project/scour
scour/scour.py
removeComments
def removeComments(element): """ Removes comments from the element and its children. """ global _num_bytes_saved_in_comments num = 0 if isinstance(element, xml.dom.minidom.Comment): _num_bytes_saved_in_comments += len(element.data) element.parentNode.removeChild(element) ...
python
def removeComments(element): """ Removes comments from the element and its children. """ global _num_bytes_saved_in_comments num = 0 if isinstance(element, xml.dom.minidom.Comment): _num_bytes_saved_in_comments += len(element.data) element.parentNode.removeChild(element) ...
[ "def", "removeComments", "(", "element", ")", ":", "global", "_num_bytes_saved_in_comments", "num", "=", "0", "if", "isinstance", "(", "element", ",", "xml", ".", "dom", ".", "minidom", ".", "Comment", ")", ":", "_num_bytes_saved_in_comments", "+=", "len", "("...
Removes comments from the element and its children.
[ "Removes", "comments", "from", "the", "element", "and", "its", "children", "." ]
train
https://github.com/scour-project/scour/blob/049264eba6b1a54ae5ba1d6a5077d8e7b80e8835/scour/scour.py#L3072-L3087
scour-project/scour
scour/scour.py
embedRasters
def embedRasters(element, options): import base64 """ Converts raster references to inline images. NOTE: there are size limits to base64-encoding handling in browsers """ global _num_rasters_embedded href = element.getAttributeNS(NS['XLINK'], 'href') # if xlink:href is set, then gr...
python
def embedRasters(element, options): import base64 """ Converts raster references to inline images. NOTE: there are size limits to base64-encoding handling in browsers """ global _num_rasters_embedded href = element.getAttributeNS(NS['XLINK'], 'href') # if xlink:href is set, then gr...
[ "def", "embedRasters", "(", "element", ",", "options", ")", ":", "import", "base64", "global", "_num_rasters_embedded", "href", "=", "element", ".", "getAttributeNS", "(", "NS", "[", "'XLINK'", "]", ",", "'href'", ")", "# if xlink:href is set, then grab the id", "...
Converts raster references to inline images. NOTE: there are size limits to base64-encoding handling in browsers
[ "Converts", "raster", "references", "to", "inline", "images", ".", "NOTE", ":", "there", "are", "size", "limits", "to", "base64", "-", "encoding", "handling", "in", "browsers" ]
train
https://github.com/scour-project/scour/blob/049264eba6b1a54ae5ba1d6a5077d8e7b80e8835/scour/scour.py#L3090-L3165
tym-xqo/nerium
nerium/formatter.py
get_format
def get_format(format_): """ Find format schema in $FORMAT_PATH or nerium/schema """ format_path = os.getenv('FORMAT_PATH', 'format_files') try: spec = importlib.util.spec_from_file_location( "format_mod", f"{format_path}/{format_}.py") format_mod = importlib.util.module_from...
python
def get_format(format_): """ Find format schema in $FORMAT_PATH or nerium/schema """ format_path = os.getenv('FORMAT_PATH', 'format_files') try: spec = importlib.util.spec_from_file_location( "format_mod", f"{format_path}/{format_}.py") format_mod = importlib.util.module_from...
[ "def", "get_format", "(", "format_", ")", ":", "format_path", "=", "os", ".", "getenv", "(", "'FORMAT_PATH'", ",", "'format_files'", ")", "try", ":", "spec", "=", "importlib", ".", "util", ".", "spec_from_file_location", "(", "\"format_mod\"", ",", "f\"{format...
Find format schema in $FORMAT_PATH or nerium/schema
[ "Find", "format", "schema", "in", "$FORMAT_PATH", "or", "nerium", "/", "schema" ]
train
https://github.com/tym-xqo/nerium/blob/b234847d95f37c3a49dff15a189205fe5bbbc05f/nerium/formatter.py#L6-L21
vedvyas/doxytag2zealdb
doxytag2zealdb/propertylist.py
DoxygenPropertyList.set_property
def set_property(self, key, value): '''Set a new (or updating existing) key value pair. Args: key: A string containing the key namespace value: A str, int, or bool value Raises: NotImplementedError: an unsupported value-type was provided ''' ...
python
def set_property(self, key, value): '''Set a new (or updating existing) key value pair. Args: key: A string containing the key namespace value: A str, int, or bool value Raises: NotImplementedError: an unsupported value-type was provided ''' ...
[ "def", "set_property", "(", "self", ",", "key", ",", "value", ")", ":", "value_type", "=", "type", "(", "value", ")", "if", "value_type", "not", "in", "[", "str", ",", "int", ",", "bool", "]", ":", "raise", "NotImplementedError", "(", "'Only string, inte...
Set a new (or updating existing) key value pair. Args: key: A string containing the key namespace value: A str, int, or bool value Raises: NotImplementedError: an unsupported value-type was provided
[ "Set", "a", "new", "(", "or", "updating", "existing", ")", "key", "value", "pair", "." ]
train
https://github.com/vedvyas/doxytag2zealdb/blob/8b07a88af6794248f8cfdabb0fda9dd61c777127/doxytag2zealdb/propertylist.py#L68-L110
vedvyas/doxytag2zealdb
doxytag2zealdb/propertylist.py
DoxygenPropertyList.save
def save(self): '''Save current property list representation to the original file.''' with open(self.filename, 'w') as plist_file: plist_file.write(str(self.soup))
python
def save(self): '''Save current property list representation to the original file.''' with open(self.filename, 'w') as plist_file: plist_file.write(str(self.soup))
[ "def", "save", "(", "self", ")", ":", "with", "open", "(", "self", ".", "filename", ",", "'w'", ")", "as", "plist_file", ":", "plist_file", ".", "write", "(", "str", "(", "self", ".", "soup", ")", ")" ]
Save current property list representation to the original file.
[ "Save", "current", "property", "list", "representation", "to", "the", "original", "file", "." ]
train
https://github.com/vedvyas/doxytag2zealdb/blob/8b07a88af6794248f8cfdabb0fda9dd61c777127/doxytag2zealdb/propertylist.py#L112-L115
mezz64/pyEight
pyeight/eight.py
EightSleep.fetch_userid
def fetch_userid(self, side): """Return the userid for the specified bed side.""" for user in self.users: obj = self.users[user] if obj.side == side: return user
python
def fetch_userid(self, side): """Return the userid for the specified bed side.""" for user in self.users: obj = self.users[user] if obj.side == side: return user
[ "def", "fetch_userid", "(", "self", ",", "side", ")", ":", "for", "user", "in", "self", ".", "users", ":", "obj", "=", "self", ".", "users", "[", "user", "]", "if", "obj", ".", "side", "==", "side", ":", "return", "user" ]
Return the userid for the specified bed side.
[ "Return", "the", "userid", "for", "the", "specified", "bed", "side", "." ]
train
https://github.com/mezz64/pyEight/blob/e557e4e6876f490d0964298e9475d68b64222d4f/pyeight/eight.py#L84-L89
mezz64/pyEight
pyeight/eight.py
EightSleep.start
async def start(self): """Start api initialization.""" _LOGGER.debug('Initializing pyEight Version: %s', __version__) await self.fetch_token() if self._token is not None: await self.fetch_device_list() await self.assign_users() return True else...
python
async def start(self): """Start api initialization.""" _LOGGER.debug('Initializing pyEight Version: %s', __version__) await self.fetch_token() if self._token is not None: await self.fetch_device_list() await self.assign_users() return True else...
[ "async", "def", "start", "(", "self", ")", ":", "_LOGGER", ".", "debug", "(", "'Initializing pyEight Version: %s'", ",", "__version__", ")", "await", "self", ".", "fetch_token", "(", ")", "if", "self", ".", "_token", "is", "not", "None", ":", "await", "sel...
Start api initialization.
[ "Start", "api", "initialization", "." ]
train
https://github.com/mezz64/pyEight/blob/e557e4e6876f490d0964298e9475d68b64222d4f/pyeight/eight.py#L96-L106
mezz64/pyEight
pyeight/eight.py
EightSleep.fetch_token
async def fetch_token(self): """Fetch new session token from api.""" url = '{}/login'.format(API_URL) payload = 'email={}&password={}'.format(self._email, self._password) reg = await self.api_post(url, None, payload) if reg is None: _LOGGER.error('Unable to authentic...
python
async def fetch_token(self): """Fetch new session token from api.""" url = '{}/login'.format(API_URL) payload = 'email={}&password={}'.format(self._email, self._password) reg = await self.api_post(url, None, payload) if reg is None: _LOGGER.error('Unable to authentic...
[ "async", "def", "fetch_token", "(", "self", ")", ":", "url", "=", "'{}/login'", ".", "format", "(", "API_URL", ")", "payload", "=", "'email={}&password={}'", ".", "format", "(", "self", ".", "_email", ",", "self", ".", "_password", ")", "reg", "=", "awai...
Fetch new session token from api.
[ "Fetch", "new", "session", "token", "from", "api", "." ]
train
https://github.com/mezz64/pyEight/blob/e557e4e6876f490d0964298e9475d68b64222d4f/pyeight/eight.py#L113-L125
mezz64/pyEight
pyeight/eight.py
EightSleep.fetch_device_list
async def fetch_device_list(self): """Fetch list of devices.""" url = '{}/users/me'.format(API_URL) dlist = await self.api_get(url) if dlist is None: _LOGGER.error('Unable to fetch eight devices.') else: self._devices = dlist['user']['devices'] ...
python
async def fetch_device_list(self): """Fetch list of devices.""" url = '{}/users/me'.format(API_URL) dlist = await self.api_get(url) if dlist is None: _LOGGER.error('Unable to fetch eight devices.') else: self._devices = dlist['user']['devices'] ...
[ "async", "def", "fetch_device_list", "(", "self", ")", ":", "url", "=", "'{}/users/me'", ".", "format", "(", "API_URL", ")", "dlist", "=", "await", "self", ".", "api_get", "(", "url", ")", "if", "dlist", "is", "None", ":", "_LOGGER", ".", "error", "(",...
Fetch list of devices.
[ "Fetch", "list", "of", "devices", "." ]
train
https://github.com/mezz64/pyEight/blob/e557e4e6876f490d0964298e9475d68b64222d4f/pyeight/eight.py#L127-L136
mezz64/pyEight
pyeight/eight.py
EightSleep.assign_users
async def assign_users(self): """Update device properties.""" device = self._devices[0] url = '{}/devices/{}?filter=ownerId,leftUserId,rightUserId' \ .format(API_URL, device) data = await self.api_get(url) if data is None: _LOGGER.error('Unable to assign ...
python
async def assign_users(self): """Update device properties.""" device = self._devices[0] url = '{}/devices/{}?filter=ownerId,leftUserId,rightUserId' \ .format(API_URL, device) data = await self.api_get(url) if data is None: _LOGGER.error('Unable to assign ...
[ "async", "def", "assign_users", "(", "self", ")", ":", "device", "=", "self", ".", "_devices", "[", "0", "]", "url", "=", "'{}/devices/{}?filter=ownerId,leftUserId,rightUserId'", ".", "format", "(", "API_URL", ",", "device", ")", "data", "=", "await", "self", ...
Update device properties.
[ "Update", "device", "properties", "." ]
train
https://github.com/mezz64/pyEight/blob/e557e4e6876f490d0964298e9475d68b64222d4f/pyeight/eight.py#L138-L166
mezz64/pyEight
pyeight/eight.py
EightSleep.room_temperature
def room_temperature(self): """Return room temperature for both sides of bed.""" # Check which side is active, if both are return the average tmp = None tmp2 = None for user in self.users: obj = self.users[user] if obj.current_values['processing']: ...
python
def room_temperature(self): """Return room temperature for both sides of bed.""" # Check which side is active, if both are return the average tmp = None tmp2 = None for user in self.users: obj = self.users[user] if obj.current_values['processing']: ...
[ "def", "room_temperature", "(", "self", ")", ":", "# Check which side is active, if both are return the average", "tmp", "=", "None", "tmp2", "=", "None", "for", "user", "in", "self", ".", "users", ":", "obj", "=", "self", ".", "users", "[", "user", "]", "if",...
Return room temperature for both sides of bed.
[ "Return", "room", "temperature", "for", "both", "sides", "of", "bed", "." ]
train
https://github.com/mezz64/pyEight/blob/e557e4e6876f490d0964298e9475d68b64222d4f/pyeight/eight.py#L168-L189
mezz64/pyEight
pyeight/eight.py
EightSleep.handle_device_json
def handle_device_json(self, data): """Manage the device json list.""" self._device_json.insert(0, data) self._device_json.pop()
python
def handle_device_json(self, data): """Manage the device json list.""" self._device_json.insert(0, data) self._device_json.pop()
[ "def", "handle_device_json", "(", "self", ",", "data", ")", ":", "self", ".", "_device_json", ".", "insert", "(", "0", ",", "data", ")", "self", ".", "_device_json", ".", "pop", "(", ")" ]
Manage the device json list.
[ "Manage", "the", "device", "json", "list", "." ]
train
https://github.com/mezz64/pyEight/blob/e557e4e6876f490d0964298e9475d68b64222d4f/pyeight/eight.py#L191-L194
mezz64/pyEight
pyeight/eight.py
EightSleep.update_device_data
async def update_device_data(self): """Update device data json.""" url = '{}/devices/{}?offlineView=true'.format(API_URL, self.deviceid) # Check for access token expiration (every 15days) exp_delta = datetime.strptime(self._expdate, '%Y-%m-%dT%H:%M:%S.%fZ') \ - datetime.from...
python
async def update_device_data(self): """Update device data json.""" url = '{}/devices/{}?offlineView=true'.format(API_URL, self.deviceid) # Check for access token expiration (every 15days) exp_delta = datetime.strptime(self._expdate, '%Y-%m-%dT%H:%M:%S.%fZ') \ - datetime.from...
[ "async", "def", "update_device_data", "(", "self", ")", ":", "url", "=", "'{}/devices/{}?offlineView=true'", ".", "format", "(", "API_URL", ",", "self", ".", "deviceid", ")", "# Check for access token expiration (every 15days)", "exp_delta", "=", "datetime", ".", "str...
Update device data json.
[ "Update", "device", "data", "json", "." ]
train
https://github.com/mezz64/pyEight/blob/e557e4e6876f490d0964298e9475d68b64222d4f/pyeight/eight.py#L196-L215
mezz64/pyEight
pyeight/eight.py
EightSleep.api_get
async def api_get(self, url, params=None): """Make api fetch request.""" request = None headers = DEFAULT_HEADERS.copy() headers.update({'Session-Token': self._token}) try: with async_timeout.timeout(DEFAULT_TIMEOUT, loop=self._event_loop): request = ...
python
async def api_get(self, url, params=None): """Make api fetch request.""" request = None headers = DEFAULT_HEADERS.copy() headers.update({'Session-Token': self._token}) try: with async_timeout.timeout(DEFAULT_TIMEOUT, loop=self._event_loop): request = ...
[ "async", "def", "api_get", "(", "self", ",", "url", ",", "params", "=", "None", ")", ":", "request", "=", "None", "headers", "=", "DEFAULT_HEADERS", ".", "copy", "(", ")", "headers", ".", "update", "(", "{", "'Session-Token'", ":", "self", ".", "_token...
Make api fetch request.
[ "Make", "api", "fetch", "request", "." ]
train
https://github.com/mezz64/pyEight/blob/e557e4e6876f490d0964298e9475d68b64222d4f/pyeight/eight.py#L241-L267
mezz64/pyEight
pyeight/eight.py
EightSleep.api_put
async def api_put(self, url, data=None): """Make api post request.""" put = None headers = DEFAULT_HEADERS.copy() headers.update({'Session-Token': self._token}) try: with async_timeout.timeout(DEFAULT_TIMEOUT, loop=self._event_loop): put = await self....
python
async def api_put(self, url, data=None): """Make api post request.""" put = None headers = DEFAULT_HEADERS.copy() headers.update({'Session-Token': self._token}) try: with async_timeout.timeout(DEFAULT_TIMEOUT, loop=self._event_loop): put = await self....
[ "async", "def", "api_put", "(", "self", ",", "url", ",", "data", "=", "None", ")", ":", "put", "=", "None", "headers", "=", "DEFAULT_HEADERS", ".", "copy", "(", ")", "headers", ".", "update", "(", "{", "'Session-Token'", ":", "self", ".", "_token", "...
Make api post request.
[ "Make", "api", "post", "request", "." ]
train
https://github.com/mezz64/pyEight/blob/e557e4e6876f490d0964298e9475d68b64222d4f/pyeight/eight.py#L269-L294
MonashBI/arcana
arcana/environment/static.py
StaticEnv.satisfy
def satisfy(self, *requirements): """ Checks whether the given requirements are satisfiable within the given execution context Parameter --------- requirements : list(Requirement) List of requirements to check whether they are satisfiable """ ...
python
def satisfy(self, *requirements): """ Checks whether the given requirements are satisfiable within the given execution context Parameter --------- requirements : list(Requirement) List of requirements to check whether they are satisfiable """ ...
[ "def", "satisfy", "(", "self", ",", "*", "requirements", ")", ":", "versions", "=", "[", "]", "for", "req_range", "in", "requirements", ":", "try", ":", "version", "=", "self", ".", "_detected_versions", "[", "req_range", ".", "name", "]", "except", "Key...
Checks whether the given requirements are satisfiable within the given execution context Parameter --------- requirements : list(Requirement) List of requirements to check whether they are satisfiable
[ "Checks", "whether", "the", "given", "requirements", "are", "satisfiable", "within", "the", "given", "execution", "context" ]
train
https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/environment/static.py#L30-L64
gwww/elkm1
elkm1_lib/message.py
housecode_to_index
def housecode_to_index(housecode): """Convert a X10 housecode to a zero-based index""" match = re.search(r'^([A-P])(\d{1,2})$', housecode.upper()) if match: house_index = int(match.group(2)) if 1 <= house_index <= 16: return (ord(match.group(1)) - ord('A')) * 16 + house_index - 1...
python
def housecode_to_index(housecode): """Convert a X10 housecode to a zero-based index""" match = re.search(r'^([A-P])(\d{1,2})$', housecode.upper()) if match: house_index = int(match.group(2)) if 1 <= house_index <= 16: return (ord(match.group(1)) - ord('A')) * 16 + house_index - 1...
[ "def", "housecode_to_index", "(", "housecode", ")", ":", "match", "=", "re", ".", "search", "(", "r'^([A-P])(\\d{1,2})$'", ",", "housecode", ".", "upper", "(", ")", ")", "if", "match", ":", "house_index", "=", "int", "(", "match", ".", "group", "(", "2",...
Convert a X10 housecode to a zero-based index
[ "Convert", "a", "X10", "housecode", "to", "a", "zero", "-", "based", "index" ]
train
https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/message.py#L236-L243
gwww/elkm1
elkm1_lib/message.py
index_to_housecode
def index_to_housecode(index): """Convert a zero-based index to a X10 housecode.""" if index < 0 or index > 255: raise ValueError quotient, remainder = divmod(index, 16) return chr(quotient+ord('A')) + '{:02d}'.format(remainder+1)
python
def index_to_housecode(index): """Convert a zero-based index to a X10 housecode.""" if index < 0 or index > 255: raise ValueError quotient, remainder = divmod(index, 16) return chr(quotient+ord('A')) + '{:02d}'.format(remainder+1)
[ "def", "index_to_housecode", "(", "index", ")", ":", "if", "index", "<", "0", "or", "index", ">", "255", ":", "raise", "ValueError", "quotient", ",", "remainder", "=", "divmod", "(", "index", ",", "16", ")", "return", "chr", "(", "quotient", "+", "ord"...
Convert a zero-based index to a X10 housecode.
[ "Convert", "a", "zero", "-", "based", "index", "to", "a", "X10", "housecode", "." ]
train
https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/message.py#L246-L251
gwww/elkm1
elkm1_lib/message.py
_check_checksum
def _check_checksum(msg): """Ensure checksum in message is good.""" checksum = int(msg[-2:], 16) for char in msg[:-2]: checksum += ord(char) if (checksum % 256) != 0: raise ValueError("Elk message checksum invalid")
python
def _check_checksum(msg): """Ensure checksum in message is good.""" checksum = int(msg[-2:], 16) for char in msg[:-2]: checksum += ord(char) if (checksum % 256) != 0: raise ValueError("Elk message checksum invalid")
[ "def", "_check_checksum", "(", "msg", ")", ":", "checksum", "=", "int", "(", "msg", "[", "-", "2", ":", "]", ",", "16", ")", "for", "char", "in", "msg", "[", ":", "-", "2", "]", ":", "checksum", "+=", "ord", "(", "char", ")", "if", "(", "chec...
Ensure checksum in message is good.
[ "Ensure", "checksum", "in", "message", "is", "good", "." ]
train
https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/message.py#L268-L274
gwww/elkm1
elkm1_lib/message.py
_check_message_valid
def _check_message_valid(msg): """Check packet length valid and that checksum is good.""" try: if int(msg[:2], 16) != (len(msg) - 2): raise ValueError("Elk message length incorrect") _check_checksum(msg) except IndexError: raise ValueError("Elk message length incorrect")
python
def _check_message_valid(msg): """Check packet length valid and that checksum is good.""" try: if int(msg[:2], 16) != (len(msg) - 2): raise ValueError("Elk message length incorrect") _check_checksum(msg) except IndexError: raise ValueError("Elk message length incorrect")
[ "def", "_check_message_valid", "(", "msg", ")", ":", "try", ":", "if", "int", "(", "msg", "[", ":", "2", "]", ",", "16", ")", "!=", "(", "len", "(", "msg", ")", "-", "2", ")", ":", "raise", "ValueError", "(", "\"Elk message length incorrect\"", ")", ...
Check packet length valid and that checksum is good.
[ "Check", "packet", "length", "valid", "and", "that", "checksum", "is", "good", "." ]
train
https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/message.py#L277-L284
gwww/elkm1
elkm1_lib/message.py
cw_encode
def cw_encode(index, value, value_format): """cw: Write a custom value.""" if value_format == 2: value = value[0] << 8 + value[1] return MessageEncode('0Dcw{:02d}{:05d}00'.format(index+1, value), None)
python
def cw_encode(index, value, value_format): """cw: Write a custom value.""" if value_format == 2: value = value[0] << 8 + value[1] return MessageEncode('0Dcw{:02d}{:05d}00'.format(index+1, value), None)
[ "def", "cw_encode", "(", "index", ",", "value", ",", "value_format", ")", ":", "if", "value_format", "==", "2", ":", "value", "=", "value", "[", "0", "]", "<<", "8", "+", "value", "[", "1", "]", "return", "MessageEncode", "(", "'0Dcw{:02d}{:05d}00'", "...
cw: Write a custom value.
[ "cw", ":", "Write", "a", "custom", "value", "." ]
train
https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/message.py#L333-L337
gwww/elkm1
elkm1_lib/message.py
dm_encode
def dm_encode(keypad_area, clear, beep, timeout, line1, line2): """dm: Display message on keypad.""" return MessageEncode( '2Edm{:1d}{:1d}{:1d}{:05d}{:^<16.16}{:^<16.16}00' .format(keypad_area+1, clear, beep, timeout, line1, line2), None )
python
def dm_encode(keypad_area, clear, beep, timeout, line1, line2): """dm: Display message on keypad.""" return MessageEncode( '2Edm{:1d}{:1d}{:1d}{:05d}{:^<16.16}{:^<16.16}00' .format(keypad_area+1, clear, beep, timeout, line1, line2), None )
[ "def", "dm_encode", "(", "keypad_area", ",", "clear", ",", "beep", ",", "timeout", ",", "line1", ",", "line2", ")", ":", "return", "MessageEncode", "(", "'2Edm{:1d}{:1d}{:1d}{:05d}{:^<16.16}{:^<16.16}00'", ".", "format", "(", "keypad_area", "+", "1", ",", "clear...
dm: Display message on keypad.
[ "dm", ":", "Display", "message", "on", "keypad", "." ]
train
https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/message.py#L351-L356
gwww/elkm1
elkm1_lib/message.py
pc_encode
def pc_encode(index, function_code, extended_code, time): """pc: Control any PLC device.""" return MessageEncode('11pc{hc}{fc:02d}{ec:02d}{time:04d}00'. format(hc=index_to_housecode(index), fc=function_code, ec=extended_code, ...
python
def pc_encode(index, function_code, extended_code, time): """pc: Control any PLC device.""" return MessageEncode('11pc{hc}{fc:02d}{ec:02d}{time:04d}00'. format(hc=index_to_housecode(index), fc=function_code, ec=extended_code, ...
[ "def", "pc_encode", "(", "index", ",", "function_code", ",", "extended_code", ",", "time", ")", ":", "return", "MessageEncode", "(", "'11pc{hc}{fc:02d}{ec:02d}{time:04d}00'", ".", "format", "(", "hc", "=", "index_to_housecode", "(", "index", ")", ",", "fc", "=",...
pc: Control any PLC device.
[ "pc", ":", "Control", "any", "PLC", "device", "." ]
train
https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/message.py#L369-L374
gwww/elkm1
elkm1_lib/message.py
zb_encode
def zb_encode(zone, area, user_code): """zb: Zone bypass. Zone < 0 unbypass all; Zone > Max bypass all.""" if zone < 0: zone = 0 elif zone > Max.ZONES.value: zone = 999 else: zone += 1 return MessageEncode('10zb{zone:03d}{area:1d}{code:06d}00'.format( zone=zone, area=...
python
def zb_encode(zone, area, user_code): """zb: Zone bypass. Zone < 0 unbypass all; Zone > Max bypass all.""" if zone < 0: zone = 0 elif zone > Max.ZONES.value: zone = 999 else: zone += 1 return MessageEncode('10zb{zone:03d}{area:1d}{code:06d}00'.format( zone=zone, area=...
[ "def", "zb_encode", "(", "zone", ",", "area", ",", "user_code", ")", ":", "if", "zone", "<", "0", ":", "zone", "=", "0", "elif", "zone", ">", "Max", ".", "ZONES", ".", "value", ":", "zone", "=", "999", "else", ":", "zone", "+=", "1", "return", ...
zb: Zone bypass. Zone < 0 unbypass all; Zone > Max bypass all.
[ "zb", ":", "Zone", "bypass", ".", "Zone", "<", "0", "unbypass", "all", ";", "Zone", ">", "Max", "bypass", "all", "." ]
train
https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/message.py#L438-L447
gwww/elkm1
elkm1_lib/message.py
MessageDecode.add_handler
def add_handler(self, message_type, handler): """Manage callbacks for message handlers.""" if message_type not in self._handlers: self._handlers[message_type] = [] if handler not in self._handlers[message_type]: self._handlers[message_type].append(handler)
python
def add_handler(self, message_type, handler): """Manage callbacks for message handlers.""" if message_type not in self._handlers: self._handlers[message_type] = [] if handler not in self._handlers[message_type]: self._handlers[message_type].append(handler)
[ "def", "add_handler", "(", "self", ",", "message_type", ",", "handler", ")", ":", "if", "message_type", "not", "in", "self", ".", "_handlers", ":", "self", ".", "_handlers", "[", "message_type", "]", "=", "[", "]", "if", "handler", "not", "in", "self", ...
Manage callbacks for message handlers.
[ "Manage", "callbacks", "for", "message", "handlers", "." ]
train
https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/message.py#L33-L39
gwww/elkm1
elkm1_lib/message.py
MessageDecode.decode
def decode(self, msg): """Decode an Elk message by passing to appropriate decoder""" _check_message_valid(msg) cmd = msg[2:4] decoder = getattr(self, '_{}_decode'.format(cmd.lower()), None) if not decoder: cmd = 'unknown' decoder = self._unknown_decode ...
python
def decode(self, msg): """Decode an Elk message by passing to appropriate decoder""" _check_message_valid(msg) cmd = msg[2:4] decoder = getattr(self, '_{}_decode'.format(cmd.lower()), None) if not decoder: cmd = 'unknown' decoder = self._unknown_decode ...
[ "def", "decode", "(", "self", ",", "msg", ")", ":", "_check_message_valid", "(", "msg", ")", "cmd", "=", "msg", "[", "2", ":", "4", "]", "decoder", "=", "getattr", "(", "self", ",", "'_{}_decode'", ".", "format", "(", "cmd", ".", "lower", "(", ")",...
Decode an Elk message by passing to appropriate decoder
[ "Decode", "an", "Elk", "message", "by", "passing", "to", "appropriate", "decoder" ]
train
https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/message.py#L41-L51
gwww/elkm1
elkm1_lib/message.py
MessageDecode._as_decode
def _as_decode(self, msg): """AS: Arming status report.""" return {'armed_statuses': [x for x in msg[4:12]], 'arm_up_states': [x for x in msg[12:20]], 'alarm_states': [x for x in msg[20:28]]}
python
def _as_decode(self, msg): """AS: Arming status report.""" return {'armed_statuses': [x for x in msg[4:12]], 'arm_up_states': [x for x in msg[12:20]], 'alarm_states': [x for x in msg[20:28]]}
[ "def", "_as_decode", "(", "self", ",", "msg", ")", ":", "return", "{", "'armed_statuses'", ":", "[", "x", "for", "x", "in", "msg", "[", "4", ":", "12", "]", "]", ",", "'arm_up_states'", ":", "[", "x", "for", "x", "in", "msg", "[", "12", ":", "2...
AS: Arming status report.
[ "AS", ":", "Arming", "status", "report", "." ]
train
https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/message.py#L57-L61
gwww/elkm1
elkm1_lib/message.py
MessageDecode._cr_decode
def _cr_decode(self, msg): """CR: Custom values""" if int(msg[4:6]) > 0: index = int(msg[4:6])-1 return {'values': [self._cr_one_custom_value_decode(index, msg[6:12])]} else: part = 6 ret = [] for i in range(Max.SETTINGS.value): ...
python
def _cr_decode(self, msg): """CR: Custom values""" if int(msg[4:6]) > 0: index = int(msg[4:6])-1 return {'values': [self._cr_one_custom_value_decode(index, msg[6:12])]} else: part = 6 ret = [] for i in range(Max.SETTINGS.value): ...
[ "def", "_cr_decode", "(", "self", ",", "msg", ")", ":", "if", "int", "(", "msg", "[", "4", ":", "6", "]", ")", ">", "0", ":", "index", "=", "int", "(", "msg", "[", "4", ":", "6", "]", ")", "-", "1", "return", "{", "'values'", ":", "[", "s...
CR: Custom values
[ "CR", ":", "Custom", "values" ]
train
https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/message.py#L74-L85
gwww/elkm1
elkm1_lib/message.py
MessageDecode._cs_decode
def _cs_decode(self, msg): """CS: Output status for all outputs.""" output_status = [x == '1' for x in msg[4:4+Max.OUTPUTS.value]] return {'output_status': output_status}
python
def _cs_decode(self, msg): """CS: Output status for all outputs.""" output_status = [x == '1' for x in msg[4:4+Max.OUTPUTS.value]] return {'output_status': output_status}
[ "def", "_cs_decode", "(", "self", ",", "msg", ")", ":", "output_status", "=", "[", "x", "==", "'1'", "for", "x", "in", "msg", "[", "4", ":", "4", "+", "Max", ".", "OUTPUTS", ".", "value", "]", "]", "return", "{", "'output_status'", ":", "output_sta...
CS: Output status for all outputs.
[ "CS", ":", "Output", "status", "for", "all", "outputs", "." ]
train
https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/message.py#L91-L94
gwww/elkm1
elkm1_lib/message.py
MessageDecode._ee_decode
def _ee_decode(self, msg): """EE: Entry/exit timer report.""" return {'area': int(msg[4:5])-1, 'is_exit': msg[5:6] == '0', 'timer1': int(msg[6:9]), 'timer2': int(msg[9:12]), 'armed_status': msg[12:13]}
python
def _ee_decode(self, msg): """EE: Entry/exit timer report.""" return {'area': int(msg[4:5])-1, 'is_exit': msg[5:6] == '0', 'timer1': int(msg[6:9]), 'timer2': int(msg[9:12]), 'armed_status': msg[12:13]}
[ "def", "_ee_decode", "(", "self", ",", "msg", ")", ":", "return", "{", "'area'", ":", "int", "(", "msg", "[", "4", ":", "5", "]", ")", "-", "1", ",", "'is_exit'", ":", "msg", "[", "5", ":", "6", "]", "==", "'0'", ",", "'timer1'", ":", "int", ...
EE: Entry/exit timer report.
[ "EE", ":", "Entry", "/", "exit", "timer", "report", "." ]
train
https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/message.py#L100-L104
gwww/elkm1
elkm1_lib/message.py
MessageDecode._ic_decode
def _ic_decode(self, msg): """IC: Send Valid Or Invalid User Code Format.""" code = msg[4:16] if re.match(r'(0\d){6}', code): code = re.sub(r'0(\d)', r'\1', code) return {'code': code, 'user': int(msg[16:19])-1, 'keypad': int(msg[19:21])-1}
python
def _ic_decode(self, msg): """IC: Send Valid Or Invalid User Code Format.""" code = msg[4:16] if re.match(r'(0\d){6}', code): code = re.sub(r'0(\d)', r'\1', code) return {'code': code, 'user': int(msg[16:19])-1, 'keypad': int(msg[19:21])-1}
[ "def", "_ic_decode", "(", "self", ",", "msg", ")", ":", "code", "=", "msg", "[", "4", ":", "16", "]", "if", "re", ".", "match", "(", "r'(0\\d){6}'", ",", "code", ")", ":", "code", "=", "re", ".", "sub", "(", "r'0(\\d)'", ",", "r'\\1'", ",", "co...
IC: Send Valid Or Invalid User Code Format.
[ "IC", ":", "Send", "Valid", "Or", "Invalid", "User", "Code", "Format", "." ]
train
https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/message.py#L106-L112
gwww/elkm1
elkm1_lib/message.py
MessageDecode._ka_decode
def _ka_decode(self, msg): """KA: Keypad areas for all keypads.""" return {'keypad_areas': [ord(x)-0x31 for x in msg[4:4+Max.KEYPADS.value]]}
python
def _ka_decode(self, msg): """KA: Keypad areas for all keypads.""" return {'keypad_areas': [ord(x)-0x31 for x in msg[4:4+Max.KEYPADS.value]]}
[ "def", "_ka_decode", "(", "self", ",", "msg", ")", ":", "return", "{", "'keypad_areas'", ":", "[", "ord", "(", "x", ")", "-", "0x31", "for", "x", "in", "msg", "[", "4", ":", "4", "+", "Max", ".", "KEYPADS", ".", "value", "]", "]", "}" ]
KA: Keypad areas for all keypads.
[ "KA", ":", "Keypad", "areas", "for", "all", "keypads", "." ]
train
https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/message.py#L118-L120
gwww/elkm1
elkm1_lib/message.py
MessageDecode._lw_decode
def _lw_decode(self, msg): """LW: temperatures from all keypads and zones 1-16.""" keypad_temps = [] zone_temps = [] for i in range(16): keypad_temps.append(int(msg[4+3*i:7+3*i]) - 40) zone_temps.append(int(msg[52+3*i:55+3*i]) - 60) return {'keypad_temps':...
python
def _lw_decode(self, msg): """LW: temperatures from all keypads and zones 1-16.""" keypad_temps = [] zone_temps = [] for i in range(16): keypad_temps.append(int(msg[4+3*i:7+3*i]) - 40) zone_temps.append(int(msg[52+3*i:55+3*i]) - 60) return {'keypad_temps':...
[ "def", "_lw_decode", "(", "self", ",", "msg", ")", ":", "keypad_temps", "=", "[", "]", "zone_temps", "=", "[", "]", "for", "i", "in", "range", "(", "16", ")", ":", "keypad_temps", ".", "append", "(", "int", "(", "msg", "[", "4", "+", "3", "*", ...
LW: temperatures from all keypads and zones 1-16.
[ "LW", ":", "temperatures", "from", "all", "keypads", "and", "zones", "1", "-", "16", "." ]
train
https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/message.py#L126-L133
gwww/elkm1
elkm1_lib/message.py
MessageDecode._pc_decode
def _pc_decode(self, msg): """PC: PLC (lighting) change.""" housecode = msg[4:7] return {'housecode': housecode, 'index': housecode_to_index(housecode), 'light_level': int(msg[7:9])}
python
def _pc_decode(self, msg): """PC: PLC (lighting) change.""" housecode = msg[4:7] return {'housecode': housecode, 'index': housecode_to_index(housecode), 'light_level': int(msg[7:9])}
[ "def", "_pc_decode", "(", "self", ",", "msg", ")", ":", "housecode", "=", "msg", "[", "4", ":", "7", "]", "return", "{", "'housecode'", ":", "housecode", ",", "'index'", ":", "housecode_to_index", "(", "housecode", ")", ",", "'light_level'", ":", "int", ...
PC: PLC (lighting) change.
[ "PC", ":", "PLC", "(", "lighting", ")", "change", "." ]
train
https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/message.py#L135-L139
gwww/elkm1
elkm1_lib/message.py
MessageDecode._sd_decode
def _sd_decode(self, msg): """SD: Description text.""" desc_ch1 = msg[9] show_on_keypad = ord(desc_ch1) >= 0x80 if show_on_keypad: desc_ch1 = chr(ord(desc_ch1) & 0x7f) return {'desc_type': int(msg[4:6]), 'unit': int(msg[6:9])-1, 'desc': (desc_ch1+msg[1...
python
def _sd_decode(self, msg): """SD: Description text.""" desc_ch1 = msg[9] show_on_keypad = ord(desc_ch1) >= 0x80 if show_on_keypad: desc_ch1 = chr(ord(desc_ch1) & 0x7f) return {'desc_type': int(msg[4:6]), 'unit': int(msg[6:9])-1, 'desc': (desc_ch1+msg[1...
[ "def", "_sd_decode", "(", "self", ",", "msg", ")", ":", "desc_ch1", "=", "msg", "[", "9", "]", "show_on_keypad", "=", "ord", "(", "desc_ch1", ")", ">=", "0x80", "if", "show_on_keypad", ":", "desc_ch1", "=", "chr", "(", "ord", "(", "desc_ch1", ")", "&...
SD: Description text.
[ "SD", ":", "Description", "text", "." ]
train
https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/message.py#L150-L158
gwww/elkm1
elkm1_lib/message.py
MessageDecode._st_decode
def _st_decode(self, msg): """ST: Temperature update.""" group = int(msg[4:5]) temperature = int(msg[7:10]) if group == 0: temperature -= 60 elif group == 1: temperature -= 40 return {'group': group, 'device': int(msg[5:7])-1, 'temp...
python
def _st_decode(self, msg): """ST: Temperature update.""" group = int(msg[4:5]) temperature = int(msg[7:10]) if group == 0: temperature -= 60 elif group == 1: temperature -= 40 return {'group': group, 'device': int(msg[5:7])-1, 'temp...
[ "def", "_st_decode", "(", "self", ",", "msg", ")", ":", "group", "=", "int", "(", "msg", "[", "4", ":", "5", "]", ")", "temperature", "=", "int", "(", "msg", "[", "7", ":", "10", "]", ")", "if", "group", "==", "0", ":", "temperature", "-=", "...
ST: Temperature update.
[ "ST", ":", "Temperature", "update", "." ]
train
https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/message.py#L164-L173
gwww/elkm1
elkm1_lib/message.py
MessageDecode._tr_decode
def _tr_decode(self, msg): """TR: Thermostat data response.""" return {'thermostat_index': int(msg[4:6])-1, 'mode': int(msg[6]), 'hold': msg[7] == '1', 'fan': int(msg[8]), 'current_temp': int(msg[9:11]), 'heat_setpoint': int(msg[11:13]), 'cool_setpoint': i...
python
def _tr_decode(self, msg): """TR: Thermostat data response.""" return {'thermostat_index': int(msg[4:6])-1, 'mode': int(msg[6]), 'hold': msg[7] == '1', 'fan': int(msg[8]), 'current_temp': int(msg[9:11]), 'heat_setpoint': int(msg[11:13]), 'cool_setpoint': i...
[ "def", "_tr_decode", "(", "self", ",", "msg", ")", ":", "return", "{", "'thermostat_index'", ":", "int", "(", "msg", "[", "4", ":", "6", "]", ")", "-", "1", ",", "'mode'", ":", "int", "(", "msg", "[", "6", "]", ")", ",", "'hold'", ":", "msg", ...
TR: Thermostat data response.
[ "TR", ":", "Thermostat", "data", "response", "." ]
train
https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/message.py#L179-L184
gwww/elkm1
elkm1_lib/message.py
MessageDecode._vn_decode
def _vn_decode(self, msg): """VN: Version information.""" elkm1_version = "{}.{}.{}".format(int(msg[4:6], 16), int(msg[6:8], 16), int(msg[8:10], 16)) xep_version = "{}.{}.{}".format(int(msg[10:12], 16), int(msg[12:14], 16), ...
python
def _vn_decode(self, msg): """VN: Version information.""" elkm1_version = "{}.{}.{}".format(int(msg[4:6], 16), int(msg[6:8], 16), int(msg[8:10], 16)) xep_version = "{}.{}.{}".format(int(msg[10:12], 16), int(msg[12:14], 16), ...
[ "def", "_vn_decode", "(", "self", ",", "msg", ")", ":", "elkm1_version", "=", "\"{}.{}.{}\"", ".", "format", "(", "int", "(", "msg", "[", "4", ":", "6", "]", ",", "16", ")", ",", "int", "(", "msg", "[", "6", ":", "8", "]", ",", "16", ")", ","...
VN: Version information.
[ "VN", ":", "Version", "information", "." ]
train
https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/message.py#L186-L192
gwww/elkm1
elkm1_lib/message.py
MessageDecode._zc_decode
def _zc_decode(self, msg): """ZC: Zone Change.""" status = _status_decode(int(msg[7:8], 16)) return {'zone_number': int(msg[4:7])-1, 'zone_status': status}
python
def _zc_decode(self, msg): """ZC: Zone Change.""" status = _status_decode(int(msg[7:8], 16)) return {'zone_number': int(msg[4:7])-1, 'zone_status': status}
[ "def", "_zc_decode", "(", "self", ",", "msg", ")", ":", "status", "=", "_status_decode", "(", "int", "(", "msg", "[", "7", ":", "8", "]", ",", "16", ")", ")", "return", "{", "'zone_number'", ":", "int", "(", "msg", "[", "4", ":", "7", "]", ")",...
ZC: Zone Change.
[ "ZC", ":", "Zone", "Change", "." ]
train
https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/message.py#L202-L205
gwww/elkm1
elkm1_lib/message.py
MessageDecode._zd_decode
def _zd_decode(self, msg): """ZD: Zone definitions.""" zone_definitions = [ord(x)-0x30 for x in msg[4:4+Max.ZONES.value]] return {'zone_definitions': zone_definitions}
python
def _zd_decode(self, msg): """ZD: Zone definitions.""" zone_definitions = [ord(x)-0x30 for x in msg[4:4+Max.ZONES.value]] return {'zone_definitions': zone_definitions}
[ "def", "_zd_decode", "(", "self", ",", "msg", ")", ":", "zone_definitions", "=", "[", "ord", "(", "x", ")", "-", "0x30", "for", "x", "in", "msg", "[", "4", ":", "4", "+", "Max", ".", "ZONES", ".", "value", "]", "]", "return", "{", "'zone_definiti...
ZD: Zone definitions.
[ "ZD", ":", "Zone", "definitions", "." ]
train
https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/message.py#L207-L210
gwww/elkm1
elkm1_lib/message.py
MessageDecode._zp_decode
def _zp_decode(self, msg): """ZP: Zone partitions.""" zone_partitions = [ord(x)-0x31 for x in msg[4:4+Max.ZONES.value]] return {'zone_partitions': zone_partitions}
python
def _zp_decode(self, msg): """ZP: Zone partitions.""" zone_partitions = [ord(x)-0x31 for x in msg[4:4+Max.ZONES.value]] return {'zone_partitions': zone_partitions}
[ "def", "_zp_decode", "(", "self", ",", "msg", ")", ":", "zone_partitions", "=", "[", "ord", "(", "x", ")", "-", "0x31", "for", "x", "in", "msg", "[", "4", ":", "4", "+", "Max", ".", "ZONES", ".", "value", "]", "]", "return", "{", "'zone_partition...
ZP: Zone partitions.
[ "ZP", ":", "Zone", "partitions", "." ]
train
https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/message.py#L212-L215
gwww/elkm1
elkm1_lib/message.py
MessageDecode._zs_decode
def _zs_decode(self, msg): """ZS: Zone statuses.""" status = [_status_decode(int(x, 16)) for x in msg[4:4+Max.ZONES.value]] return {'zone_statuses': status}
python
def _zs_decode(self, msg): """ZS: Zone statuses.""" status = [_status_decode(int(x, 16)) for x in msg[4:4+Max.ZONES.value]] return {'zone_statuses': status}
[ "def", "_zs_decode", "(", "self", ",", "msg", ")", ":", "status", "=", "[", "_status_decode", "(", "int", "(", "x", ",", "16", ")", ")", "for", "x", "in", "msg", "[", "4", ":", "4", "+", "Max", ".", "ZONES", ".", "value", "]", "]", "return", ...
ZS: Zone statuses.
[ "ZS", ":", "Zone", "statuses", "." ]
train
https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/message.py#L217-L220
MonashBI/arcana
arcana/repository/xnat.py
XnatRepo.connect
def connect(self): """ Parameters ---------- prev_login : xnat.XNATSession An XNAT login that has been opened in the code that calls the method that calls login. It is wrapped in a NoExitWrapper so the returned connection can be used in a "...
python
def connect(self): """ Parameters ---------- prev_login : xnat.XNATSession An XNAT login that has been opened in the code that calls the method that calls login. It is wrapped in a NoExitWrapper so the returned connection can be used in a "...
[ "def", "connect", "(", "self", ")", ":", "sess_kwargs", "=", "{", "}", "if", "self", ".", "_user", "is", "not", "None", ":", "sess_kwargs", "[", "'user'", "]", "=", "self", ".", "_user", "if", "self", ".", "_password", "is", "not", "None", ":", "se...
Parameters ---------- prev_login : xnat.XNATSession An XNAT login that has been opened in the code that calls the method that calls login. It is wrapped in a NoExitWrapper so the returned connection can be used in a "with" statement in the method.
[ "Parameters", "----------", "prev_login", ":", "xnat", ".", "XNATSession", "An", "XNAT", "login", "that", "has", "been", "opened", "in", "the", "code", "that", "calls", "the", "method", "that", "calls", "login", ".", "It", "is", "wrapped", "in", "a", "NoEx...
train
https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/repository/xnat.py#L144-L159
MonashBI/arcana
arcana/repository/xnat.py
XnatRepo.get_fileset
def get_fileset(self, fileset): """ Caches a single fileset (if the 'path' attribute is accessed and it has not been previously cached for example Parameters ---------- fileset : Fileset The fileset to cache prev_login : xnat.XNATSession A...
python
def get_fileset(self, fileset): """ Caches a single fileset (if the 'path' attribute is accessed and it has not been previously cached for example Parameters ---------- fileset : Fileset The fileset to cache prev_login : xnat.XNATSession A...
[ "def", "get_fileset", "(", "self", ",", "fileset", ")", ":", "if", "fileset", ".", "format", "is", "None", ":", "raise", "ArcanaUsageError", "(", "\"Attempting to download {}, which has not been assigned a \"", "\"file format (see Fileset.formatted)\"", ".", "format", "("...
Caches a single fileset (if the 'path' attribute is accessed and it has not been previously cached for example Parameters ---------- fileset : Fileset The fileset to cache prev_login : xnat.XNATSession An XNATSession object to use for the connection. A ne...
[ "Caches", "a", "single", "fileset", "(", "if", "the", "path", "attribute", "is", "accessed", "and", "it", "has", "not", "been", "previously", "cached", "for", "example" ]
train
https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/repository/xnat.py#L165-L273
MonashBI/arcana
arcana/repository/xnat.py
XnatRepo.get_checksums
def get_checksums(self, fileset): """ Downloads the MD5 digests associated with the files in the file-set. These are saved with the downloaded files in the cache and used to check if the files have been updated on the server Parameters ---------- resource : xnat....
python
def get_checksums(self, fileset): """ Downloads the MD5 digests associated with the files in the file-set. These are saved with the downloaded files in the cache and used to check if the files have been updated on the server Parameters ---------- resource : xnat....
[ "def", "get_checksums", "(", "self", ",", "fileset", ")", ":", "if", "fileset", ".", "uri", "is", "None", ":", "raise", "ArcanaUsageError", "(", "\"Can't retrieve checksums as URI has not been set for {}\"", ".", "format", "(", "fileset", ")", ")", "with", "self",...
Downloads the MD5 digests associated with the files in the file-set. These are saved with the downloaded files in the cache and used to check if the files have been updated on the server Parameters ---------- resource : xnat.ResourceCatalog The xnat resource ...
[ "Downloads", "the", "MD5", "digests", "associated", "with", "the", "files", "in", "the", "file", "-", "set", ".", "These", "are", "saved", "with", "the", "downloaded", "files", "in", "the", "cache", "and", "used", "to", "check", "if", "the", "files", "ha...
train
https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/repository/xnat.py#L377-L406
MonashBI/arcana
arcana/repository/xnat.py
XnatRepo.find_data
def find_data(self, subject_ids=None, visit_ids=None, **kwargs): """ Find all filesets, fields and provenance records within an XNAT project Parameters ---------- subject_ids : list(str) List of subject IDs with which to filter the tree with. If None all ...
python
def find_data(self, subject_ids=None, visit_ids=None, **kwargs): """ Find all filesets, fields and provenance records within an XNAT project Parameters ---------- subject_ids : list(str) List of subject IDs with which to filter the tree with. If None all ...
[ "def", "find_data", "(", "self", ",", "subject_ids", "=", "None", ",", "visit_ids", "=", "None", ",", "*", "*", "kwargs", ")", ":", "subject_ids", "=", "self", ".", "convert_subject_ids", "(", "subject_ids", ")", "# Add derived visit IDs to list of visit ids to fi...
Find all filesets, fields and provenance records within an XNAT project Parameters ---------- subject_ids : list(str) List of subject IDs with which to filter the tree with. If None all are returned visit_ids : list(str) List of visit IDs with which t...
[ "Find", "all", "filesets", "fields", "and", "provenance", "records", "within", "an", "XNAT", "project" ]
train
https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/repository/xnat.py#L408-L580
MonashBI/arcana
arcana/repository/xnat.py
XnatRepo.convert_subject_ids
def convert_subject_ids(self, subject_ids): """ Convert subject ids to strings if they are integers """ # TODO: need to make this generalisable via a # splitting+mapping function passed to the repository if subject_ids is not None: subject_ids = set( ...
python
def convert_subject_ids(self, subject_ids): """ Convert subject ids to strings if they are integers """ # TODO: need to make this generalisable via a # splitting+mapping function passed to the repository if subject_ids is not None: subject_ids = set( ...
[ "def", "convert_subject_ids", "(", "self", ",", "subject_ids", ")", ":", "# TODO: need to make this generalisable via a", "# splitting+mapping function passed to the repository", "if", "subject_ids", "is", "not", "None", ":", "subject_ids", "=", "set", "(", "(", "'{:0...
Convert subject ids to strings if they are integers
[ "Convert", "subject", "ids", "to", "strings", "if", "they", "are", "integers" ]
train
https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/repository/xnat.py#L582-L592
MonashBI/arcana
arcana/repository/xnat.py
XnatRepo.get_xsession
def get_xsession(self, item): """ Returns the XNAT session and cache dir corresponding to the item. """ subj_label, sess_label = self._get_item_labels(item) with self: xproject = self._login.projects[self.project_id] try: xsubject =...
python
def get_xsession(self, item): """ Returns the XNAT session and cache dir corresponding to the item. """ subj_label, sess_label = self._get_item_labels(item) with self: xproject = self._login.projects[self.project_id] try: xsubject =...
[ "def", "get_xsession", "(", "self", ",", "item", ")", ":", "subj_label", ",", "sess_label", "=", "self", ".", "_get_item_labels", "(", "item", ")", "with", "self", ":", "xproject", "=", "self", ".", "_login", ".", "projects", "[", "self", ".", "project_i...
Returns the XNAT session and cache dir corresponding to the item.
[ "Returns", "the", "XNAT", "session", "and", "cache", "dir", "corresponding", "to", "the", "item", "." ]
train
https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/repository/xnat.py#L690-L712
MonashBI/arcana
arcana/repository/xnat.py
XnatRepo._get_item_labels
def _get_item_labels(self, item, no_from_study=False): """ Returns the labels for the XNAT subject and sessions given the frequency and provided IDs. """ subject_id = self.inv_map_subject_id(item.subject_id) visit_id = self.inv_map_visit_id(item.visit_id) subj_lab...
python
def _get_item_labels(self, item, no_from_study=False): """ Returns the labels for the XNAT subject and sessions given the frequency and provided IDs. """ subject_id = self.inv_map_subject_id(item.subject_id) visit_id = self.inv_map_visit_id(item.visit_id) subj_lab...
[ "def", "_get_item_labels", "(", "self", ",", "item", ",", "no_from_study", "=", "False", ")", ":", "subject_id", "=", "self", ".", "inv_map_subject_id", "(", "item", ".", "subject_id", ")", "visit_id", "=", "self", ".", "inv_map_visit_id", "(", "item", ".", ...
Returns the labels for the XNAT subject and sessions given the frequency and provided IDs.
[ "Returns", "the", "labels", "for", "the", "XNAT", "subject", "and", "sessions", "given", "the", "frequency", "and", "provided", "IDs", "." ]
train
https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/repository/xnat.py#L714-L725
MonashBI/arcana
arcana/repository/xnat.py
XnatRepo._get_labels
def _get_labels(self, frequency, subject_id=None, visit_id=None): """ Returns the labels for the XNAT subject and sessions given the frequency and provided IDs. """ if frequency == 'per_session': subj_label = '{}_{}'.format(self.project_id, ...
python
def _get_labels(self, frequency, subject_id=None, visit_id=None): """ Returns the labels for the XNAT subject and sessions given the frequency and provided IDs. """ if frequency == 'per_session': subj_label = '{}_{}'.format(self.project_id, ...
[ "def", "_get_labels", "(", "self", ",", "frequency", ",", "subject_id", "=", "None", ",", "visit_id", "=", "None", ")", ":", "if", "frequency", "==", "'per_session'", ":", "subj_label", "=", "'{}_{}'", ".", "format", "(", "self", ".", "project_id", ",", ...
Returns the labels for the XNAT subject and sessions given the frequency and provided IDs.
[ "Returns", "the", "labels", "for", "the", "XNAT", "subject", "and", "sessions", "given", "the", "frequency", "and", "provided", "IDs", "." ]
train
https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/repository/xnat.py#L727-L758
gwww/elkm1
elkm1_lib/outputs.py
Output.turn_on
def turn_on(self, time): """(Helper) Turn on an output""" self._elk.send(cn_encode(self._index, time))
python
def turn_on(self, time): """(Helper) Turn on an output""" self._elk.send(cn_encode(self._index, time))
[ "def", "turn_on", "(", "self", ",", "time", ")", ":", "self", ".", "_elk", ".", "send", "(", "cn_encode", "(", "self", ".", "_index", ",", "time", ")", ")" ]
(Helper) Turn on an output
[ "(", "Helper", ")", "Turn", "on", "an", "output" ]
train
https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/outputs.py#L17-L19
gwww/elkm1
elkm1_lib/outputs.py
Outputs.sync
def sync(self): """Retrieve areas from ElkM1""" self.elk.send(cs_encode()) self.get_descriptions(TextDescriptions.OUTPUT.value)
python
def sync(self): """Retrieve areas from ElkM1""" self.elk.send(cs_encode()) self.get_descriptions(TextDescriptions.OUTPUT.value)
[ "def", "sync", "(", "self", ")", ":", "self", ".", "elk", ".", "send", "(", "cs_encode", "(", ")", ")", "self", ".", "get_descriptions", "(", "TextDescriptions", ".", "OUTPUT", ".", "value", ")" ]
Retrieve areas from ElkM1
[ "Retrieve", "areas", "from", "ElkM1" ]
train
https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/outputs.py#L33-L36
MonashBI/arcana
arcana/environment/requirement/matlab.py
MatlabPackageRequirement.detect_version_str
def detect_version_str(self): """ Try to detect version of package from command help text. Bit of a long shot as they are typically included """ help_text = run_matlab_cmd("help('{}')".format(self.test_func)) if not help_text: raise ArcanaRequirementNotFoundEr...
python
def detect_version_str(self): """ Try to detect version of package from command help text. Bit of a long shot as they are typically included """ help_text = run_matlab_cmd("help('{}')".format(self.test_func)) if not help_text: raise ArcanaRequirementNotFoundEr...
[ "def", "detect_version_str", "(", "self", ")", ":", "help_text", "=", "run_matlab_cmd", "(", "\"help('{}')\"", ".", "format", "(", "self", ".", "test_func", ")", ")", "if", "not", "help_text", ":", "raise", "ArcanaRequirementNotFoundError", "(", "\"Did not find te...
Try to detect version of package from command help text. Bit of a long shot as they are typically included
[ "Try", "to", "detect", "version", "of", "package", "from", "command", "help", "text", ".", "Bit", "of", "a", "long", "shot", "as", "they", "are", "typically", "included" ]
train
https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/environment/requirement/matlab.py#L75-L85
mezz64/pyEight
pyeight/user.py
EightUser.target_heating_level
def target_heating_level(self): """Return target heating level.""" try: if self.side == 'left': level = self.device.device_data['leftTargetHeatingLevel'] elif self.side == 'right': level = self.device.device_data['rightTargetHeatingLevel'] ...
python
def target_heating_level(self): """Return target heating level.""" try: if self.side == 'left': level = self.device.device_data['leftTargetHeatingLevel'] elif self.side == 'right': level = self.device.device_data['rightTargetHeatingLevel'] ...
[ "def", "target_heating_level", "(", "self", ")", ":", "try", ":", "if", "self", ".", "side", "==", "'left'", ":", "level", "=", "self", ".", "device", ".", "device_data", "[", "'leftTargetHeatingLevel'", "]", "elif", "self", ".", "side", "==", "'right'", ...
Return target heating level.
[ "Return", "target", "heating", "level", "." ]
train
https://github.com/mezz64/pyEight/blob/e557e4e6876f490d0964298e9475d68b64222d4f/pyeight/user.py#L41-L50
mezz64/pyEight
pyeight/user.py
EightUser.heating_level
def heating_level(self): """Return heating level.""" try: if self.side == 'left': level = self.device.device_data['leftHeatingLevel'] elif self.side == 'right': level = self.device.device_data['rightHeatingLevel'] return level e...
python
def heating_level(self): """Return heating level.""" try: if self.side == 'left': level = self.device.device_data['leftHeatingLevel'] elif self.side == 'right': level = self.device.device_data['rightHeatingLevel'] return level e...
[ "def", "heating_level", "(", "self", ")", ":", "try", ":", "if", "self", ".", "side", "==", "'left'", ":", "level", "=", "self", ".", "device", ".", "device_data", "[", "'leftHeatingLevel'", "]", "elif", "self", ".", "side", "==", "'right'", ":", "leve...
Return heating level.
[ "Return", "heating", "level", "." ]
train
https://github.com/mezz64/pyEight/blob/e557e4e6876f490d0964298e9475d68b64222d4f/pyeight/user.py#L53-L62
mezz64/pyEight
pyeight/user.py
EightUser.past_heating_level
def past_heating_level(self, num): """Return a heating level from the past.""" if num > 9: return 0 try: if self.side == 'left': level = self.device.device_data_history[ num]['leftHeatingLevel'] elif self.side == 'right': ...
python
def past_heating_level(self, num): """Return a heating level from the past.""" if num > 9: return 0 try: if self.side == 'left': level = self.device.device_data_history[ num]['leftHeatingLevel'] elif self.side == 'right': ...
[ "def", "past_heating_level", "(", "self", ",", "num", ")", ":", "if", "num", ">", "9", ":", "return", "0", "try", ":", "if", "self", ".", "side", "==", "'left'", ":", "level", "=", "self", ".", "device", ".", "device_data_history", "[", "num", "]", ...
Return a heating level from the past.
[ "Return", "a", "heating", "level", "from", "the", "past", "." ]
train
https://github.com/mezz64/pyEight/blob/e557e4e6876f490d0964298e9475d68b64222d4f/pyeight/user.py#L64-L78
mezz64/pyEight
pyeight/user.py
EightUser.now_heating
def now_heating(self): """Return current heating state.""" try: if self.side == 'left': heat = self.device.device_data['leftNowHeating'] elif self.side == 'right': heat = self.device.device_data['rightNowHeating'] return heat ex...
python
def now_heating(self): """Return current heating state.""" try: if self.side == 'left': heat = self.device.device_data['leftNowHeating'] elif self.side == 'right': heat = self.device.device_data['rightNowHeating'] return heat ex...
[ "def", "now_heating", "(", "self", ")", ":", "try", ":", "if", "self", ".", "side", "==", "'left'", ":", "heat", "=", "self", ".", "device", ".", "device_data", "[", "'leftNowHeating'", "]", "elif", "self", ".", "side", "==", "'right'", ":", "heat", ...
Return current heating state.
[ "Return", "current", "heating", "state", "." ]
train
https://github.com/mezz64/pyEight/blob/e557e4e6876f490d0964298e9475d68b64222d4f/pyeight/user.py#L81-L90
mezz64/pyEight
pyeight/user.py
EightUser.heating_remaining
def heating_remaining(self): """Return seconds of heat time remaining.""" try: if self.side == 'left': timerem = self.device.device_data['leftHeatingDuration'] elif self.side == 'right': timerem = self.device.device_data['rightHeatingDuration'] ...
python
def heating_remaining(self): """Return seconds of heat time remaining.""" try: if self.side == 'left': timerem = self.device.device_data['leftHeatingDuration'] elif self.side == 'right': timerem = self.device.device_data['rightHeatingDuration'] ...
[ "def", "heating_remaining", "(", "self", ")", ":", "try", ":", "if", "self", ".", "side", "==", "'left'", ":", "timerem", "=", "self", ".", "device", ".", "device_data", "[", "'leftHeatingDuration'", "]", "elif", "self", ".", "side", "==", "'right'", ":"...
Return seconds of heat time remaining.
[ "Return", "seconds", "of", "heat", "time", "remaining", "." ]
train
https://github.com/mezz64/pyEight/blob/e557e4e6876f490d0964298e9475d68b64222d4f/pyeight/user.py#L93-L102
mezz64/pyEight
pyeight/user.py
EightUser.last_seen
def last_seen(self): """Return mattress last seen time.""" """ These values seem to be rarely updated correctly in the API. Don't expect accurate results from this property. """ try: if self.side == 'left': lastseen = self.device.device_data['l...
python
def last_seen(self): """Return mattress last seen time.""" """ These values seem to be rarely updated correctly in the API. Don't expect accurate results from this property. """ try: if self.side == 'left': lastseen = self.device.device_data['l...
[ "def", "last_seen", "(", "self", ")", ":", "\"\"\"\n These values seem to be rarely updated correctly in the API.\n Don't expect accurate results from this property.\n \"\"\"", "try", ":", "if", "self", ".", "side", "==", "'left'", ":", "lastseen", "=", "self...
Return mattress last seen time.
[ "Return", "mattress", "last", "seen", "time", "." ]
train
https://github.com/mezz64/pyEight/blob/e557e4e6876f490d0964298e9475d68b64222d4f/pyeight/user.py#L105-L121
mezz64/pyEight
pyeight/user.py
EightUser.heating_values
def heating_values(self): """Return a dict of all the current heating values.""" heating_dict = { 'level': self.heating_level, 'target': self.target_heating_level, 'active': self.now_heating, 'remaining': self.heating_remaining, 'last_seen': se...
python
def heating_values(self): """Return a dict of all the current heating values.""" heating_dict = { 'level': self.heating_level, 'target': self.target_heating_level, 'active': self.now_heating, 'remaining': self.heating_remaining, 'last_seen': se...
[ "def", "heating_values", "(", "self", ")", ":", "heating_dict", "=", "{", "'level'", ":", "self", ".", "heating_level", ",", "'target'", ":", "self", ".", "target_heating_level", ",", "'active'", ":", "self", ".", "now_heating", ",", "'remaining'", ":", "sel...
Return a dict of all the current heating values.
[ "Return", "a", "dict", "of", "all", "the", "current", "heating", "values", "." ]
train
https://github.com/mezz64/pyEight/blob/e557e4e6876f490d0964298e9475d68b64222d4f/pyeight/user.py#L124-L133
mezz64/pyEight
pyeight/user.py
EightUser.current_sleep_stage
def current_sleep_stage(self): """Return sleep stage for in-progress session.""" try: stages = self.intervals[0]['stages'] num_stages = len(stages) if num_stages == 0: return None # API now always has an awake state last in the dict ...
python
def current_sleep_stage(self): """Return sleep stage for in-progress session.""" try: stages = self.intervals[0]['stages'] num_stages = len(stages) if num_stages == 0: return None # API now always has an awake state last in the dict ...
[ "def", "current_sleep_stage", "(", "self", ")", ":", "try", ":", "stages", "=", "self", ".", "intervals", "[", "0", "]", "[", "'stages'", "]", "num_stages", "=", "len", "(", "stages", ")", "if", "num_stages", "==", "0", ":", "return", "None", "# API no...
Return sleep stage for in-progress session.
[ "Return", "sleep", "stage", "for", "in", "-", "progress", "session", "." ]
train
https://github.com/mezz64/pyEight/blob/e557e4e6876f490d0964298e9475d68b64222d4f/pyeight/user.py#L160-L188
mezz64/pyEight
pyeight/user.py
EightUser.current_sleep_breakdown
def current_sleep_breakdown(self): """Return durations of sleep stages for in-progress session.""" try: stages = self.intervals[0]['stages'] breakdown = {'awake': 0, 'light': 0, 'deep': 0, 'rem': 0} for stage in stages: if stage['stage'] == 'awake': ...
python
def current_sleep_breakdown(self): """Return durations of sleep stages for in-progress session.""" try: stages = self.intervals[0]['stages'] breakdown = {'awake': 0, 'light': 0, 'deep': 0, 'rem': 0} for stage in stages: if stage['stage'] == 'awake': ...
[ "def", "current_sleep_breakdown", "(", "self", ")", ":", "try", ":", "stages", "=", "self", ".", "intervals", "[", "0", "]", "[", "'stages'", "]", "breakdown", "=", "{", "'awake'", ":", "0", ",", "'light'", ":", "0", ",", "'deep'", ":", "0", ",", "...
Return durations of sleep stages for in-progress session.
[ "Return", "durations", "of", "sleep", "stages", "for", "in", "-", "progress", "session", "." ]
train
https://github.com/mezz64/pyEight/blob/e557e4e6876f490d0964298e9475d68b64222d4f/pyeight/user.py#L200-L216
mezz64/pyEight
pyeight/user.py
EightUser.current_bed_temp
def current_bed_temp(self): """Return current bed temperature for in-progress session.""" try: bedtemps = self.intervals[0]['timeseries']['tempBedC'] num_temps = len(bedtemps) if num_temps == 0: return None bedtemp = bedtemps[num_temps-1]...
python
def current_bed_temp(self): """Return current bed temperature for in-progress session.""" try: bedtemps = self.intervals[0]['timeseries']['tempBedC'] num_temps = len(bedtemps) if num_temps == 0: return None bedtemp = bedtemps[num_temps-1]...
[ "def", "current_bed_temp", "(", "self", ")", ":", "try", ":", "bedtemps", "=", "self", ".", "intervals", "[", "0", "]", "[", "'timeseries'", "]", "[", "'tempBedC'", "]", "num_temps", "=", "len", "(", "bedtemps", ")", "if", "num_temps", "==", "0", ":", ...
Return current bed temperature for in-progress session.
[ "Return", "current", "bed", "temperature", "for", "in", "-", "progress", "session", "." ]
train
https://github.com/mezz64/pyEight/blob/e557e4e6876f490d0964298e9475d68b64222d4f/pyeight/user.py#L219-L231
mezz64/pyEight
pyeight/user.py
EightUser.current_room_temp
def current_room_temp(self): """Return current room temperature for in-progress session.""" try: rmtemps = self.intervals[0]['timeseries']['tempRoomC'] num_temps = len(rmtemps) if num_temps == 0: return None rmtemp = rmtemps[num_temps-1][...
python
def current_room_temp(self): """Return current room temperature for in-progress session.""" try: rmtemps = self.intervals[0]['timeseries']['tempRoomC'] num_temps = len(rmtemps) if num_temps == 0: return None rmtemp = rmtemps[num_temps-1][...
[ "def", "current_room_temp", "(", "self", ")", ":", "try", ":", "rmtemps", "=", "self", ".", "intervals", "[", "0", "]", "[", "'timeseries'", "]", "[", "'tempRoomC'", "]", "num_temps", "=", "len", "(", "rmtemps", ")", "if", "num_temps", "==", "0", ":", ...
Return current room temperature for in-progress session.
[ "Return", "current", "room", "temperature", "for", "in", "-", "progress", "session", "." ]
train
https://github.com/mezz64/pyEight/blob/e557e4e6876f490d0964298e9475d68b64222d4f/pyeight/user.py#L234-L246
mezz64/pyEight
pyeight/user.py
EightUser.current_resp_rate
def current_resp_rate(self): """Return current respiratory rate for in-progress session.""" try: rates = self.intervals[0]['timeseries']['respiratoryRate'] num_rates = len(rates) if num_rates == 0: return None rate = rates[num_rates-1][1]...
python
def current_resp_rate(self): """Return current respiratory rate for in-progress session.""" try: rates = self.intervals[0]['timeseries']['respiratoryRate'] num_rates = len(rates) if num_rates == 0: return None rate = rates[num_rates-1][1]...
[ "def", "current_resp_rate", "(", "self", ")", ":", "try", ":", "rates", "=", "self", ".", "intervals", "[", "0", "]", "[", "'timeseries'", "]", "[", "'respiratoryRate'", "]", "num_rates", "=", "len", "(", "rates", ")", "if", "num_rates", "==", "0", ":"...
Return current respiratory rate for in-progress session.
[ "Return", "current", "respiratory", "rate", "for", "in", "-", "progress", "session", "." ]
train
https://github.com/mezz64/pyEight/blob/e557e4e6876f490d0964298e9475d68b64222d4f/pyeight/user.py#L258-L270
mezz64/pyEight
pyeight/user.py
EightUser.current_heart_rate
def current_heart_rate(self): """Return current heart rate for in-progress session.""" try: rates = self.intervals[0]['timeseries']['heartRate'] num_rates = len(rates) if num_rates == 0: return None rate = rates[num_rates-1][1] ex...
python
def current_heart_rate(self): """Return current heart rate for in-progress session.""" try: rates = self.intervals[0]['timeseries']['heartRate'] num_rates = len(rates) if num_rates == 0: return None rate = rates[num_rates-1][1] ex...
[ "def", "current_heart_rate", "(", "self", ")", ":", "try", ":", "rates", "=", "self", ".", "intervals", "[", "0", "]", "[", "'timeseries'", "]", "[", "'heartRate'", "]", "num_rates", "=", "len", "(", "rates", ")", "if", "num_rates", "==", "0", ":", "...
Return current heart rate for in-progress session.
[ "Return", "current", "heart", "rate", "for", "in", "-", "progress", "session", "." ]
train
https://github.com/mezz64/pyEight/blob/e557e4e6876f490d0964298e9475d68b64222d4f/pyeight/user.py#L273-L285
mezz64/pyEight
pyeight/user.py
EightUser.current_values
def current_values(self): """Return a dict of all the 'current' parameters.""" current_dict = { 'date': self.current_session_date, 'score': self.current_sleep_score, 'stage': self.current_sleep_stage, 'breakdown': self.current_sleep_breakdown, ...
python
def current_values(self): """Return a dict of all the 'current' parameters.""" current_dict = { 'date': self.current_session_date, 'score': self.current_sleep_score, 'stage': self.current_sleep_stage, 'breakdown': self.current_sleep_breakdown, ...
[ "def", "current_values", "(", "self", ")", ":", "current_dict", "=", "{", "'date'", ":", "self", ".", "current_session_date", ",", "'score'", ":", "self", ".", "current_sleep_score", ",", "'stage'", ":", "self", ".", "current_sleep_stage", ",", "'breakdown'", ...
Return a dict of all the 'current' parameters.
[ "Return", "a", "dict", "of", "all", "the", "current", "parameters", "." ]
train
https://github.com/mezz64/pyEight/blob/e557e4e6876f490d0964298e9475d68b64222d4f/pyeight/user.py#L288-L302
mezz64/pyEight
pyeight/user.py
EightUser.last_session_date
def last_session_date(self): """Return date/time for start of last session data.""" try: date = self.intervals[1]['ts'] except KeyError: return None date_f = datetime.strptime(date, '%Y-%m-%dT%H:%M:%S.%fZ') now = time.time() offset = datetime.fromt...
python
def last_session_date(self): """Return date/time for start of last session data.""" try: date = self.intervals[1]['ts'] except KeyError: return None date_f = datetime.strptime(date, '%Y-%m-%dT%H:%M:%S.%fZ') now = time.time() offset = datetime.fromt...
[ "def", "last_session_date", "(", "self", ")", ":", "try", ":", "date", "=", "self", ".", "intervals", "[", "1", "]", "[", "'ts'", "]", "except", "KeyError", ":", "return", "None", "date_f", "=", "datetime", ".", "strptime", "(", "date", ",", "'%Y-%m-%d...
Return date/time for start of last session data.
[ "Return", "date", "/", "time", "for", "start", "of", "last", "session", "data", "." ]
train
https://github.com/mezz64/pyEight/blob/e557e4e6876f490d0964298e9475d68b64222d4f/pyeight/user.py#L305-L314
mezz64/pyEight
pyeight/user.py
EightUser.last_sleep_breakdown
def last_sleep_breakdown(self): """Return durations of sleep stages for last complete session.""" try: stages = self.intervals[1]['stages'] except KeyError: return None breakdown = {'awake': 0, 'light': 0, 'deep': 0, 'rem': 0} for stage in stages: ...
python
def last_sleep_breakdown(self): """Return durations of sleep stages for last complete session.""" try: stages = self.intervals[1]['stages'] except KeyError: return None breakdown = {'awake': 0, 'light': 0, 'deep': 0, 'rem': 0} for stage in stages: ...
[ "def", "last_sleep_breakdown", "(", "self", ")", ":", "try", ":", "stages", "=", "self", ".", "intervals", "[", "1", "]", "[", "'stages'", "]", "except", "KeyError", ":", "return", "None", "breakdown", "=", "{", "'awake'", ":", "0", ",", "'light'", ":"...
Return durations of sleep stages for last complete session.
[ "Return", "durations", "of", "sleep", "stages", "for", "last", "complete", "session", "." ]
train
https://github.com/mezz64/pyEight/blob/e557e4e6876f490d0964298e9475d68b64222d4f/pyeight/user.py#L336-L353
mezz64/pyEight
pyeight/user.py
EightUser.last_bed_temp
def last_bed_temp(self): """Return avg bed temperature for last session.""" try: bedtemps = self.intervals[1]['timeseries']['tempBedC'] except KeyError: return None tmp = 0 num_temps = len(bedtemps) if num_temps == 0: return None ...
python
def last_bed_temp(self): """Return avg bed temperature for last session.""" try: bedtemps = self.intervals[1]['timeseries']['tempBedC'] except KeyError: return None tmp = 0 num_temps = len(bedtemps) if num_temps == 0: return None ...
[ "def", "last_bed_temp", "(", "self", ")", ":", "try", ":", "bedtemps", "=", "self", ".", "intervals", "[", "1", "]", "[", "'timeseries'", "]", "[", "'tempBedC'", "]", "except", "KeyError", ":", "return", "None", "tmp", "=", "0", "num_temps", "=", "len"...
Return avg bed temperature for last session.
[ "Return", "avg", "bed", "temperature", "for", "last", "session", "." ]
train
https://github.com/mezz64/pyEight/blob/e557e4e6876f490d0964298e9475d68b64222d4f/pyeight/user.py#L356-L371