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


Python ExtendedAtomDict.clear方法代码示例

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


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

示例1: PackageSet

# 需要导入模块: from portage.dep import ExtendedAtomDict [as 别名]
# 或者: from portage.dep.ExtendedAtomDict import clear [as 别名]
class PackageSet(object):
    # Set this to operations that are supported by your subclass. While
    # technically there is no difference between "merge" and "unmerge" regarding
    # package sets, the latter doesn't make sense for some sets like "system"
    # or "security" and therefore isn't supported by them.
    _operations = ["merge"]
    description = "generic package set"

    def __init__(self, allow_wildcard=False, allow_repo=False):
        self._atoms = set()
        self._atommap = ExtendedAtomDict(set)
        self._loaded = False
        self._loading = False
        self.errors = []
        self._nonatoms = set()
        self.world_candidate = False
        self._allow_wildcard = allow_wildcard
        self._allow_repo = allow_repo

    def __contains__(self, atom):
        self._load()
        return atom in self._atoms or atom in self._nonatoms

    def __iter__(self):
        self._load()
        for x in self._atoms:
            yield x
        for x in self._nonatoms:
            yield x

    def __bool__(self):
        self._load()
        return bool(self._atoms or self._nonatoms)

    if sys.hexversion < 0x3000000:
        __nonzero__ = __bool__

    def supportsOperation(self, op):
        if not op in OPERATIONS:
            raise ValueError(op)
        return op in self._operations

    def _load(self):
        if not (self._loaded or self._loading):
            self._loading = True
            self.load()
            self._loaded = True
            self._loading = False

    def getAtoms(self):
        self._load()
        return self._atoms.copy()

    def getNonAtoms(self):
        self._load()
        return self._nonatoms.copy()

    def _setAtoms(self, atoms):
        self._atoms.clear()
        self._nonatoms.clear()
        for a in atoms:
            if not isinstance(a, Atom):
                if isinstance(a, basestring):
                    a = a.strip()
                if not a:
                    continue
                try:
                    a = Atom(a, allow_wildcard=True, allow_repo=True)
                except InvalidAtom:
                    self._nonatoms.add(a)
                    continue
            if not self._allow_wildcard and a.extended_syntax:
                raise InvalidAtom("extended atom syntax not allowed here")
            if not self._allow_repo and a.repo:
                raise InvalidAtom("repository specification not allowed here")
            self._atoms.add(a)

        self._updateAtomMap()

    def load(self):
        # This method must be overwritten by subclasses
        # Editable sets should use the value of self._mtime to determine if they
        # need to reload themselves
        raise NotImplementedError()

    def containsCPV(self, cpv):
        self._load()
        for a in self._atoms:
            if match_from_list(a, [cpv]):
                return True
        return False

    def getMetadata(self, key):
        if hasattr(self, key.lower()):
            return getattr(self, key.lower())
        else:
            return ""

    def _updateAtomMap(self, atoms=None):
        """Update self._atommap for specific atoms or all atoms."""
#.........这里部分代码省略.........
开发者ID:entoo,项目名称:portage-src,代码行数:103,代码来源:base.py


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