Add requirement for python-magic, and add wrappers to Mastodon.py
This commit is contained in:
pare
191ad84cef
commit
7e2259e3ee
S'han modificat 3 arxius amb 18 adicions i 2 eliminacions
4
.gitignore
vendido
4
.gitignore
vendido
|
@ -91,4 +91,6 @@ ENV/
|
||||||
# Secret files (for credentials used in testing)
|
# Secret files (for credentials used in testing)
|
||||||
*.secret
|
*.secret
|
||||||
pytooter_clientcred.txt
|
pytooter_clientcred.txt
|
||||||
pytooter_usercred.txt
|
pytooter_usercred.txtPipfile
|
||||||
|
Pipfile.lock
|
||||||
|
Pipfile
|
||||||
|
|
|
@ -31,6 +31,11 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from urlparse import urlparse
|
from urlparse import urlparse
|
||||||
|
|
||||||
|
try:
|
||||||
|
import magic
|
||||||
|
except ImportError:
|
||||||
|
magic = None
|
||||||
|
|
||||||
###
|
###
|
||||||
# Version check functions, including decorator and parser
|
# Version check functions, including decorator and parser
|
||||||
###
|
###
|
||||||
|
@ -2529,3 +2534,11 @@ class MastodonRatelimitError(MastodonError):
|
||||||
class MastodonMalformedEventError(MastodonError):
|
class MastodonMalformedEventError(MastodonError):
|
||||||
"""Raised when the server-sent event stream is malformed"""
|
"""Raised when the server-sent event stream is malformed"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def guess_type(media_file):
|
||||||
|
mime_type = None
|
||||||
|
if magic:
|
||||||
|
mime_type = magic.from_file(media_file, mime=True)
|
||||||
|
else:
|
||||||
|
mime_type = mimetypes.guess_type(media_file)[0]
|
||||||
|
return mime_type
|
||||||
|
|
1
setup.py
1
setup.py
|
@ -14,6 +14,7 @@ setup(name='Mastodon.py',
|
||||||
'python-dateutil',
|
'python-dateutil',
|
||||||
'six',
|
'six',
|
||||||
'pytz',
|
'pytz',
|
||||||
|
'python-magic',
|
||||||
'decorator>=4.0.0',
|
'decorator>=4.0.0',
|
||||||
'http_ece>=1.0.5',
|
'http_ece>=1.0.5',
|
||||||
'cryptography>=1.6.0'
|
'cryptography>=1.6.0'
|
||||||
|
|
Loading…
Referencia en una nova incidència