Skip to content

Commit

Permalink
_magic_mimetype support more versions of python-magic
Browse files Browse the repository at this point in the history
  • Loading branch information
tgbugs committed Oct 1, 2019
1 parent 51c5333 commit c6ac2da
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion augpathlib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,12 @@ def encoding(self):
def _magic_mimetype(self):
""" This can be slow because it has to open the files. """
if self.exists():
return magic.detect_from_filename(self).mime_type
if hasattr(magic, 'detect_from_filename'):
# sys-apps/file python-magic api
return magic.detect_from_filename(self).mime_type
else:
# python-magic
return magic.from_file(self.as_posix(), mime=True)

def checksum(self, cypher=default_cypher):
""" checksum() always recomputes from the data
Expand Down

0 comments on commit c6ac2da

Please sign in to comment.