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


Python osutils.normpath函数代码示例

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


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

示例1: test_from_abspath

 def test_from_abspath(self):
     self.mk_profiles({"name": "profiles"}, {"name": "profiles/1"})
     base = pjoin(self.dir, "profiles")
     p = self.kls.from_abspath(pjoin(base, "1"))
     self.assertNotEqual(p, None)
     self.assertEqual(normpath(p.basepath), normpath(base))
     self.assertEqual(normpath(p.profile), normpath(pjoin(base, "1")))
开发者ID:veelai,项目名称:pkgcore,代码行数:7,代码来源:test_profiles.py

示例2: _internal_offset_iter_scan

def _internal_offset_iter_scan(path, chksum_handlers, offset, stat_func=os.lstat,
                               hidden=True, backup=True):
    offset = normpath(offset)
    path = normpath(path)
    dirs = collections.deque([path[len(offset):]])
    if dirs[0]:
        yield gen_obj(dirs[0], chksum_handlers=chksum_handlers,
            stat_func=stat_func)

    sep = os.path.sep
    while dirs:
        base = dirs.popleft()
        real_base = pjoin(offset, base.lstrip(sep))
        base = base.rstrip(sep) + sep
        for x in listdir(real_base):
            if not hidden and x.startswith('.'):
                continue
            if not backup and x.endswith('~'):
                continue
            path = pjoin(base, x)
            obj = gen_obj(path, chksum_handlers=chksum_handlers,
                        real_location=pjoin(real_base, x),
                        stat_func=os.lstat)
            yield obj
            if obj.is_dir:
                dirs.append(path)
开发者ID:radhermit,项目名称:pkgcore,代码行数:26,代码来源:livefs.py

示例3: _cmd_implementation_sanity_check

 def _cmd_implementation_sanity_check(self, domain):
     pkg = self.pkg
     eapi = pkg.eapi_obj
     if eapi.options.has_required_use:
         use = pkg.use
         for node in pkg.required_use:
             if not node.match(use):
                 print(textwrap.dedent(
                     """
                     REQUIRED_USE requirement wasn't met
                     Failed to match: {}
                     from: {}
                     for USE: {}
                     pkg: {}
                     """.format(node, pkg.required_use, " ".join(use), pkg.cpvstr)
                 ))
                 return False
     if 'pretend' not in pkg.mandatory_phases:
         return True
     commands = None
     if not pkg.built:
         commands = {"request_inherit": partial(inherit_handler, self._eclass_cache)}
     env = expected_ebuild_env(pkg)
     tmpdir = normpath(domain._get_tempspace())
     builddir = pjoin(tmpdir, env["CATEGORY"], env["PF"])
     pkg_tmpdir = normpath(pjoin(builddir, "temp"))
     ensure_dirs(pkg_tmpdir, mode=0770, gid=portage_gid, minimal=True)
     env["ROOT"] = domain.root
     env["T"] = pkg_tmpdir
     try:
         logger.debug("running ebuild pkg_pretend sanity check for %s", pkg.cpvstr)
         start = time.time()
         ret = run_generic_phase(pkg, "pretend", env, userpriv=True, sandbox=True,
                                 fakeroot=False, extra_handlers=commands)
         logger.debug("pkg_pretend sanity check for %s took %2.2f seconds",
             pkg.cpvstr, time.time() - start)
         return ret
     except format.GenericBuildError as e:
         logger.error("pkg_pretend sanity check for %s failed with exception %r"
             % (pkg.cpvstr, e))
         return False
     finally:
         shutil.rmtree(builddir)
         # try to wipe the cat dir; if not empty, ignore it
         try:
             os.rmdir(os.path.dirname(builddir))
         except EnvironmentError as e:
             if e.errno != errno.ENOTEMPTY:
                 raise
开发者ID:floppym,项目名称:pkgcore,代码行数:49,代码来源:ebd.py

示例4: _add_profile

    def _add_profile(self, profile_override=None):
        if profile_override is None:
            profile = self._find_profile_link()
        else:
            profile = normpath(abspath(profile_override))
            if not os.path.exists(profile):
                raise errors.ComplexInstantiationError(f"{profile} doesn't exist")

        paths = profiles.OnDiskProfile.split_abspath(profile)
        if paths is None:
            raise errors.ComplexInstantiationError(
                '%s expands to %s, but no profile detected' %
                (pjoin(self.dir, 'make.profile'), profile))

        user_profile_path = pjoin(self.dir, 'profile')
        if os.path.isdir(user_profile_path):
            self["profile"] = basics.AutoConfigSection({
                "class": "pkgcore.ebuild.profiles.UserProfile",
                "parent_path": paths[0],
                "parent_profile": paths[1],
                "user_path": user_profile_path,
            })
        else:
            self["profile"] = basics.AutoConfigSection({
                "class": "pkgcore.ebuild.profiles.OnDiskProfile",
                "basepath": paths[0],
                "profile": paths[1],
            })
开发者ID:radhermit,项目名称:pkgcore,代码行数:28,代码来源:portage_conf.py

示例5: add_profile

def add_profile(config, base_path, user_profile_path=None, profile_override=None):
    if profile_override is None:
        profile = _find_profile_link(base_path)
    else:
        profile = normpath(abspath(profile_override))
        if not os.path.exists(profile):
            raise_from(errors.ComplexInstantiationError(
                "%s doesn't exist" % (profile,)))

    paths = profiles.OnDiskProfile.split_abspath(profile)
    if paths is None:
        raise errors.ComplexInstantiationError(
            '%s expands to %s, but no profile detected' %
            (pjoin(base_path, 'make.profile'), profile))

    if os.path.isdir(user_profile_path):
        config["profile"] = basics.AutoConfigSection({
            "class": "pkgcore.ebuild.profiles.UserProfile",
            "parent_path": paths[0],
            "parent_profile": paths[1],
            "user_path": user_profile_path,
        })
    else:
        config["profile"] = basics.AutoConfigSection({
            "class": "pkgcore.ebuild.profiles.OnDiskProfile",
            "basepath": paths[0],
            "profile": paths[1],
        })
开发者ID:vapier,项目名称:pkgcore,代码行数:28,代码来源:portage_conf.py

示例6: __init__

    def __init__(self, location, strict=True, **d):

        d["location"] = normpath(location)

        s = object.__setattr__
        if strict:
            for k in self.__attrs__:
                s(self, k, d[k])
        else:
            for k, v in d.iteritems():
                s(self, k, v)
开发者ID:chutz,项目名称:pkgcore,代码行数:11,代码来源:fs.py

示例7: init_distfiles_env

 def init_distfiles_env(self):
     # cvs/svn ebuilds need to die.
     distdir_write = self.domain.fetcher.get_storage_path()
     if distdir_write is None:
         raise format.GenericBuildError("no usable distdir was found "
             "for PORTAGE_ACTUAL_DISTDIR from fetcher %s" % self.domain.fetcher)
     self.env["PORTAGE_ACTUAL_DISTDIR"] = distdir_write
     self.env["DISTDIR"] = normpath(
         pjoin(self.builddir, "distdir"))
     for x in ("PORTAGE_ACTUAL_DISTDIR", "DISTDIR"):
         self.env[x] = os.path.realpath(self.env[x]).rstrip("/") + "/"
开发者ID:chutz,项目名称:pkgcore,代码行数:11,代码来源:ebd.py

示例8: _find_profile_link

 def _find_profile_link(self):
     make_profile = pjoin(self.dir, 'make.profile')
     try:
         return normpath(abspath(
             pjoin(self.dir, os.readlink(make_profile))))
     except EnvironmentError as e:
         if e.errno in (errno.ENOENT, errno.EINVAL):
             raise errors.ComplexInstantiationError(
                 f"{make_profile} must be a symlink pointing to a real target") from e
         raise errors.ComplexInstantiationError(
             f"{make_profile}: unexpected error- {e.strerror}") from e
开发者ID:radhermit,项目名称:pkgcore,代码行数:11,代码来源:portage_conf.py

示例9: __init__

    def __init__(self, mode, tempdir, hooks, csets, preserves, observer,
                 offset=None, disable_plugins=False, parallelism=None):
        if observer is None:
            observer = observer_mod.repo_observer(observer_mod.null_output)
        self.observer = observer
        self.mode = mode
        if tempdir is not None:
            tempdir = normpath(tempdir) + '/'
        self.tempdir = tempdir

        if parallelism is None:
            parallelism = get_proc_count()

        self.parallelism = parallelism

        self.hooks = ImmutableDict((x, []) for x in hooks)

        self.preserve_csets = []
        self.cset_sources = {}
        # instantiate these separately so their values are preserved
        self.preserved_csets = LazyValDict(
            self.preserve_csets, self._get_cset_source)
        for k, v in csets.iteritems():
            if isinstance(v, basestring):
                v = getattr(self, v, v)
            if not callable(v):
                raise TypeError(
                    "cset values must be either the string name of "
                    "existing methods, or callables (got %s)" % v)

            if k in preserves:
                self.add_preserved_cset(k, v)
            else:
                self.add_cset(k, v)

        if offset is None:
            offset = "/"
        self.offset = offset

        if not disable_plugins:
            # merge in default triggers first.
            for trigger in get_plugins('triggers'):
                t = trigger()
                t.register(self)

        # merge in overrides
        for hook, triggers in hooks.iteritems():
            for trigger in triggers:
                self.add_trigger(hook, trigger)

        self.regenerate_csets()
        for x in hooks:
            setattr(self, x, partial(self.execute_hook, x))
开发者ID:floppym,项目名称:pkgcore,代码行数:53,代码来源:engine.py

示例10: _init_distfiles_env

 def _init_distfiles_env(self):
     # TODO: PORTAGE_ACTUAL_DISTDIR usage by vcs eclasses needs to be killed off
     distdir_write = self.domain.fetcher.get_storage_path()
     if distdir_write is None:
         raise format.GenericBuildError(
             "no usable distdir was found "
             f"for PORTAGE_ACTUAL_DISTDIR from fetcher {self.domain.fetcher}")
     self.env["PORTAGE_ACTUAL_DISTDIR"] = distdir_write
     self.env["DISTDIR"] = normpath(
         pjoin(self.builddir, "distdir"))
     for x in ("PORTAGE_ACTUAL_DISTDIR", "DISTDIR"):
         self.env[x] = os.path.realpath(self.env[x]).rstrip(os.sep) + os.sep
开发者ID:radhermit,项目名称:pkgcore,代码行数:12,代码来源:ebd.py

示例11: gen_config_protect_filter

def gen_config_protect_filter(offset, extra_protects=(), extra_disables=()):
    collapsed_d, inc, colon = collapse_envd(pjoin(offset, "etc/env.d"))
    collapsed_d.setdefault("CONFIG_PROTECT", []).extend(extra_protects)
    collapsed_d.setdefault("CONFIG_PROTECT_MASK", []).extend(extra_disables)

    r = [values.StrGlobMatch(normpath(x).rstrip("/") + "/")
         for x in set(stable_unique(collapsed_d["CONFIG_PROTECT"] + ["/etc"]))]
    if len(r) > 1:
        r = values.OrRestriction(*r)
    else:
        r = r[0]
    neg = stable_unique(collapsed_d["CONFIG_PROTECT_MASK"])
    if neg:
        if len(neg) == 1:
            r2 = values.StrGlobMatch(normpath(neg[0]).rstrip("/") + "/",
                                     negate=True)
        else:
            r2 = values.OrRestriction(
                negate=True,
                *[values.StrGlobMatch(normpath(x).rstrip("/") + "/")
                  for x in set(neg)])
        r = values.AndRestriction(r, r2)
    return r
开发者ID:vapier,项目名称:pkgcore,代码行数:23,代码来源:triggers.py

示例12: _set_op_vars

    def _set_op_vars(self, tmp_offset):
        # don't fool with this, without fooling with setup.
        self.tmpdir = self.domain.pm_tmpdir
        if tmp_offset:
            self.tmpdir = pjoin(self.tmpdir, tmp_offset.strip(os.sep))

        self.builddir = pjoin(self.tmpdir, self.env["CATEGORY"], self.env["PF"])
        for x, y in (("T", "temp"),
                     ("WORKDIR", "work"),
                     ("D", "image"),
                     ("HOME", "homedir")):
            self.env[x] = normpath(pjoin(self.builddir, y))
        self.env["D"] += self.eapi.options.trailing_slash
        self.env["PORTAGE_LOGFILE"] = normpath(pjoin(self.env["T"], "build.log"))

        # XXX: Note that this is just EAPI 3 support, not yet prefix
        # full awareness.
        if self.prefix_mode:
            self.env["ED"] = normpath(
                pjoin(self.env["D"].rstrip(os.sep), self.prefix.rstrip(os.sep))) \
                    + self.eapi.options.trailing_slash

        # temporary install dir correct for all EAPIs
        self.ED = self.env.get('ED', self.env['D'])
开发者ID:radhermit,项目名称:pkgcore,代码行数:24,代码来源:ebd.py

示例13: _internal_iter_scan

def _internal_iter_scan(path, chksum_handlers, stat_func=os.lstat):
    dirs = collections.deque([normpath(path)])
    obj = gen_obj(dirs[0], chksum_handlers=chksum_handlers,
        stat_func=stat_func)
    yield obj
    if not obj.is_dir:
        return
    while dirs:
        base = dirs.popleft()
        for x in listdir(base):
            path = pjoin(base, x)
            obj = gen_obj(path, chksum_handlers=chksum_handlers,
                        real_location=path, stat_func=stat_func)
            yield obj
            if obj.is_dir:
                dirs.append(path)
开发者ID:den4ix,项目名称:pkgcore,代码行数:16,代码来源:livefs.py

示例14: iter_child_nodes

    def iter_child_nodes(self, start_point):
        """Yield a stream of nodes that are fs entries contained within the
        passed in start point.

        :param start_point: fs filepath all yielded nodes must be within.
        """

        if isinstance(start_point, fs.fsBase):
            if start_point.is_sym:
                start_point = start_point.target
            else:
                start_point = start_point.location
        for x in self:
            cn_path = normpath(start_point).rstrip(path.sep) + path.sep
            # what about sym targets?
            if x.location.startswith(cn_path):
                yield x
开发者ID:den4ix,项目名称:pkgcore,代码行数:17,代码来源:contents.py

示例15: _find_profile_link

def _find_profile_link(base_path, portage_compat=False):
    make_profile = pjoin(base_path, 'make.profile')
    try:
        return normpath(abspath(
            pjoin(base_path, os.readlink(make_profile))))
    except EnvironmentError as oe:
        if oe.errno in (errno.ENOENT, errno.EINVAL):
            if oe.errno == errno.ENOENT:
                if portage_compat:
                    return None
                profile = _find_profile_link(pjoin(base_path, 'portage'), True)
                if profile is not None:
                    return profile
            raise_from(errors.ComplexInstantiationError(
                "%s must be a symlink pointing to a real target" % (
                    make_profile,)))
        raise_from(errors.ComplexInstantiationError(
            "%s: unexpected error- %s" % (make_profile, oe.strerror)))
开发者ID:vapier,项目名称:pkgcore,代码行数:18,代码来源:portage_conf.py


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