ahupp / python-magic

A python wrapper for libmagic
Other
2.59k stars 280 forks source link

Add a way to specify a default for `magic_file`. #305

Closed maringuu closed 10 months ago

maringuu commented 10 months ago

My use case it the following: We have some additional magic that we want to always use in our project. So one idea would be to create an instance of Magic with the appropriate magic_file. But now when we want to specify mime=True or follow_symlinks=True we need to create a new instance of Magic. I guess one could say that all other arguments than magic_file are of a more short-lived nature.

This leads to some boilerplate which I think belongs in python-magic instead.

My proposal would be to add some way to set a default value for magic_file. While I know that this is the way libmagic is designed I think we can to better in a wrapper library.

Related:

304

https://github.com/fkie-cad/FACT_core/pull/1140

ahupp commented 10 months ago

See my comment on your PR, but I'd support adding an environment variable that sets the default magic file.