ahupp / ahupp/python-magic

Ability to detect whether detect mimetype corresponds to the file extension

Open
#338 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2.9k
Forks
304
PR merge metrics
No merged PRs in 30d

Description

As per https://github.com/ahupp/python-magic/issues/228#issuecomment-741967910, libmagic should be able to do this, but I do not see a way to get this library to give me the list of possible file extensions for a given file type.

Would be nice to have a verify_file_extension() function or something akin to it, but I can write that myself, it's just that I can't get the list at all.

mimetypes library does have a function for this.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the linked libmagic issue and comparing its capabilities with Python's mimetypes library. Determine whether the wrapper can expose possible extensions or support a verify_file_extension()-style API, then define tests showing that a detected MIME type can be checked against a file extension.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.