Python file type module

filetype 1.2.0

Infer file type and MIME type of any file/buffer. No external dependencies.

Ссылки проекта

Статистика

Метаданные

Лицензия: MIT License (MIT)

Метки file, libmagic, magic, infer, numbers, magicnumbers, discovery, mime, type, kind

Сопровождающие

Классификаторы

Описание проекта

Small and dependency free Python package to infer file type and MIME type checking the magic numbers signature of a file or buffer.

This is a Python port from filetype Go package.

Features

  • Simple and friendly API
  • Supports a wide range of file types
  • Provides file extension and MIME type inference
  • File discovery by extension or MIME type
  • File discovery by kind (image, video, audio…)
  • Pluggable: add new custom type matchers
  • Fast, even processing large files
  • Only first 261 bytes representing the max file header is required, so you can just pass a list of bytes
  • Dependency free (just Python code, no C extensions, no libmagic bindings)
  • Cross-platform file recognition

Installation

API

Examples

Simple file type checking

Supported types

Image

Video

Audio

Archive

  • br — application/x-brotli
  • rpm — application/x-rpm
  • dcm — application/dicom
  • epub — application/epub+zip
  • zip — application/zip
  • tar — application/x-tar
  • rar — application/x-rar-compressed
  • gz — application/gzip
  • bz2 — application/x-bzip2
  • 7z — application/x-7z-compressed
  • xz — application/x-xz
  • pdf — application/pdf
  • exe — application/x-msdownload
  • swf — application/x-shockwave-flash
  • rtf — application/rtf
  • eot — application/octet-stream
  • ps — application/postscript
  • sqlite — application/x-sqlite3
  • nes — application/x-nintendo-nes-rom
  • crx — application/x-google-chrome-extension
  • cab — application/vnd.ms-cab-compressed
  • deb — application/x-deb
  • ar — application/x-unix-archive
  • Z — application/x-compress
  • lzo — application/x-lzop
  • lz — application/x-lzip
  • lz4 — application/x-lz4
  • zstd — application/zstd
Читайте также:  Цвета

Document

  • doc — application/msword
  • docx — application/vnd.openxmlformats-officedocument.wordprocessingml.document
  • odt — application/vnd.oasis.opendocument.text
  • xls — application/vnd.ms-excel
  • xlsx — application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
  • ods — application/vnd.oasis.opendocument.spreadsheet
  • ppt — application/vnd.ms-powerpoint
  • pptx — application/vnd.openxmlformats-officedocument.presentationml.presentation
  • odp — application/vnd.oasis.opendocument.presentation

Font

  • woff — application/font-woff
  • woff2 — application/font-woff
  • ttf — application/font-sfnt
  • otf — application/font-sfnt

Источник

Оцените статью