Module refinery.units.formats.archive
Expand source code Browse git
from __future__ import annotations
from datetime import datetime
from refinery.lib.types import Callable, Param, buf
from refinery.units import Arg
from refinery.units.formats import PathExtractorUnit, UnpackResult
class MultipleArchives(Exception):
pass
class ArchiveUnit(PathExtractorUnit, abstract=True):
def __init__(
self, *paths, list=False, join_path=False, drop_path=False, fuzzy=0, exact=False, regex=False, path=b'path',
date: Param[buf, Arg('-D', metavar='NAME',
help='Name of the meta variable to receive the extracted file date. The default value is "{default}".')] = b'date',
pwd: Param[buf, Arg('-p', help='Optionally specify an extraction password.')] = B'',
**kwargs
):
super().__init__(
*paths,
list=list,
join_path=join_path,
drop_path=drop_path,
fuzzy=fuzzy,
exact=exact,
regex=regex,
path=path,
pwd=pwd,
date=date,
**kwargs
)
_COMMON_PASSWORDS = [
'infected',
'virus',
'malware',
'dangerous',
'flare',
'1234',
'123',
'Infected',
'infected!',
'INFECTED',
'notinfected',
'unzip-me',
'password',
]
def _pack(
self,
path: str,
date: datetime | str | None,
data: buf | Callable[[], buf],
**meta
) -> UnpackResult:
if isinstance(date, datetime):
date = date.isoformat(' ', 'seconds')
if isinstance(date, str):
meta[self.args.date.decode(self.codec)] = date
return UnpackResult(path, data, **meta)
Sub-modules
refinery.units.formats.archive.innopwdrefinery.units.formats.archive.xtrefinery.units.formats.archive.xt7zrefinery.units.formats.archive.xtacerefinery.units.formats.archive.xtasarrefinery.units.formats.archive.xtcabrefinery.units.formats.archive.xtchmrefinery.units.formats.archive.xtcpiorefinery.units.formats.archive.xtdmprefinery.units.formats.archive.xtgzrefinery.units.formats.archive.xtinnorefinery.units.formats.archive.xtisorefinery.units.formats.archive.xtissrefinery.units.formats.archive.xtmachorefinery.units.formats.archive.xtmagtaperefinery.units.formats.archive.xtnoderefinery.units.formats.archive.xtnsisrefinery.units.formats.archive.xtnuitkarefinery.units.formats.archive.xtpyirefinery.units.formats.archive.xtrparefinery.units.formats.archive.xtsimrefinery.units.formats.archive.xtsqlrefinery.units.formats.archive.xttarrefinery.units.formats.archive.xtziprefinery.units.formats.archive.xtzpaq-
This code was ported directly from unzpaq.cpp; it is not very Pythonic and has inherited a somewhat convoluted structure from the source. Cleaning it …
Classes
class MultipleArchives (*args, **kwargs)-
Common base class for all non-exit exceptions.
Expand source code Browse git
class MultipleArchives(Exception): passAncestors
- builtins.Exception
- builtins.BaseException
class ArchiveUnit (*paths, list=False, join_path=False, drop_path=False, fuzzy=0, exact=False, regex=False, path=b'path', date=b'date', pwd=b'', **kwargs)-
Expand source code Browse git
class ArchiveUnit(PathExtractorUnit, abstract=True): def __init__( self, *paths, list=False, join_path=False, drop_path=False, fuzzy=0, exact=False, regex=False, path=b'path', date: Param[buf, Arg('-D', metavar='NAME', help='Name of the meta variable to receive the extracted file date. The default value is "{default}".')] = b'date', pwd: Param[buf, Arg('-p', help='Optionally specify an extraction password.')] = B'', **kwargs ): super().__init__( *paths, list=list, join_path=join_path, drop_path=drop_path, fuzzy=fuzzy, exact=exact, regex=regex, path=path, pwd=pwd, date=date, **kwargs ) _COMMON_PASSWORDS = [ 'infected', 'virus', 'malware', 'dangerous', 'flare', '1234', '123', 'Infected', 'infected!', 'INFECTED', 'notinfected', 'unzip-me', 'password', ] def _pack( self, path: str, date: datetime | str | None, data: buf | Callable[[], buf], **meta ) -> UnpackResult: if isinstance(date, datetime): date = date.isoformat(' ', 'seconds') if isinstance(date, str): meta[self.args.date.decode(self.codec)] = date return UnpackResult(path, data, **meta)Ancestors
Subclasses
- xt
- xt7z
- xtace
- xtasar
- xtcab
- xtcpio
- xtdmp
- xtgz
- xtinno
- xtiso
- xtiss
- xtmacho
- xtnode
- xtnsis
- xtpyi
- xtsim
- xttar
- xtzip
- xtzpaq
- xtpdf
- pyc
Inherited members
PathExtractorUnit:CustomJoinBehaviourCustomPathSeparatorFilterEverythingRequiresassemblecodecconsolefilterfinishhandlesis_quietis_reversiblelabelledleniencylog_alwayslog_debuglog_detachlog_faillog_infolog_levellog_warnloggernamenozzleoptional_dependenciesreadread1required_dependenciesreverserunsourcesuperinit
UnitBase: