Skip to content

Commit

Permalink
remove fstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
kootenpv committed Jan 10, 2022
1 parent 8eb3a05 commit ae89d97
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion yagmail/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__project__ = "yagmail"
__version__ = "0.14.256"
__version__ = "0.14.260"

from yagmail.error import YagConnectionClosed
from yagmail.error import YagAddressError
Expand Down
19 changes: 8 additions & 11 deletions yagmail/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -114,9 +115,7 @@ def prepare_message(
# pylint: disable=unidiomatic-typecheck
if type(content_string) == inline:
htmlstr += '<img src="cid:{0}" title="{1}"/>'.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"])
Expand Down Expand Up @@ -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":
Expand Down Expand Up @@ -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

0 comments on commit ae89d97

Please sign in to comment.