Bug 1431379 - Move ChromeManifestHandler class in a separate file. r=chmanchester

This commit is contained in:
Marco Castelluccio 2018-01-25 15:52:34 +01:00
Родитель 978b39e16d
Коммит 94bc709ac5
3 изменённых файлов: 50 добавлений и 39 удалений

Просмотреть файл

@ -20,47 +20,10 @@ from mozbuild.frontend.data import JARManifest, ChromeManifestEntry
from mozpack.copier import FileRegistry
from mozpack.files import PreprocessedFile
from mozpack.manifests import InstallManifest
from mozpack.chrome.manifest import (
Manifest,
ManifestChrome,
ManifestOverride,
ManifestResource,
parse_manifest,
)
import mozpack.path as mozpath
from manifest_handler import ChromeManifestHandler
class ChromeManifestHandler(object):
def __init__(self):
self.overrides = {}
self.chrome_mapping = defaultdict(set)
def handle_manifest_entry(self, entry):
format_strings = {
"content": "chrome://%s/content/",
"resource": "resource://%s/",
"locale": "chrome://%s/locale/",
"skin": "chrome://%s/skin/",
}
if isinstance(entry, (ManifestChrome, ManifestResource)):
if isinstance(entry, ManifestResource):
dest = entry.target
url = urlparse.urlparse(dest)
if not url.scheme:
dest = mozpath.normpath(mozpath.join(entry.base, dest))
if url.scheme == 'file':
dest = mozpath.normpath(url.path)
else:
dest = mozpath.normpath(entry.path)
base_uri = format_strings[entry.type] % entry.name
self.chrome_mapping[base_uri].add(dest)
if isinstance(entry, ManifestOverride):
self.overrides[entry.overloaded] = entry.overload
if isinstance(entry, Manifest):
for e in parse_manifest(None, entry.path):
self.handle_manifest_entry(e)
_line_comment_re = re.compile('^//@line (\d+) "(.+)"$')
def generate_pp_info(path, topsrcdir):

Просмотреть файл

@ -9,7 +9,7 @@ import urlparse
from mozpack.chrome.manifest import parse_manifest
import mozpack.path as mozpath
from chrome_map import ChromeManifestHandler
from manifest_handler import ChromeManifestHandler
class LcovRecord(object):
__slots__ = ("test_name",

Просмотреть файл

@ -0,0 +1,48 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# 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/.
from collections import defaultdict
import urlparse
from mozpack.chrome.manifest import (
Manifest,
ManifestChrome,
ManifestOverride,
ManifestResource,
parse_manifest,
)
import mozpack.path as mozpath
class ChromeManifestHandler(object):
def __init__(self):
self.overrides = {}
self.chrome_mapping = defaultdict(set)
def handle_manifest_entry(self, entry):
format_strings = {
"content": "chrome://%s/content/",
"resource": "resource://%s/",
"locale": "chrome://%s/locale/",
"skin": "chrome://%s/skin/",
}
if isinstance(entry, (ManifestChrome, ManifestResource)):
if isinstance(entry, ManifestResource):
dest = entry.target
url = urlparse.urlparse(dest)
if not url.scheme:
dest = mozpath.normpath(mozpath.join(entry.base, dest))
if url.scheme == 'file':
dest = mozpath.normpath(url.path)
else:
dest = mozpath.normpath(entry.path)
base_uri = format_strings[entry.type] % entry.name
self.chrome_mapping[base_uri].add(dest)
if isinstance(entry, ManifestOverride):
self.overrides[entry.overloaded] = entry.overload
if isinstance(entry, Manifest):
for e in parse_manifest(None, entry.path):
self.handle_manifest_entry(e)