piknik

Unnamed repository; edit this file 'description' to name the repository.
Info | Log | Files | Refs | README | LICENSE

commit 9a655f448de6877ef7cd0a8cae2968a24a071165
parent 4344d3ef2207515b4d0ccb6ccdf4be399f22b0d5
Author: lash <dev@holbrook.no>
Date:   Tue, 15 Nov 2022 09:27:57 +0000

Handle fail guess mime type

Diffstat:
M.gitignore | 2++
Mpiknik/msg.py | 10+++++++---
2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1,3 +1,5 @@ __pycache__ *.pyc build/ +dist/ +*.egg-info diff --git a/piknik/msg.py b/piknik/msg.py @@ -47,14 +47,18 @@ class IssueMessage: def detect_file(self, v): - return mimetypes.guess_type(v) + r = mimetypes.guess_type(v) + if r[0] == None: + return ('application/octet-stream', None,) + return r def from_file(self, v): - mime_type = self.detect_file(v) - m = Message() + + mime_type = self.detect_file(v) m.set_type(mime_type[0]) + if mime_type[1] != None: m.set_charset(mime-type[1]) m.add_header('Content-Transfer-Encoding', 'BASE64')