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


Python osutils.listdir_files函数代码示例

本文整理汇总了Python中snakeoil.osutils.listdir_files函数的典型用法代码示例。如果您正苦于以下问题:Python listdir_files函数的具体用法?Python listdir_files怎么用?Python listdir_files使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: main

def main(options, out, err):
    if options.debug:
        out.write('starting scanning distdir %s...' % options.distdir)
    files = set(basename(file) for file in listdir_files(options.distdir))

    if options.debug:
        out.write('scanning repo...')

    pfiles = set()
    for pkg in options.repo.itermatch(options.restrict, sorter=sorted):
        try:
            pfiles.update(fetchable.filename for fetchable in
                        iflatten_instance(pkg.fetchables, fetchable_kls))
        except ParseChksumError as e:
            err.write("got corruption error '%s', with package %s " %
                (e, pkg.cpvstr))
            if options.ignore_failures:
                err.write("skipping...")
                err.write()
            else:
                err.write("aborting...")
                return 1
        except Exception as e:
            err.write("got error '%s', parsing package %s in repo '%s'" %
                (e, pkg.cpvstr, pkg.repo))
            raise

    d = options.distdir
    for file in (files - pfiles):
        out.write(pjoin(d, file))
开发者ID:floppym,项目名称:pkgcore,代码行数:30,代码来源:pclean.py

示例2: _add_sets

    def _add_sets(self):
        self["world"] = basics.AutoConfigSection({
            "class": "pkgcore.pkgsets.filelist.WorldFile",
            "location": pjoin(self.root, econst.WORLD_FILE.lstrip('/'))})
        self["system"] = basics.AutoConfigSection({
            "class": "pkgcore.pkgsets.system.SystemSet",
            "profile": "profile"})
        self["installed"] = basics.AutoConfigSection({
            "class": "pkgcore.pkgsets.installed.Installed",
            "vdb": "vdb"})
        self["versioned-installed"] = basics.AutoConfigSection({
            "class": "pkgcore.pkgsets.installed.VersionedInstalled",
            "vdb": "vdb"})

        set_fp = pjoin(self.dir, "sets")
        try:
            for setname in listdir_files(set_fp):
                # Potential for name clashes here, those will just make
                # the set not show up in config.
                if setname in ("system", "world"):
                    logger.warning(
                        "user defined set %r is disallowed; ignoring",
                        pjoin(set_fp, setname))
                    continue
                self[setname] = basics.AutoConfigSection({
                    "class": "pkgcore.pkgsets.filelist.FileList",
                    "location": pjoin(set_fp, setname)})
        except FileNotFoundError:
            pass
开发者ID:radhermit,项目名称:pkgcore,代码行数:29,代码来源:portage_conf.py

示例3: licenses

 def licenses(self):
     """Return the set of all defined licenses in a repo."""
     try:
         content = listdir_files(self.licenses_dir)
     except EnvironmentError:
         content = ()
     return frozenset(content)
开发者ID:radhermit,项目名称:pkgcore,代码行数:7,代码来源:repo_objs.py

示例4: iter_vulnerabilities

 def iter_vulnerabilities(self):
     """generator yielding each GLSA restriction"""
     for path in self.paths:
         for fn in listdir_files(path):
             # glsa-1234-12.xml
             if not (fn.startswith("glsa-") and fn.endswith(".xml")):
                 continue
             # This verifies the filename is of the correct syntax.
             try:
                 [int(x) for x in fn[5:-4].split("-")]
             except ValueError:
                 continue
             root = etree.parse(pjoin(path, fn))
             glsa_node = root.getroot()
             if glsa_node.tag != 'glsa':
                 raise ValueError("glsa without glsa rootnode")
             for affected in root.findall('affected'):
                 for pkg in affected.findall('package'):
                     try:
                         pkgname = str(pkg.get('name')).strip()
                         pkg_vuln_restrict = \
                             self.generate_intersects_from_pkg_node(
                                 pkg, tag="glsa(%s)" % fn[5:-4])
                         if pkg_vuln_restrict is None:
                             continue
                         pkgatom = atom.atom(pkgname)
                         yield fn[5:-4], pkgname, pkgatom, pkg_vuln_restrict
                     except (TypeError, ValueError) as v:
                         # thrown from cpv.
                         logger.warning(
                             "invalid glsa- %s, package %s: error %s",
                             fn, pkgname, v)
                         del v
开发者ID:radhermit,项目名称:pkgcore,代码行数:33,代码来源:glsa.py

示例5: _reload_state

 def _reload_state(self):
     try:
         self.__set_stage_state__([x[1:]
             for x in listdir_files(self.builddir) if x.startswith(".")])
     except EnvironmentError as e:
         if e.errno not in (errno.ENOTDIR, errno.ENOENT):
             raise
开发者ID:chutz,项目名称:pkgcore,代码行数:7,代码来源:ebd.py

示例6: trigger

    def trigger(self, engine, existing_cset, install_cset):
        # hackish, but it works.
        protected_filter = gen_config_protect_filter(
            engine.offset, self.extra_protects, self.extra_disables).match
        ignore_filter = gen_collision_ignore_filter(engine.offset).match
        protected = {}

        for x in existing_cset.iterfiles():
            if not ignore_filter(x.location) and protected_filter(x.location):
                replacement = install_cset[x]
                if not simple_chksum_compare(replacement, x):
                    protected.setdefault(
                        pjoin(engine.offset,
                              os.path.dirname(x.location).lstrip(os.path.sep)),
                        []).append((os.path.basename(replacement.location),
                                    replacement))

        for dir_loc, entries in protected.iteritems():
            updates = {x[0]: [] for x in entries}
            try:
                existing = sorted(x for x in listdir_files(dir_loc)
                                  if x.startswith("._cfg"))
            except OSError as oe:
                if oe.errno != errno.ENOENT:
                    raise
                # this shouldn't occur.
                continue

            for x in existing:
                try:
                    # ._cfg0000_filename
                    count = int(x[5:9])
                    if x[9] != "_":
                        raise ValueError
                    fn = x[10:]
                except (ValueError, IndexError):
                    continue
                if fn in updates:
                    updates[fn].append((count, fn))

            # now we rename.
            for fname, entry in entries:
                # check for any updates with the same chksums.
                count = 0
                for cfg_count, cfg_fname in updates[fname]:
                    if simple_chksum_compare(livefs.gen_obj(
                            pjoin(dir_loc, cfg_fname)), entry):
                        count = cfg_count
                        break
                    count = max(count, cfg_count + 1)
                try:
                    install_cset.remove(entry)
                except KeyError:
                    # this shouldn't occur...
                    continue
                new_fn = pjoin(dir_loc, "._cfg%04i_%s" % (count, fname))
                new_entry = entry.change_attributes(location=new_fn)
                install_cset.add(new_entry)
                self.renames[new_entry] = entry
            del updates
开发者ID:vapier,项目名称:pkgcore,代码行数:60,代码来源:triggers.py

示例7: collapse_envd

def collapse_envd(base):
    collapsed_d = {}
    try:
        env_d_files = sorted(listdir_files(base))
    except OSError, oe:
        if oe.errno != errno.ENOENT:
            raise
开发者ID:veelai,项目名称:pkgcore,代码行数:7,代码来源:triggers.py

示例8: add_sets

def add_sets(config, root, portage_base_dir):
    config["world"] = basics.AutoConfigSection({
        "class": "pkgcore.pkgsets.filelist.WorldFile",
        "location": pjoin(root, const.WORLD_FILE)})
    config["system"] = basics.AutoConfigSection({
        "class": "pkgcore.pkgsets.system.SystemSet",
        "profile": "profile"})
    config["installed"] = basics.AutoConfigSection({
        "class": "pkgcore.pkgsets.installed.Installed",
        "vdb": "vdb"})
    config["versioned-installed"] = basics.AutoConfigSection({
        "class": "pkgcore.pkgsets.installed.VersionedInstalled",
        "vdb": "vdb"})

    set_fp = pjoin(portage_base_dir, "sets")
    try:
        for setname in listdir_files(set_fp):
            # Potential for name clashes here, those will just make
            # the set not show up in config.
            if setname in ("system", "world"):
                logger.warning(
                    "user defined set %s is disallowed; ignoring" %
                    pjoin(set_fp, setname))
                continue
            config[setname] = basics.AutoConfigSection({
                "class": "pkgcore.pkgsets.filelist.FileList",
                "location": pjoin(set_fp, setname)})
    except OSError as e:
        if e.errno != errno.ENOENT:
            raise
开发者ID:vapier,项目名称:pkgcore,代码行数:30,代码来源:portage_conf.py

示例9: regen

    def regen(self, binary, basepath):
        ignores = ("dir", "dir.old")
        try:
            files = listdir_files(basepath)
        except OSError as oe:
            if oe.errno == errno.ENOENT:
                return
            raise

        if self.should_skip_directory(basepath, files):
            return

        # wipe old indexes.
        for x in set(ignores).intersection(files):
            os.remove(pjoin(basepath, x))

        index = pjoin(basepath, 'dir')
        for x in files:
            if x in ignores or x.startswith("."):
                continue

            ret, data = spawn.spawn_get_output(
                [binary, '--quiet', pjoin(basepath, x), '--dir-file', index],
                collect_fds=(1,2), split_lines=False)

            if not data or "already exists" in data or \
                    "warning: no info dir entry" in data:
                continue
            yield pjoin(basepath, x)
开发者ID:chutz,项目名称:pkgcore,代码行数:29,代码来源:triggers.py

示例10: _scan_directory

def _scan_directory(path):
    files = []
    for x in listdir_files(path):
        match = valid_updates_re.match(x)
        if match is not None:
            files.append(((match.group(2), match.group(1)), x))
    files.sort(key=itemgetter(0))
    return [x[1] for x in files]
开发者ID:veelai,项目名称:pkgcore,代码行数:8,代码来源:pkg_updates.py

示例11: raw_use_expand_desc

 def raw_use_expand_desc(self):
     base = pjoin(self.profiles_base, 'desc')
     try:
         targets = sorted(listdir_files(base))
     except EnvironmentError, e:
         if e.errno != errno.ENOENT:
             raise
         return ()
开发者ID:veelai,项目名称:pkgcore,代码行数:8,代码来源:repo_objs.py

示例12: regen

 def regen(self, binary, basepath):
     ignores = ("dir", "dir.old")
     try:
         files = listdir_files(basepath)
     except OSError, oe:
         if oe.errno == errno.ENOENT:
             return
         raise
开发者ID:veelai,项目名称:pkgcore,代码行数:8,代码来源:triggers.py

示例13: _load_eclasses

 def _load_eclasses(self):
     """Force an update of the internal view of on disk/remote eclasses."""
     ec = {}
     eclass_len = len(".eclass")
     try:
         files = listdir_files(self.eclassdir)
     except EnvironmentError, e:
         if e.errno not in (errno.ENOENT, errno.ENOTDIR):
             raise
         return ImmutableDict()
开发者ID:veelai,项目名称:pkgcore,代码行数:10,代码来源:eclass_cache.py

示例14: collapse_envd

def collapse_envd(base):
    collapsed_d = {}
    try:
        env_d_files = sorted(listdir_files(base))
    except OSError as oe:
        if oe.errno != errno.ENOENT:
            raise
    else:
        for x in env_d_files:
            if x.endswith(".bak") or x.endswith("~") or x.startswith("._cfg") \
                    or len(x) <= 2 or not x[0:2].isdigit():
                continue
            d = read_bash_dict(pjoin(base, x))
            # inefficient, but works.
            for k, v in d.iteritems():
                collapsed_d.setdefault(k, []).append(v)
            del d

    loc_incrementals = set(incrementals)
    loc_colon_parsed = set(colon_parsed)

    # split out env.d defined incrementals..
    # update incrementals *and* colon parsed for colon_separated;
    # incrementals on its own is space separated.

    for x in collapsed_d.pop("COLON_SEPARATED", []):
        v = x.split()
        if v:
            loc_colon_parsed.update(v)

    loc_incrementals.update(loc_colon_parsed)

    # now space.
    for x in collapsed_d.pop("SPACE_SEPARATED", []):
        v = x.split()
        if v:
            loc_incrementals.update(v)

    # now reinterpret.
    for k, v in collapsed_d.iteritems():
        if k not in loc_incrementals:
            collapsed_d[k] = v[-1]
            continue
        if k in loc_colon_parsed:
            collapsed_d[k] = filter(None, iflatten_instance(
                x.split(':') for x in v))
        else:
            collapsed_d[k] = filter(None, iflatten_instance(
                x.split() for x in v))

    return collapsed_d, loc_incrementals, loc_colon_parsed
开发者ID:vapier,项目名称:pkgcore,代码行数:51,代码来源:triggers.py

示例15: _get_versions

 def _get_versions(self, catpkg):
     cppath = pjoin(self.base, catpkg[0], catpkg[1])
     pkg = f'{catpkg[-1]}-'
     lp = len(pkg)
     extension = self.extension
     ext_len = -len(extension)
     try:
         return tuple(
             x[lp:ext_len] for x in listdir_files(cppath)
             if x[ext_len:] == extension and x[:lp] == pkg)
     except EnvironmentError as e:
         raise KeyError(
             "failed fetching versions for package %s: %s" %
             (pjoin(self.base, '/'.join(catpkg)), str(e))) from e
开发者ID:radhermit,项目名称:pkgcore,代码行数:14,代码来源:repository.py


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