[archive] move DownloadArchive into its own module
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
|
||||
"""Common classes and constants used by postprocessor modules."""
|
||||
|
||||
from .. import util, formatter
|
||||
from .. import util, formatter, archive
|
||||
|
||||
|
||||
class PostProcessor():
|
||||
@@ -22,30 +22,31 @@ class PostProcessor():
|
||||
return self.__class__.__name__
|
||||
|
||||
def _init_archive(self, job, options, prefix=None):
|
||||
archive = options.get("archive")
|
||||
if archive:
|
||||
archive_path = options.get("archive")
|
||||
if archive_path:
|
||||
extr = job.extractor
|
||||
archive = util.expand_path(archive)
|
||||
archive_path = util.expand_path(archive_path)
|
||||
if not prefix:
|
||||
prefix = "_" + self.name.upper() + "_"
|
||||
archive_format = (
|
||||
options.get("archive-prefix", extr.category) +
|
||||
options.get("archive-format", prefix + extr.archive_fmt))
|
||||
try:
|
||||
if "{" in archive:
|
||||
archive = formatter.parse(archive).format_map(
|
||||
if "{" in archive_path:
|
||||
archive_path = formatter.parse(archive_path).format_map(
|
||||
job.pathfmt.kwdict)
|
||||
self.archive = util.DownloadArchive(
|
||||
archive, archive_format,
|
||||
self.archive = archive.DownloadArchive(
|
||||
archive_path, archive_format,
|
||||
options.get("archive-pragma"),
|
||||
"_archive_" + self.name)
|
||||
except Exception as exc:
|
||||
self.log.warning(
|
||||
"Failed to open %s archive at '%s' (%s: %s)",
|
||||
self.name, archive, exc.__class__.__name__, exc)
|
||||
self.name, archive_path, exc.__class__.__name__, exc)
|
||||
else:
|
||||
self.log.debug("Using %s archive '%s'", self.name, archive)
|
||||
self.log.debug(
|
||||
"Using %s archive '%s'", self.name, archive_path)
|
||||
return True
|
||||
else:
|
||||
self.archive = None
|
||||
|
||||
self.archive = None
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user