* [gentoo-portage-dev] [PATCH] compression_probe: support lz4, lzip, lzop
@ 2015-01-17 11:10 Michał Górny
2015-01-17 21:59 ` Zac Medico
0 siblings, 1 reply; 3+ messages in thread
From: Michał Górny @ 2015-01-17 11:10 UTC (permalink / raw
To: gentoo-portage-dev; +Cc: Michał Górny
---
pym/portage/util/compression_probe.py | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/pym/portage/util/compression_probe.py b/pym/portage/util/compression_probe.py
index 1dc3547..74f74b1 100644
--- a/pym/portage/util/compression_probe.py
+++ b/pym/portage/util/compression_probe.py
@@ -14,14 +14,22 @@ from portage.exception import FileNotFound, PermissionDenied
_decompressors = {
"bzip2": "${PORTAGE_BUNZIP2_COMMAND:-${PORTAGE_BZIP2_COMMAND} -d}",
"gzip": "gzip -d",
+ "lz4": "lz4 -d",
+ "lzip": "lzip -d",
+ "lzop": "lzop -d",
"xz": "xz -d",
}
_compression_re = re.compile(b'^(' +
b'(?P<bzip2>\x42\x5a\x68\x39)|' +
b'(?P<gzip>\x1f\x8b)|' +
+ b'(?P<lz4>(?:\x04\x22\x4d\x18|\x02\x21\x4c\x18))|' +
+ b'(?P<lzip>LZIP)|' +
+ b'(?P<lzop>\x89LZO\x00\x0d\x0a\x1a\x0a)|' +
b'(?P<xz>\xfd\x37\x7a\x58\x5a\x00))')
+_max_compression_re_len = 9
+
def compression_probe(f):
"""
Identify the compression type of a file. Returns one of the
@@ -29,6 +37,9 @@ def compression_probe(f):
bzip2
gzip
+ lz4
+ lzip
+ lzop
xz
@param f: a file path, or file-like object
@@ -59,7 +70,7 @@ def compression_probe(f):
def _compression_probe_file(f):
- m = _compression_re.match(f.read(6))
+ m = _compression_re.match(f.read(_max_compression_re_len))
if m is not None:
for k, v in m.groupdict().items():
if v is not None:
--
2.2.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [gentoo-portage-dev] [PATCH] compression_probe: support lz4, lzip, lzop
2015-01-17 11:10 [gentoo-portage-dev] [PATCH] compression_probe: support lz4, lzip, lzop Michał Górny
@ 2015-01-17 21:59 ` Zac Medico
2015-01-18 17:06 ` Brian Dolbec
0 siblings, 1 reply; 3+ messages in thread
From: Zac Medico @ 2015-01-17 21:59 UTC (permalink / raw
To: gentoo-portage-dev; +Cc: Michał Górny
On 01/17/2015 03:10 AM, Michał Górny wrote:
> ---
> pym/portage/util/compression_probe.py | 13 ++++++++++++-
> 1 file changed, 12 insertions(+), 1 deletion(-)
LGTM.
BTW, I've verified that all the the new entries in _decompressors
support -c and -q, as required by BinpkgExtractorAsync.
--
Thanks,
Zac
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [gentoo-portage-dev] [PATCH] compression_probe: support lz4, lzip, lzop
2015-01-17 21:59 ` Zac Medico
@ 2015-01-18 17:06 ` Brian Dolbec
0 siblings, 0 replies; 3+ messages in thread
From: Brian Dolbec @ 2015-01-18 17:06 UTC (permalink / raw
To: gentoo-portage-dev
On Sat, 17 Jan 2015 13:59:02 -0800
Zac Medico <zmedico@gentoo.org> wrote:
> On 01/17/2015 03:10 AM, Michał Górny wrote:
> > ---
> > pym/portage/util/compression_probe.py | 13 ++++++++++++-
> > 1 file changed, 12 insertions(+), 1 deletion(-)
>
> LGTM.
>
> BTW, I've verified that all the the new entries in _decompressors
> support -c and -q, as required by BinpkgExtractorAsync.
yes, looks good, merge please
--
Brian Dolbec <dolsen>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-01-18 17:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-17 11:10 [gentoo-portage-dev] [PATCH] compression_probe: support lz4, lzip, lzop Michał Górny
2015-01-17 21:59 ` Zac Medico
2015-01-18 17:06 ` Brian Dolbec
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox