diff --git a/setup.py b/setup.py index c48e83e..9472379 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ LONG_DESCRIPTION = f.read() MAJOR_VERSION = '0' MINOR_VERSION = '14' -MICRO_VERSION = '256' +MICRO_VERSION = '260' VERSION = "{}.{}.{}".format(MAJOR_VERSION, MINOR_VERSION, MICRO_VERSION) setup( diff --git a/yagmail/__init__.py b/yagmail/__init__.py index f6911fc..f670523 100644 --- a/yagmail/__init__.py +++ b/yagmail/__init__.py @@ -1,5 +1,5 @@ __project__ = "yagmail" -__version__ = "0.14.256" +__version__ = "0.14.260" from yagmail.error import YagConnectionClosed from yagmail.error import YagAddressError diff --git a/yagmail/message.py b/yagmail/message.py index 7b77d0a..ed577b5 100644 --- a/yagmail/message.py +++ b/yagmail/message.py @@ -51,7 +51,7 @@ def prepare_message( group_messages=True, ): # check if closed!!!!!! XXX - """ Prepare a MIME message """ + """Prepare a MIME message""" if not isinstance(contents, (list, tuple)): if contents is not None: @@ -63,7 +63,8 @@ def prepare_message( if attachments is not None: for a in attachments: if not isinstance(a, io.IOBase) and not os.path.isfile(a): - raise TypeError(f'{a} must be a valid filepath or file handle (instance of io.IOBase). {a} is of type {type(a)}') + msg = "{a} must be a valid filepath or file handle (instance of io.IOBase). {a} is of type {tp}" + raise TypeError(msg.format(a=a, tp=type(a))) contents = attachments if contents is None else contents + attachments if contents is not None: @@ -114,9 +115,7 @@ def prepare_message( # pylint: disable=unidiomatic-typecheck if type(content_string) == inline: htmlstr += ''.format(hashed_ref, alias) - content_object["mime_object"].add_header( - "Content-ID", "<{0}>".format(hashed_ref) - ) + content_object["mime_object"].add_header("Content-ID", "<{0}>".format(hashed_ref)) altstr.append("-- img {0} should be here -- ".format(alias)) # inline images should be in related MIME block msg_related.attach(content_object["mime_object"]) @@ -156,9 +155,9 @@ def prepare_contents(contents, encoding): unnamed_attachment_id = 1 for is_marked_up, content in contents: if isinstance(content, io.IOBase): - if not hasattr(content, 'name'): + if not hasattr(content, "name"): # If the IO object has no name attribute, give it one. - content.name = f'attachment_{unnamed_attachment_id}' + content.name = "attachment_{}".format(unnamed_attachment_id) content_object = get_mime_object(is_marked_up, content, encoding) if content_object["main_type"] == "image": @@ -225,11 +224,9 @@ def get_mime_object(is_marked_up, content_string, encoding): content_object["main_type"] = "application" content_object["sub_type"] = "octet-stream" - mime_object = MIMEBase( - content_object["main_type"], content_object["sub_type"], name=(encoding, '', content_name) - ) + mime_object = MIMEBase(content_object["main_type"], content_object["sub_type"], name=(encoding, "", content_name)) mime_object.set_payload(content) if content_object["main_type"] == "application": - mime_object.add_header('Content-Disposition', 'attachment', filename=content_name) + mime_object.add_header("Content-Disposition", "attachment", filename=content_name) content_object["mime_object"] = mime_object return content_object