file-type-guesser

Guess a files type from its content and extension


Keywords
git, scm
License
MIT
Install
pip install file-type-guesser==0.2.0

Documentation

File Type Guesser

Test PyPI PyPI - Python Version PyPI - Downloads License MIT Open Issues Line Count Last Commit

Guess a file's type from its content and extension.

This is intended to be a pure Python implementation of something like python-magic. This means it should work on all platforms that can run Python as it does not require external binaries like libmagic.

This project currently is not heavily tested and not fully feature complete

Example Of Use

from pathlib import Path
from file_type_guesser import guess_file

path = Path("README.md")
guess = guess_file(path)
print(guess)
ContentGuess(category=<FileTypes.TEXT: 1>, extention='md', content_ext='md')