ahupp / python-magic

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

Proposal: Add `magic.set_magic_file` #306

Closed maringuu closed 10 months ago

maringuu commented 10 months ago

This would be a solution to #305. I'm not happy with the name of the function and would like to discuss this change in general.

Any comments?

ahupp commented 10 months ago

Since this is global state, other libraries that also depend on python-magic would pickup the change and may get unexpected behavior. I'd support an environment variable that sets the default, since that puts it under the users (rather than potentially a libraries) control.

ahupp commented 10 months ago

Obviously a library can set the environment variable, but that's going to be clearly wrong while a function makes it inviting.

maringuu commented 10 months ago

environment variable that sets the default

That will be the MAGIC environment variable as defined by libmagic(3).

Since this is global state, other libraries that also depend on python-magic would pickup the change

Good point, I didn't think if that.

Closing.