Skip to content

Commit

Permalink
Update docs and README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
dormant-user committed Oct 26, 2023
1 parent b010cb0 commit c09d598
Show file tree
Hide file tree
Showing 16 changed files with 69 additions and 50 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 Vignesh Sivanandha Rao
Copyright (c) 2020 Vignesh Rao

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ gitverse-release reverse -f release_notes.rst -t 'Release Notes'

## License & copyright

© Vignesh Sivanandha Rao
© Vignesh Rao

Licensed under the [MIT License][license]

Expand Down
4 changes: 2 additions & 2 deletions doc_generator/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
# -- Project information -----------------------------------------------------

project = 'Gmail Connector'
copyright = '2021, Vignesh Sivanandha Rao'
author = 'Vignesh Sivanandha Rao'
copyright = '2021, Vignesh Rao'
author = 'Vignesh Rao'

# -- General configuration ---------------------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions docs/README.html
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ <h3>Runbook<a class="headerlink" href="#runbook" title="Permalink to this headin
</section>
<section id="license-copyright">
<h2>License &amp; copyright<a class="headerlink" href="#license-copyright" title="Permalink to this heading"></a></h2>
<p>© Vignesh Sivanandha Rao</p>
<p>© Vignesh Rao</p>
<p>Licensed under the <a class="reference external" href="https://github.com/thevickypedia/gmail-connector/blob/master/LICENSE">MIT License</a></p>
</section>
</section>
Expand Down Expand Up @@ -347,7 +347,7 @@ <h3>Navigation</h3>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2021, Vignesh Sivanandha Rao.
&#169; Copyright 2021, Vignesh Rao.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 5.1.1.
</div>
</body>
Expand Down
2 changes: 1 addition & 1 deletion docs/_sources/README.md.txt
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ gitverse-release reverse -f release_notes.rst -t 'Release Notes'

## License & copyright

&copy; Vignesh Sivanandha Rao
&copy; Vignesh Rao

Licensed under the [MIT License][license]

Expand Down
2 changes: 1 addition & 1 deletion docs/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ <h3>Navigation</h3>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2021, Vignesh Sivanandha Rao.
&#169; Copyright 2021, Vignesh Rao.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 5.1.1.
</div>
</body>
Expand Down
46 changes: 28 additions & 18 deletions docs/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/py-modindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ <h3>Navigation</h3>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2021, Vignesh Sivanandha Rao.
&#169; Copyright 2021, Vignesh Rao.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 5.1.1.
</div>
</body>
Expand Down
2 changes: 1 addition & 1 deletion docs/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ <h3>Navigation</h3>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2021, Vignesh Sivanandha Rao.
&#169; Copyright 2021, Vignesh Rao.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 5.1.1.
</div>
</body>
Expand Down
2 changes: 1 addition & 1 deletion docs/searchindex.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion gmailconnector/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
from .validator.address import EmailAddress # noqa: F401
from .validator.validate_email import validate_email # noqa: F401

version = "1.0-beta"
version = "1.0"
6 changes: 3 additions & 3 deletions gmailconnector/read_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ReadEmail:
LOCAL_TIMEZONE = datetime.now(timezone.utc).astimezone().tzinfo

def __init__(self, **kwargs: 'Unpack[IngressConfig]'):
"""Initiates necessary args, creates a connection with Gmail host to read emails from the chosen folder.
"""Loads all the necessary args, creates a connection with Gmail host to read emails from the chosen folder.
Keyword Args:
gmail_user: Gmail username to authenticate SMTP lib.
Expand Down Expand Up @@ -61,7 +61,7 @@ def authenticate(self):
Returns:
Response:
A custom response class with properties: ok, status and body to the user.
A custom response object with properties: ok, status and body to the user.
"""
if self.mail is None:
return Response(dictionary={
Expand Down Expand Up @@ -213,7 +213,7 @@ def read_mail(self, messages: list or str, humanize_datetime: bool = False) -> G
Yields:
dict:
A custom response class with properties: ok, status and body to the user.
A custom response object with properties: ok, status and body to the user.
"""
for nm in messages[0].split():
dummy, data = self.mail.fetch(nm, '(RFC822)')
Expand Down
8 changes: 4 additions & 4 deletions gmailconnector/send_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ def validate_email(address: Union[str, list]) -> Union[str, list]:


class SendEmail:
"""Initiates Emailer object to email defined recipient from a defined sender with or without attachments.
"""Initiates Emailer object to send an email.
>>> SendEmail
"""

def __init__(self, **kwargs: 'Unpack[EgressConfig]'):
"""Initiates necessary args, creates a connection with Gmail host based on chosen encryption type.
"""Loads all the necessary args, creates a connection with Gmail host based on chosen encryption type.
Keyword Args:
gmail_user: Gmail username to authenticate SMTP lib.
Expand Down Expand Up @@ -68,7 +68,7 @@ def authenticate(self) -> Response:
Returns:
Response:
A custom response class with properties: ok, status and body to the user.
A custom response object with properties: ok, status and body to the user.
"""
if self.server is None:
return Response(dictionary={
Expand Down Expand Up @@ -189,7 +189,7 @@ def send_email(self, subject: str, recipient: Union[str, list],
Returns:
Response:
A custom response class with properties: ok, status and body to the user.
A custom response object with properties: ok, status and body to the user.
"""
recipient = validate_email(address=recipient)
cc = validate_email(address=cc) if cc else None
Expand Down
11 changes: 5 additions & 6 deletions gmailconnector/send_sms.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class SendSMS:
"""

def __init__(self, **kwargs: 'Unpack[EgressConfig]'):
"""Initiates necessary args, creates a connection with Gmail host based on chosen encryption type.
"""Loads all the necessary args, creates a connection with Gmail host based on chosen encryption type.
Keyword Args:
gmail_user: Gmail username to authenticate SMTP lib.
Expand Down Expand Up @@ -58,7 +58,7 @@ def authenticate(self) -> Response:
Returns:
Response:
A custom response class with properties: ok, status and body to the user.
A custom response object with properties: ok, status and body to the user.
"""
if self.server is None:
return Response(dictionary={
Expand Down Expand Up @@ -99,7 +99,7 @@ def send_sms(self,
subject: str = None,
sms_gateway: SMSGateway = None,
delete_sent: bool = False) -> Response:
"""Initiates a TLS connection and sends a text message through SMS gateway of destination number.
"""Initiates an SMTP connection and sends a text message through SMS gateway of destination number.
Args:
phone: Phone number.
Expand All @@ -112,14 +112,13 @@ def send_sms(self,
See Also:
- Encodes body of the message to `ascii` with `ignore` flag and then decodes it.
- This is done to ignore special characters (like °) without raising `UnicodeEncodeError`
- Validates the endpoint ``phone-number@sms-gateway`` before trying to send the SMS.
Notes:
Other flags that can be set includes `replace` and `xmlcharrefreplace`
Returns:
Response:
A custom response class with properties: ok, status and body to the user.
A custom response object with properties: ok, status and body to the user.
"""
if phone:
self.env.phone = phone
Expand All @@ -138,7 +137,7 @@ def send_sms(self,
raise ValueError(
f"\n\tcountry code should match the pattern {COUNTRY_CODE.pattern}"
)
body = f'\n\n{message}'.encode('ascii', 'ignore').decode('ascii')
body = f'\n{message}'.encode('ascii', 'ignore').decode('ascii')
subject = subject or f"Message from {self.env.gmail_user}"
if not self._authenticated:
status = self.authenticate
Expand Down
22 changes: 16 additions & 6 deletions gmailconnector/sms_deleter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,26 @@
from email.header import decode_header, make_header
from typing import Dict, Union

from .models.options import Folder


class DeleteSent:
"""Initiates DeleteSent object to delete the sent SMS email from SentItems.
"""Instantiate the DeleteSent object to delete the SMS email from SentItems.
>>> DeleteSent
"""

def __init__(self, **kwargs):
"""Instantiate the members from kwargs."""
"""Initiates keyword arguments and creates an SSL connection.
Keyword Args:
username: Gmail username to authenticate SMTP lib.
password: Gmail password to authenticate SMTP lib.
subject: Subject of the email to be deleted.
body: Body of the email to be deleted.
to: To address of the email to be deleted.
"""
self.username = kwargs.get('username')
self.password = kwargs.get('password')
self.subject = kwargs.get('subject')
Expand All @@ -24,16 +34,16 @@ def __init__(self, **kwargs):
self.create_ssl_connection()

def create_ssl_connection(self) -> None:
"""Create a connection using SSL encryption."""
"""Creates a connection using SSL encryption and selects the sent folder."""
try:
self.mail = imaplib.IMAP4_SSL('imap.gmail.com')
self.mail.login(user=self.username, password=self.password)
self.mail.list()
self.mail.select('"[Gmail]/Sent Mail"')
self.mail.select(Folder.sent)
except Exception as error:
self.error = error.__str__()

def thread_executor(self, item_id: bytes or str) -> Dict[str, str]:
def thread_executor(self, item_id: Union[bytes, str]) -> Dict[str, str]:
"""Gets invoked in multiple threads, to set the flag as ``Deleted`` for the message which was just sent.
Args:
Expand Down Expand Up @@ -61,7 +71,7 @@ def delete_sent(self) -> Union[Dict[str, str], None]:
Invokes ``thread_executor`` to sweep through sent items to delete the email.
Warnings:
Deletion time depends on the number of existing emails in the ``Sent`` folder.
Time taken for deletion depends on the number of existing emails in the ``Sent`` folder.
"""
if self.mail is None:
return
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "gmail-connector"
dynamic = ["version", "dependencies"]
description = "Python module to, send SMS, emails and read emails"
readme = "README.md"
authors = [{ name = "Vignesh Sivanandha Rao", email = "[email protected]" }]
authors = [{ name = "Vignesh Rao", email = "[email protected]" }]
license = { file = "LICENSE" }
classifiers = [
"Development Status :: 5 - Production/Stable",
Expand Down

0 comments on commit c09d598

Please sign in to comment.