Skip to content

Commit 454c19a

Browse files
debbiedubArneBab
authored andcommitted
Fix flake8 findings for guessMimetype
1 parent cf39144 commit 454c19a

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

fcp3/node.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3185,6 +3185,7 @@ def sha256dda(nodehelloid, identifier, path=None):
31853185
tohash = b"-".join([nodehelloid.encode('utf-8'), identifier.encode('utf-8'), open(path, "rb").read()])
31863186
return hashlib.sha256(tohash).digest()
31873187

3188+
31883189
def guessMimetype(filename):
31893190
"""
31903191
Returns a guess of a mimetype based on a filename's extension
@@ -3197,20 +3198,22 @@ def guessMimetype(filename):
31973198
return ('application/x-tar', 'bzip2')
31983199
try:
31993200
m = mimetypes.guess_type(filename, False)[0]
3200-
except TypeError: # bytes compared to string string …
3201+
except TypeError: # bytes compared to string string …
32013202
try:
32023203
m = mimetypes.guess_type(filename.decode(), False)[0]
3203-
except:
3204+
except Exception:
32043205
m = None
3205-
except:
3206+
except Exception:
32063207
m = None
3207-
if m == "audio/mpegurl": # disallowed mime type by FF
3208+
if m == "audio/mpegurl": # disallowed mime type by FF
32083209
m = "audio/x-mpegurl"
3209-
if m is None: # either an exception or a genuine None
3210-
# FIXME: log(INFO, "Could not find mimetype for filename %s" % filename)
3210+
if m is None: # either an exception or a genuine None
3211+
# FIXME: log(INFO,
3212+
# "Could not find mimetype for filename %s" % filename)
32113213
m = "application/octet-stream"
32123214
return m
32133215

3216+
32143217
_re_slugify = re.compile('[^\w\s\.-]', re.UNICODE)
32153218
_re_slugify_multidashes = re.compile('[-\s]+', re.UNICODE)
32163219
def toUrlsafe(filename):

0 commit comments

Comments
 (0)