当前位置: 首页>>代码示例>>Python>>正文


Python Model.parse_tag方法代码示例

本文整理汇总了Python中scap.Model.Model.parse_tag方法的典型用法代码示例。如果您正苦于以下问题:Python Model.parse_tag方法的具体用法?Python Model.parse_tag怎么用?Python Model.parse_tag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scap.Model.Model的用法示例。


在下文中一共展示了Model.parse_tag方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: resolve

# 需要导入模块: from scap.Model import Model [as 别名]
# 或者: from scap.Model.Model import parse_tag [as 别名]
    def resolve(self, benchmark):
        ### Loading.Resolve.Items

        # For each Item in the Benchmark that has an extends property, resolve
        # it by using the following steps:

        # (1) if the Item is Group, resolve all the enclosed Items,
        for item_id in self.items:
            logger.debug('Resolving item: ' + item_id)
            self.items[item_id].resolve(benchmark)

        # (2) resolve the extended Item,
        if self.extends is None:
            return

        extended = self.get_extended(benchmark)
        extended.resolve(benchmark)

        # (3) prepend the property sequence from the extended Item to the
        # extending Item,
        # (5) remove duplicate properties and apply property overrides, and
        for name in self._model_map['attributes']:
            attr_map = self._model_map['attributes'][name]

            if 'in' in attr_map:
                attr_name = attr_map['in']
            else:
                xmlns, attr_name = Model.parse_tag(name)
                attr_name = attr_name.replace('-', '_')
            self.resolve_property(extended, attr_name)

        for element_def in self._model_map['elements']:
            if element_def['tag_name'].endswith('*'):
                continue

            if 'list' in element_def:
                self.resolve_property(extended, element_def['list'])
            elif 'dict' in element_def:
                self.resolve_property(extended, element_def['dict'])
            else:
                if 'in' in element_def:
                    name = element_def['in']
                else:
                    name = element_def['tag_name'].replace('-', '_')
            self.resolve_property(extended, name)

        # (4) if the Item is a Group, assign values for the id properties of
        # Items copied from the extended Group,
        if hasattr(extended, 'items') and len(extended.items) > 0:
            for ext_item in extended.items:
                # make a copy of the item and append to our items
                self.items.append(ext_item.copy())

        # (6) remove the extends property.
        self.extends = None
开发者ID:cjaymes,项目名称:pyscap,代码行数:57,代码来源:GroupType.py

示例2: resolve

# 需要导入模块: from scap.Model import Model [as 别名]
# 或者: from scap.Model.Model import parse_tag [as 别名]
    def resolve(self, benchmark):
        ### Loading.Resolve.Items

        # For each Item in the Benchmark that has an extends property, resolve
        # it by using the following steps:
        if self.extends is None:
            logger.debug('Extendable not extending: ' + self.id)
            return

        # (2) resolve the extended Item,
        extended = self.get_extended(benchmark)
        logger.debug('Found extended Extendable: ' + extended.id)
        extended.resolve(benchmark)

        # (3) prepend the property sequence from the extended Item to the
        # extending Item,
        # (5) remove duplicate properties and apply property overrides, and
        for name in self._model_map['attributes']:
            attr_map = self._model_map['attributes'][name]

            if 'in' in attr_map:
                attr_name = attr_map['in']
            else:
                xmlns, attr_name = Model.parse_tag(name)
                attr_name = attr_name.replace('-', '_')
            self.resolve_property(extended, attr_name)

        for element_def in self._model_map['elements']:
            if element_def['tag_name'].endswith('*'):
                continue

            if 'list' in element_def:
                self.resolve_property(extended, element_def['list'])
            elif 'dict' in tag_map:
                self.resolve_property(extended, element_def['dict'])
            else:
                if 'in' in element_def:
                    name = element_def['in']
                else:
                    name = element_def['tag_name'].replace('-', '_')
            self.resolve_property(extended, name)

        # (6) remove the extends property.
        self.extends = None
开发者ID:cjaymes,项目名称:pyscap,代码行数:46,代码来源:Extendable.py

示例3: test_parse_tag

# 需要导入模块: from scap.Model import Model [as 别名]
# 或者: from scap.Model.Model import parse_tag [as 别名]
def test_parse_tag():
    assert Model.parse_tag('{http://jaymes.biz/test}test') == ('http://jaymes.biz/test', 'test')
    assert Model.parse_tag('test') == (None, 'test')
开发者ID:cjaymes,项目名称:pyscap,代码行数:5,代码来源:test_Model.py


注:本文中的scap.Model.Model.parse_tag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。