예제 #1
0
파일: LEMS.py 프로젝트: stevemarsh/pylems
    def parse_component_by_typename(self, node, type):
        """
        Parses components defined directly by component name.

        @param node: Node containing the <Component> element
        @type node: xml.etree.Element

        @param type: Type of this component.
        @type type: string

        @raise ParseError: Raised when the component does not have an id.
        """

        if self.current_context.context_type == Context.GLOBAL:
            # Global component instatiation
            if "id" in node.lattrib:
                id = node.lattrib["id"]
            else:
                self.raise_error("Component must have an id")

            type = node.tag

            component = Component(id, self.current_context, type, None)

            self.current_context.add_component(component)

        else:
            # Child instantiation

            if "id" in node.lattrib:
                id = node.lattrib["id"]
                type = node.tag
            else:
                id = node.tag
                type = "__type_inherited__"

            component = Component(id, self.current_context, type)

            self.current_context.add_child(component)

        for key in node.attrib:
            if key.lower() not in ["extends", "id", "type"]:
                param = Parameter(key, "__dimension_inherited__")
                param.set_value(node.attrib[key])
                component.add_parameter(param)

        self.push_context(component.context)
        self.process_nested_tags(node)
        self.pop_context()
예제 #2
0
파일: LEMS.py 프로젝트: stevemarsh/pylems
    def parse_component(self, node):
        """
        Parses <Component>

        @param node: Node containing the <ComponentType> element
        @type node: xml.etree.Element
        """

        if 'id' in node.lattrib:
            id = node.lattrib['id']
        else:
            self.raise_error('Component must have an id')

        if 'type' in node.lattrib:
            type = node.lattrib['type']
        else:
            type = None

        if type == None:
            if 'extends' in node.lattrib:
                extends = node.lattrib['extends']
            else:
                self.raise_error('Component must have a type or must ' +
                                 'extend another component')
        else:
            extends = None

        component = Component(id, self.current_context, type, extends)
        self.current_context.add_component(component)

        for key in node.attrib:
            if key.lower() not in ['extends', 'id', 'type']:
                param = Parameter(key, '__dimension_inherited__')
                param.set_value(node.attrib[key])
                component.add_parameter(param)

        self.push_context(component.context)
        self.process_nested_tags(node)
        self.pop_context()
예제 #3
0
파일: LEMS.py 프로젝트: stevemarsh/pylems
    def parse_component(self, node):
        """
        Parses <Component>

        @param node: Node containing the <ComponentType> element
        @type node: xml.etree.Element
        """

        if "id" in node.lattrib:
            id = node.lattrib["id"]
        else:
            self.raise_error("Component must have an id")

        if "type" in node.lattrib:
            type = node.lattrib["type"]
        else:
            type = None

        if type == None:
            if "extends" in node.lattrib:
                extends = node.lattrib["extends"]
            else:
                self.raise_error("Component must have a type or must " + "extend another component")
        else:
            extends = None

        component = Component(id, self.current_context, type, extends)
        self.current_context.add_component(component)

        for key in node.attrib:
            if key.lower() not in ["extends", "id", "type"]:
                param = Parameter(key, "__dimension_inherited__")
                param.set_value(node.attrib[key])
                component.add_parameter(param)

        self.push_context(component.context)
        self.process_nested_tags(node)
        self.pop_context()
예제 #4
0
파일: LEMS.py 프로젝트: stevemarsh/pylems
    def parse_component_by_typename(self, node, type):
        """
        Parses components defined directly by component name.

        @param node: Node containing the <Component> element
        @type node: xml.etree.Element

        @param type: Type of this component.
        @type type: string

        @raise ParseError: Raised when the component does not have an id.
        """

        if self.current_context.context_type == Context.GLOBAL:
            # Global component instatiation
            if 'id' in node.lattrib:
                id = node.lattrib['id']
            else:
                self.raise_error('Component must have an id')

            type = node.tag

            component = Component(id, self.current_context, type, None)

            self.current_context.add_component(component)

        else:
            # Child instantiation

            if 'id' in node.lattrib:
                id = node.lattrib['id']
                type = node.tag
            else:
                id = node.tag
                type = '__type_inherited__'

            component = Component(id, self.current_context, type)

            self.current_context.add_child(component)

        for key in node.attrib:
            if key.lower() not in ['extends', 'id', 'type']:
                param = Parameter(key, '__dimension_inherited__')
                param.set_value(node.attrib[key])
                component.add_parameter(param)

        self.push_context(component.context)
        self.process_nested_tags(node)
        self.pop_context()