• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python path.normpath函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: normalize_path

    def normalize_path(self, path, filesystem_absolute=False, srcdir=None):
        """Normalizes paths.

        If the path is absolute, behavior is governed by filesystem_absolute.
        If filesystem_absolute is True, the path is interpreted as absolute on
        the actual filesystem. If it is false, the path is treated as absolute
        within the current topsrcdir.

        If the path is not absolute, it will be treated as relative to the
        currently executing file. If there is no currently executing file, it
        will be treated as relative to topsrcdir.
        """
        if os.path.isabs(path):
            if filesystem_absolute:
                return path
            for root in [self.topsrcdir] + self.external_source_dirs:
                # mozpath.join would ignore the self.topsrcdir argument if we
                # passed in the absolute path, so omit the leading /
                p = mozpath.normpath(mozpath.join(root, path[1:]))
                if os.path.exists(p):
                    return p
            # mozpath.join would ignore the self.topsrcdir argument if we passed
            # in the absolute path, so omit the leading /
            return mozpath.normpath(mozpath.join(self.topsrcdir, path[1:]))
        elif srcdir:
            return mozpath.normpath(mozpath.join(srcdir, path))
        elif len(self._execution_stack):
            return mozpath.normpath(mozpath.join(
                mozpath.dirname(self._execution_stack[-1]), path))
        else:
            return mozpath.normpath(mozpath.join(self.topsrcdir, path))
开发者ID:jrmuizel,项目名称:mozilla-central-skia,代码行数:31,代码来源:reader.py


示例2: handle_manifest_entry

    def handle_manifest_entry(self, entry):
        format_strings = {
            "content": "chrome://%s/content/",
            "resource": "resource://%s/",
            "locale": "chrome://%s/locale/",
            "skin": "chrome://%s/skin/",
        }

        if isinstance(entry, (ManifestChrome, ManifestResource)):
            if isinstance(entry, ManifestResource):
                dest = entry.target
                url = urlparse.urlparse(dest)
                if not url.scheme:
                    dest = mozpath.normpath(mozpath.join(entry.base, dest))
                if url.scheme == 'file':
                    dest = mozpath.normpath(url.path)
            else:
                dest = mozpath.normpath(entry.path)

            base_uri = format_strings[entry.type] % entry.name
            self.chrome_mapping[base_uri].add(dest)
        if isinstance(entry, ManifestOverride):
            self.overrides[entry.overloaded] = entry.overload
        if isinstance(entry, Manifest):
            for e in parse_manifest(None, entry.path):
                self.handle_manifest_entry(e)
开发者ID:luke-chang,项目名称:gecko-1,代码行数:26,代码来源:manifest_handler.py


示例3: rewrite_url

    def rewrite_url(self, url):
        # This applies one-off rules and returns None for urls that we aren't
        # going to be able to resolve to a source file ("about:" urls, for
        # instance).
        if url in self._final_mapping:
            return self._final_mapping[url]
        if url.endswith('> eval'):
            return None
        if url.endswith('> Function'):
            return None
        if ' -> ' in url:
            url = url.split(' -> ')[1].rstrip()
        if '?' in url:
            url = url.split('?')[0]

        url_obj = urlparse.urlparse(url)
        if url_obj.scheme == 'jar':
            app_name = self.MOZ_APP_NAME
            omnijar_name = self.OMNIJAR_NAME

            if app_name in url:
                if omnijar_name in url:
                    # e.g. file:///home/worker/workspace/build/application/firefox/omni.ja!/components/MainProcessSingleton.js
                    parts = url_obj.path.split(omnijar_name + '!', 1)
                elif '.xpi!' in url:
                    # e.g. file:///home/worker/workspace/build/application/firefox/browser/features/[email protected]!/bootstrap.js
                    parts = url_obj.path.split('.xpi!', 1)
                else:
                    # We don't know how to handle this jar: path, so return it to the
                    # caller to make it print a warning.
                    return url_obj.path, None

                dir_parts = parts[0].rsplit(app_name + '/', 1)
                url = mozpath.normpath(mozpath.join(self.topobjdir, 'dist', 'bin', dir_parts[1].lstrip('/'), parts[1].lstrip('/')))
            elif '.xpi!' in url:
                # e.g. file:///tmp/tmpMdo5gV.mozrunner/extensions/[email protected]!/bootstrap.js
                # This matching mechanism is quite brittle and based on examples seen in the wild.
                # There's no rule to match the XPI name to the path in dist/xpi-stage.
                parts = url_obj.path.split('.xpi!', 1)
                addon_name = os.path.basename(parts[0])
                if '[email protected]' in addon_name:
                    addon_name = addon_name[:-len('[email protected]')]
                elif addon_name.endswith('@mozilla.org'):
                    addon_name = addon_name[:-len('@mozilla.org')]
                url = mozpath.normpath(mozpath.join(self.topobjdir, 'dist', 'xpi-stage', addon_name, parts[1].lstrip('/')))
        elif url_obj.scheme == 'file' and os.path.isabs(url_obj.path):
            path = url_obj.path
            if not os.path.isfile(path):
                # This may have been in a profile directory that no
                # longer exists.
                return None
            if not path.startswith(self.topobjdir):
                return path, None
            url = url_obj.path
        elif url_obj.scheme in ('http', 'https', 'javascript', 'data', 'about'):
            return None

        result = self.find_files(url)
        self._final_mapping[url] = result
        return result
开发者ID:luke-chang,项目名称:gecko-1,代码行数:60,代码来源:lcov_rewriter.py


示例4: is_read_allowed

def is_read_allowed(path, config):
    """Whether we are allowed to load a mozbuild file at the specified path.

    This is used as cheap security to ensure the build is isolated to known
    source directories.

    We are allowed to read from the main source directory and any defined
    external source directories. The latter is to allow 3rd party applications
    to hook into our build system.
    """
    assert os.path.isabs(path)
    assert os.path.isabs(config.topsrcdir)

    path = mozpath.normpath(path)
    topsrcdir = mozpath.normpath(config.topsrcdir)

    if mozpath.basedir(path, [topsrcdir]):
        return True

    if config.external_source_dir:
        external_dir = os.path.normcase(config.external_source_dir)
        norm_path = os.path.normcase(path)
        if mozpath.basedir(norm_path, [external_dir]):
            return True

    return False
开发者ID:c0mmandCS,项目名称:Waterfox,代码行数:26,代码来源:reader.py


示例5: test_include_failures

    def test_include_failures(self):
        with self.assertRaises(ConfigureError) as e:
            with self.moz_configure('include("../foo.configure")'):
                self.get_config()

        self.assertEquals(
            e.exception.message,
            'Cannot include `%s` because it is not in a subdirectory of `%s`'
            % (mozpath.normpath(mozpath.join(test_data_path, '..',
                                             'foo.configure')),
               mozpath.normsep(test_data_path))
        )

        with self.assertRaises(ConfigureError) as e:
            with self.moz_configure('''
                include('extra.configure')
                include('extra.configure')
            '''):
                self.get_config()

        self.assertEquals(
            e.exception.message,
            'Cannot include `%s` because it was included already.'
            % mozpath.normpath(mozpath.join(test_data_path,
                                            'extra.configure'))
        )

        with self.assertRaises(TypeError) as e:
            with self.moz_configure('''
                include(42)
            '''):
                self.get_config()

        self.assertEquals(e.exception.message, "Unexpected type: 'int'")
开发者ID:subsevenx2001,项目名称:gecko-dev,代码行数:34,代码来源:test_configure.py


示例6: is_read_allowed

def is_read_allowed(path, config):
    """Whether we are allowed to load a mozbuild file at the specified path.

    This is used as cheap security to ensure the build is isolated to known
    source directories.

    We are allowed to read from the main source directory and any defined
    external source directories. The latter is to allow 3rd party applications
    to hook into our build system.
    """
    assert os.path.isabs(path)
    assert os.path.isabs(config.topsrcdir)

    path = mozpath.normpath(path)
    topsrcdir = mozpath.normpath(config.topsrcdir)

    if path.startswith(topsrcdir):
        return True

    external_dirs = config.substs.get('EXTERNAL_SOURCE_DIR', '').split()
    for external in external_dirs:
        if not os.path.isabs(external):
            external = mozpath.join(config.topsrcdir, external)
        external = mozpath.normpath(external)

        if path.startswith(external):
            return True

    return False
开发者ID:chenhequn,项目名称:gecko,代码行数:29,代码来源:reader.py


示例7: __init__

 def __init__(self, srcdir, objdir, fix):
     self.srcdir = mozpath.normpath(srcdir)
     self.objdir = mozpath.normpath(objdir)
     self.srcdir_mount = self.getmount(self.srcdir)
     self.objdir_mount = self.getmount(self.objdir)
     self.path_mounts = [
         ('srcdir', self.srcdir, self.srcdir_mount),
         ('objdir', self.objdir, self.objdir_mount)
     ]
     self.fix = fix
     self.results = []
开发者ID:luke-chang,项目名称:gecko-1,代码行数:11,代码来源:doctor.py


示例8: output_to_inputs_tree

    def output_to_inputs_tree(self):
        '''
        Return a dictionary mapping each output path to the set of its
        required input paths.

        All paths are normalized.
        '''
        tree = {}
        for output, file in self:
            output = mozpath.normpath(output)
            tree[output] = set(mozpath.normpath(f) for f in file.inputs())
        return tree
开发者ID:luke-chang,项目名称:gecko-1,代码行数:12,代码来源:copier.py


示例9: test_config_file_substitution

    def test_config_file_substitution(self):
        reader = self.reader("config-file-substitution")
        objs = self.read_topsrcdir(reader)
        self.assertEqual(len(objs), 2)

        self.assertIsInstance(objs[0], ConfigFileSubstitution)
        self.assertIsInstance(objs[1], ConfigFileSubstitution)

        topobjdir = mozpath.abspath(reader.config.topobjdir)
        self.assertEqual(objs[0].relpath, "foo")
        self.assertEqual(mozpath.normpath(objs[0].output_path), mozpath.normpath(mozpath.join(topobjdir, "foo")))
        self.assertEqual(mozpath.normpath(objs[1].output_path), mozpath.normpath(mozpath.join(topobjdir, "bar")))
开发者ID:logicoftekk,项目名称:cyberfox,代码行数:12,代码来源:test_emitter.py


示例10: input_to_outputs_tree

    def input_to_outputs_tree(self):
        '''
        Return a dictionary mapping each input path to the set of
        impacted output paths.

        All paths are normalized.
        '''
        tree = defaultdict(set)
        for output, file in self:
            output = mozpath.normpath(output)
            for input in file.inputs():
                input = mozpath.normpath(input)
                tree[input].add(output)
        return dict(tree)
开发者ID:luke-chang,项目名称:gecko-1,代码行数:14,代码来源:copier.py


示例11: _get_backend_file

 def _get_backend_file(self, relobjdir):
     objdir = mozpath.normpath(mozpath.join(self.environment.topobjdir, relobjdir))
     if objdir not in self._backend_files:
         self._backend_files[objdir] = \
                 BackendTupfile(objdir, self.environment,
                                self.environment.topsrcdir, self.environment.topobjdir)
     return self._backend_files[objdir]
开发者ID:luke-chang,项目名称:gecko-1,代码行数:7,代码来源:tup.py


示例12: add_manifest

    def add_manifest(self, entry):
        # Store manifest entries in a single manifest per directory, named
        # after their parent directory, except for root manifests, all named
        # chrome.manifest.
        if entry.base:
            name = mozpath.basename(entry.base)
        else:
            name = 'chrome'
        path = mozpath.normpath(mozpath.join(entry.base, '%s.manifest' % name))
        if not self.copier.contains(path):
            # Add a reference to the manifest file in the parent manifest, if
            # the manifest file is not a root manifest.
            if entry.base:
                parent = mozpath.dirname(entry.base)
                relbase = mozpath.basename(entry.base)
                relpath = mozpath.join(relbase,
                                            mozpath.basename(path))
                self.add_manifest(Manifest(parent, relpath))
            self.copier.add(path, ManifestFile(entry.base))

        if isinstance(entry, ManifestChrome):
            data = self._chrome_db.setdefault(entry.name, {})
            entries = data.setdefault(entry.type, [])
            for e in entries:
                # Ideally, we'd actually check whether entry.flags are more
                # specific than e.flags, but in practice the following test
                # is enough for now.
                if not entry.flags or e.flags and entry.flags == e.flags:
                    errors.fatal('"%s" overrides "%s"' % (entry, e))
            entries.append(entry)

        self.copier[path].add(entry)
开发者ID:Wafflespeanut,项目名称:gecko-dev,代码行数:32,代码来源:formats.py


示例13: addDependencies

 def addDependencies(self, target, deps):
     if not target in self.newDeps:
         self.newDeps[target] = set()
     for p in deps:
         p = mozpath.normpath(p)
         self.newDeps[target].add(p)
         self.sourceFiles.add(p)
开发者ID:html-shell,项目名称:mozbuild,代码行数:7,代码来源:internal.py


示例14: _process_files

    def _process_files(self, obj, files, target, preprocessor = False, marker='#', target_is_file=False, optional=False):
        for f in files:
            if optional:
                full_dest = f
            elif target_is_file:
                full_dest = target
            else:
                full_dest = mozpath.join(target, mozpath.basename(f))
            install_manifest, dest = self._get_manifest_from_target(full_dest)
            source = None if (obj is None) else mozpath.normpath(mozpath.join(obj.srcdir, f))
            if preprocessor:
                dep_file = mozpath.join(self.dep_path, target, mozpath.basename(f) +'.pp')
                exist_defines = self._paths_to_defines.get(obj.srcdir, {})

                xul_defines = dict(exist_defines)
                for flag in self.XULPPFLAGS:
                    if flag.startswith('-D'):
                        define = flag[2:].split('=')
                        xul_defines[define[0]] = define[1] if len(define) >= 2 else ''
                defines = compute_defines(obj.config, defines = xul_defines)
                new_marker = marker
                if marker == 'jar':
                    new_marker = '%' if f.endswith('.css') else '#'
                install_manifest.add_preprocess(source, dest, dep_file, marker=new_marker, defines=defines)
            elif optional:
                install_manifest.add_optional_exists(dest)
            else:
                install_manifest.add_symlink(source, dest)
开发者ID:html-shell,项目名称:mozbuild,代码行数:28,代码来源:internal.py


示例15: _add_entry

    def _add_entry(self, dest, entry, normlize_dest=True):
        if normlize_dest:
            dest = mozpath.normpath(dest)
        if dest in self._dests:
            raise ValueError("Item already in manifest: %s" % dest)

        self._dests[dest] = entry
开发者ID:html-shell,项目名称:mozbuild,代码行数:7,代码来源:manifests.py


示例16: find_reftest_dirs

def find_reftest_dirs(topsrcdir, manifests):
    from reftest import ReftestManifest

    dirs = set()
    for p in manifests:
        m = ReftestManifest()
        m.load(os.path.join(topsrcdir, p))
        dirs |= m.dirs

    dirs = {mozpath.normpath(d[len(topsrcdir):]).lstrip('/') for d in dirs}

    # Filter out children captured by parent directories because duplicates
    # will confuse things later on.
    def parents(p):
        while True:
            p = mozpath.dirname(p)
            if not p:
                break
            yield p

    seen = set()
    for d in sorted(dirs, key=len):
        if not any(p in seen for p in parents(d)):
            seen.add(d)

    return sorted(seen)
开发者ID:Nazi-Nigger,项目名称:gecko-dev,代码行数:26,代码来源:test_archive.py


示例17: load_deps_file

    def load_deps_file(self, objdir, fh):
        """Load a single dependency file."""
        for rule in read_dep_makefile(fh):
            for target in rule.targets():
                full_target = mozpath.normpath(mozpath.join(objdir,
                    target))

                normalized_deps = []
                for d in rule.dependencies():
                    full_depend = mozpath.join(objdir, d)
                    # Resolve symbolic links from $objdir/dist/include and
                    # the like to their srcdir equivalents.  Don't use
                    # _realpath_cache.get(full_depend, os.path.realpath(...)),
                    # as the whole point of this cache is to avoid hitting
                    # the filesystem if we don't have to.
                    if full_depend in self._realpath_cache:
                        full_depend = self._realpath_cache[full_depend]
                    else:
                        resolved = os.path.realpath(full_depend)
                        self._realpath_cache[full_depend] = resolved
                        full_depend = resolved
                    normalized_deps.append(full_depend)
                    self.dependencies.setdefault(full_depend, set()).add(full_target)

                assert full_target not in self.targets
                self.targets[full_target] = normalized_deps
开发者ID:froydnj,项目名称:gecko-dev,代码行数:26,代码来源:analyze.py


示例18: __init__

    def __init__(self, config):
        self.config = config
        self.topsrcdir = mozpath.normpath(config.topsrcdir)

        self.tests_by_path = defaultdict(list)
        self.installs_by_path = defaultdict(list)
        self.deferred_installs = set()
开发者ID:leplatrem,项目名称:gecko-dev,代码行数:7,代码来源:common.py


示例19: include_file

    def include_file(self, path):
        '''Include one file in the sandbox. Users of this class probably want

        Note: this will execute all template invocations, as well as @depends
        functions that depend on '--help', but nothing else.
        '''

        if self._paths:
            path = mozpath.join(mozpath.dirname(self._paths[-1]), path)
            path = mozpath.normpath(path)
            if not mozpath.basedir(path, (mozpath.dirname(self._paths[0]),)):
                raise ConfigureError(
                    'Cannot include `%s` because it is not in a subdirectory '
                    'of `%s`' % (path, mozpath.dirname(self._paths[0])))
        else:
            path = mozpath.realpath(mozpath.abspath(path))
        if path in self._all_paths:
            raise ConfigureError(
                'Cannot include `%s` because it was included already.' % path)
        self._paths.append(path)
        self._all_paths.add(path)

        source = open(path, 'rb').read()

        code = compile(source, path, 'exec')

        exec_(code, self)

        self._paths.pop(-1)
开发者ID:lazyparser,项目名称:gecko-dev,代码行数:29,代码来源:__init__.py


示例20: resolve_tests

    def resolve_tests(self, paths=None, flavor=None, under_path=None):
        """Resolve tests from an identifier.

        This is a generator of dicts describing each test.

        ``paths`` can be an iterable of values to use to identify tests to run.
        If an entry is a known test file, tests associated with that file are
        returned (there may be multiple configurations for a single file). If
        an entry is a directory, all tests in that directory are returned. If
        the string appears in a known test file, that test file is considered.

        If ``under_path`` is a string, it will be used to filter out tests that
        aren't in the specified path prefix relative to topsrcdir or the
        test's installed dir.

        If ``flavor`` is a string, it will be used to filter returned tests
        to only be the flavor specified. A flavor is something like
        ``xpcshell``.
        """
        def fltr(tests):
            for test in tests:
                if flavor:
                   if (flavor == 'devtools' and test.get('flavor') != 'browser-chrome') or \
                      (flavor != 'devtools' and test.get('flavor') != flavor):
                    continue

                if under_path \
                    and not test['file_relpath'].startswith(under_path):
                    continue

                # Make a copy so modifications don't change the source.
                yield dict(test)

        paths = paths or []
        paths = [mozpath.normpath(p) for p in paths]
        if not paths:
            paths = [None]

        candidate_paths = set()

        for path in sorted(paths):
            if path is None:
                candidate_paths |= set(self._tests_by_path.keys())
                continue

            # If the path is a directory, pull in all tests in that directory.
            if path in self._test_dirs:
                candidate_paths |= {p for p in self._tests_by_path
                                    if p.startswith(path)}
                continue

            # If it's a test file, add just that file.
            candidate_paths |= {p for p in self._tests_by_path if path in p}

        for p in sorted(candidate_paths):
            tests = self._tests_by_path[p]

            for test in fltr(tests):
                yield test
开发者ID:JasonGross,项目名称:mozjs,代码行数:59,代码来源:testing.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python path.relpath函数代码示例发布时间:2022-05-27
下一篇:
Python path.match函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap