mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-21 01:05:45 +00:00
Bug 1604277 - mozpack/errors.py and mozpack/manifests.py support python3 r=mars
Differential Revision: https://phabricator.services.mozilla.com/D57362 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
3e58392872
commit
c8aa318a85
@ -113,7 +113,7 @@ class FileRegistry(object):
|
|||||||
'''
|
'''
|
||||||
Return all paths stored in the container, in the order they were added.
|
Return all paths stored in the container, in the order they were added.
|
||||||
'''
|
'''
|
||||||
return self._files.keys()
|
return list(self._files)
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
'''
|
'''
|
||||||
|
@ -6,6 +6,7 @@ from __future__ import absolute_import, print_function, unicode_literals
|
|||||||
|
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
import json
|
import json
|
||||||
|
import six
|
||||||
|
|
||||||
from .files import (
|
from .files import (
|
||||||
AbsoluteSymlinkFile,
|
AbsoluteSymlinkFile,
|
||||||
@ -116,7 +117,7 @@ class InstallManifest(object):
|
|||||||
self._source_files = set()
|
self._source_files = set()
|
||||||
|
|
||||||
if path or fileobj:
|
if path or fileobj:
|
||||||
with _auto_fileobj(path, fileobj, 'rb') as fh:
|
with _auto_fileobj(path, fileobj, 'r') as fh:
|
||||||
self._source_files.add(fh.name)
|
self._source_files.add(fh.name)
|
||||||
self._load_from_fileobj(fh)
|
self._load_from_fileobj(fh)
|
||||||
|
|
||||||
@ -175,7 +176,7 @@ class InstallManifest(object):
|
|||||||
dest, content = fields[1:]
|
dest, content = fields[1:]
|
||||||
|
|
||||||
self.add_content(
|
self.add_content(
|
||||||
self._decode_field_entry(content).encode('utf-8'), dest)
|
six.ensure_text(self._decode_field_entry(content)), dest)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Don't fail for non-actionable items, allowing
|
# Don't fail for non-actionable items, allowing
|
||||||
@ -228,7 +229,7 @@ class InstallManifest(object):
|
|||||||
|
|
||||||
It is an error if both are specified.
|
It is an error if both are specified.
|
||||||
"""
|
"""
|
||||||
with _auto_fileobj(path, fileobj, 'wb') as fh:
|
with _auto_fileobj(path, fileobj, 'wt') as fh:
|
||||||
fh.write('%d\n' % self.CURRENT_VERSION)
|
fh.write('%d\n' % self.CURRENT_VERSION)
|
||||||
|
|
||||||
for dest in sorted(self._dests):
|
for dest in sorted(self._dests):
|
||||||
@ -243,12 +244,12 @@ class InstallManifest(object):
|
|||||||
source = mozpath.join(base, path)
|
source = mozpath.join(base, path)
|
||||||
parts = ['%d' % type, mozpath.join(dest, path), source]
|
parts = ['%d' % type, mozpath.join(dest, path), source]
|
||||||
fh.write('%s\n' % self.FIELD_SEPARATOR.join(
|
fh.write('%s\n' % self.FIELD_SEPARATOR.join(
|
||||||
p.encode('utf-8') for p in parts))
|
six.ensure_text(p) for p in parts))
|
||||||
else:
|
else:
|
||||||
parts = ['%d' % entry[0], dest]
|
parts = ['%d' % entry[0], dest]
|
||||||
parts.extend(entry[1:])
|
parts.extend(entry[1:])
|
||||||
fh.write('%s\n' % self.FIELD_SEPARATOR.join(
|
fh.write('%s\n' % self.FIELD_SEPARATOR.join(
|
||||||
p.encode('utf-8') for p in parts))
|
six.ensure_text(p) for p in parts))
|
||||||
|
|
||||||
def add_link(self, source, dest):
|
def add_link(self, source, dest):
|
||||||
"""Add a link to this manifest.
|
"""Add a link to this manifest.
|
||||||
|
@ -4,6 +4,8 @@ subsuite = mozbuild
|
|||||||
[test_archive.py]
|
[test_archive.py]
|
||||||
[test_chrome_flags.py]
|
[test_chrome_flags.py]
|
||||||
[test_chrome_manifest.py]
|
[test_chrome_manifest.py]
|
||||||
|
[test_errors.py]
|
||||||
[test_files.py]
|
[test_files.py]
|
||||||
|
[test_manifests.py]
|
||||||
[test_mozjar.py]
|
[test_mozjar.py]
|
||||||
[test_path.py]
|
[test_path.py]
|
||||||
|
@ -3,8 +3,6 @@ subsuite = mozbuild
|
|||||||
skip-if = python == 3
|
skip-if = python == 3
|
||||||
|
|
||||||
[test_copier.py]
|
[test_copier.py]
|
||||||
[test_errors.py]
|
|
||||||
[test_manifests.py]
|
|
||||||
[test_packager.py]
|
[test_packager.py]
|
||||||
[test_packager_formats.py]
|
[test_packager_formats.py]
|
||||||
[test_packager_l10n.py]
|
[test_packager_l10n.py]
|
||||||
|
@ -26,7 +26,7 @@ class TestInstallManifest(TestWithTmpDir):
|
|||||||
|
|
||||||
def test_malformed(self):
|
def test_malformed(self):
|
||||||
f = self.tmppath('manifest')
|
f = self.tmppath('manifest')
|
||||||
open(f, 'wb').write('junk\n')
|
open(f, 'wt').write('junk\n')
|
||||||
with self.assertRaises(UnreadableInstallManifest):
|
with self.assertRaises(UnreadableInstallManifest):
|
||||||
InstallManifest(f)
|
InstallManifest(f)
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ class TestInstallManifest(TestWithTmpDir):
|
|||||||
m.write(path=p)
|
m.write(path=p)
|
||||||
self.assertTrue(os.path.isfile(p))
|
self.assertTrue(os.path.isfile(p))
|
||||||
|
|
||||||
with open(p, 'rb') as fh:
|
with open(p, 'r') as fh:
|
||||||
c = fh.read()
|
c = fh.read()
|
||||||
|
|
||||||
self.assertEqual(c.count('\n'), 9)
|
self.assertEqual(c.count('\n'), 9)
|
||||||
@ -109,7 +109,7 @@ class TestInstallManifest(TestWithTmpDir):
|
|||||||
p2 = self.tmppath('m2')
|
p2 = self.tmppath('m2')
|
||||||
m2.write(path=p2)
|
m2.write(path=p2)
|
||||||
|
|
||||||
with open(p2, 'rb') as fh:
|
with open(p2, 'r') as fh:
|
||||||
c2 = fh.read()
|
c2 = fh.read()
|
||||||
|
|
||||||
self.assertEqual(c, c2)
|
self.assertEqual(c, c2)
|
||||||
|
Loading…
Reference in New Issue
Block a user