Skip to content

Commit d0b298a

Browse files
authored
Merge pull request #83 from dosas/feature/issue-71
Added support for lzop.
2 parents e32b2cf + 092bf19 commit d0b298a

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ Archive
131131
- **deb** - ``application/x-deb``
132132
- **ar** - ``application/x-unix-archive``
133133
- **Z** - ``application/x-compress``
134+
- **lzo** - ``application/x-lzop``
134135
- **lz** - ``application/x-lzip``
135136
- **lz4** - ``application/x-lz4``
136137

filetype/types/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
archive.Deb(),
8585
archive.Ar(),
8686
archive.Z(),
87+
archive.Lzop(),
8788
archive.Lz(),
8889
archive.Lz4(),
8990
)

filetype/types/archive.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,31 @@ def match(self, buf):
494494
buf[1] == 0x9D)))
495495

496496

497+
class Lzop(Type):
498+
"""
499+
Implements the Lzop archive type matcher.
500+
"""
501+
MIME = 'application/x-lzop'
502+
EXTENSION = 'lzo'
503+
504+
def __init__(self):
505+
super(Lzop, self).__init__(
506+
mime=Lzop.MIME,
507+
extension=Lzop.EXTENSION
508+
)
509+
510+
def match(self, buf):
511+
return (len(buf) > 7 and
512+
buf[0] == 0x89 and
513+
buf[1] == 0x4C and
514+
buf[2] == 0x5A and
515+
buf[3] == 0x4F and
516+
buf[4] == 0x00 and
517+
buf[5] == 0x0D and
518+
buf[6] == 0x0A and
519+
buf[7] == 0x1A)
520+
521+
497522
class Lz(Type):
498523
"""
499524
Implements the Lz archive type matcher.

0 commit comments

Comments
 (0)