Bug 1147283 - Replace mozpack.path with mozpath. r=mshal
Back when mozpack.path was added, it was used as: import mozpack.path mozpack.path.func() Nowadays, the common idiom is: import mozpack.path as mozpath mozpath.func() because it's shorter. $ git grep mozpath\\. | wc -l 423 $ git grep mozpack.path\\. | wc -l 123 This change was done with: $ git grep -l mozpack.path\\. | xargs sed -i 's/mozpack\.path\./mozpath./g' $ git grep -l 'import mozpack.path$' | xargs sed -i 's/import mozpack.path$/\0 as mozpath/' $ (pat='import mozpack.path as mozpath'; git grep -l "$pat" | xargs sed -i "1,/$pat/b;/$pat/d")
This commit is contained in:
@@ -48,13 +48,13 @@ class CompareLocales(MachCommandBase):
|
||||
try:
|
||||
self.substs # explicitly check
|
||||
if not l10n_ini:
|
||||
l10n_ini = mozpack.path.join(
|
||||
l10n_ini = mozpath.join(
|
||||
self.topsrcdir,
|
||||
self.substs['MOZ_BUILD_APP'],
|
||||
'locales', 'l10n.ini'
|
||||
)
|
||||
if not l10n_base:
|
||||
l10n_base = mozpack.path.join(
|
||||
l10n_base = mozpath.join(
|
||||
self.topsrcdir,
|
||||
self.substs['L10NBASEDIR']
|
||||
)
|
||||
@@ -67,7 +67,7 @@ class CompareLocales(MachCommandBase):
|
||||
try:
|
||||
# self.substs is raising an Exception if we're not configured
|
||||
# don't merge if we're not
|
||||
merge_dir = mozpack.path.join(
|
||||
merge_dir = mozpath.join(
|
||||
self.topobjdir,
|
||||
self.substs['MOZ_BUILD_APP'],
|
||||
'locales', 'merge-{ab_CD}'
|
||||
|
||||
@@ -7,7 +7,7 @@ from __future__ import print_function, unicode_literals
|
||||
import argparse
|
||||
import glob
|
||||
import logging
|
||||
import mozpack.path
|
||||
import mozpack.path as mozpath
|
||||
import os
|
||||
import sys
|
||||
|
||||
@@ -71,7 +71,7 @@ class MachCommands(MachCommandBase):
|
||||
last_search_dir = search_dirs[-1]
|
||||
for t in tests:
|
||||
for d in search_dirs:
|
||||
test = mozpack.path.join(d, t)
|
||||
test = mozpath.join(d, t)
|
||||
if test.endswith('.py') and os.path.isfile(test):
|
||||
files.append(test)
|
||||
break
|
||||
@@ -79,8 +79,8 @@ class MachCommands(MachCommandBase):
|
||||
files.append(test + '.py')
|
||||
break
|
||||
elif os.path.isdir(test):
|
||||
files += glob.glob(mozpack.path.join(test, 'test*.py'))
|
||||
files += glob.glob(mozpack.path.join(test, 'unit*.py'))
|
||||
files += glob.glob(mozpath.join(test, 'test*.py'))
|
||||
files += glob.glob(mozpath.join(test, 'unit*.py'))
|
||||
break
|
||||
elif d == last_search_dir:
|
||||
self.log(logging.WARN, 'python-test',
|
||||
|
||||
@@ -26,7 +26,6 @@ from ..frontend.data import (
|
||||
ReaderSummary,
|
||||
)
|
||||
from .configenvironment import ConfigEnvironment
|
||||
import mozpack.path as mozpath
|
||||
|
||||
|
||||
class BackendConsumeSummary(object):
|
||||
|
||||
@@ -7,7 +7,6 @@ from __future__ import print_function, unicode_literals
|
||||
import argparse
|
||||
import glob
|
||||
import logging
|
||||
import mozpack.path
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
@@ -6,7 +6,7 @@ from __future__ import print_function, unicode_literals
|
||||
|
||||
import json
|
||||
import logging
|
||||
import mozpack.path
|
||||
import mozpack.path as mozpath
|
||||
import multiprocessing
|
||||
import os
|
||||
import subprocess
|
||||
@@ -706,12 +706,12 @@ class PathArgument(object):
|
||||
# path relative to that base directory.
|
||||
for base_dir in [self.topobjdir, self.topsrcdir]:
|
||||
if abspath.startswith(os.path.abspath(base_dir)):
|
||||
return mozpack.path.relpath(abspath, base_dir)
|
||||
return mozpath.relpath(abspath, base_dir)
|
||||
|
||||
return mozpack.path.normsep(self.arg)
|
||||
return mozpath.normsep(self.arg)
|
||||
|
||||
def srcdir_path(self):
|
||||
return mozpack.path.join(self.topsrcdir, self.relpath())
|
||||
return mozpath.join(self.topsrcdir, self.relpath())
|
||||
|
||||
def objdir_path(self):
|
||||
return mozpack.path.join(self.topobjdir, self.relpath())
|
||||
return mozpath.join(self.topobjdir, self.relpath())
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import re
|
||||
import os
|
||||
from urlparse import urlparse
|
||||
import mozpack.path
|
||||
import mozpack.path as mozpath
|
||||
from mozpack.chrome.flags import Flags
|
||||
from mozpack.errors import errors
|
||||
|
||||
@@ -101,12 +101,12 @@ class ManifestEntryWithRelPath(ManifestEntry):
|
||||
entry relative to a new base directory.
|
||||
'''
|
||||
clone = ManifestEntry.rebase(self, base)
|
||||
clone.relpath = mozpack.path.rebase(self.base, base, self.relpath)
|
||||
clone.relpath = mozpath.rebase(self.base, base, self.relpath)
|
||||
return clone
|
||||
|
||||
@property
|
||||
def path(self):
|
||||
return mozpack.path.normpath(mozpack.path.join(self.base,
|
||||
return mozpath.normpath(mozpath.join(self.base,
|
||||
self.relpath))
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ class ManifestChrome(ManifestEntryWithRelPath):
|
||||
|
||||
@property
|
||||
def location(self):
|
||||
return mozpack.path.join(self.base, self.relpath)
|
||||
return mozpath.join(self.base, self.relpath)
|
||||
|
||||
|
||||
class ManifestContent(ManifestChrome):
|
||||
@@ -251,7 +251,7 @@ class ManifestResource(ManifestEntry):
|
||||
if u.scheme and u.scheme != 'jar':
|
||||
return ManifestEntry.rebase(self, base)
|
||||
clone = ManifestEntry.rebase(self, base)
|
||||
clone.target = mozpack.path.rebase(self.base, base, self.target)
|
||||
clone.target = mozpath.rebase(self.base, base, self.target)
|
||||
return clone
|
||||
|
||||
|
||||
@@ -344,7 +344,7 @@ def parse_manifest(root, path, fileobj=None):
|
||||
'''
|
||||
Parse a manifest file.
|
||||
'''
|
||||
base = mozpack.path.dirname(path)
|
||||
base = mozpath.dirname(path)
|
||||
if root:
|
||||
path = os.path.normpath(os.path.abspath(os.path.join(root, path)))
|
||||
if not fileobj:
|
||||
|
||||
@@ -10,7 +10,7 @@ from mozpack.files import (
|
||||
BaseFile,
|
||||
Dest,
|
||||
)
|
||||
import mozpack.path
|
||||
import mozpack.path as mozpath
|
||||
import errno
|
||||
from collections import (
|
||||
Counter,
|
||||
@@ -41,7 +41,7 @@ class FileRegistry(object):
|
||||
partial_paths = []
|
||||
partial_path = path
|
||||
while partial_path:
|
||||
partial_path = mozpack.path.dirname(partial_path)
|
||||
partial_path = mozpath.dirname(partial_path)
|
||||
if partial_path:
|
||||
partial_paths.append(partial_path)
|
||||
return partial_paths
|
||||
@@ -73,13 +73,13 @@ class FileRegistry(object):
|
||||
'''
|
||||
if '*' in pattern:
|
||||
return [p for p in self.paths()
|
||||
if mozpack.path.match(p, pattern)]
|
||||
if mozpath.match(p, pattern)]
|
||||
if pattern == '':
|
||||
return self.paths()
|
||||
if pattern in self._files:
|
||||
return [pattern]
|
||||
return [p for p in self.paths()
|
||||
if mozpack.path.basedir(p, [pattern]) == pattern]
|
||||
if mozpath.basedir(p, [pattern]) == pattern]
|
||||
|
||||
def remove(self, pattern):
|
||||
'''
|
||||
|
||||
@@ -26,7 +26,7 @@ from mozpack.errors import (
|
||||
errors,
|
||||
)
|
||||
from mozpack.mozjar import JarReader
|
||||
import mozpack.path
|
||||
import mozpack.path as mozpath
|
||||
from collections import OrderedDict
|
||||
from jsmin import JavascriptMinify
|
||||
from tempfile import (
|
||||
@@ -412,7 +412,7 @@ class PreprocessedFile(BaseFile):
|
||||
# If a dependency file was specified, and it exists, add any
|
||||
# dependencies from that file to our list.
|
||||
if self.depfile and os.path.exists(self.depfile):
|
||||
target = mozpack.path.normpath(dest.name)
|
||||
target = mozpath.normpath(dest.name)
|
||||
with open(self.depfile, 'rb') as fileobj:
|
||||
for rule in makeutil.read_dep_makefile(fileobj):
|
||||
if target in rule.targets():
|
||||
@@ -755,7 +755,7 @@ class FileFinder(BaseFinder):
|
||||
|
||||
``ignore`` accepts an iterable of patterns to ignore. Entries are
|
||||
strings that match paths relative to ``base`` using
|
||||
``mozpack.path.match()``. This means if an entry corresponds
|
||||
``mozpath.match()``. This means if an entry corresponds
|
||||
to a directory, all files under that directory will be ignored. If
|
||||
an entry corresponds to a file, that particular file will be ignored.
|
||||
'''
|
||||
@@ -771,7 +771,7 @@ class FileFinder(BaseFinder):
|
||||
scanning directories, but are not ignored when explicitely requested.
|
||||
'''
|
||||
if '*' in pattern:
|
||||
return self._find_glob('', mozpack.path.split(pattern))
|
||||
return self._find_glob('', mozpath.split(pattern))
|
||||
elif os.path.isdir(os.path.join(self.base, pattern)):
|
||||
return self._find_dir(pattern)
|
||||
else:
|
||||
@@ -785,7 +785,7 @@ class FileFinder(BaseFinder):
|
||||
path itself has leafs starting with a '.', they are not ignored.
|
||||
'''
|
||||
for p in self.ignore:
|
||||
if mozpack.path.match(path, p):
|
||||
if mozpath.match(path, p):
|
||||
return
|
||||
|
||||
# The sorted makes the output idempotent. Otherwise, we are
|
||||
@@ -794,7 +794,7 @@ class FileFinder(BaseFinder):
|
||||
for p in sorted(os.listdir(os.path.join(self.base, path))):
|
||||
if p.startswith('.'):
|
||||
continue
|
||||
for p_, f in self._find(mozpack.path.join(path, p)):
|
||||
for p_, f in self._find(mozpath.join(path, p)):
|
||||
yield p_, f
|
||||
|
||||
def _find_file(self, path):
|
||||
@@ -807,7 +807,7 @@ class FileFinder(BaseFinder):
|
||||
return
|
||||
|
||||
for p in self.ignore:
|
||||
if mozpack.path.match(path, p):
|
||||
if mozpath.match(path, p):
|
||||
return
|
||||
|
||||
if self.find_executables and is_executable(srcpath):
|
||||
@@ -821,7 +821,7 @@ class FileFinder(BaseFinder):
|
||||
contains globbing patterns ('*' or '**'). This is meant to be an
|
||||
equivalent of:
|
||||
for p, f in self:
|
||||
if mozpack.path.match(p, pattern):
|
||||
if mozpath.match(p, pattern):
|
||||
yield p, f
|
||||
but avoids scanning the entire tree.
|
||||
'''
|
||||
@@ -830,26 +830,26 @@ class FileFinder(BaseFinder):
|
||||
yield p, f
|
||||
elif pattern[0] == '**':
|
||||
for p, f in self._find(base):
|
||||
if mozpack.path.match(p, mozpack.path.join(*pattern)):
|
||||
if mozpath.match(p, mozpath.join(*pattern)):
|
||||
yield p, f
|
||||
elif '*' in pattern[0]:
|
||||
if not os.path.exists(os.path.join(self.base, base)):
|
||||
return
|
||||
|
||||
for p in self.ignore:
|
||||
if mozpack.path.match(base, p):
|
||||
if mozpath.match(base, p):
|
||||
return
|
||||
|
||||
# See above comment w.r.t. sorted() and idempotent behavior.
|
||||
for p in sorted(os.listdir(os.path.join(self.base, base))):
|
||||
if p.startswith('.') and not pattern[0].startswith('.'):
|
||||
continue
|
||||
if mozpack.path.match(p, pattern[0]):
|
||||
for p_, f in self._find_glob(mozpack.path.join(base, p),
|
||||
if mozpath.match(p, pattern[0]):
|
||||
for p_, f in self._find_glob(mozpath.join(base, p),
|
||||
pattern[1:]):
|
||||
yield p_, f
|
||||
else:
|
||||
for p, f in self._find_glob(mozpack.path.join(base, pattern[0]),
|
||||
for p, f in self._find_glob(mozpath.join(base, pattern[0]),
|
||||
pattern[1:]):
|
||||
yield p, f
|
||||
|
||||
@@ -874,7 +874,7 @@ class JarFinder(BaseFinder):
|
||||
'''
|
||||
if '*' in pattern:
|
||||
for p in self._files:
|
||||
if mozpack.path.match(p, pattern):
|
||||
if mozpath.match(p, pattern):
|
||||
yield p, DeflatedFile(self._files[p])
|
||||
elif pattern == '':
|
||||
for p in self._files:
|
||||
@@ -883,5 +883,5 @@ class JarFinder(BaseFinder):
|
||||
yield pattern, DeflatedFile(self._files[pattern])
|
||||
else:
|
||||
for p in self._files:
|
||||
if mozpack.path.basedir(p, [pattern]) == pattern:
|
||||
if mozpath.basedir(p, [pattern]) == pattern:
|
||||
yield p, DeflatedFile(self._files[p])
|
||||
|
||||
@@ -12,7 +12,7 @@ from zipfile import (
|
||||
)
|
||||
from collections import OrderedDict
|
||||
from urlparse import urlparse, ParseResult
|
||||
import mozpack.path
|
||||
import mozpack.path as mozpath
|
||||
|
||||
JAR_STORED = ZIP_STORED
|
||||
JAR_DEFLATED = ZIP_DEFLATED
|
||||
@@ -580,7 +580,7 @@ class JarWriter(object):
|
||||
JarFileReader instance. The latter two allow to avoid uncompressing
|
||||
data to recompress it.
|
||||
'''
|
||||
name = mozpack.path.normsep(name)
|
||||
name = mozpath.normsep(name)
|
||||
|
||||
if name in self._contents:
|
||||
raise JarWriterError("File %s already in JarWriter" % name)
|
||||
@@ -803,4 +803,4 @@ class JarLog(dict):
|
||||
if os.path.isabs(path[1:]):
|
||||
path = path[1:]
|
||||
path = os.path.realpath(path)
|
||||
return mozpack.path.normsep(os.path.normcase(path))
|
||||
return mozpath.normsep(os.path.normcase(path))
|
||||
|
||||
@@ -13,7 +13,7 @@ from mozpack.chrome.manifest import (
|
||||
is_manifest,
|
||||
parse_manifest,
|
||||
)
|
||||
import mozpack.path
|
||||
import mozpack.path as mozpath
|
||||
from collections import deque
|
||||
|
||||
|
||||
@@ -253,8 +253,8 @@ class SimplePackager(object):
|
||||
self._queue.append(self.formatter.add_interfaces, path, file)
|
||||
else:
|
||||
self._file_queue.append(self.formatter.add, path, file)
|
||||
if mozpack.path.basename(path) == 'install.rdf':
|
||||
self._addons.add(mozpack.path.dirname(path))
|
||||
if mozpath.basename(path) == 'install.rdf':
|
||||
self._addons.add(mozpath.dirname(path))
|
||||
|
||||
def _add_manifest_file(self, path, file):
|
||||
'''
|
||||
@@ -264,7 +264,7 @@ class SimplePackager(object):
|
||||
base = ''
|
||||
if hasattr(file, 'path'):
|
||||
# Find the directory the given path is relative to.
|
||||
b = mozpack.path.normsep(file.path)
|
||||
b = mozpath.normsep(file.path)
|
||||
if b.endswith('/' + path) or b == path:
|
||||
base = os.path.normpath(b[:-len(path)])
|
||||
for e in parse_manifest(base, path, file.open()):
|
||||
@@ -288,7 +288,7 @@ class SimplePackager(object):
|
||||
manifests are manifests that are included in no other manifest.
|
||||
`addons` indicates whether to include addon bases as well.
|
||||
'''
|
||||
all_bases = set(mozpack.path.dirname(m)
|
||||
all_bases = set(mozpath.dirname(m)
|
||||
for m in self._manifests - self._included_manifests)
|
||||
if not addons:
|
||||
all_bases -= self._addons
|
||||
@@ -300,7 +300,7 @@ class SimplePackager(object):
|
||||
'''
|
||||
self._closed = True
|
||||
broken_addons = sorted(m for m in self._included_manifests
|
||||
if mozpack.path.dirname(m) in self._addons)
|
||||
if mozpath.dirname(m) in self._addons)
|
||||
if broken_addons:
|
||||
errors.fatal(
|
||||
'Addon base manifest (%s) is included in some other manifest' %
|
||||
@@ -339,8 +339,8 @@ class SimpleManifestSink(object):
|
||||
'''
|
||||
Remove any bin/ prefix.
|
||||
'''
|
||||
if mozpack.path.basedir(path, ['bin']) == 'bin':
|
||||
return mozpack.path.relpath(path, 'bin')
|
||||
if mozpath.basedir(path, ['bin']) == 'bin':
|
||||
return mozpath.relpath(path, 'bin')
|
||||
return path
|
||||
|
||||
def add(self, component, pattern):
|
||||
@@ -353,7 +353,7 @@ class SimpleManifestSink(object):
|
||||
added = True
|
||||
if is_manifest(p):
|
||||
self._manifests.add(p)
|
||||
dest = mozpack.path.join(component.destdir, SimpleManifestSink.normalize_path(p))
|
||||
dest = mozpath.join(component.destdir, SimpleManifestSink.normalize_path(p))
|
||||
self.packager.add(dest, f)
|
||||
if not added:
|
||||
errors.error('Missing file(s): %s' % pattern)
|
||||
@@ -372,9 +372,9 @@ class SimpleManifestSink(object):
|
||||
if auto_root_manifest:
|
||||
# Simple package manifests don't contain the root manifests, so
|
||||
# find and add them.
|
||||
paths = [mozpack.path.dirname(m) for m in self._manifests]
|
||||
path = mozpack.path.dirname(mozpack.path.commonprefix(paths))
|
||||
for p, f in self._finder.find(mozpack.path.join(path,
|
||||
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)
|
||||
|
||||
@@ -10,7 +10,7 @@ from mozpack.chrome.manifest import (
|
||||
ManifestResource,
|
||||
)
|
||||
from urlparse import urlparse
|
||||
import mozpack.path
|
||||
import mozpack.path as mozpath
|
||||
from mozpack.files import (
|
||||
ManifestFile,
|
||||
XPTFile,
|
||||
@@ -87,7 +87,7 @@ class FlatFormatter(object):
|
||||
Return the deepest base directory containing the given path.
|
||||
'''
|
||||
self._frozen_bases = True
|
||||
return mozpack.path.basedir(path, self._bases)
|
||||
return mozpath.basedir(path, self._bases)
|
||||
|
||||
def add(self, path, content):
|
||||
self.copier.add(path, content)
|
||||
@@ -100,18 +100,18 @@ class FlatFormatter(object):
|
||||
if entry.base == base:
|
||||
name = 'chrome'
|
||||
else:
|
||||
name = mozpack.path.basename(entry.base)
|
||||
path = mozpack.path.normpath(mozpack.path.join(entry.base,
|
||||
name = mozpath.basename(entry.base)
|
||||
path = mozpath.normpath(mozpath.join(entry.base,
|
||||
'%s.manifest' % name))
|
||||
if not self.copier.contains(path):
|
||||
assert mozpack.path.basedir(entry.base, [base]) == base
|
||||
assert mozpath.basedir(entry.base, [base]) == base
|
||||
# Add a reference to the manifest file in the parent manifest, if
|
||||
# the manifest file is not a root manifest.
|
||||
if len(entry.base) > len(base):
|
||||
parent = mozpack.path.dirname(entry.base)
|
||||
relbase = mozpack.path.basename(entry.base)
|
||||
relpath = mozpack.path.join(relbase,
|
||||
mozpack.path.basename(path))
|
||||
parent = mozpath.dirname(entry.base)
|
||||
relbase = mozpath.basename(entry.base)
|
||||
relpath = mozpath.join(relbase,
|
||||
mozpath.basename(path))
|
||||
FlatFormatter.add_manifest(self, Manifest(parent, relpath))
|
||||
self.copier.add(path, ManifestFile(entry.base))
|
||||
self.copier[path].add(entry)
|
||||
@@ -119,11 +119,11 @@ class FlatFormatter(object):
|
||||
def add_interfaces(self, path, content):
|
||||
# Interfaces in the same directory are all linked together in an
|
||||
# interfaces.xpt file.
|
||||
interfaces_path = mozpack.path.join(mozpack.path.dirname(path),
|
||||
interfaces_path = mozpath.join(mozpath.dirname(path),
|
||||
'interfaces.xpt')
|
||||
if not self.copier.contains(interfaces_path):
|
||||
FlatFormatter.add_manifest(self, ManifestInterfaces(
|
||||
mozpack.path.dirname(path), 'interfaces.xpt'))
|
||||
mozpath.dirname(path), 'interfaces.xpt'))
|
||||
self.copier.add(interfaces_path, XPTFile())
|
||||
self.copier[interfaces_path].add(content)
|
||||
|
||||
@@ -152,7 +152,7 @@ class JarFormatter(FlatFormatter):
|
||||
detect under which .jar (if any) the path should go.
|
||||
'''
|
||||
self._frozen_chrome = True
|
||||
return mozpack.path.basedir(path, self._chrome)
|
||||
return mozpath.basedir(path, self._chrome)
|
||||
|
||||
def add(self, path, content):
|
||||
chrome = self._chromepath(path)
|
||||
@@ -160,9 +160,9 @@ class JarFormatter(FlatFormatter):
|
||||
jar = chrome + '.jar'
|
||||
if not self.copier.contains(jar):
|
||||
self.copier.add(jar, Jarrer(self._compress, self._optimize))
|
||||
if not self.copier[jar].contains(mozpack.path.relpath(path,
|
||||
if not self.copier[jar].contains(mozpath.relpath(path,
|
||||
chrome)):
|
||||
self.copier[jar].add(mozpack.path.relpath(path, chrome),
|
||||
self.copier[jar].add(mozpath.relpath(path, chrome),
|
||||
content)
|
||||
else:
|
||||
FlatFormatter.add(self, path, content)
|
||||
@@ -173,10 +173,10 @@ class JarFormatter(FlatFormatter):
|
||||
Return the corresponding chrome path and the new entry.
|
||||
'''
|
||||
base = entry.base
|
||||
basepath = mozpack.path.split(relpath)[0]
|
||||
chromepath = mozpack.path.join(base, basepath)
|
||||
basepath = mozpath.split(relpath)[0]
|
||||
chromepath = mozpath.join(base, basepath)
|
||||
entry = entry.rebase(chromepath) \
|
||||
.move(mozpack.path.join(base, 'jar:%s.jar!' % basepath)) \
|
||||
.move(mozpath.join(base, 'jar:%s.jar!' % basepath)) \
|
||||
.rebase(base)
|
||||
return chromepath, entry
|
||||
|
||||
@@ -201,7 +201,7 @@ class JarFormatter(FlatFormatter):
|
||||
if not self.copier.contains(chrome + '.jar'):
|
||||
return False
|
||||
return self.copier[chrome + '.jar']. \
|
||||
contains(mozpack.path.relpath(path, chrome))
|
||||
contains(mozpath.relpath(path, chrome))
|
||||
|
||||
|
||||
class OmniJarFormatter(JarFormatter):
|
||||
@@ -231,9 +231,9 @@ class OmniJarFormatter(JarFormatter):
|
||||
if not base in self.omnijars:
|
||||
omnijar = Jarrer(self._compress, self._optimize)
|
||||
self.omnijars[base] = FlatFormatter(omnijar)
|
||||
self.copier.add(mozpack.path.join(base, self._omnijar_name),
|
||||
self.copier.add(mozpath.join(base, self._omnijar_name),
|
||||
omnijar)
|
||||
return self.omnijars[base], base, mozpack.path.relpath(path, base)
|
||||
return self.omnijars[base], base, mozpath.relpath(path, base)
|
||||
|
||||
def add(self, path, content):
|
||||
formatter, base, path = self._get_formatter(path)
|
||||
@@ -245,7 +245,7 @@ class OmniJarFormatter(JarFormatter):
|
||||
else:
|
||||
formatter, base, path = self._get_formatter(entry.base,
|
||||
is_resource=True)
|
||||
entry = entry.move(mozpack.path.relpath(entry.base, base))
|
||||
entry = entry.move(mozpath.relpath(entry.base, base))
|
||||
formatter.add_manifest(entry)
|
||||
|
||||
def add_interfaces(self, path, content):
|
||||
@@ -257,7 +257,7 @@ class OmniJarFormatter(JarFormatter):
|
||||
if self.copier.contains(path):
|
||||
return True
|
||||
for base, copier in self.omnijars.iteritems():
|
||||
if copier.contains(mozpack.path.relpath(path, base)):
|
||||
if copier.contains(mozpath.relpath(path, base)):
|
||||
return True
|
||||
return False
|
||||
|
||||
@@ -268,11 +268,11 @@ class OmniJarFormatter(JarFormatter):
|
||||
'''
|
||||
if base is None:
|
||||
base = self._get_base(path)
|
||||
path = mozpack.path.relpath(path, base)
|
||||
if any(mozpack.path.match(path, p.replace('*', '**'))
|
||||
path = mozpath.relpath(path, base)
|
||||
if any(mozpath.match(path, p.replace('*', '**'))
|
||||
for p in self._non_resources):
|
||||
return False
|
||||
path = mozpack.path.split(path)
|
||||
path = mozpath.split(path)
|
||||
if path[0] == 'chrome':
|
||||
return len(path) == 1 or path[1] != 'icons'
|
||||
if path[0] == 'components':
|
||||
|
||||
@@ -8,7 +8,7 @@ directory.
|
||||
'''
|
||||
|
||||
import os
|
||||
import mozpack.path
|
||||
import mozpack.path as mozpath
|
||||
from mozpack.packager.formats import (
|
||||
FlatFormatter,
|
||||
JarFormatter,
|
||||
@@ -45,10 +45,10 @@ class LocaleManifestFinder(object):
|
||||
self.locales = list(set(e.id for e in self.entries
|
||||
if isinstance(e, ManifestLocale)))
|
||||
# Find all paths whose manifest are included by no other manifest.
|
||||
includes = set(mozpack.path.join(e.base, e.relpath)
|
||||
includes = set(mozpath.join(e.base, e.relpath)
|
||||
for m in manifests.itervalues()
|
||||
for e in m if isinstance(e, Manifest))
|
||||
self.bases = [mozpack.path.dirname(p)
|
||||
self.bases = [mozpath.dirname(p)
|
||||
for p in set(manifests.keys()) - includes]
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ def _repack(app_finder, l10n_finder, copier, formatter, non_chrome=set()):
|
||||
l10n_paths = {}
|
||||
for e in l10n.entries:
|
||||
if isinstance(e, ManifestChrome):
|
||||
base = mozpack.path.basedir(e.path, app.bases)
|
||||
base = mozpath.basedir(e.path, app.bases)
|
||||
l10n_paths.setdefault(base, {})
|
||||
l10n_paths[base][e.name] = e.path
|
||||
|
||||
@@ -81,7 +81,7 @@ def _repack(app_finder, l10n_finder, copier, formatter, non_chrome=set()):
|
||||
paths = {}
|
||||
for e in app.entries:
|
||||
if isinstance(e, ManifestEntryWithRelPath):
|
||||
base = mozpack.path.basedir(e.path, app.bases)
|
||||
base = mozpath.basedir(e.path, app.bases)
|
||||
if base not in l10n_paths:
|
||||
errors.fatal("Locale doesn't contain %s/" % base)
|
||||
# Allow errors to accumulate
|
||||
@@ -95,7 +95,7 @@ def _repack(app_finder, l10n_finder, copier, formatter, non_chrome=set()):
|
||||
|
||||
for pattern in non_chrome:
|
||||
for base in app.bases:
|
||||
path = mozpack.path.join(base, pattern)
|
||||
path = mozpath.join(base, pattern)
|
||||
left = set(p for p, f in app_finder.find(path))
|
||||
right = set(p for p, f in l10n_finder.find(path))
|
||||
for p in right:
|
||||
@@ -119,10 +119,10 @@ def _repack(app_finder, l10n_finder, copier, formatter, non_chrome=set()):
|
||||
if not path:
|
||||
continue
|
||||
else:
|
||||
base = mozpack.path.basedir(p, paths.keys())
|
||||
base = mozpath.basedir(p, paths.keys())
|
||||
if base:
|
||||
subpath = mozpack.path.relpath(p, base)
|
||||
path = mozpack.path.normpath(mozpack.path.join(paths[base],
|
||||
subpath = mozpath.relpath(p, base)
|
||||
path = mozpath.normpath(mozpath.join(paths[base],
|
||||
subpath))
|
||||
if path:
|
||||
files = [f for p, f in l10n_finder.find(path)]
|
||||
@@ -139,23 +139,23 @@ def _repack(app_finder, l10n_finder, copier, formatter, non_chrome=set()):
|
||||
l10n_manifests = []
|
||||
for base in set(e.base for e in l10n.entries):
|
||||
m = ManifestFile(base, [e for e in l10n.entries if e.base == base])
|
||||
path = mozpack.path.join(base, 'chrome.%s.manifest' % l10n_locale)
|
||||
path = mozpath.join(base, 'chrome.%s.manifest' % l10n_locale)
|
||||
l10n_manifests.append((path, m))
|
||||
bases = packager.get_bases()
|
||||
for path, m in l10n_manifests:
|
||||
base = mozpack.path.basedir(path, bases)
|
||||
base = mozpath.basedir(path, bases)
|
||||
packager.add(path, m)
|
||||
# Add a "manifest $path" entry in the top manifest under that base.
|
||||
m = ManifestFile(base)
|
||||
m.add(Manifest(base, mozpack.path.relpath(path, base)))
|
||||
packager.add(mozpack.path.join(base, 'chrome.manifest'), m)
|
||||
m.add(Manifest(base, mozpath.relpath(path, base)))
|
||||
packager.add(mozpath.join(base, 'chrome.manifest'), m)
|
||||
|
||||
packager.close()
|
||||
|
||||
# Add any remaining non chrome files.
|
||||
for pattern in non_chrome:
|
||||
for base in bases:
|
||||
for p, f in l10n_finder.find(mozpack.path.join(base, pattern)):
|
||||
for p, f in l10n_finder.find(mozpath.join(base, pattern)):
|
||||
if not formatter.contains(p):
|
||||
formatter.add(p, f)
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
import mozpack.path
|
||||
import mozpack.path as mozpath
|
||||
from mozpack.files import (
|
||||
FileFinder,
|
||||
DeflatedFile,
|
||||
@@ -50,18 +50,18 @@ class UnpackFinder(FileFinder):
|
||||
# Skip the precomplete file, which is generated at packaging time.
|
||||
if p == 'precomplete':
|
||||
continue
|
||||
base = mozpack.path.dirname(p)
|
||||
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 \
|
||||
(mozpack.path.basename(p) == self.omnijar or
|
||||
(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 = mozpack.path.basename(p)
|
||||
self.omnijar = mozpath.basename(p)
|
||||
self._fill_with_omnijar(base, jar)
|
||||
continue
|
||||
# If the file is a manifest, scan its entries for some referencing
|
||||
@@ -80,10 +80,10 @@ class UnpackFinder(FileFinder):
|
||||
|
||||
def _fill_with_omnijar(self, base, jar):
|
||||
for j in jar:
|
||||
path = mozpack.path.join(base, j.filename)
|
||||
path = mozpath.join(base, j.filename)
|
||||
if is_manifest(j.filename):
|
||||
m = self.files[path] if self.files.contains(path) \
|
||||
else ManifestFile(mozpack.path.dirname(path))
|
||||
else ManifestFile(mozpath.dirname(path))
|
||||
for e in parse_manifest(None, path, j):
|
||||
m.add(e)
|
||||
if not self.files.contains(path):
|
||||
@@ -112,9 +112,9 @@ class UnpackFinder(FileFinder):
|
||||
assert len(jar) == 1
|
||||
jar = jar[0]
|
||||
if not jarpath in jars:
|
||||
base = mozpack.path.splitext(jarpath)[0]
|
||||
base = mozpath.splitext(jarpath)[0]
|
||||
for j in self._open_jar(jarpath, jar):
|
||||
self.files.add(mozpack.path.join(base,
|
||||
self.files.add(mozpath.join(base,
|
||||
j.filename),
|
||||
DeflatedFile(j))
|
||||
jars.add(jarpath)
|
||||
@@ -154,10 +154,10 @@ class UnpackFinder(FileFinder):
|
||||
'''
|
||||
base = entry.base
|
||||
jar, relpath = urlparse(relpath).path.split('!', 1)
|
||||
entry = entry.rebase(mozpack.path.join(base, 'jar:%s!' % jar)) \
|
||||
.move(mozpack.path.join(base, mozpack.path.splitext(jar)[0])) \
|
||||
entry = entry.rebase(mozpath.join(base, 'jar:%s!' % jar)) \
|
||||
.move(mozpath.join(base, mozpath.splitext(jar)[0])) \
|
||||
.rebase(base)
|
||||
return mozpack.path.join(base, jar), entry
|
||||
return mozpath.join(base, jar), entry
|
||||
|
||||
|
||||
def unpack_to_registry(source, registry):
|
||||
@@ -169,7 +169,7 @@ def unpack_to_registry(source, registry):
|
||||
finder = UnpackFinder(source)
|
||||
packager = SimplePackager(FlatFormatter(registry))
|
||||
for p, f in finder.find('*'):
|
||||
if mozpack.path.split(p)[0] not in STARTUP_CACHE_PATHS:
|
||||
if mozpath.split(p)[0] not in STARTUP_CACHE_PATHS:
|
||||
packager.add(p, f)
|
||||
packager.close()
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ from mozpack.files import (
|
||||
ExistingFile,
|
||||
)
|
||||
from mozpack.mozjar import JarReader
|
||||
import mozpack.path
|
||||
import mozpack.path as mozpath
|
||||
import unittest
|
||||
import mozunit
|
||||
import os
|
||||
@@ -152,7 +152,7 @@ class TestFileCopier(TestWithTmpDir):
|
||||
all_dirs = set()
|
||||
for root, dirs, files in os.walk(base):
|
||||
if not dirs:
|
||||
all_dirs.add(mozpack.path.relpath(root, base))
|
||||
all_dirs.add(mozpath.relpath(root, base))
|
||||
return all_dirs
|
||||
|
||||
def all_files(self, base):
|
||||
@@ -160,7 +160,7 @@ class TestFileCopier(TestWithTmpDir):
|
||||
for root, dirs, files in os.walk(base):
|
||||
for f in files:
|
||||
all_files.add(
|
||||
mozpack.path.join(mozpack.path.relpath(root, base), f))
|
||||
mozpath.join(mozpath.relpath(root, base), f))
|
||||
return all_files
|
||||
|
||||
def test_file_copier(self):
|
||||
|
||||
@@ -37,7 +37,7 @@ import os
|
||||
import random
|
||||
import string
|
||||
import sys
|
||||
import mozpack.path
|
||||
import mozpack.path as mozpath
|
||||
from tempfile import mkdtemp
|
||||
from io import BytesIO
|
||||
from xpt import Typelib
|
||||
@@ -870,7 +870,7 @@ class MatchTestTemplate(object):
|
||||
finder.find(pattern)])
|
||||
self.assertEqual(sorted([f for f, c in finder.find(pattern)]),
|
||||
sorted([f for f, c in finder
|
||||
if mozpack.path.match(f, pattern)]))
|
||||
if mozpath.match(f, pattern)]))
|
||||
|
||||
|
||||
def do_check(test, finder, pattern, result):
|
||||
|
||||
@@ -17,7 +17,7 @@ import unittest
|
||||
import mozunit
|
||||
from cStringIO import StringIO
|
||||
from urllib import pathname2url
|
||||
import mozpack.path
|
||||
import mozpack.path as mozpath
|
||||
import os
|
||||
|
||||
|
||||
@@ -288,7 +288,7 @@ class TestJarLog(unittest.TestCase):
|
||||
]))
|
||||
log = JarLog(fileobj=s)
|
||||
canonicalize = lambda p: \
|
||||
mozpack.path.normsep(os.path.normcase(os.path.realpath(p)))
|
||||
mozpath.normsep(os.path.normcase(os.path.realpath(p)))
|
||||
baz_jar = canonicalize('bar/baz.jar')
|
||||
qux_zip = canonicalize('qux.zip')
|
||||
self.assertEqual(set(log.keys()), set([
|
||||
|
||||
@@ -23,7 +23,7 @@ from mozpack.errors import (
|
||||
errors,
|
||||
ErrorMessage,
|
||||
)
|
||||
import mozpack.path
|
||||
import mozpack.path as mozpath
|
||||
|
||||
MANIFEST = '''
|
||||
bar/*
|
||||
@@ -99,7 +99,7 @@ class MockFinder(object):
|
||||
def find(self, path):
|
||||
self.log.append(path)
|
||||
for f in sorted(self.files):
|
||||
if mozpack.path.match(f, path):
|
||||
if mozpath.match(f, path):
|
||||
yield f, self.files[f]
|
||||
|
||||
def __iter__(self):
|
||||
|
||||
@@ -15,7 +15,7 @@ from mozpack.executables import (
|
||||
from mozpack.mozjar import JarReader
|
||||
from mozpack.errors import errors
|
||||
from tempfile import mkstemp
|
||||
import mozpack.path
|
||||
import mozpack.path as mozpath
|
||||
import struct
|
||||
import os
|
||||
import subprocess
|
||||
@@ -83,7 +83,7 @@ class UnifiedFinder(BaseFinder):
|
||||
one of the two trees and not the other. It will also error out if
|
||||
matches can be found on both ends but their contents are not identical.
|
||||
|
||||
The sorted argument gives a list of mozpack.path.match patterns. File
|
||||
The sorted argument gives a list of mozpath.match patterns. File
|
||||
paths matching one of these patterns will have their contents compared
|
||||
with their lines sorted.
|
||||
'''
|
||||
@@ -146,7 +146,7 @@ class UnifiedFinder(BaseFinder):
|
||||
if content1 == content2:
|
||||
return file1
|
||||
for pattern in self._sorted:
|
||||
if mozpack.path.match(path, pattern):
|
||||
if mozpath.match(path, pattern):
|
||||
if sorted(content1) == sorted(content2):
|
||||
return file1
|
||||
break
|
||||
@@ -167,7 +167,7 @@ class UnifiedBuildFinder(UnifiedFinder):
|
||||
'''
|
||||
Unify buildconfig.html contents, or defer to UnifiedFinder.unify_file.
|
||||
'''
|
||||
if mozpack.path.basename(path) == 'buildconfig.html':
|
||||
if mozpath.basename(path) == 'buildconfig.html':
|
||||
content1 = file1.open().readlines()
|
||||
content2 = file2.open().readlines()
|
||||
# Copy everything from the first file up to the end of its <body>,
|
||||
|
||||
Reference in New Issue
Block a user