launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #24575
[Merge] ~cjwatson/launchpad:compat-lzma into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:compat-lzma into launchpad:master.
Commit message:
Move conditional lzma imports into lp.services.compat
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/381912
This pacifies format-imports.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:compat-lzma into launchpad:master.
diff --git a/lib/lp/archivepublisher/publishing.py b/lib/lp/archivepublisher/publishing.py
index 3365c68..cd19ed8 100644
--- a/lib/lp/archivepublisher/publishing.py
+++ b/lib/lp/archivepublisher/publishing.py
@@ -35,10 +35,6 @@ from debian.deb822 import (
_multivalued,
Release,
)
-try:
- import lzma
-except ImportError:
- from backports import lzma
import scandir
from storm.expr import Desc
from zope.component import getUtility
@@ -75,6 +71,7 @@ from lp.registry.interfaces.pocket import (
)
from lp.registry.interfaces.series import SeriesStatus
from lp.registry.model.distroseries import DistroSeries
+from lp.services.compat import lzma
from lp.services.database.constants import UTC_NOW
from lp.services.database.interfaces import IStore
from lp.services.features import getFeatureFlag
diff --git a/lib/lp/archivepublisher/tests/test_publisher.py b/lib/lp/archivepublisher/tests/test_publisher.py
index d94fd34..3f36826 100644
--- a/lib/lp/archivepublisher/tests/test_publisher.py
+++ b/lib/lp/archivepublisher/tests/test_publisher.py
@@ -32,10 +32,6 @@ import time
from debian.deb822 import Release
from fixtures import MonkeyPatch
-try:
- import lzma
-except ImportError:
- from backports import lzma
import mock
import pytz
import scandir
@@ -89,6 +85,7 @@ from lp.registry.interfaces.pocket import (
pocketsuffix,
)
from lp.registry.interfaces.series import SeriesStatus
+from lp.services.compat import lzma
from lp.services.config import config
from lp.services.database.constants import UTC_NOW
from lp.services.database.sqlbase import flush_database_caches
diff --git a/lib/lp/archivepublisher/tests/test_repositoryindexfile.py b/lib/lp/archivepublisher/tests/test_repositoryindexfile.py
index 50c6442..b058fa2 100644
--- a/lib/lp/archivepublisher/tests/test_repositoryindexfile.py
+++ b/lib/lp/archivepublisher/tests/test_repositoryindexfile.py
@@ -15,12 +15,8 @@ import stat
import tempfile
import unittest
-try:
- import lzma
-except ImportError:
- from backports import lzma
-
from lp.archivepublisher.utils import RepositoryIndexFile
+from lp.services.compat import lzma
from lp.soyuz.enums import IndexCompressionType
diff --git a/lib/lp/archivepublisher/utils.py b/lib/lp/archivepublisher/utils.py
index 2e76562..1736af9 100644
--- a/lib/lp/archivepublisher/utils.py
+++ b/lib/lp/archivepublisher/utils.py
@@ -17,11 +17,7 @@ import os
import stat
import tempfile
-try:
- import lzma
-except ImportError:
- from backports import lzma
-
+from lp.services.compat import lzma
from lp.soyuz.enums import (
ArchivePurpose,
IndexCompressionType,
diff --git a/lib/lp/archiveuploader/tests/test_nascentuploadfile.py b/lib/lp/archiveuploader/tests/test_nascentuploadfile.py
index c4d81bf..54841a9 100644
--- a/lib/lp/archiveuploader/tests/test_nascentuploadfile.py
+++ b/lib/lp/archiveuploader/tests/test_nascentuploadfile.py
@@ -20,10 +20,6 @@ from debian.deb822 import (
Deb822,
Dsc,
)
-try:
- import lzma
-except ImportError:
- from backports import lzma
from testtools.matchers import (
Contains,
Equals,
@@ -43,6 +39,7 @@ from lp.archiveuploader.nascentuploadfile import (
from lp.archiveuploader.tests import AbsolutelyAnythingGoesUploadPolicy
from lp.buildmaster.enums import BuildStatus
from lp.registry.interfaces.pocket import PackagePublishingPocket
+from lp.services.compat import lzma
from lp.services.log.logger import BufferLogger
from lp.services.osutils import write_file
from lp.soyuz.enums import (
diff --git a/lib/lp/services/compat.py b/lib/lp/services/compat.py
index 942e690..6ddfbf3 100644
--- a/lib/lp/services/compat.py
+++ b/lib/lp/services/compat.py
@@ -10,6 +10,7 @@ from __future__ import absolute_import, print_function, unicode_literals
__metaclass__ = type
__all__ = [
+ 'lzma',
'SafeConfigParser',
]
@@ -17,3 +18,8 @@ try:
from configparser import ConfigParser as SafeConfigParser
except ImportError:
from ConfigParser import SafeConfigParser
+
+try:
+ import lzma
+except ImportError:
+ from backports import lzma