예제 #1
0
 def arch_profiles(self):
     """Return the mapping of arches to profiles for a repo."""
     d = mappings.defaultdict(list)
     fp = pjoin(self.profile_base, 'profiles.desc')
     try:
         for line in iter_read_bash(fp):
             l = line.split()
             try:
                 key, profile, status = l
             except ValueError:
                 logger.error(
                     "%s: line doesn't follow 'key profile status' form: %s",
                     fp, line)
                 continue
             # Normalize the profile name on the offchance someone slipped an extra /
             # into it.
             d[key].append(
                 _KnownProfile('/'.join(filter(None, profile.split('/'))),
                               status))
     except EnvironmentError as e:
         if e.errno != errno.ENOENT:
             raise
         logger.debug("No profile descriptions found at %r", fp)
     return mappings.ImmutableDict(
         (k, tuple(sorted(v))) for k, v in d.iteritems())
예제 #2
0
파일: weakrefs.py 프로젝트: chutz/snakeoil
    def __new__(cls, name, bases, d):
        if '__del__' in d:
            d['__finalizer__'] = d.pop("__del__")
        elif not '__finalizer__' in d and not \
            any(hasattr(parent, "__finalizer__") for parent in bases):
            raise TypeError(
                "cls %s doesn't have either __del__ nor a __finalizer__" %
                (name, ))

        if not '__disable_finalization__' in d and not \
            any(hasattr(parent, "__disable_finalization__") for parent in bases):
            # install tracking
            d['__disable_finalization__'] = __disable_finalization__
            d['__enable_finalization__'] = __enable_finalization__
        # install tracking bits.  we do this per class- this is intended to avoid any
        # potential stupid subclasses wiping a parents tracking.

        d['__finalizer_weakrefs__'] = mappings.defaultdict(dict)

        new_cls = super(WeakRefFinalizer, cls).__new__(cls, name, bases, d)
        new_cls.__proxy_class__ = partial(make_kls(new_cls, WeakRefProxy), cls,
                                          lambda x: x)
        new_cls.__proxy_class__.__name__ = name
        cls.__known_classes__[new_cls] = True
        return new_cls
예제 #3
0
파일: repo_objs.py 프로젝트: veelai/pkgcore
 def arch_profiles(self):
     d = mappings.defaultdict(list)
     fp = pjoin(self.profile_base, 'profiles.desc')
     try:
         for line in fileutils.iter_read_bash(fp):
             l = line.split()
             try:
                 key, profile, status = l
             except ValueError:
                 logger.error(
                     "%s: line doesn't follow 'key profile status' form: %s",
                      fp, line)
                 continue
             # Normalize the profile name on the offchance someone slipped an extra /
             # into it.
             d[key].append(_KnownProfile(
                 '/'.join(filter(None, profile.split('/'))), status))
     except EnvironmentError, e:
         if e.errno != errno.ENOENT:
             raise
         logger.debug("No profile descriptions found at %r", fp)
예제 #4
0
 def arch_profiles(self):
     """Return the mapping of arches to profiles for a repo."""
     d = mappings.defaultdict(list)
     fp = pjoin(self.profile_base, 'profiles.desc')
     try:
         for line in iter_read_bash(fp):
             l = line.split()
             try:
                 key, profile, status = l
             except ValueError:
                 logger.error(
                     f"{fp}: line doesn't follow 'key profile status' form: {line}")
                 continue
             # Normalize the profile name on the offchance someone slipped an extra /
             # into it.
             d[key].append(_KnownProfile(
                 '/'.join(filter(None, profile.split('/'))), status))
     except FileNotFoundError:
         logger.debug(f"No profile descriptions found at {fp!r}")
     return mappings.ImmutableDict(
         (k, tuple(sorted(v))) for k, v in d.items())
예제 #5
0
파일: weakrefs.py 프로젝트: rhn/snakeoil
    def __new__(cls, name, bases, d):
        if '__del__' in d:
            d['__finalizer__'] = d.pop("__del__")
        elif not '__finalizer__' in d and not \
            any(hasattr(parent, "__finalizer__") for parent in bases):
            raise TypeError("cls %s doesn't have either __del__ nor a __finalizer__"
                            % (name,))

        if not '__disable_finalization__' in d and not \
            any(hasattr(parent, "__disable_finalization__") for parent in bases):
            # install tracking
            d['__disable_finalization__'] = __disable_finalization__
            d['__enable_finalization__'] = __enable_finalization__
        # install tracking bits.  we do this per class- this is intended to avoid any
        # potential stupid subclasses wiping a parents tracking.

        d['__finalizer_weakrefs__'] = mappings.defaultdict(dict)

        new_cls = super(WeakRefFinalizer, cls).__new__(cls, name, bases, d)
        new_cls.__proxy_class__ = partial(make_kls(new_cls, WeakRefProxy), cls, lambda x: x)
        new_cls.__proxy_class__.__name__ = name
        cls.__known_classes__[new_cls] = True
        return new_cls