當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。