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


Python path.join函数代码示例

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


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

示例1: __init__

 def __init__(self, context, basename, cargo_file, crate_type, dependencies,
              features, target_dir, **args):
     StaticLibrary.__init__(self, context, basename, **args)
     self.cargo_file = cargo_file
     self.crate_type = crate_type
     # We need to adjust our naming here because cargo replaces '-' in
     # package names defined in Cargo.toml with underscores in actual
     # filenames. But we need to keep the basename consistent because
     # many other things in the build system depend on that.
     assert self.crate_type == 'staticlib'
     self.lib_name = '%s%s%s' % (context.config.rust_lib_prefix,
                                  basename.replace('-', '_'),
                                  context.config.rust_lib_suffix)
     self.dependencies = dependencies
     self.features = features
     self.target_dir = target_dir
     # Skip setting properties below which depend on cargo
     # when we don't have a compile environment. The required
     # config keys won't be available, but the instance variables
     # that we don't set should never be accessed by the actual
     # build in that case.
     if not context.config.substs.get('COMPILE_ENVIRONMENT'):
         return
     build_dir = mozpath.join(target_dir,
                              cargo_output_directory(context, self.TARGET_SUBST_VAR))
     self.import_name = mozpath.join(build_dir, self.lib_name)
     self.deps_path = mozpath.join(build_dir, 'deps')
开发者ID:Wafflespeanut,项目名称:gecko-dev,代码行数:27,代码来源:data.py

示例2: test_final_target

    def test_final_target(self):
        """Test that FINAL_TARGET is written to backend.mk correctly."""
        env = self._consume('final_target', RecursiveMakeBackend)

        final_target_rule = "FINAL_TARGET = $(if $(XPI_NAME),$(DIST)/xpi-stage/$(XPI_NAME),$(DIST)/bin)$(DIST_SUBDIR:%=/%)"
        expected = dict()
        expected[env.topobjdir] = []
        expected[mozpath.join(env.topobjdir, 'both')] = [
            'XPI_NAME = mycrazyxpi',
            'DIST_SUBDIR = asubdir',
            final_target_rule
        ]
        expected[mozpath.join(env.topobjdir, 'dist-subdir')] = [
            'DIST_SUBDIR = asubdir',
            final_target_rule
        ]
        expected[mozpath.join(env.topobjdir, 'xpi-name')] = [
            'XPI_NAME = mycrazyxpi',
            final_target_rule
        ]
        expected[mozpath.join(env.topobjdir, 'final-target')] = [
            'FINAL_TARGET = $(DEPTH)/random-final-target'
        ]
        for key, expected_rules in expected.iteritems():
            backend_path = mozpath.join(key, 'backend.mk')
            lines = [l.strip() for l in open(backend_path, 'rt').readlines()[2:]]
            found = [str for str in lines if
                str.startswith('FINAL_TARGET') or str.startswith('XPI_NAME') or
                str.startswith('DIST_SUBDIR')]
            self.assertEqual(found, expected_rules)
开发者ID:html-shell,项目名称:mozbuild,代码行数:30,代码来源:test_recursivemake.py

示例3: test_install_manifests_package_tests

    def test_install_manifests_package_tests(self):
        """Ensure test suites honor package_tests=False."""
        env = self._consume('test-manifests-package-tests', RecursiveMakeBackend)

        tests_dir = mozpath.join(env.topobjdir, '_tests')

        all_tests_path = mozpath.join(env.topobjdir, 'all-tests.json')
        self.assertTrue(os.path.exists(all_tests_path))

        with open(all_tests_path, 'rt') as fh:
            o = json.load(fh)

            self.assertIn('mochitest.js', o)
            self.assertIn('not_packaged.java', o)

        man_dir = mozpath.join(env.topobjdir, '_build_manifests', 'install')
        self.assertTrue(os.path.isdir(man_dir))

        full = mozpath.join(man_dir, 'tests')
        self.assertTrue(os.path.exists(full))

        m = InstallManifest(path=full)

        # Only mochitest.js should be in the install manifest.
        self.assertTrue('testing/mochitest/tests/mochitest.js' in m)

        # The path is odd here because we do not normalize at test manifest
        # processing time.  This is a fragile test because there's currently no
        # way to iterate the manifest.
        self.assertFalse('instrumentation/./not_packaged.java' in m)
开发者ID:html-shell,项目名称:mozbuild,代码行数:30,代码来源:test_recursivemake.py

示例4: test_basic

 def test_basic(self):
     """Ensure the RecursiveMakeBackend works without error."""
     env = self._consume('stub0', RecursiveMakeBackend)
     self.assertTrue(os.path.exists(mozpath.join(env.topobjdir,
         'backend.RecursiveMakeBackend')))
     self.assertTrue(os.path.exists(mozpath.join(env.topobjdir,
         'backend.RecursiveMakeBackend.pp')))
开发者ID:html-shell,项目名称:mozbuild,代码行数:7,代码来源:test_recursivemake.py

示例5: test_dirs_traversal_simple

    def test_dirs_traversal_simple(self):
        reader = self.reader("traversal-simple")
        objs = self.read_topsrcdir(reader, filter_common=False)
        self.assertEqual(len(objs), 4)

        for o in objs:
            self.assertIsInstance(o, DirectoryTraversal)
            self.assertEqual(o.test_dirs, [])
            self.assertTrue(os.path.isabs(o.context_main_path))
            self.assertEqual(len(o.context_all_paths), 1)

        reldirs = [o.relativedir for o in objs]
        self.assertEqual(reldirs, ["", "foo", "foo/biz", "bar"])

        self.assertEqual(objs[3].affected_tiers, {"misc"})

        dirs = [[d.full_path for d in o.dirs] for o in objs]
        self.assertEqual(
            dirs,
            [
                [mozpath.join(reader.config.topsrcdir, "foo"), mozpath.join(reader.config.topsrcdir, "bar")],
                [mozpath.join(reader.config.topsrcdir, "foo", "biz")],
                [],
                [],
            ],
        )
开发者ID:logicoftekk,项目名称:cyberfox,代码行数:26,代码来源:test_emitter.py

示例6: generateXpcomCppHeader

    def generateXpcomCppHeader(self, config, filename, cache_dir):
        prefixname = filename[:-4]
        targetFilePath  = mozpath.join(config.topobjdir, 'dist/include', prefixname  + ".h")
        if not self.targetNeedBuild(targetFilePath):
            return

        sourceFilePath = mozpath.join(config.topobjdir, 'dist/idl', filename)

        includePaths = [mozpath.join(config.topobjdir, 'dist/idl'),
            mozpath.join(self.libxul_sdk, 'idl')]
        import xpidl
        import header
        try:
            filename = mozpath.join('../../../dist/idl', filename)
            p = xpidl.IDLParser(outputdir=cache_dir)
            idl = p.parse(open(sourceFilePath).read(), filename=filename)
            idl.resolve(includePaths, p)
            outfd = open(targetFilePath, 'w')
            header.print_header(idl, outfd, filename)
            outfd.close()
            deps = set()
            self.updateIdlDeps(config, idl.deps, deps)
            self.addDependencies(targetFilePath, deps)
            self.addDependencies(targetFilePath, [targetFilePath])
            print('%s -> %s' % (sourceFilePath, targetFilePath))
        except Exception as e:
            print("Failed to generate IDL from %s to %s!" % (sourceFilePath, targetFilePath));
            print(e)
开发者ID:html-shell,项目名称:mozbuild,代码行数:28,代码来源:internal.py

示例7: generateXpcomXpt

    def generateXpcomXpt(self, config, targetPath, files, cache_dir):
        if not self.targetNeedBuild(targetPath):
            return
        xpts = []
        includePaths = [mozpath.join(config.topobjdir, 'dist/idl'),
            mozpath.join(self.libxul_sdk, 'idl')]

        import xpidl
        import xpt
        import typelib
        deps = set()
        p = xpidl.IDLParser(outputdir=cache_dir)
        for f in files:
            idl_data = open(f).read()
            filename =  mozpath.join('../../../dist/idl', os.path.basename(f))

            idl = p.parse(idl_data, filename = filename)
            idl.resolve(includePaths, p)
            xptIo = io.BytesIO()
            typelib.write_typelib(idl, xptIo, filename = filename)
            xptIo.seek(0)
            xpts.append(xptIo)

            self.updateIdlDeps(config, idl.deps, deps)

        print("Generating %s" % targetPath)
        xpt.xpt_link(xpts).write(targetPath)
        self.addDependencies(targetPath, deps)
        self.addDependencies(targetPath, [targetPath])
开发者ID:html-shell,项目名称:mozbuild,代码行数:29,代码来源:internal.py

示例8: test_binary_components

    def test_binary_components(self):
        """Ensure binary components are correctly handled."""
        env = self._consume('binary-components', RecursiveMakeBackend)

        with open(mozpath.join(env.topobjdir, 'foo', 'backend.mk')) as fh:
            lines = fh.readlines()[2:]

        self.assertEqual(lines, [
            'misc::\n',
            '\t$(call py_action,buildlist,$(DEPTH)/dist/bin/chrome.manifest '
            + "'manifest components/components.manifest')\n",
            '\t$(call py_action,buildlist,'
            + '$(DEPTH)/dist/bin/components/components.manifest '
            + "'binary-component foo')\n",
            'LIBRARY_NAME := foo\n',
            'FORCE_SHARED_LIB := 1\n',
            'IMPORT_LIBRARY := foo\n',
            'SHARED_LIBRARY := foo\n',
            'IS_COMPONENT := 1\n',
            'DSO_SONAME := foo\n',
        ])

        with open(mozpath.join(env.topobjdir, 'bar', 'backend.mk')) as fh:
            lines = fh.readlines()[2:]

        self.assertEqual(lines, [
            'LIBRARY_NAME := bar\n',
            'FORCE_SHARED_LIB := 1\n',
            'IMPORT_LIBRARY := bar\n',
            'SHARED_LIBRARY := bar\n',
            'IS_COMPONENT := 1\n',
            'DSO_SONAME := bar\n',
        ])
开发者ID:kilikkuo,项目名称:gecko-dev,代码行数:33,代码来源:test_recursivemake.py

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

示例10: test_objdir_path

    def test_objdir_path(self):
        config = self.config
        ctxt = Context(config=config)
        ctxt.push_source(mozpath.join(config.topsrcdir, 'foo', 'moz.build'))

        path = ObjDirPath(ctxt, '!qux')
        self.assertEqual(path, '!qux')
        self.assertEqual(path.full_path,
                         mozpath.join(config.topobjdir, 'foo', 'qux'))

        path = ObjDirPath(ctxt, '!../bar/qux')
        self.assertEqual(path, '!../bar/qux')
        self.assertEqual(path.full_path,
                         mozpath.join(config.topobjdir, 'bar', 'qux'))

        path = ObjDirPath(ctxt, '!/qux/qux')
        self.assertEqual(path, '!/qux/qux')
        self.assertEqual(path.full_path,
                         mozpath.join(config.topobjdir, 'qux', 'qux'))

        with self.assertRaises(ValueError):
            path = ObjDirPath(ctxt, '../bar/qux')

        with self.assertRaises(ValueError):
            path = ObjDirPath(ctxt, '/qux/qux')

        path = ObjDirPath(path)
        self.assertIsInstance(path, ObjDirPath)
        self.assertEqual(path, '!/qux/qux')
        self.assertEqual(path.full_path,
                         mozpath.join(config.topobjdir, 'qux', 'qux'))

        path = Path(path)
        self.assertIsInstance(path, ObjDirPath)
开发者ID:kleopatra999,项目名称:system-addons,代码行数:34,代码来源:test_context.py

示例11: get_conf

def get_conf(conf_file):
    conf = Configuration(conf_file)
    inc_dir = [
        mozpath.join(buildconfig.topsrcdir, 'accessible', 'interfaces'),
        mozpath.join(buildconfig.topsrcdir, 'xpcom', 'base'),
    ]
    return conf, inc_dir
开发者ID:Chabma,项目名称:gecko-dev,代码行数:7,代码来源:AccEventGen.py

示例12: process_tests_artifact

    def process_tests_artifact(self, filename, processed_filename):
        from mozbuild.action.test_archive import OBJDIR_TEST_FILES
        added_entry = False

        with JarWriter(file=processed_filename, optimize=False, compress_level=5) as writer:
            reader = JarReader(filename)
            for filename, entry in reader.entries.iteritems():
                for pattern, (src_prefix, dest_prefix) in self.test_artifact_patterns:
                    if not mozpath.match(filename, pattern):
                        continue
                    destpath = mozpath.relpath(filename, src_prefix)
                    destpath = mozpath.join(dest_prefix, destpath)
                    self.log(logging.INFO, 'artifact',
                             {'destpath': destpath},
                             'Adding {destpath} to processed archive')
                    mode = entry['external_attr'] >> 16
                    writer.add(destpath.encode('utf-8'), reader[filename], mode=mode)
                    added_entry = True
                    break
                for files_entry in OBJDIR_TEST_FILES.values():
                    origin_pattern = files_entry['pattern']
                    leaf_filename = filename
                    if 'dest' in files_entry:
                        dest = files_entry['dest']
                        origin_pattern = mozpath.join(dest, origin_pattern)
                        leaf_filename = filename[len(dest) + 1:]
                    if mozpath.match(filename, origin_pattern):
                        destpath = mozpath.join('..', files_entry['base'], leaf_filename)
                        mode = entry['external_attr'] >> 16
                        writer.add(destpath.encode('utf-8'), reader[filename], mode=mode)

        if not added_entry:
            raise ValueError('Archive format changed! No pattern from "{patterns}"'
                             'matched an archive path.'.format(
                                 patterns=LinuxArtifactJob.test_artifact_patterns))
开发者ID:mykmelez,项目名称:spidernode,代码行数:35,代码来源:artifacts.py

示例13: _handle_idl_manager

    def _handle_idl_manager(self, manager):
        build_files = self._install_manifests['xpidl']

        for p in ('Makefile', 'backend.mk', '.deps/.mkdir.done',
            'xpt/.mkdir.done'):
            build_files.add_optional_exists(p)

        for idl in manager.idls.values():
            self._install_manifests['dist_idl'].add_symlink(idl['source'],
                idl['basename'])
            self._install_manifests['dist_include'].add_optional_exists('%s.h'
                % idl['root'])

        for module in manager.modules:
            build_files.add_optional_exists(mozpath.join('xpt',
                '%s.xpt' % module))
            build_files.add_optional_exists(mozpath.join('.deps',
                '%s.pp' % module))

        modules = manager.modules
        xpt_modules = sorted(modules.keys())
        rules = []

        for module in xpt_modules:
            deps = sorted(modules[module])
            idl_deps = ['$(dist_idl_dir)/%s.idl' % dep for dep in deps]
            rules.extend([
                # It may seem strange to have the .idl files listed as
                # prerequisites both here and in the auto-generated .pp files.
                # It is necessary to list them here to handle the case where a
                # new .idl is added to an xpt. If we add a new .idl and nothing
                # else has changed, the new .idl won't be referenced anywhere
                # except in the command invocation. Therefore, the .xpt won't
                # be rebuilt because the dependencies say it is up to date. By
                # listing the .idls here, we ensure the make file has a
                # reference to the new .idl. Since the new .idl presumably has
                # an mtime newer than the .xpt, it will trigger xpt generation.
                '$(idl_xpt_dir)/%s.xpt: %s' % (module, ' '.join(idl_deps)),
                '\[email protected] "$(notdir [email protected])"',
                '\t$(idlprocess) $(basename $(notdir [email protected])) %s' % ' '.join(deps),
                '',
            ])

        # Create dependency for output header so we force regeneration if the
        # header was deleted. This ideally should not be necessary. However,
        # some processes (such as PGO at the time this was implemented) wipe
        # out dist/include without regard to our install manifests.

        out_path = os.path.join(self.environment.topobjdir, 'config',
            'makefiles', 'xpidl', 'Makefile')
        with self._write_file(out_path) as fh:
            self.environment.create_config_file(fh, extra=dict(
                xpidl_rules='\n'.join(rules),
                xpidl_modules=' '.join(xpt_modules),
            ))

        # The Makefile can't regenerate itself because of custom substitution.
        # We need to list it here to ensure changes cause regeneration.
        self.backend_input_files.add(os.path.join(self.environment.topsrcdir,
            'config', 'makefiles', 'xpidl', 'Makefile.in'))
开发者ID:lpy,项目名称:mozilla-central,代码行数:60,代码来源:recursivemake.py

示例14: get_config_files

def get_config_files(data):
    config_status = mozpath.join(data['objdir'], 'config.status')
    if not os.path.exists(config_status):
        return [], []

    configure = mozpath.join(data['srcdir'], 'configure')
    config_files = []
    command_files = []

    # Scan the config.status output for information about configuration files
    # it generates.
    config_status_output = subprocess.check_output(
        [data['shell'], '-c', '%s --help' % config_status],
        stderr=subprocess.STDOUT).splitlines()
    state = None
    for line in config_status_output:
        if line.startswith('Configuration') and line.endswith(':'):
            if line.endswith('commands:'):
                state = 'commands'
            else:
                state = 'config'
        elif not line.strip():
            state = None
        elif state:
            for f, t in (split_template(couple) for couple in line.split()):
                f = mozpath.join(data['objdir'], f)
                t = mozpath.join(data['srcdir'], t)
                if state == 'commands':
                    command_files.append(f)
                else:
                    config_files.append((f, t))

    return config_files, command_files
开发者ID:Shaif95,项目名称:gecko-dev,代码行数:33,代码来源:subconfigure.py

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


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