Skip to content

Commit

Permalink
fix: TypeError on python < 3.10
Browse files Browse the repository at this point in the history
  • Loading branch information
Al-Taie committed Feb 9, 2022
1 parent 8218492 commit 070de7c
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 19 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,14 @@ mail.about()

#### Changelogs

> - 2022.2.2 update:
> - - Support Html Message
> - - Fix issue #1 TypeError on python < 3.10
> > 2022.2.10 update:
> - Fix issue #3 TypeError on python < 3.10
<br>

> > 2022.2.2 update:
> - Support Html Message
> - Fix issue #1 TypeError on python < 3.10
**Follow Me on Instagram: [@9_Tay](https://www.instagram.com/9_tay). 🌸**

Expand Down
Binary file added dist/quick-mailer-2022.2.10.tar.gz
Binary file not shown.
Binary file added dist/quick_mailer-2022.2.10-py3-none-any.whl
Binary file not shown.
15 changes: 10 additions & 5 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ The Module support **Gmail And Microsoft** right now, but in the nearly future w
pip install quick-mailer
```

[//]: # (**[-->> pypi Link]&#40;https://pypi.org/project/quick-mailer&#41;**)
**[-->> pypi Link](https://pypi.org/project/quick-mailer)**

**[-->> GitHub Link](https://github.com/Al-Taie/quick-mailer)**
[//]: # (**[-->> GitHub Link]&#40;https://github.com/Al-Taie/quick-mailer&#41;**)

# Usage:

Expand Down Expand Up @@ -134,9 +134,14 @@ mail.about()

#### Changelogs

> - 2022.2.2 update:
> - - Support Html Message
> - - Fix issue #1 TypeError on python < 3.10
> > 2022.2.10 update:
> - Fix issue #3 TypeError on python < 3.10
<br>

> > 2022.2.2 update:
> - Support Html Message
> - Fix issue #1 TypeError on python < 3.10
**Follow Me on Instagram: [@9_Tay](https://www.instagram.com/9_tay). 🌸**

Expand Down
2 changes: 1 addition & 1 deletion mailer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
from mailer.utils import example

__all__ = ['Mailer', '__VERSION__', 'example']
__VERSION__ = '2022.2.2'
__VERSION__ = '2022.2.10'
15 changes: 12 additions & 3 deletions mailer/send.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,28 @@ def __prepare_attachments(self,
if image is not None:
image_data: Union[bytes, bool] = file_reader(image)
# assert image_data, ImageNotFoundError()
assert image_data, ImageNotFoundError()

if not image_data:
raise ImageNotFoundError()

image = MIMEImage(_imagedata=image_data, name=image)
self._msg.attach(image)

if audio is not None:
audio_data: Union[bytes, bool] = file_reader(audio)
assert audio_data, AudioNotFoundError()

if not audio_data:
raise AudioNotFoundError()

audio = MIMEAudio(_audiodata=audio_data, name=audio, _subtype='')
self._msg.attach(audio)

if file is not None:
file_data: Union[bytes, bool] = file_reader(file)
assert file_data, FileNotFoundError("File not exists in a path!")

if not file_data:
raise FileNotFoundError("File not exists in a path!")

file = MIMEApp(_data=file_data, name=file)
self._msg.attach(file)

Expand Down
4 changes: 2 additions & 2 deletions mailer/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Text
from typing import Text, Union


def file_reader(filename: str) -> bytes | bool:
def file_reader(filename: str) -> Union[bytes, bool]:
try:
with open(filename, 'rb') as f:
return f.read()
Expand Down
15 changes: 11 additions & 4 deletions quick_mailer.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: quick-mailer
Version: 2022.2.2
Version: 2022.2.10
Summary: This Module help you to send fast Email.🌸
Home-page: https://github.com/Al-Taie/quick-mailer
Author: Ahmed Al-Taie
Expand Down Expand Up @@ -29,6 +29,7 @@ And you can attach **image, audio, and other files easily.**
The Module support **Gmail And Microsoft** right now, but in the nearly future will support other mail services.

# Installation:

```cmd
pip install quick-mailer
```
Expand All @@ -38,7 +39,9 @@ pip install quick-mailer
**[-->> GitHub Link](https://github.com/Al-Taie/quick-mailer)**

# Usage:

**Send Message**

```py
from mailer import Mailer

Expand Down Expand Up @@ -146,10 +149,14 @@ mail.about()
```

#### Changelogs
> > 2022.2.10 update:
> - Fix issue #3 TypeError on python < 3.10

<br>

> - 2022.2.2 update:
> - - Support Html Message
> - - Fix issue #1 TypeError on python < 3.10
> > 2022.2.2 update:
> - Support Html Message
> - Fix issue #1 TypeError on python < 3.10

**Follow Me on Instagram: [@9_Tay](https://www.instagram.com/9_tay). 🌸**

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Instagram: @9_Tay
# Mail: [email protected]
# Created Time: 2020-07-26 21:41:25
# Update Time: 2022-02-01 01:37:35
# Update Time: 2022-02-10 00:29:21
#############################################

from setuptools import setup, find_packages
Expand Down

0 comments on commit 070de7c

Please sign in to comment.