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

Python path.basename函数代码示例

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

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



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

示例1: 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


示例2: _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


示例3: __init__

    def __init__(self, source):
        if isinstance(source, BaseFinder):
            self._finder = source
        else:
            self._finder = FileFinder(source)
        self.base = self._finder.base
        self.files = FileRegistry()
        self.kind = 'flat'
        self.omnijar = None
        self.jarlogs = {}
        self.optimizedjars = False
        self.compressed = True

        jars = set()

        for p, f in self._finder.find('*'):
            # Skip the precomplete file, which is generated at packaging time.
            if p == 'precomplete':
                continue
            base = mozpath.dirname(p)
            # If the file is a zip/jar that is not a .xpi, and contains a
            # chrome.manifest, it is an omnijar. All the files it contains
            # go in the directory containing the omnijar. Manifests are merged
            # if there is a corresponding manifest in the directory.
            if not p.endswith('.xpi') and self._maybe_zip(f) and \
                    (mozpath.basename(p) == self.omnijar or
                     not self.omnijar):
                jar = self._open_jar(p, f)
                if 'chrome.manifest' in jar:
                    self.kind = 'omni'
                    self.omnijar = mozpath.basename(p)
                    self._fill_with_jar(base, jar)
                    continue
            # If the file is a manifest, scan its entries for some referencing
            # jar: urls. If there are some, the files contained in the jar they
            # point to, go under a directory named after the jar.
            if is_manifest(p):
                m = self.files[p] if self.files.contains(p) \
                    else ManifestFile(base)
                for e in parse_manifest(self.base, p, f.open()):
                    m.add(self._handle_manifest_entry(e, jars))
                if self.files.contains(p):
                    continue
                f = m
            # If the file is a packed addon, unpack it under a directory named
            # after the xpi.
            if p.endswith('.xpi') and self._maybe_zip(f):
                self._fill_with_jar(p[:-4], self._open_jar(p, f))
                continue
            if not p in jars:
                self.files.add(p, f)
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:51,代码来源:unpack.py


示例4: register_idl

    def register_idl(self, idl, allow_existing=False):
        """Registers an IDL file with this instance.

        The IDL file will be built, installed, etc.
        """
        basename = mozpath.basename(idl.source_path)
        root = mozpath.splitext(basename)[0]
        xpt = "%s.xpt" % idl.module
        manifest = mozpath.join(idl.install_target, "components", "interfaces.manifest")
        chrome_manifest = mozpath.join(idl.install_target, "chrome.manifest")

        entry = {
            "source": idl.source_path,
            "module": idl.module,
            "basename": basename,
            "root": root,
            "manifest": manifest,
        }

        if not allow_existing and entry["basename"] in self.idls:
            raise Exception("IDL already registered: %s" % entry["basename"])

        self.idls[entry["basename"]] = entry
        t = self.modules.setdefault(entry["module"], (idl.install_target, set()))
        t[1].add(entry["root"])

        if idl.add_to_manifest:
            self.interface_manifests.setdefault(manifest, set()).add(xpt)
            self.chrome_manifests.add(chrome_manifest)
开发者ID:rnd-user,项目名称:gecko-dev,代码行数:29,代码来源:common.py


示例5: iteritems

 def iteritems(self):
     existing_files = self._load_config_track()
     for f in existing_files:
         # The track file contains filenames, and the basename is the
         # variable name.
         var = mozpath.basename(f)
         yield var, self[var]
开发者ID:luke-chang,项目名称:gecko-1,代码行数:7,代码来源:configenvironment.py


示例6: __init__

    def __init__(self, context, source, module, add_to_manifest):
        ContextDerived.__init__(self, context)

        self.source_path = source
        self.basename = mozpath.basename(source)
        self.module = module
        self.add_to_manifest = add_to_manifest
开发者ID:cstipkovic,项目名称:gecko-dev,代码行数:7,代码来源:data.py


示例7: _get_manager_args

    def _get_manager_args(self):
        tmp = tempfile.mkdtemp()
        self.addCleanup(shutil.rmtree, tmp)

        cache_dir = mozpath.join(tmp, 'cache')
        os.mkdir(cache_dir)

        ip = self._static_input_paths

        inputs = (
            ip,
            {mozpath.splitext(mozpath.basename(p))[0] for p in ip},
            set(),
            set(),
        )

        return dict(
            config_path=self._config_path,
            inputs=inputs,
            exported_header_dir=mozpath.join(tmp, 'exports'),
            codegen_dir=mozpath.join(tmp, 'codegen'),
            state_path=mozpath.join(tmp, 'state.json'),
            make_deps_path=mozpath.join(tmp, 'codegen.pp'),
            make_deps_target='codegen.pp',
            cache_dir=cache_dir,
        )
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:26,代码来源:test_mozwebidlcodegen.py


示例8: _binding_info

    def _binding_info(self, p):
        """Compute binding metadata for an input path.

        Returns a tuple of:

          (stem, binding_stem, is_event, output_files)

        output_files is itself a tuple. The first two items are the binding
        header and C++ paths, respectively. The 2nd pair are the event header
        and C++ paths or None if this isn't an event binding.
        """
        basename = mozpath.basename(p)
        stem = mozpath.splitext(basename)[0]
        binding_stem = '%sBinding' % stem

        if stem in self._exported_stems:
            header_dir = self._exported_header_dir
        else:
            header_dir = self._codegen_dir

        is_event = stem in self._generated_events_stems

        files = (
            mozpath.join(header_dir, '%s.h' % binding_stem),
            mozpath.join(self._codegen_dir, '%s.cpp' % binding_stem),
            mozpath.join(header_dir, '%s.h' % stem) if is_event else None,
            mozpath.join(self._codegen_dir, '%s.cpp' % stem) if is_event else None,
        )

        return stem, binding_stem, is_event, header_dir, files
开发者ID:artines1,项目名称:gecko-dev,代码行数:30,代码来源:__init__.py


示例9: consume_object

    def consume_object(self, obj):
        if isinstance(obj, TestManifest):
            for test in obj.tests:
                self._test_manager.add(test, flavor=obj.flavor,
                    topsrcdir=obj.topsrcdir)

        elif isinstance(obj, XPIDLFile):
            self._idl_manager.register_idl(obj.source_path, obj.module)

        elif isinstance(obj, ConfigFileSubstitution):
            # Do not handle ConfigFileSubstitution for Makefiles. Leave that
            # to other
            if mozpath.basename(obj.output_path) == 'Makefile':
                return
            with self._get_preprocessor(obj) as pp:
                pp.do_include(obj.input_path)
            self.backend_input_files.add(obj.input_path)

        elif isinstance(obj, HeaderFileSubstitution):
            self._create_config_header(obj)
            self.backend_input_files.add(obj.input_path)

        else:
            return

        obj.ack()
开发者ID:chuck-lee,项目名称:mozilla-central,代码行数:26,代码来源:common.py


示例10: repackage_installer

def repackage_installer(topsrcdir, tag, setupexe, package, output):
    if package and not zipfile.is_zipfile(package):
        raise Exception("Package file %s is not a valid .zip file." % package)

    # We need the full path for the tag and output, since we chdir later.
    tag = mozpath.realpath(tag)
    output = mozpath.realpath(output)
    ensureParentDir(output)

    tmpdir = tempfile.mkdtemp()
    old_cwd = os.getcwd()
    try:
        if package:
            z = zipfile.ZipFile(package)
            z.extractall(tmpdir)
            z.close()

        # Copy setup.exe into the root of the install dir, alongside the
        # package.
        shutil.copyfile(setupexe, mozpath.join(tmpdir, mozpath.basename(setupexe)))

        # archive_exe requires us to be in the directory where the package is
        # unpacked (the tmpdir)
        os.chdir(tmpdir)

        sfx_package = mozpath.join(topsrcdir, 'other-licenses/7zstub/firefox/7zSD.sfx')

        package_name = 'firefox' if package else None
        archive_exe(package_name, tag, sfx_package, output)

    finally:
        os.chdir(old_cwd)
        shutil.rmtree(tmpdir)
开发者ID:luke-chang,项目名称:gecko-1,代码行数:33,代码来源:installer.py


示例11: consume_object

    def consume_object(self, obj):
        self._configs.add(obj.config)

        if isinstance(obj, TestManifest):
            for test in obj.tests:
                self._test_manager.add(test, flavor=obj.flavor,
                    topsrcdir=obj.topsrcdir)

        elif isinstance(obj, XPIDLFile):
            self._idl_manager.register_idl(obj)

        elif isinstance(obj, ConfigFileSubstitution):
            # Do not handle ConfigFileSubstitution for Makefiles. Leave that
            # to other
            if mozpath.basename(obj.output_path) == 'Makefile':
                return False
            with self._get_preprocessor(obj) as pp:
                pp.do_include(obj.input_path)
            self.backend_input_files.add(obj.input_path)

        # We should consider aggregating WebIDL types in emitter.py.
        elif isinstance(obj, WebIDLFile):
            self._webidls.sources.add(mozpath.join(obj.srcdir, obj.basename))

        elif isinstance(obj, GeneratedEventWebIDLFile):
            self._webidls.generated_events_sources.add(mozpath.join(
                obj.srcdir, obj.basename))

        elif isinstance(obj, TestWebIDLFile):
            self._webidls.test_sources.add(mozpath.join(obj.srcdir,
                obj.basename))

        elif isinstance(obj, PreprocessedTestWebIDLFile):
            self._webidls.preprocessed_test_sources.add(mozpath.join(
                obj.srcdir, obj.basename))

        elif isinstance(obj, GeneratedWebIDLFile):
            self._webidls.generated_sources.add(mozpath.join(obj.srcdir,
                obj.basename))

        elif isinstance(obj, PreprocessedWebIDLFile):
            self._webidls.preprocessed_sources.add(mozpath.join(
                obj.srcdir, obj.basename))

        elif isinstance(obj, ExampleWebIDLInterface):
            self._webidls.example_interfaces.add(obj.name)

        elif isinstance(obj, IPDLFile):
            self._ipdl_sources.add(mozpath.join(obj.srcdir, obj.basename))

        elif isinstance(obj, UnifiedSources):
            if obj.have_unified_mapping:
                self._write_unified_files(obj.unified_source_mapping, obj.objdir)
            if hasattr(self, '_process_unified_sources'):
                self._process_unified_sources(obj)
        else:
            return False

        return True
开发者ID:psvramaraju,项目名称:gecko-dev,代码行数:59,代码来源:common.py


示例12: consume_object

    def consume_object(self, obj):
        self._configs.add(obj.config)

        if isinstance(obj, TestManifest):
            for test in obj.tests:
                self._test_manager.add(test, flavor=obj.flavor,
                    topsrcdir=obj.topsrcdir)

        elif isinstance(obj, XPIDLFile):
            self._idl_manager.register_idl(obj.source_path, obj.module,
                obj.install_target)

        elif isinstance(obj, ConfigFileSubstitution):
            # Do not handle ConfigFileSubstitution for Makefiles. Leave that
            # to other
            if mozpath.basename(obj.output_path) == 'Makefile':
                return
            with self._get_preprocessor(obj) as pp:
                pp.do_include(obj.input_path)
            self.backend_input_files.add(obj.input_path)

        elif isinstance(obj, HeaderFileSubstitution):
            self._create_config_header(obj)
            self.backend_input_files.add(obj.input_path)

        # We should consider aggregating WebIDL types in emitter.py.
        elif isinstance(obj, WebIDLFile):
            self._webidls.sources.add(mozpath.join(obj.srcdir, obj.basename))

        elif isinstance(obj, GeneratedEventWebIDLFile):
            self._webidls.generated_events_sources.add(mozpath.join(
                obj.srcdir, obj.basename))

        elif isinstance(obj, TestWebIDLFile):
            self._webidls.test_sources.add(mozpath.join(obj.srcdir,
                obj.basename))

        elif isinstance(obj, PreprocessedTestWebIDLFile):
            self._webidls.preprocessed_test_sources.add(mozpath.join(
                obj.srcdir, obj.basename))

        elif isinstance(obj, GeneratedWebIDLFile):
            self._webidls.generated_sources.add(mozpath.join(obj.srcdir,
                obj.basename))

        elif isinstance(obj, PreprocessedWebIDLFile):
            self._webidls.preprocessed_sources.add(mozpath.join(
                obj.srcdir, obj.basename))

        elif isinstance(obj, ExampleWebIDLInterface):
            self._webidls.example_interfaces.add(obj.name)

        elif isinstance(obj, IPDLFile):
            self._ipdl_sources.add(mozpath.join(obj.srcdir, obj.basename))

        else:
            return

        obj.ack()
开发者ID:ashishrana7,项目名称:firefox,代码行数:59,代码来源:common.py


示例13: __init__

    def __init__(self, context, source, module):
        ContextDerived.__init__(self, context)

        self.source_path = source
        self.basename = mozpath.basename(source)
        self.module = module

        self.install_target = context['FINAL_TARGET']
开发者ID:LordJZ,项目名称:gecko-dev,代码行数:8,代码来源:data.py


示例14: _process_test_harness_files

    def _process_test_harness_files(self, obj):
        for path, files in obj.srcdir_files.iteritems():
            for source in files:
                dest = '%s/%s' % (path, mozpath.basename(source))
                self._install_manifests['tests'].add_symlink(source, dest)

        for path, patterns in obj.srcdir_pattern_files.iteritems():
            for p in patterns:
                if p[:1] == '/':
                  self._install_manifests['tests'].add_pattern_symlink(obj.topsrcdir, p, path)
                else:
                  self._install_manifests['tests'].add_pattern_symlink(obj.srcdir, p, path)

        for path, files in obj.objdir_files.iteritems():
            for source in files:
                dest = '%s/%s' % (path, mozpath.basename(source))
                print(source, mozpath.join(reltarget, dest))
                test_manifest.add_symlink(source, mozpath.join(reltarget, dest))
开发者ID:html-shell,项目名称:mozbuild,代码行数:18,代码来源:internal.py


示例15: consume_object

    def consume_object(self, obj):
        if not isinstance(obj, Defines) and isinstance(obj, ContextDerived):
            defines = self._defines.get(obj.objdir, {})
            if defines:
                defines = defines.defines

        if isinstance(obj, Defines):
            self._defines[obj.objdir] = obj

            # We're assuming below that Defines come first for a given objdir,
            # which is kind of set in stone from the order things are treated
            # in emitter.py.
            assert obj.objdir not in self._seen_directories

        elif isinstance(obj, JARManifest) and \
                obj.install_target.startswith('dist/bin'):
            self._consume_jar_manifest(obj, defines)

        elif isinstance(obj, (FinalTargetFiles,
                              FinalTargetPreprocessedFiles)) and \
                obj.install_target.startswith('dist/bin'):
            for path, files in obj.files.walk():
                for f in files:
                    if isinstance(obj, FinalTargetPreprocessedFiles):
                        self._add_preprocess(obj, f.full_path, path,
                                             defines=defines)
                    else:
                        self._install_manifests[obj.install_target].add_symlink(
                            f.full_path,
                            mozpath.join(path, mozpath.basename(f))
                        )

        elif isinstance(obj, ChromeManifestEntry) and \
                obj.install_target.startswith('dist/bin'):
            top_level = mozpath.join(obj.install_target, 'chrome.manifest')
            if obj.path != top_level:
                entry = 'manifest %s' % mozpath.relpath(obj.path,
                                                        obj.install_target)
                if entry not in self._manifest_entries[top_level]:
                    self._manifest_entries[top_level].append(entry)
            self._manifest_entries[obj.path].append(str(obj.entry))

        elif isinstance(obj, XPIDLFile):
            self._has_xpidl = True
            # XPIDL are emitted before Defines, which breaks the assert in the
            # branch for Defines. OTOH, we don't actually care about the
            # XPIDLFile objects just yet, so we can just pretend we didn't see
            # an object in the directory yet.
            return True

        else:
            # We currently ignore a lot of object types, so just acknowledge
            # everything.
            return True

        self._seen_directories.add(obj.objdir)
        return True
开发者ID:renhongxu123,项目名称:gecko-dev,代码行数:57,代码来源:fastermake.py


示例16: files_from

        def files_from(ipdl):
            base = mozpath.basename(ipdl)
            root, ext = mozpath.splitext(base)

            # Both .ipdl and .ipdlh become .cpp files
            files = ["%s.cpp" % root]
            if ext == ".ipdl":
                # .ipdl also becomes Child/Parent.cpp files
                files.extend(["%sChild.cpp" % root, "%sParent.cpp" % root])
            return files
开发者ID:rnd-user,项目名称:gecko-dev,代码行数:10,代码来源:common.py


示例17: 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))
     self.copier[path].add(entry)
开发者ID:MekliCZ,项目名称:positron,代码行数:20,代码来源:formats.py


示例18: symlink_rule

    def symlink_rule(self, source, output=None, output_group=None):
        outputs = [output] if output else [mozpath.basename(source)]
        if output_group:
            outputs.append(output_group)

        # The !tup_ln macro does a symlink or file copy (depending on the
        # platform) without shelling out to a subprocess.
        self.rule(
            cmd=['!tup_ln'],
            inputs=[source],
            outputs=outputs,
        )
开发者ID:luke-chang,项目名称:gecko-1,代码行数:12,代码来源:tup.py


示例19: _add_preprocess

 def _add_preprocess(self, obj, path, dest, **kwargs):
     target = mozpath.basename(path)
     # This matches what PP_TARGETS do in config/rules.
     if target.endswith('.in'):
         target = target[:-3]
     depfile = mozpath.join(
         self.environment.topobjdir, 'faster', '.deps',
         mozpath.join(obj.install_target, dest, target).replace('/', '_'))
     self._install_manifests[obj.install_target].add_preprocess(
         mozpath.join(obj.srcdir, path),
         mozpath.join(dest, target),
         depfile,
         **kwargs)
开发者ID:nikhilgupta23,项目名称:gecko-dev,代码行数:13,代码来源:fastermake.py


示例20: test_test_harness_files

    def test_test_harness_files(self):
        reader = self.reader("test-harness-files")
        objs = self.read_topsrcdir(reader)

        self.assertEqual(len(objs), 1)
        self.assertIsInstance(objs[0], TestHarnessFiles)

        expected = {"mochitest": ["runtests.py", "utils.py"], "testing/mochitest": ["mochitest.py", "mochitest.ini"]}

        for path, strings in objs[0].srcdir_files.iteritems():
            self.assertTrue(path in expected)
            basenames = sorted(mozpath.basename(s) for s in strings)
            self.assertEqual(sorted(expected[path]), basenames)
开发者ID:logicoftekk,项目名称:cyberfox,代码行数:13,代码来源:test_emitter.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python path.dirname函数代码示例发布时间:2022-05-27
下一篇:
Python path.basedir函数代码示例发布时间: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