Skip to content

Commit 85fb57f

Browse files
author
dosas
committed
Add rpm and dcm type.
1 parent c518f58 commit 85fb57f

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

README.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ Audio
105105
Archive
106106
^^^^^^^
107107

108+
- **rpm** - ``application/x-rpm``
109+
- **dcm** - ``application/dicom``
108110
- **epub** - ``application/epub+zip``
109111
- **zip** - ``application/zip``
110112
- **tar** - ``application/x-tar``

filetype/types/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@
5858

5959
# Supported archive container types
6060
ARCHIVE = (
61+
archive.Rpm(),
62+
archive.Dcm(),
6163
archive.Epub(),
6264
archive.Zip(),
6365
archive.Tar(),

filetype/types/archive.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,3 +513,35 @@ def match(self, buf):
513513
buf[1] == 0x5A and
514514
buf[2] == 0x49 and
515515
buf[3] == 0x50)
516+
517+
518+
class Dcm(Type):
519+
"""Implements the Dcm image type matcher."""
520+
521+
MIME = 'application/dicom'
522+
EXTENSION = 'dcm'
523+
524+
def __init__(self):
525+
super(Dcm, self).__init__(
526+
mime=Dcm.MIME,
527+
extension=Dcm.EXTENSION
528+
)
529+
530+
def match(self, buf):
531+
return buf[128:131] == bytearray([0x44, 0x49, 0x43, 0x4d])
532+
533+
534+
class Rpm(Type):
535+
"""Implements the Rpm image type matcher."""
536+
537+
MIME = 'application/x-rpm'
538+
EXTENSION = 'rpm'
539+
540+
def __init__(self):
541+
super(Rpm, self).__init__(
542+
mime=Rpm.MIME,
543+
extension=Rpm.EXTENSION
544+
)
545+
546+
def match(self, buf):
547+
return buf[:4] == bytearray([0xed, 0xab, 0xee, 0xdb])

0 commit comments

Comments
 (0)