-
Notifications
You must be signed in to change notification settings - Fork 115
Add some file types from the Go version #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
fzzylogic
wants to merge
6
commits into
h2non:master
Choose a base branch
from
fzzylogic:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c2a89b8
enh: Add low hanging fruit from GO version
fzzylogic fa1d9af
bug: Replace Dcm with Dwg under IMAGES
fzzylogic 08bee20
bug: Update __init__ for new types
fzzylogic e65c111
bug: Import types in match.py
fzzylogic 5091580
enh: Add new helpers and matchers for new types
fzzylogic 1937d2b
chores: Add new detected file types to docs
fzzylogic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,10 @@ | |
|
||
from __future__ import absolute_import | ||
|
||
from . import application | ||
from . import archive | ||
from . import audio | ||
from . import document | ||
from . import font | ||
from . import image | ||
from . import video | ||
|
@@ -23,20 +25,21 @@ | |
image.Psd(), | ||
image.Ico(), | ||
image.Heic(), | ||
image.Dcm(), | ||
image.Dwg(), | ||
) | ||
|
||
# Supported video types | ||
VIDEO = ( | ||
video.Mp4(), | ||
video.M4v(), | ||
video.Mkv(), | ||
video.Webm(), | ||
video.Mov(), | ||
video.Avi(), | ||
video.Wmv(), | ||
video.Mpeg(), | ||
video.Webm(), | ||
video.Flv(), | ||
video.Mp4(), | ||
video.Match3gp(), | ||
) | ||
|
||
# Supported audio types | ||
|
@@ -48,6 +51,7 @@ | |
audio.Flac(), | ||
audio.Wav(), | ||
audio.Amr(), | ||
audio.Aac(), | ||
) | ||
|
||
# Supported font types | ||
|
@@ -77,7 +81,24 @@ | |
archive.Ar(), | ||
archive.Z(), | ||
archive.Lz(), | ||
archive.Rpm(), | ||
archive.Elf(), | ||
archive.Dcm(), | ||
archive.Iso(), | ||
) | ||
|
||
# Supported application types | ||
APPLICATION = ( | ||
application.Wasm(), | ||
) | ||
|
||
# Supported application types | ||
DOCUMENT = ( | ||
document.Doc(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doc type it will valid for xls and ppt because of same file signature, so no need to define the others. |
||
document.Xls(), | ||
document.Ppt(), | ||
) | ||
|
||
|
||
# Expose supported type matchers | ||
TYPES = list(VIDEO + IMAGE + AUDIO + FONT + ARCHIVE) | ||
TYPES = list(VIDEO + IMAGE + AUDIO + FONT + ARCHIVE + APPLICATION + DOCUMENT) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from __future__ import absolute_import | ||
|
||
from .base import Type | ||
|
||
|
||
class Wasm(Type): | ||
""" | ||
Implements the WASM Web Assembly 1.0 filetype. | ||
|
||
WASM has starts with `\0asm`, followed by the version. | ||
http://webassembly.github.io/spec/core/binary/modules.html#binary-magic | ||
""" | ||
|
||
MIME = 'application/wasm' | ||
EXTENSION = 'wasm' | ||
|
||
def __init__(self): | ||
super(Wasm, self).__init__( | ||
mime=Wasm.MIME, | ||
extension=Wasm.EXTENSION | ||
) | ||
|
||
def match(self, buf): | ||
return (len(buf) > 8 and | ||
buf[0] == 0x00 and | ||
buf[1] == 0x61 and | ||
buf[2] == 0x73 and | ||
buf[3] == 0x6D and | ||
buf[4] == 0x01 and | ||
buf[5] == 0x00 and | ||
buf[6] == 0x00 and | ||
buf[7] == 0x00) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Group microsoft office pre 2007 documents as
application/x-ole-storage
as this 3 types have same file signatures. We can determine the file type by filename extension.