本文整理汇总了Python中mozpack.path.dirname函数的典型用法代码示例。如果您正苦于以下问题:Python dirname函数的具体用法?Python dirname怎么用?Python dirname使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dirname函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: 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
示例2: _global_dependencies_changed
def _global_dependencies_changed(self):
"""Determine whether the global dependencies have changed."""
current_files = set(iter_modules_in_path(mozpath.dirname(__file__)))
# We need to catch other .py files from /dom/bindings. We assume these
# are in the same directory as the config file.
current_files |= set(iter_modules_in_path(mozpath.dirname(self._config_path)))
current_files.add(self._config_path)
current_hashes = {}
for f in current_files:
# This will fail if the file doesn't exist. If a current global
# dependency doesn't exist, something else is wrong.
with open(f, 'rb') as fh:
current_hashes[f] = hashlib.sha1(fh.read()).hexdigest()
# The set of files has changed.
if current_files ^ set(self._state['global_depends'].keys()):
return True, current_hashes
# Compare hashes.
for f, sha1 in current_hashes.items():
if sha1 != self._state['global_depends'][f]:
return True, current_hashes
return False, current_hashes
开发者ID:artines1,项目名称:gecko-dev,代码行数:27,代码来源:__init__.py
示例3: install_test_files
def install_test_files(topsrcdir, topobjdir, tests_root, test_objs):
"""Installs the requested test files to the objdir. This is invoked by
test runners to avoid installing tens of thousands of test files when
only a few tests need to be run.
"""
flavor_info = {flavor: (root, prefix, install)
for (flavor, root, prefix, install) in TEST_MANIFESTS.values()}
objdir_dest = mozpath.join(topobjdir, tests_root)
converter = SupportFilesConverter()
install_info = TestInstallInfo()
for o in test_objs:
flavor = o['flavor']
if flavor not in flavor_info:
# This is a test flavor that isn't installed by the build system.
continue
root, prefix, install = flavor_info[flavor]
if not install:
# This flavor isn't installed to the objdir.
continue
manifest_path = o['manifest']
manifest_dir = mozpath.dirname(manifest_path)
out_dir = mozpath.join(root, prefix, manifest_dir[len(topsrcdir) + 1:])
file_relpath = o['file_relpath']
source = mozpath.join(topsrcdir, file_relpath)
dest = mozpath.join(root, prefix, file_relpath)
if 'install-to-subdir' in o:
out_dir = mozpath.join(out_dir, o['install-to-subdir'])
manifest_relpath = mozpath.relpath(source, mozpath.dirname(manifest_path))
dest = mozpath.join(out_dir, manifest_relpath)
install_info.installs.append((source, dest))
install_info |= converter.convert_support_files(o, root,
manifest_dir,
out_dir)
manifest = InstallManifest()
for source, dest in set(install_info.installs):
if dest in install_info.external_installs:
continue
manifest.add_symlink(source, dest)
for base, pattern, dest in install_info.pattern_installs:
manifest.add_pattern_symlink(base, pattern, dest)
_resolve_installs(install_info.deferred_installs, topobjdir, manifest)
# Harness files are treated as a monolith and installed each time we run tests.
# Fortunately there are not very many.
manifest |= InstallManifest(mozpath.join(topobjdir,
'_build_manifests',
'install', tests_root))
copier = FileCopier()
manifest.populate_registry(copier)
copier.copy(objdir_dest,
remove_unaccounted=False)
开发者ID:mozilla,项目名称:positron-spidernode,代码行数:58,代码来源:testing.py
示例4: __init__
def __init__(self, context, manifest_path, entry):
ContextDerived.__init__(self, context)
assert isinstance(entry, ManifestEntry)
self.path = mozpath.join(self.install_target, manifest_path)
# Ensure the entry is relative to the directory containing the
# manifest path.
entry = entry.rebase(mozpath.dirname(manifest_path))
# Then add the install_target to the entry base directory.
self.entry = entry.move(mozpath.dirname(self.path))
开发者ID:cstipkovic,项目名称:gecko-dev,代码行数:9,代码来源:data.py
示例5: add_interfaces
def add_interfaces(self, path, content):
# Interfaces in the same directory are all linked together in an
# interfaces.xpt file.
interfaces_path = mozpath.join(mozpath.dirname(path),
'interfaces.xpt')
if not self.copier.contains(interfaces_path):
FlatFormatter.add_manifest(self, ManifestInterfaces(
mozpath.dirname(path), 'interfaces.xpt'))
self.copier.add(interfaces_path, XPTFile())
self.copier[interfaces_path].add(content)
开发者ID:AtulKumar2,项目名称:gecko-dev,代码行数:10,代码来源:formats.py
示例6: close
def close(self, auto_root_manifest=True):
'''
Add possibly missing bits and push all instructions to the formatter.
'''
if auto_root_manifest:
# Simple package manifests don't contain the root manifests, so
# find and add them.
paths = [mozpath.dirname(m) for m in self._manifests]
path = mozpath.dirname(mozpath.commonprefix(paths))
for p, f in self._finder.find(mozpath.join(path,
'chrome.manifest')):
if not p in self._manifests:
self.packager.add(SimpleManifestSink.normalize_path(p), f)
self.packager.close()
开发者ID:MekliCZ,项目名称:positron,代码行数:14,代码来源:__init__.py
示例7: 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
示例8: 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
示例9: _write_file
def _write_file(self, path=None, fh=None):
"""Context manager to write a file.
This is a glorified wrapper around FileAvoidWrite with integration to
update the BackendConsumeSummary on this instance.
Example usage:
with self._write_file('foo.txt') as fh:
fh.write('hello world')
"""
if path is not None:
assert fh is None
fh = FileAvoidWrite(path)
else:
assert fh is not None
dirname = mozpath.dirname(fh.name)
try:
os.makedirs(dirname)
except OSError as error:
if error.errno != errno.EEXIST:
raise
yield fh
self._backend_output_files.add(mozpath.relpath(fh.name, self.environment.topobjdir))
existed, updated = fh.close()
if not existed:
self.summary.created_count += 1
elif updated:
self.summary.updated_count += 1
else:
self.summary.unchanged_count += 1
开发者ID:chuck-lee,项目名称:mozilla-central,代码行数:35,代码来源:base.py
示例10: _get_preprocessor
def _get_preprocessor(self, obj):
'''Returns a preprocessor with a few predefined values depending on
the given BaseConfigSubstitution(-like) object, and all the substs
in the current environment.'''
pp = Preprocessor()
srcdir = mozpath.dirname(obj.input_path)
pp.context.update(obj.config.substs)
pp.context.update(
top_srcdir=obj.topsrcdir,
srcdir=srcdir,
relativesrcdir=mozpath.relpath(srcdir, obj.topsrcdir) or '.',
DEPTH=mozpath.relpath(obj.topobjdir, mozpath.dirname(obj.output_path)) or '.',
)
pp.do_filter('attemptSubstitution')
pp.setMarker(None)
with self._write_file(obj.output_path) as fh:
pp.out = fh
yield pp
开发者ID:ppbao,项目名称:mozilla-os2,代码行数:18,代码来源:base.py
示例11: _get_preprocessor
def _get_preprocessor(self, obj):
"""Returns a preprocessor with a few predefined values depending on
the given BaseConfigSubstitution(-like) object, and all the substs
in the current environment."""
pp = Preprocessor()
srcdir = mozpath.dirname(obj.input_path)
pp.context.update({k: " ".join(v) if isinstance(v, list) else v for k, v in obj.config.substs.iteritems()})
pp.context.update(
top_srcdir=obj.topsrcdir,
topobjdir=obj.topobjdir,
srcdir=srcdir,
relativesrcdir=mozpath.relpath(srcdir, obj.topsrcdir) or ".",
DEPTH=mozpath.relpath(obj.topobjdir, mozpath.dirname(obj.output_path)) or ".",
)
pp.do_filter("attemptSubstitution")
pp.setMarker(None)
with self._write_file(obj.output_path) as fh:
pp.out = fh
yield pp
开发者ID:subsevenx2001,项目名称:gecko-dev,代码行数:19,代码来源:base.py
示例12: _partial_paths
def _partial_paths(self, path):
'''
Turn "foo/bar/baz/zot" into ["foo/bar/baz", "foo/bar", "foo"].
'''
partial_paths = []
partial_path = path
while partial_path:
partial_path = mozpath.dirname(partial_path)
if partial_path:
partial_paths.append(partial_path)
return partial_paths
开发者ID:AtulKumar2,项目名称:gecko-dev,代码行数:11,代码来源:copier.py
示例13: add
def add(self, t, flavor=None):
t = dict(t)
t['flavor'] = flavor
path = mozpath.normpath(t['path'])
assert path.startswith(self.topsrcdir)
key = path[len(self.topsrcdir)+1:]
t['file_relpath'] = key
t['dir_relpath'] = mozpath.dirname(key)
self.tests_by_path[key].append(t)
开发者ID:jonathanmarvens,项目名称:mozilla-central,代码行数:12,代码来源:common.py
示例14: add
def add(self, t, flavor, topsrcdir):
t = dict(t)
t['flavor'] = flavor
path = mozpath.normpath(t['path'])
assert mozpath.basedir(path, [topsrcdir])
key = path[len(topsrcdir)+1:]
t['file_relpath'] = key
t['dir_relpath'] = mozpath.dirname(key)
self.tests_by_path[key].append(t)
开发者ID:Wafflespeanut,项目名称:gecko-dev,代码行数:12,代码来源:test_manifest.py
示例15: _handle_ipdl_sources
def _handle_ipdl_sources(self, ipdl_dir, sorted_ipdl_sources, sorted_nonstatic_ipdl_sources,
sorted_static_ipdl_sources, unified_ipdl_cppsrcs_mapping):
# Preferably we wouldn't have to import ipdl, but we need to parse the
# ast in order to determine the namespaces since they are used in the
# header output paths.
sys.path.append(mozpath.join(self.environment.topsrcdir, 'ipc', 'ipdl'))
import ipdl
backend_file = self._get_backend_file('ipc/ipdl')
outheaderdir = '_ipdlheaders'
srcdir = mozpath.join(self.environment.topsrcdir, 'ipc/ipdl')
cmd = [
'$(PYTHON_PATH)',
'$(PLY_INCLUDE)',
'%s/ipdl.py' % srcdir,
'--sync-msg-list=%s/sync-messages.ini' % srcdir,
'--msg-metadata=%s/message-metadata.ini' % srcdir,
'--outheaders-dir=%s' % outheaderdir,
'--outcpp-dir=.',
]
ipdldirs = sorted(set(mozpath.dirname(p) for p in sorted_ipdl_sources))
cmd.extend(['-I%s' % d for d in ipdldirs])
cmd.extend(sorted_ipdl_sources)
outputs = ['IPCMessageTypeName.cpp', mozpath.join(outheaderdir, 'IPCMessageStart.h'), 'ipdl_lextab.py', 'ipdl_yacctab.py']
for filename in sorted_ipdl_sources:
filepath, ext = os.path.splitext(filename)
dirname, basename = os.path.split(filepath)
dirname = mozpath.relpath(dirname, self.environment.topsrcdir)
extensions = ['']
if ext == '.ipdl':
extensions.extend(['Child', 'Parent'])
with open(filename) as f:
ast = ipdl.parse(f.read(), filename, includedirs=ipdldirs)
self.backend_input_files.add(filename)
headerdir = os.path.join(outheaderdir, *([ns.name for ns in ast.namespaces]))
for extension in extensions:
outputs.append("%s%s.cpp" % (basename, extension))
outputs.append(mozpath.join(headerdir, '%s%s.h' % (basename, extension)))
backend_file.rule(
display='IPDL code generation',
cmd=cmd,
outputs=outputs,
extra_outputs=[self._installed_files],
check_unchanged=True,
)
backend_file.sources['.cpp'].extend(u[0] for u in unified_ipdl_cppsrcs_mapping)
开发者ID:luke-chang,项目名称:gecko-1,代码行数:52,代码来源:tup.py
示例16: add
def add(self, path, file):
'''
Add the given BaseFile instance with the given path.
'''
assert not self._closed
if is_manifest(path):
self._add_manifest_file(path, file)
elif path.endswith('.xpt'):
self._queue.append(self.formatter.add_interfaces, path, file)
else:
self._file_queue.append(self.formatter.add, path, file)
if mozpath.basename(path) == 'install.rdf':
self._addons.add(mozpath.dirname(path))
开发者ID:AtulKumar2,项目名称:gecko-dev,代码行数:13,代码来源:__init__.py
示例17: _fill_with_jar
def _fill_with_jar(self, base, jar):
for j in jar:
path = mozpath.join(base, j.filename)
if is_manifest(j.filename):
m = self.files[path] if self.files.contains(path) \
else ManifestFile(mozpath.dirname(path))
for e in parse_manifest(None, path, j):
m.add(e)
if not self.files.contains(path):
self.files.add(path, m)
continue
else:
self.files.add(path, DeflatedFile(j))
开发者ID:brendandahl,项目名称:positron,代码行数:13,代码来源:unpack.py
示例18: __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
示例19: exec_file
def exec_file(self, path):
'''Execute one file within the sandbox. Users of this class probably
want to use `run` instead.'''
if self._paths:
path = mozpath.join(mozpath.dirname(self._paths[-1]), 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._paths:
raise ConfigureError(
'Cannot include `%s` because it was included already.' % path)
self._paths.append(path)
source = open(path, 'rb').read()
code = compile(source, path, 'exec')
exec(code, self)
self._paths.pop(-1)
开发者ID:linclark,项目名称:gecko-dev,代码行数:24,代码来源:__init__.py
示例20: __init__
def __init__(self, sandbox, path, manifest, flavor=None,
install_prefix=None, relpath=None, dupe_manifest=False):
SandboxDerived.__init__(self, sandbox)
self.path = path
self.directory = mozpath.dirname(path)
self.manifest = manifest
self.flavor = flavor
self.install_prefix = install_prefix
self.manifest_relpath = relpath
self.dupe_manifest = dupe_manifest
self.installs = {}
self.pattern_installs = []
self.tests = []
self.external_installs = set()
开发者ID:sandhua,项目名称:gecko-dev,代码行数:15,代码来源:data.py
注:本文中的mozpack.path.dirname函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论