Module refinery.units.formats.archive.xtace
Expand source code Browse git
from __future__ import annotations
from refinery.lib.structures import MemoryFile
from refinery.lib.thirdparty import acefile
from refinery.units.formats.archive import ArchiveUnit
class xtace(ArchiveUnit, docs='{0}{s}{PathExtractorUnit}'):
"""
Extract files from an ACE archive.
"""
def unpack(self, data):
ace = acefile.open(MemoryFile(data, output=bytes))
for member in ace.getmembers():
member: acefile.AceMember
comment = {} if not member.comment else {'comment': member.comment}
yield self._pack(
member.filename,
member.datetime,
lambda a=ace, m=member: a.read(m, pwd=self.args.pwd),
**comment
)
@classmethod
def handles(cls, data) -> bool:
return data[7:14] == b'**ACE**'
Classes
class xtace (*paths, list=False, join_path=False, drop_path=False, fuzzy=0, exact=False, regex=False, path=b'path', date=b'date', pwd=b'')-
Extract files from an ACE archive. This unit is a path extractor which extracts data from a hierarchical structure. Each extracted item is emitted as a separate chunk and has attached to it a meta variable that contains its path within the source structure. The positional arguments to the command are patterns that can be used to filter the extracted items by their path. To view only the paths of all chunks, use the listing switch:
emit something | xtace --listOtherwise, extracted items are written to the standard output port and usually require a frame to properly process. In order to dump all extracted data to disk, the following pipeline can be used:
emit something | xtace [| dump {path} ]Expand source code Browse git
class xtace(ArchiveUnit, docs='{0}{s}{PathExtractorUnit}'): """ Extract files from an ACE archive. """ def unpack(self, data): ace = acefile.open(MemoryFile(data, output=bytes)) for member in ace.getmembers(): member: acefile.AceMember comment = {} if not member.comment else {'comment': member.comment} yield self._pack( member.filename, member.datetime, lambda a=ace, m=member: a.read(m, pwd=self.args.pwd), **comment ) @classmethod def handles(cls, data) -> bool: return data[7:14] == b'**ACE**'Ancestors
Subclasses
Class variables
var required_dependenciesvar optional_dependenciesvar consolevar reverse
Methods
def unpack(self, data)-
Expand source code Browse git
def unpack(self, data): ace = acefile.open(MemoryFile(data, output=bytes)) for member in ace.getmembers(): member: acefile.AceMember comment = {} if not member.comment else {'comment': member.comment} yield self._pack( member.filename, member.datetime, lambda a=ace, m=member: a.read(m, pwd=self.args.pwd), **comment )
Inherited members