Exemplo n.º 1
0
def ParseCode(cat, save_location):
    """\
    Returns the component serialized to the given XML file
    """
    et = ElementTree.ElementTree(file=save_location)
    root = et.getroot()
    XmlUtils.VerifyVersion(root)
    try:
        cat.description = root.get("description")
    except KeyError:
        raise MalformedXmlError()
def ParseCode(prop, save_location):
    """\
    Returns the component serialized to the given XML file
    """
    et = ElementTree.ElementTree(file=save_location)
    root = et.getroot()
    XmlUtils.VerifyVersion(root)
    try:
        prop.description = root.get("description")
        prop.display_text = root.get("display_text")
        prop.rank = root.get("rank")
        prop.categories = []
        for cat in root.findall("category"):
            prop.categories.append(cat.get("name"))
        prop.tpcl_display = root.findtext(
            "tpcl_display", Property.DEFAULT_TPCL_DISPLAY).strip()
        prop.tpcl_requires = root.findtext(
            "tpcl_requires", Property.DEFAULT_TPCL_REQUIRES).strip()
    except KeyError:
        raise MalformedXmlError()
def ParseCode(comp, save_location):
    """\
    Returns the component serialized to the given XML file
    """
    et = ElementTree.ElementTree(file=save_location)
    root = et.getroot()
    XmlUtils.VerifyVersion(root)
    try:
        comp.description = root.get("description")
        comp.category = root.get("category")
        comp.categories = []
        for cat in root.findall("category"):
            comp.categories.append(cat.get("name"))
        comp.tpcl_requirements = root.findtext(
            "tpcl_requirements", Component.DEFAULT_TPCL_REQUIREMENTS).strip()
        comp.properties = {}
        for prop in root.findall("property"):
            comp.properties[prop.get("name")] = prop.findtext(
                "tpcl_cost", '(lambda (design) 0)').strip()
    except KeyError:
        raise MalformedXmlError()