コード例 #1
0
ファイル: views.py プロジェクト: skada/splunk-appframework
def load_elem(element, ignore=None):
    """Load the given XML element as a `dict`, skipping any child elements
       listed in the given `ignore` argument."""
    result = data.load_attrs(element) or {}
    result['kind'] = element.tag
    for child in list(element):
        if ignore and child.tag in ignore: continue
        name, value = data.load_elem(child)
        result[name] = value
    return result
コード例 #2
0
ファイル: views.py プロジェクト: skada/splunk-appframework
def load_panel(element):
    """Load dashboard panel view data from the given XML element."""

    # Project the tag name as a panel `kind` property and project all option
    # child elements onto a simple options record.
    result = { 'kind': element.tag }

    # Special case <html> panels, which are just literal HTML
    if element.tag == "html":
        result['content'] = ElementTree.tostring(element)
    else:
        for child in list(element):
            if child.tag == "option":
                k = child.attrib['name']
                v = child.text
                if 'options' not in result: 
                    result['options'] = {}
                result['options'][k] = v
            else:
                k, v = data.load_elem(child)
                result[k] = v

    return result