Module refinery.units.formats.archive.xtiex
Expand source code Browse git
from __future__ import annotations
from refinery import perc, xtcab
from refinery.lib.id import is_likely_pe, buffer_contains
from refinery.lib.types import buf
from refinery.units.formats.archive import ArchiveUnit
class xtiex(xtcab, docs='{0}{p}{PathExtractorUnit}'):
"""
Extract files from IExpress setup self-extracting archive.
"""
def unpack(self, data: buf):
try:
cab = next(data | perc('RCDATA/CABINET/*'))
except StopIteration as SI:
raise ValueError('no RCDATA resource named CABINET was found') from SI
yield from super().unpack(cab)
def filter(self, chunks):
yield from super(ArchiveUnit, self).filter(chunks)
@classmethod
def handles(cls, data: buf) -> bool:
if not is_likely_pe(data):
return False
return buffer_contains(data, B'CABINET')
Classes
class xtiex (*paths, list=False, join_path=False, drop_path=False, fuzzy=0, exact=False, regex=False, path=b'path', exclude=None, date=b'date', pwd=b'')-
Extract files from IExpress setup self-extracting archive.
This unit extracts items with an associated virtual path from a container; each extracted item is emitted as a separate chunk with a corresponding meta variable named "path".
Positional arguments to xtiex are patterns to filter the extracted items. Use the
-xflag to add an exclusion pattern. To extract all files with a foo or bar extension, but none that has the word "temp" in its path:xtiex .foo .bar -x tempTo view only the paths of all chunks, use the listing switch:
emit data | ... | xtiex -lOtherwise, 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 data | ... | xtiex [| dump extracted/{path} ]The value
{path}is a placeholder which is substituted by the virtual path of the extracted item. When using xtiex to unpack a file on disk, the following pattern can be useful:ef pack.bin [| xtiex -j | d2p ]The unit
efis also a path extractor. By specifying-j(or--join), the paths of extracted items are combined. Here,d2pis a shortcut fordump {path}. It deconflicts the joined paths with the local file system: Ifpack.bincontains itemsone.txtandtwo.txt, the following local file tree would be the result:pack.bin pack/one.txt pack/two.txtFinally, the
-d(or--drop) switch can be used to not create (or alter) the path metadata at all, which is useful in cases where path metadata from a previous unit should be preserved.Expand source code Browse git
class xtiex(xtcab, docs='{0}{p}{PathExtractorUnit}'): """ Extract files from IExpress setup self-extracting archive. """ def unpack(self, data: buf): try: cab = next(data | perc('RCDATA/CABINET/*')) except StopIteration as SI: raise ValueError('no RCDATA resource named CABINET was found') from SI yield from super().unpack(cab) def filter(self, chunks): yield from super(ArchiveUnit, self).filter(chunks) @classmethod def handles(cls, data: buf) -> bool: if not is_likely_pe(data): return False return buffer_contains(data, B'CABINET')Ancestors
Subclasses
Methods
def unpack(self, data)-
Expand source code Browse git
def unpack(self, data: buf): try: cab = next(data | perc('RCDATA/CABINET/*')) except StopIteration as SI: raise ValueError('no RCDATA resource named CABINET was found') from SI yield from super().unpack(cab)
Inherited members
xtcab:xtcab:CommonPasswordsCustomJoinBehaviourCustomPathSeparatorFilterEverythingRequiresactassemblecarvedcodecfinishhandlesis_quietis_reversibleisattylabelledleniencylog_alwayslog_debuglog_detachlog_faillog_infolog_levellog_warnloggernamenozzleprocessreadread1resetreverserunsourcesuperinit
ArchiveUnit: