Skip to content

Instantly share code, notes, and snippets.

@dmwyatt
Last active February 21, 2024 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmwyatt/d3307d830b71e1677472843a43d4dccb to your computer and use it in GitHub Desktop.
Save dmwyatt/d3307d830b71e1677472843a43d4dccb to your computer and use it in GitHub Desktop.
A Union of all file types in `filetype` package
frofrom typing import Union
from filetype.types import application, archive, audio, document, font, image, video
ImageFileType = Union[
image.Dwg,
image.Xcf,
image.Jpeg,
image.Jpx,
image.Apng,
image.Png,
image.Gif,
image.Webp,
image.Tiff,
image.Cr2,
image.Bmp,
image.Jxr,
image.Psd,
image.Ico,
image.Heic,
image.Dcm,
image.Avif,
]
VideoFileType = Union[
video.M3gp,
video.Mp4,
video.M4v,
video.Mkv,
video.Mov,
video.Avi,
video.Wmv,
video.Mpeg,
video.Webm,
video.Flv,
]
AudioFileType = Union[
audio.Aac,
audio.Midi,
audio.Mp3,
audio.M4a,
audio.Ogg,
audio.Flac,
audio.Wav,
audio.Amr,
audio.Aiff,
]
FontFileType = Union[
font.Woff,
font.Woff2,
font.Ttf,
font.Otf,
]
DocumentFileType = Union[
document.Doc,
document.Docx,
document.Odt,
document.Xls,
document.Xlsx,
document.Ods,
document.Ppt,
document.Pptx,
document.Odp,
]
ArchiveFileType = Union[
archive.Br,
archive.Rpm,
archive.Epub,
archive.Zip,
archive.Tar,
archive.Rar,
archive.Gz,
archive.Bz2,
archive.SevenZ,
archive.Pdf,
archive.Exe,
archive.Swf,
archive.Rtf,
archive.Nes,
archive.Crx,
archive.Cab,
archive.Eot,
archive.Ps,
archive.Xz,
archive.Sqlite,
archive.Deb,
archive.Ar,
archive.Z,
archive.Lzop,
archive.Lz,
archive.Elf,
archive.Lz4,
archive.Zstd,
]
ApplicationFileType = Union[application.Wasm,]
FileType = Union[
ImageFileType,
VideoFileType,
AudioFileType,
FontFileType,
ArchiveFileType,
ApplicationFileType,
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment