diff --git a/README.rst b/README.rst index 87ce898..53cfaf5 100644 --- a/README.rst +++ b/README.rst @@ -124,6 +124,7 @@ Archive - **deb** - ``application/x-deb`` - **ar** - ``application/x-unix-archive`` - **Z** - ``application/x-compress`` +- **lzo** - ``application/x-lzop`` - **lz** - ``application/x-lzip`` Font diff --git a/filetype/types/__init__.py b/filetype/types/__init__.py index 87d95b8..4eb9844 100644 --- a/filetype/types/__init__.py +++ b/filetype/types/__init__.py @@ -76,6 +76,7 @@ archive.Deb(), archive.Ar(), archive.Z(), + archive.Lzop(), archive.Lz(), ) diff --git a/filetype/types/archive.py b/filetype/types/archive.py index 5cde4b3..c38d96d 100644 --- a/filetype/types/archive.py +++ b/filetype/types/archive.py @@ -494,6 +494,31 @@ def match(self, buf): buf[1] == 0x9D))) +class Lzop(Type): + """ + Implements the Lzop archive type matcher. + """ + MIME = 'application/x-lzop' + EXTENSION = 'lzo' + + def __init__(self): + super(Lzop, self).__init__( + mime=Lzop.MIME, + extension=Lzop.EXTENSION + ) + + def match(self, buf): + return (len(buf) > 7 and + buf[0] == 0x89 and + buf[1] == 0x4C and + buf[2] == 0x5A and + buf[3] == 0x4F and + buf[4] == 0x00 and + buf[5] == 0x0D and + buf[6] == 0x0A and + buf[7] == 0x1A) + + class Lz(Type): """ Implements the Lz archive type matcher.