Parse a typed node, returns a usable description
354500
def type_description_from_node(gi_node):
    '''
    
    '''
    ctype_name, gi_name, array_nesting = unnest_type (gi_node)

    cur_ns = get_namespace(gi_node)

    if ctype_name is not None:
        type_tokens = __type_tokens_from_cdecl (ctype_name)
    else:
        type_tokens = __type_tokens_from_gitype (cur_ns, gi_name)

    namespaced = '%s.%s' % (cur_ns, gi_name)
    if namespaced in ALL_GI_TYPES:
        gi_name = namespaced

    return SymbolTypeDesc(type_tokens, gi_name, ctype_name, array_nesting)
787945
def get_text_node(self, tree, xpath_str):
        """"""
        try:
            text = tree.xpath(xpath_str, namespaces=self.namespaces)[0].text
            return text_type(text) if text else ''
        except IndexError:  # pragma: nocover
            return ''
429789
def parse(self) -> InstanceRoute:
        """"""
        res = InstanceRoute()
        if self.at_end():
            return res
        if self.peek() == "/":
            self.offset += 1
        if self.at_end():
            return res
        sn = self.schema_node
        while True:
            name, ns = self.prefixed_name()
            cn = sn.get_data_child(name, ns)
            if cn is None:
                for cn in sn.children:
                    if (isinstance(cn, RpcActionNode) and cn.name == name and
                            (ns is None or cn.ns == ns)):
                        res.append(ActionName(name, ns))
                        return res
                raise NonexistentSchemaNode(sn.qual_name, name, ns)
            res.append(MemberName(name, ns))
            if self.at_end():
                return res
            if isinstance(cn, SequenceNode):
                self.char("=")
                res.append(self._key_values(cn))
                if self.at_end():
                    return res
            else:
                self.char("/")
            sn = cn
646728
def parse_link(self, node):
        

        if 'name' in node.lattrib:
            name = node.lattrib['name']
        else:
            self.raise_error('<Link> must specify a name')

        if 'type' in node.lattrib:
            type_ = node.lattrib['type']
        else:
            self.raise_error("Link '{0}' must specify a type", name)

        description = node.lattrib.get('description', '')

        self.current_component_type.add_link(Link(name, type_, description))
853843
function(node,type) {
        var attributes = {};
        for(var attr = 0; attr < node.attributes.length; attr++) {
            if (type == "number") {
                attributes[node.attributes[attr].nodeName] = parseFloat(node.attributes[attr].nodeValue);
            } else {
                attributes[node.attributes[attr].nodeName] = node.attributes[attr].nodeValue;
            }
        }
        return attributes;
    }
371102
def parse_input_fields_definition(lexer: Lexer) -> List[InputValueDefinitionNode]:
    """"""
    return (
        cast(
            List[InputValueDefinitionNode],
            many_nodes(
                lexer, TokenKind.BRACE_L, parse_input_value_def, TokenKind.BRACE_R
            ),
        )
        if peek(lexer, TokenKind.BRACE_L)
        else []
    )
1038886
def parse_object_type_extension(lexer: Lexer) -> Node:
    """"""
    start = lexer.token
    expect_keyword(lexer, "extend")
    expect_keyword(lexer, "type")
    name = parse_name(lexer)
    interfaces = parse_implements_interfaces(lexer)
    directives = parse_directives(lexer, True)
    fields = parse_fields_definition(lexer)
    if not (interfaces or directives or fields):
        raise unexpected(lexer)
    return Node(
        name=name,
        interfaces=interfaces,
        directives=directives,
        fields=fields,
        loc=loc(lexer, start),
    )
340548
def parse_type_system_definition(lexer: Lexer) -> Node:
    """"""
    # Many definitions begin with a description and require a lookahead.
    keyword_token = lexer.lookahead() if peek_description(lexer) else lexer.token
    func = _parse_type_system_definition_functions.get(cast(str, keyword_token.value))
    if func:
        return func(lexer)
    raise unexpected(lexer, keyword_token)
1124062
def _parse_property(self, node):
        # type: (ElementTree.Element) -> Tuple[str, Any]
        
        # Get information
        name = node.attrib[ATTR_NAME]
        vtype = node.attrib.get(ATTR_VALUE_TYPE, TYPE_STRING)

        # Look for a value as a single child node
        try:
            value_node = next(iter(node))
            value = self._parse_value_node(vtype, value_node)
        except StopIteration:
            # Value is an attribute
            value = self._convert_value(vtype, node.attrib[ATTR_VALUE])

        return name, value
197161
def parse(celf, s) :
        ""

        def from_string_elts(celf, attrs, tree) :
            elts = dict((k, attrs[k]) for k in attrs)
            child_tags = dict \
              (
                (childclass.tag_name, childclass)
                for childclass in tuple(celf.tag_elts.values()) + (Introspection.Annotation,)
              )
            children = []
            for child in tree :
                if child.tag not in child_tags :
                    raise KeyError("unrecognized tag %s" % child.tag)
                #end if
                childclass = child_tags[child.tag]
                childattrs = {}
                for attrname in childclass.tag_attrs :
                    if hasattr(childclass, "tag_attrs_optional") and attrname in childclass.tag_attrs_optional :
                        childattrs[attrname] = child.attrib.get(attrname, None)
                    else :
                        if attrname not in child.attrib :
                            raise ValueError("missing %s attribute for %s tag" % (attrname, child.tag))
                        #end if
                        childattrs[attrname] = child.attrib[attrname]
                    #end if
                #end for
                if hasattr(childclass, "attr_convert") :
                    for attr in childclass.attr_convert :
                        if attr in childattrs :
                            childattrs[attr] = childclass.attr_convert[attr](childattrs[attr])
                        #end if
                    #end for
                #end if
                children.append(from_string_elts(childclass, childattrs, child))
            #end for
            for child_tag, childclass in tuple(celf.tag_elts.items()) + ((), (("annotations", Introspection.Annotation),))[tree.tag != "annotation"] :
                for child in children :
                    if isinstance(child, childclass) :
                        if child_tag not in elts :
                            elts[child_tag] = []
                        #end if
                        elts[child_tag].append(child)
                    #end if
                #end for
            #end for
            return \
                celf(**elts)
        #end from_string_elts

    #begin parse
        tree = XMLElementTree.fromstring(s)
        assert tree.tag == "node", "root of introspection tree must be <node> tag"
        return \
            from_string_elts(Introspection, {}, tree)
911523
def get_node_type(type_str):
    """"""
    if type_str == "container":
        return NodeType.CONTAINER
    elif type_str == "loop_plate":
        return NodeType.LOOP
    elif type_str == "assign":
        return NodeType.ASSIGN
    elif type_str == "condition":
        return NodeType.CONDITION
    elif type_str == "decision":
        return NodeType.DECISION
    else:
        raise ValueError("Unrecognized type string: ", type_str)
783371
function parse (node, self) {
  let block = false

  if (node.nodeType === 3) {
    let delimiters = self.templateDelimiters

    if (delimiters) {
      let tokens = parseTemplate(node.data, delimiters)

      if (tokens.length) {
        if (!(tokens.length === 1 && tokens[0].type === 0)) {
          tokens.forEach((token, i) => {
            let text = document.createTextNode(token.value)
            node.parentNode.insertBefore(text, node)

            if (token.type === 1) {
              self.buildBinding(TextBinding, text, null, token.value)
            }
          })

          node.parentNode.removeChild(node)
        }
      }
    }
  } else if (node.nodeType === 1) {
    block = self.traverse(node)
  }

  if (!block) {
    Array.prototype.slice.call(node.childNodes).forEach(function (node) { parse(node, self) })
  }
}
773027
def _parse_tree(self, node):
        
        if node.tag == 'firmware':
            if 'type' in node.attrib and node.attrib['type'] == 'flashed':
                self.kind = 'firmware-flashed'
            self.value = node.text.lower()
856701
def _parse_tree(self, node):
        
        if 'date' in node.attrib:
            dt = dateutil.parser.parse(node.attrib['date'])
            self.date = int(dt.strftime("%s"))
        if 'id' in node.attrib:
            self.id = node.attrib['id']
        if 'karma' in node.attrib:
            self.karma = int(node.attrib['karma'])
        if 'score' in node.attrib:
            self.score = int(node.attrib['score'])
        if 'rating' in node.attrib:
            self.rating = int(node.attrib['rating'])
        for c3 in node:
            if c3.tag == 'lang':
                self.locale = c3.text
            if c3.tag == 'version':
                self.version = c3.text
            if c3.tag == 'reviewer_id':
                self.reviewer_id = c3.text
            if c3.tag == 'reviewer_name':
                self.reviewer_name = c3.text
            if c3.tag == 'summary':
                self.summary = c3.text
            if c3.tag == 'description':
                self.description = _parse_desc(c3)
            if c3.tag == 'metadata':
                for c4 in c3:
                    if c4.tag == 'value':
                        if 'key' in c4.attrib:
                            self.metadata[c4.attrib['key']] = c4.text
557479
def _parse(self):
        """"""
        while self._cur_token['type'] in (TT.ws, TT.lbreak):
            self._skip_whitespace()
            self._skip_newlines()

        self._data = self._parse_value()

        return self._data
1186926
def _parse_tree(self, node):
        
        self.kind = node.tag
        if 'compare' in node.attrib:
            self.compare = node.attrib['compare']
        if 'version' in node.attrib:
            self.version = node.attrib['version']
        self.value = node.text
989774
def typed_node_from_id(id: str) -> TypedNode:
    
    filter_out_types = [
        'cliqueLeader',
        'Class',
        'Node',
        'Individual',
        'quality',
        'sequence feature'
    ]
    node = next(get_scigraph_nodes([id]))

    if 'lbl' in node:
        label = node['lbl']
    else:
        label = None  # Empty string or None?

    types = [typ.lower() for typ in node['meta']['types']
             if typ not in filter_out_types]

    return TypedNode(
        id=node['id'],
        label=label,
        type=types[0],
        taxon = get_taxon(id)
    )