diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fce71e0..eb18250 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -30,10 +30,11 @@ repos: - id: requirements-txt-fixer - id: trailing-whitespace - - repo: https://github.com/PyCQA/isort - rev: 5.12.0 + - repo: https://github.com/psf/black + rev: 22.3.0 hooks: - - id: isort + - id: black + exclude: doc_generator/ - repo: https://github.com/PyCQA/flake8 rev: 7.0.0 @@ -41,6 +42,12 @@ repos: - id: flake8 args: [-j8, '--ignore=F401,W503,E203,E501,F821,E306,E722,N812'] + - repo: https://github.com/PyCQA/isort + rev: 5.12.0 + hooks: + - id: isort + args: [--profile, black] + - repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt rev: 0.2.3 hooks: diff --git a/docs/genindex.html b/docs/genindex.html index ecc5a80..06c161f 100644 --- a/docs/genindex.html +++ b/docs/genindex.html @@ -53,7 +53,6 @@

Index

| M | N | O - | P | R | S | T @@ -413,24 +412,14 @@

O

-

P

- - -
-

R

    -
  • recipient (gmailconnector.models.config.EgressConfig attribute) +
  • ReadEmail (class in gmailconnector.read_email)
  • Response (class in gmailconnector.models.responder)
  • diff --git a/docs/index.html b/docs/index.html index fd9af22..6c1c7d0 100644 --- a/docs/index.html +++ b/docs/index.html @@ -61,7 +61,7 @@

    Welcome to Gmail Connector’s documentation!

    Send SMS

    -class gmailconnector.send_sms.SendSMS
    +class gmailconnector.send_sms.SendSMS(**kwargs: Unpack)

    Initiates Messenger object to send an SMS to a phone number using SMS gateway provided by the mobile carrier.

    >>> SendSMS
     
    @@ -201,7 +201,7 @@

    Welcome to Gmail Connector’s documentation!

    Send Email

    -class gmailconnector.send_email.SendEmail
    +class gmailconnector.send_email.SendEmail(**kwargs: Unpack)

    Initiates Emailer object to send an email.

    >>> SendEmail
     
    @@ -282,7 +282,7 @@

    Welcome to Gmail Connector’s documentation!
    -send_email(subject: str, recipient: Union[str, list], sender: str = 'GmailConnector', body: Optional[str] = None, html_body: Optional[str] = None, attachment: Optional[Union[str, list]] = None, filename: Optional[Union[str, list]] = None, custom_attachment: Optional[Dict[Union[str, PathLike], str]] = None, cc: Optional[Union[str, list]] = None, bcc: Optional[Union[str, list]] = None, fail_if_attach_fails: bool = True) Response
    +send_email(subject: str, recipient: Union[str, list], sender: str = 'GmailConnector', body: str = None, html_body: str = None, attachment: Union[str, list] = None, filename: Union[str, list] = None, custom_attachment: Dict[Union[str, PathLike], str] = None, cc: Union[str, list] = None, bcc: Union[str, list] = None, fail_if_attach_fails: bool = True) Response

    Initiates a TLS connection and sends the email.

    Parameters:
    @@ -322,7 +322,7 @@

    Welcome to Gmail Connector’s documentation!

    Read Email

    -class gmailconnector.read_email.ReadEmail
    +class gmailconnector.read_email.ReadEmail(**kwargs: Unpack)

    Initiates Emailer object to authenticate and yield the emails according the conditions/filters.

    >>> ReadEmail
     
    @@ -430,7 +430,7 @@

    Welcome to Gmail Connector’s documentation!

    Validator

    -gmailconnector.validator.validate_email.validate_email(email_address: str, timeout: ~typing.Union[int, float] = 5, sender: ~typing.Optional[str] = None, debug: bool = False, smtp_check: bool = True, logger: ~logging.Logger = <Logger validator (DEBUG)>) Response
    +gmailconnector.validator.validate_email.validate_email(email_address: str, timeout: ~typing.Union[int, float] = 5, sender: str = None, debug: bool = False, smtp_check: bool = True, logger: ~logging.Logger = <Logger validator (DEBUG)>) Response

    Validates email address deliver-ability using SMTP.

    Parameters:
    @@ -556,7 +556,7 @@

    Welcome to Gmail Connector’s documentation!

    Models - Config

    -class gmailconnector.models.config.EgressConfig(_case_sensitive: bool | None = None, _env_prefix: str | None = None, _env_file: DotenvType | None = PosixPath('.'), _env_file_encoding: str | None = None, _env_nested_delimiter: str | None = None, _secrets_dir: str | Path | None = None, *, gmail_user: EmailStr, gmail_pass: str, recipient: Optional[EmailStr] = None, phone: Optional[str] = None, gmail_host: str = 'smtp.gmail.com', encryption: Encryption = Encryption.TLS, timeout: int = 10, **values: Any)
    +class gmailconnector.models.config.EgressConfig(_case_sensitive: bool | None = None, _env_prefix: str | None = None, _env_file: DotenvType | None = PosixPath('.'), _env_file_encoding: str | None = None, _env_nested_delimiter: str | None = None, _secrets_dir: str | Path | None = None, *, gmail_user: EmailStr, gmail_pass: str, gmail_host: str = 'smtp.gmail.com', encryption: Encryption = Encryption.TLS, timeout: int = 10, **values: Any)

    Configure arguments for SendEmail/SendSMS and validate using pydantic to share across modules.

    >>> EgressConfig
     
    @@ -615,22 +615,12 @@

    Welcome to Gmail Connector’s documentation!
    -model_fields: ClassVar[dict[str, FieldInfo]] = {'encryption': FieldInfo(annotation=Encryption, required=False, default=<Encryption.TLS: 'TLS'>), 'gmail_host': FieldInfo(annotation=str, required=False, default='smtp.gmail.com'), 'gmail_pass': FieldInfo(annotation=str, required=True), 'gmail_user': FieldInfo(annotation=EmailStr, required=True), 'phone': FieldInfo(annotation=Union[str, NoneType], required=False, metadata=[PydanticGeneralMetadata(pattern='\\d{10}$')]), 'recipient': FieldInfo(annotation=Union[EmailStr, NoneType], required=False), 'timeout': FieldInfo(annotation=int, required=False, default=10)}
    +model_fields: ClassVar[dict[str, FieldInfo]] = {'encryption': FieldInfo(annotation=Encryption, required=False, default=<Encryption.TLS: 'TLS'>), 'gmail_host': FieldInfo(annotation=str, required=False, default='smtp.gmail.com'), 'gmail_pass': FieldInfo(annotation=str, required=True), 'gmail_user': FieldInfo(annotation=EmailStr, required=True), 'timeout': FieldInfo(annotation=int, required=False, default=10)}

    Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

    This replaces Model.__fields__ from Pydantic V1.

    -
    -
    -phone: Optional[str]
    -
    - -
    -
    -recipient: Optional[EmailStr]
    -
    -
    timeout: int
    @@ -640,7 +630,7 @@

    Welcome to Gmail Connector’s documentation!
    -class gmailconnector.models.config.Encryption(value)
    +class gmailconnector.models.config.Encryption(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

    Enum wrapper for TLS and SSL encryption.

    >>> Encryption
     
    @@ -856,7 +846,7 @@

    Welcome to Gmail Connector’s documentation!
    -class gmailconnector.models.options.Folder(value)
    +class gmailconnector.models.options.Folder(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

    Wrapper for folders to choose emails from.

    diff --git a/docs/objects.inv b/docs/objects.inv index 08f2939..767faa3 100644 Binary files a/docs/objects.inv and b/docs/objects.inv differ diff --git a/docs/searchindex.js b/docs/searchindex.js index 8311d60..5bfd164 100644 --- a/docs/searchindex.js +++ b/docs/searchindex.js @@ -1 +1 @@ -Search.setIndex({"docnames": ["README", "index"], "filenames": ["README.md", "index.rst"], "titles": ["Gmail Connector", "Welcome to Gmail Connector\u2019s documentation!"], "terms": {"python": 0, "ani": [0, 1], "folder": [0, 1], "As": 0, "mai": 0, "30": 0, "2022": 0, "googl": 0, "longer": 0, "support": 0, "third": 0, "parti": 0, "applic": 0, "access": [0, 1], "account": 0, "onli": [0, 1], "us": [0, 1], "usernam": [0, 1], "password": [0, 1], "which": [0, 1], "wa": [0, 1], "origin": 0, "avail": [0, 1], "through": [0, 1], "lesssecureapp": 0, "an": [0, 1], "altern": 0, "approach": 0, "i": [0, 1], "gener": [0, 1], "apppassword": 0, "instead": [0, 1], "refer": [0, 1], "http": [0, 1], "com": [0, 1], "answer": [0, 1], "6010255": 0, "pip": 0, "environ": [0, 1], "variabl": [0, 1], "can": [0, 1], "load": [0, 1], "from": [0, 1], "file": [0, 1], "gmail_us": [0, 1], "gmail_pass": [0, 1], "account_password": 0, "custom": [0, 1], "To": [0, 1], "set": [0, 1], "filenam": [0, 1], "env_fil": [0, 1], "befor": 0, "import": [0, 1], "gmailconnector": [0, 1], "o": 0, "avoid": 0, "argument": [0, 1], "dure": [0, 1], "object": [0, 1], "instanti": [0, 1], "gc": 0, "kwarg": [0, 1], "dict": [0, 1], "email_address": [0, 1], "encrypt": [0, 1], "ssl": [0, 1], "timeout": [0, 1], "5": [0, 1], "email_obj": 0, "sendemail": [0, 1], "sms_object": 0, "sendsm": [0, 1], "auth": 0, "authent": [0, 1], "happen": 0, "separ": 0, "assert": 0, "ok": [0, 1], "bodi": [0, 1], "respons": [0, 1], "send_sm": [0, 1], "phone": [0, 1], "1234567890": 0, "country_cod": [0, 1], "1": [0, 1], "messag": [0, 1], "test": 0, "sms_gatewai": [0, 1], "smsgatewai": 0, "verizon": [0, 1], "delete_s": [0, 1], "true": [0, 1], "fals": [0, 1], "keep": 0, "sent": 0, "json": [0, 1], "print": 0, "more": [0, 1], "warn": 0, "": 0, "gatewai": [0, 1], "ha": [0, 1], "payload": 0, "limit": 0, "so": [0, 1], "recommend": 0, "break": 0, "larger": 0, "multipl": [0, 1], "subject": [0, 1], "default": [0, 1], "address": 0, "_": 0, "carrier": [0, 1], "tmomail": [0, 1], "net": [0, 1], "delet": 0, "boolean": [0, 1], "flag": [0, 1], "outbound": 0, "sentitem": [0, 1], "If": 0, "known": 0, "ensur": 0, "proper": 0, "deliveri": 0, "mail_object": 0, "send_email": [0, 1], "beforehand": 0, "basic": 0, "recipi": [0, 1], "howdi": 0, "verifi": 0, "requir": [0, 1], "smtp": [0, 1], "port": [0, 1], "25": [0, 1], "validation_result": 0, "validate_email": [0, 1], "someon": 0, "exampl": 0, "valid": 0, "found": 0, "elif": 0, "invalid": [0, 1], "els": 0, "incomplet": 0, "couldn": 0, "t": 0, "mostli": 0, "becaus": 0, "block": [0, 1], "isp": 0, "differ": 0, "case": 0, "add": [0, 1], "attach": [0, 1], "without": [0, 1], "imag": 0, "path": [0, 1], "join": 0, "getcwd": 0, "listdir": 0, "name": [0, 1], "appl": 0, "flower": 0, "balloon": 0, "2": [0, 1], "dictionari": [0, 1], "custom_attach": [0, 1], "zip": 0, "3": 0, "list": [0, 1], "4": 0, "singl": 0, "random_apple_xroamutiypa": 0, "jpeg": 0, "blank": 0, "html": [0, 1], "format": [0, 1], "inlin": 0, "public": 0, "src": 0, "itself": [0, 1], "sender": [0, 1], "cc": [0, 1], "whom": [0, 1], "d": [0, 1], "bcc": [0, 1], "than": [0, 1], "one": 0, "wrap": 0, "username1": 0, "username2": 0, "datetim": [0, 1], "reader": 0, "reademail": [0, 1], "all": [0, 1], "filter1": 0, "condit": [0, 1], "sinc": [0, 1], "date": [0, 1], "year": 0, "2010": 0, "month": 0, "dai": 0, "filter2": 0, "secur": 0, "alert": 0, "filter3": 0, "text": [0, 1], "filter4": 0, "categori": [0, 1], "not_delet": [0, 1], "filter": [0, 1], "appli": 0, "each_mail": 0, "read_mail": [0, 1], "humanize_datetim": [0, 1], "get": [0, 1], "date_tim": 0, "sender_email": 0, "precommit": 0, "doc": 0, "creation": 0, "ar": 0, "run": 0, "everi": 0, "commit": 0, "sphinx": 0, "pre": 0, "20": 0, "0": [0, 1], "recommonmark": 0, "7": 0, "m": 0, "gitvers": 0, "revers": 0, "f": 0, "release_not": 0, "rst": 0, "org": 0, "project": 0, "thevickypedia": 0, "github": 0, "io": [0, 1], "vignesh": 0, "rao": 0, "under": 0, "mit": 0, "instal": 1, "env": 1, "var": 1, "usag": 1, "licens": 1, "copyright": 1, "class": 1, "initi": 1, "messeng": 1, "number": 1, "provid": 1, "mobil": 1, "necessari": 1, "arg": 1, "creat": 1, "connect": 1, "host": 1, "base": 1, "chosen": 1, "type": 1, "keyword": 1, "lib": 1, "gmail_host": 1, "hostnam": 1, "server": 1, "properti": 1, "return": 1, "A": 1, "statu": 1, "user": 1, "create_ssl_connect": 1, "str": 1, "union": 1, "int": 1, "float": 1, "none": 1, "create_tls_connect": 1, "tl": 1, "smsgatewaymodel": 1, "att": 1, "mm": 1, "tmobil": 1, "vtext": 1, "boost": 1, "smsmyboostmobil": 1, "cricket": 1, "cricketwireless": 1, "uscellular": 1, "uscc": 1, "bool": 1, "destin": 1, "paramet": 1, "content": 1, "countri": 1, "code": 1, "line": 1, "take": 1, "item": 1, "encod": 1, "ascii": 1, "ignor": 1, "decod": 1, "thi": 1, "done": 1, "special": 1, "charact": 1, "like": 1, "rais": 1, "unicodeencodeerror": 1, "note": 1, "other": 1, "includ": 1, "replac": 1, "xmlcharrefreplac": 1, "sms_delet": 1, "deletes": 1, "select": 1, "right": 1, "after": 1, "invok": 1, "thread_executor": 1, "sweep": 1, "time": 1, "taken": 1, "depend": 1, "exist": 1, "item_id": 1, "byte": 1, "thread": 1, "just": 1, "id": 1, "create_connect": 1, "request": 1, "multipart_messag": 1, "html_bodi": 1, "mimemultipart": 1, "multipart": 1, "pass": 1, "given": 1, "version": 1, "pathlik": 1, "fail_if_attach_fail": 1, "filepath": 1, "kei": 1, "valu": 1, "restrict": 1, "fail": 1, "them": 1, "read_email": 1, "yield": 1, "accord": 1, "where": 1, "have": 1, "imapcli": 1, "readthedoc": 1, "en": 1, "_modul": 1, "xlist_fold": 1, "broad": 1, "claus": 1, "catch": 1, "login": 1, "error": 1, "same": 1, "imaplib": 1, "get_info": 1, "response_part": 1, "tupl": 1, "dt_flag": 1, "extract": 1, "receiv": 1, "part": 1, "whether": 1, "convert": 1, "human": 1, "readabl": 1, "inform": 1, "iter": 1, "__str__": 1, "unseen": 1, "search": 1, "form": 1, "api": 1, "contain": 1, "match": 1, "criteria": 1, "method": 1, "debug": 1, "smtp_check": 1, "logger": 1, "log": 1, "deliv": 1, "abil": 1, "second": 1, "wait": 1, "result": 1, "enabl": 1, "check": 1, "bring": 1, "your": 1, "own": 1, "clearli": 1, "mx": 1, "record": 1, "temporari": 1, "emailaddress": 1, "validateaddress": 1, "split": 1, "domin": 1, "further": 1, "idna": 1, "internation": 1, "string": 1, "ipv4address": 1, "ipv6address": 1, "get_mx_record": 1, "mail": 1, "exchang": 1, "fqdn": 1, "fulli": 1, "qualifi": 1, "ip": 1, "authorit": 1, "non": 1, "section": 1, "addressformaterror": 1, "invaliddomain": 1, "notmailserv": 1, "unresponsivemailserv": 1, "unrespons": 1, "egressconfig": 1, "_case_sensit": 1, "_env_prefix": 1, "_env_fil": 1, "dotenvtyp": 1, "posixpath": 1, "_env_file_encod": 1, "_env_nested_delimit": 1, "_secrets_dir": 1, "emailstr": 1, "10": 1, "configur": 1, "pydant": 1, "share": 1, "across": 1, "modul": 1, "new": 1, "pars": 1, "input": 1, "data": 1, "validationerror": 1, "pydantic_cor": 1, "cannot": 1, "__init__": 1, "__pydantic_self__": 1, "common": 1, "self": 1, "first": 1, "allow": 1, "field": 1, "env_prefix": 1, "extra": 1, "model_config": 1, "classvar": 1, "settingsconfigdict": 1, "arbitrary_types_allow": 1, "case_sensit": 1, "env_file_encod": 1, "env_nested_delimit": 1, "protected_namespac": 1, "model_": 1, "settings_": 1, "secrets_dir": 1, "validate_default": 1, "should": 1, "conform": 1, "configdict": 1, "model_field": 1, "fieldinfo": 1, "annot": 1, "nonetyp": 1, "metadata": 1, "pydanticgeneralmetadata": 1, "pattern": 1, "about": 1, "defin": 1, "map": 1, "__fields__": 1, "v1": 1, "enum": 1, "wrapper": 1, "ingressconfig": 1, "inbox": 1, "imap": 1, "while": 1, "NOT": 1, "seen": 1, "static": 1, "retriev": 1, "small": 1, "size": 1, "smaller": 1, "particular": 1, "present": 1, "choos": 1, "draft": 1, "spam": 1, "star": 1, "trash": 1, "turn": 1, "insert": 1, "pair": 1, "member": 1, "count": 1, "un": 1, "index": 1, "page": 1}, "objects": {"gmailconnector.models": [[1, 0, 0, "-", "config"], [1, 0, 0, "-", "options"], [1, 0, 0, "-", "responder"]], "gmailconnector.models.config": [[1, 1, 1, "", "EgressConfig"], [1, 1, 1, "", "Encryption"], [1, 1, 1, "", "IngressConfig"], [1, 1, 1, "", "SMSGatewayModel"]], "gmailconnector.models.config.EgressConfig": [[1, 1, 1, "", "Config"], [1, 2, 1, "", "encryption"], [1, 2, 1, "", "gmail_host"], [1, 2, 1, "", "gmail_pass"], [1, 2, 1, "", "gmail_user"], [1, 2, 1, "", "model_config"], [1, 2, 1, "", "model_fields"], [1, 2, 1, "", "phone"], [1, 2, 1, "", "recipient"], [1, 2, 1, "", "timeout"]], "gmailconnector.models.config.EgressConfig.Config": [[1, 2, 1, "", "env_file"], [1, 2, 1, "", "env_prefix"], [1, 2, 1, "", "extra"]], "gmailconnector.models.config.Encryption": [[1, 2, 1, "", "SSL"], [1, 2, 1, "", "TLS"]], "gmailconnector.models.config.IngressConfig": [[1, 1, 1, "", "Config"], [1, 2, 1, "", "folder"], [1, 2, 1, "", "gmail_host"], [1, 2, 1, "", "gmail_pass"], [1, 2, 1, "", "gmail_user"], [1, 2, 1, "", "model_config"], [1, 2, 1, "", "model_fields"], [1, 2, 1, "", "timeout"]], "gmailconnector.models.config.IngressConfig.Config": [[1, 2, 1, "", "env_file"], [1, 2, 1, "", "env_prefix"], [1, 2, 1, "", "extra"]], "gmailconnector.models.config.SMSGatewayModel": [[1, 2, 1, "", "att"], [1, 2, 1, "", "boost"], [1, 2, 1, "", "cricket"], [1, 2, 1, "", "model_config"], [1, 2, 1, "", "model_fields"], [1, 2, 1, "", "tmobile"], [1, 2, 1, "", "uscellular"], [1, 2, 1, "", "verizon"]], "gmailconnector.models.options": [[1, 1, 1, "", "Category"], [1, 1, 1, "", "Condition"], [1, 1, 1, "", "Folder"]], "gmailconnector.models.options.Category": [[1, 2, 1, "", "all"], [1, 2, 1, "", "flagged"], [1, 2, 1, "", "not_deleted"], [1, 2, 1, "", "seen"], [1, 2, 1, "", "unseen"]], "gmailconnector.models.options.Condition": [[1, 3, 1, "", "since"], [1, 3, 1, "", "small"], [1, 3, 1, "", "subject"], [1, 3, 1, "", "text"]], "gmailconnector.models.options.Folder": [[1, 2, 1, "", "all"], [1, 2, 1, "", "drafts"], [1, 2, 1, "", "important"], [1, 2, 1, "", "inbox"], [1, 2, 1, "", "sent"], [1, 2, 1, "", "spam"], [1, 2, 1, "", "starred"], [1, 2, 1, "", "trash"]], "gmailconnector.models.responder": [[1, 1, 1, "", "Email"], [1, 1, 1, "", "Response"]], "gmailconnector.models.responder.Response": [[1, 4, 1, "", "body"], [1, 4, 1, "", "count"], [1, 4, 1, "", "extra"], [1, 3, 1, "", "json"], [1, 4, 1, "", "ok"], [1, 4, 1, "", "status"]], "gmailconnector": [[1, 0, 0, "-", "read_email"], [1, 0, 0, "-", "send_email"], [1, 0, 0, "-", "send_sms"], [1, 0, 0, "-", "sms_deleter"]], "gmailconnector.read_email": [[1, 1, 1, "", "ReadEmail"]], "gmailconnector.read_email.ReadEmail": [[1, 4, 1, "", "authenticate"], [1, 3, 1, "", "create_ssl_connection"], [1, 3, 1, "", "get_info"], [1, 3, 1, "", "instantiate"], [1, 3, 1, "", "read_mail"]], "gmailconnector.send_email": [[1, 1, 1, "", "SendEmail"], [1, 5, 1, "", "validate_email"]], "gmailconnector.send_email.SendEmail": [[1, 4, 1, "", "authenticate"], [1, 3, 1, "", "create_connection"], [1, 3, 1, "", "create_ssl_connection"], [1, 3, 1, "", "create_tls_connection"], [1, 3, 1, "", "multipart_message"], [1, 3, 1, "", "send_email"]], "gmailconnector.send_sms": [[1, 1, 1, "", "SendSMS"]], "gmailconnector.send_sms.SendSMS": [[1, 4, 1, "", "authenticate"], [1, 3, 1, "", "create_ssl_connection"], [1, 3, 1, "", "create_tls_connection"], [1, 3, 1, "", "send_sms"]], "gmailconnector.sms_deleter": [[1, 1, 1, "", "DeleteSent"]], "gmailconnector.sms_deleter.DeleteSent": [[1, 3, 1, "", "create_ssl_connection"], [1, 3, 1, "", "delete_sent"], [1, 3, 1, "", "thread_executor"]], "gmailconnector.validator": [[1, 0, 0, "-", "address"], [1, 0, 0, "-", "domain"], [1, 0, 0, "-", "exceptions"], [1, 0, 0, "-", "validate_email"]], "gmailconnector.validator.address": [[1, 1, 1, "", "EmailAddress"]], "gmailconnector.validator.address.EmailAddress": [[1, 4, 1, "", "domain"], [1, 4, 1, "", "email"], [1, 4, 1, "", "user"]], "gmailconnector.validator.domain": [[1, 5, 1, "", "get_mx_records"]], "gmailconnector.validator.exceptions": [[1, 6, 1, "", "AddressFormatError"], [1, 6, 1, "", "InvalidDomain"], [1, 6, 1, "", "NotMailServer"], [1, 6, 1, "", "UnresponsiveMailServer"]], "gmailconnector.validator.validate_email": [[1, 5, 1, "", "validate_email"]]}, "objtypes": {"0": "py:module", "1": "py:class", "2": "py:attribute", "3": "py:method", "4": "py:property", "5": "py:function", "6": "py:exception"}, "objnames": {"0": ["py", "module", "Python module"], "1": ["py", "class", "Python class"], "2": ["py", "attribute", "Python attribute"], "3": ["py", "method", "Python method"], "4": ["py", "property", "Python property"], "5": ["py", "function", "Python function"], "6": ["py", "exception", "Python exception"]}, "titleterms": {"gmail": [0, 1], "connector": [0, 1], "instal": 0, "env": 0, "var": 0, "usag": 0, "send": [0, 1], "sm": [0, 1], "addit": 0, "arg": 0, "email": [0, 1], "read": [0, 1], "lint": 0, "releas": 0, "note": 0, "pypi": 0, "modul": 0, "runbook": 0, "licens": 0, "copyright": 0, "welcom": 1, "": 1, "document": 1, "me": 1, "delet": 1, "sent": 1, "valid": 1, "address": 1, "domain": 1, "except": 1, "model": 1, "config": 1, "option": 1, "respond": 1, "indic": 1, "tabl": 1}, "envversion": {"sphinx.domains.c": 2, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 6, "sphinx.domains.index": 1, "sphinx.domains.javascript": 2, "sphinx.domains.math": 2, "sphinx.domains.python": 3, "sphinx.domains.rst": 2, "sphinx.domains.std": 2, "sphinx": 56}}) \ No newline at end of file +Search.setIndex({"docnames": ["README", "index"], "filenames": ["README.md", "index.rst"], "titles": ["Gmail Connector", "Welcome to Gmail Connector\u2019s documentation!"], "terms": {"python": 0, "ani": [0, 1], "folder": [0, 1], "As": 0, "mai": 0, "30": 0, "2022": 0, "googl": 0, "longer": 0, "support": 0, "third": 0, "parti": 0, "applic": 0, "access": [0, 1], "account": 0, "onli": [0, 1], "us": [0, 1], "usernam": [0, 1], "password": [0, 1], "which": [0, 1], "wa": [0, 1], "origin": 0, "avail": [0, 1], "through": [0, 1], "lesssecureapp": 0, "an": [0, 1], "altern": 0, "approach": 0, "i": [0, 1], "gener": [0, 1], "apppassword": 0, "instead": [0, 1], "refer": [0, 1], "http": [0, 1], "com": [0, 1], "answer": [0, 1], "6010255": 0, "pip": 0, "environ": [0, 1], "variabl": [0, 1], "can": [0, 1], "load": [0, 1], "from": [0, 1], "file": [0, 1], "gmail_us": [0, 1], "gmail_pass": [0, 1], "account_password": 0, "custom": [0, 1], "To": [0, 1], "set": [0, 1], "filenam": [0, 1], "env_fil": [0, 1], "befor": 0, "import": [0, 1], "gmailconnector": [0, 1], "o": 0, "avoid": 0, "argument": [0, 1], "dure": [0, 1], "object": [0, 1], "instanti": [0, 1], "gc": 0, "kwarg": [0, 1], "dict": [0, 1], "email_address": [0, 1], "encrypt": [0, 1], "ssl": [0, 1], "timeout": [0, 1], "5": [0, 1], "email_obj": 0, "sendemail": [0, 1], "sms_object": 0, "sendsm": [0, 1], "auth": 0, "authent": [0, 1], "happen": 0, "separ": 0, "assert": 0, "ok": [0, 1], "bodi": [0, 1], "respons": [0, 1], "send_sm": [0, 1], "phone": [0, 1], "1234567890": 0, "country_cod": [0, 1], "1": [0, 1], "messag": [0, 1], "test": 0, "sms_gatewai": [0, 1], "smsgatewai": 0, "verizon": [0, 1], "delete_s": [0, 1], "true": [0, 1], "fals": [0, 1], "keep": 0, "sent": 0, "json": [0, 1], "print": 0, "more": [0, 1], "warn": 0, "": 0, "gatewai": [0, 1], "ha": [0, 1], "payload": 0, "limit": 0, "so": [0, 1], "recommend": 0, "break": 0, "larger": 0, "multipl": [0, 1], "subject": [0, 1], "default": [0, 1], "address": 0, "_": 0, "carrier": [0, 1], "tmomail": [0, 1], "net": [0, 1], "delet": 0, "boolean": [0, 1], "flag": [0, 1], "outbound": 0, "sentitem": [0, 1], "If": 0, "known": 0, "ensur": 0, "proper": 0, "deliveri": 0, "mail_object": 0, "send_email": [0, 1], "beforehand": 0, "basic": 0, "recipi": [0, 1], "howdi": 0, "verifi": 0, "requir": [0, 1], "smtp": [0, 1], "port": [0, 1], "25": [0, 1], "validation_result": 0, "validate_email": [0, 1], "someon": 0, "exampl": 0, "valid": 0, "found": 0, "elif": 0, "invalid": [0, 1], "els": 0, "incomplet": 0, "couldn": 0, "t": 0, "mostli": 0, "becaus": 0, "block": [0, 1], "isp": 0, "differ": 0, "case": 0, "add": [0, 1], "attach": [0, 1], "without": [0, 1], "imag": 0, "path": [0, 1], "join": 0, "getcwd": 0, "listdir": 0, "name": [0, 1], "appl": 0, "flower": 0, "balloon": 0, "2": [0, 1], "dictionari": [0, 1], "custom_attach": [0, 1], "zip": 0, "3": 0, "list": [0, 1], "4": 0, "singl": 0, "random_apple_xroamutiypa": 0, "jpeg": 0, "blank": 0, "html": [0, 1], "format": [0, 1], "inlin": 0, "public": 0, "src": 0, "itself": [0, 1], "sender": [0, 1], "cc": [0, 1], "whom": [0, 1], "d": [0, 1], "bcc": [0, 1], "than": [0, 1], "one": 0, "wrap": 0, "username1": 0, "username2": 0, "datetim": [0, 1], "reader": 0, "reademail": [0, 1], "all": [0, 1], "filter1": 0, "condit": [0, 1], "sinc": [0, 1], "date": [0, 1], "year": 0, "2010": 0, "month": 0, "dai": 0, "filter2": 0, "secur": 0, "alert": 0, "filter3": 0, "text": [0, 1], "filter4": 0, "categori": [0, 1], "not_delet": [0, 1], "filter": [0, 1], "appli": 0, "each_mail": 0, "read_mail": [0, 1], "humanize_datetim": [0, 1], "get": [0, 1], "date_tim": 0, "sender_email": 0, "precommit": 0, "doc": 0, "creation": 0, "ar": 0, "run": 0, "everi": 0, "commit": 0, "sphinx": 0, "pre": 0, "20": 0, "0": [0, 1], "recommonmark": 0, "7": 0, "m": 0, "gitvers": 0, "revers": 0, "f": 0, "release_not": 0, "rst": 0, "org": 0, "project": 0, "thevickypedia": 0, "github": 0, "io": [0, 1], "vignesh": 0, "rao": 0, "under": 0, "mit": 0, "instal": 1, "env": 1, "var": 1, "usag": 1, "licens": 1, "copyright": 1, "class": 1, "unpack": 1, "initi": 1, "messeng": 1, "number": 1, "provid": 1, "mobil": 1, "necessari": 1, "arg": 1, "creat": 1, "connect": 1, "host": 1, "base": 1, "chosen": 1, "type": 1, "keyword": 1, "lib": 1, "gmail_host": 1, "hostnam": 1, "server": 1, "properti": 1, "return": 1, "A": 1, "statu": 1, "user": 1, "create_ssl_connect": 1, "str": 1, "union": 1, "int": 1, "float": 1, "none": 1, "create_tls_connect": 1, "tl": 1, "smsgatewaymodel": 1, "att": 1, "mm": 1, "tmobil": 1, "vtext": 1, "boost": 1, "smsmyboostmobil": 1, "cricket": 1, "cricketwireless": 1, "uscellular": 1, "uscc": 1, "bool": 1, "destin": 1, "paramet": 1, "content": 1, "countri": 1, "code": 1, "line": 1, "take": 1, "item": 1, "encod": 1, "ascii": 1, "ignor": 1, "decod": 1, "thi": 1, "done": 1, "special": 1, "charact": 1, "like": 1, "rais": 1, "unicodeencodeerror": 1, "note": 1, "other": 1, "includ": 1, "replac": 1, "xmlcharrefreplac": 1, "sms_delet": 1, "deletes": 1, "select": 1, "right": 1, "after": 1, "invok": 1, "thread_executor": 1, "sweep": 1, "time": 1, "taken": 1, "depend": 1, "exist": 1, "item_id": 1, "byte": 1, "thread": 1, "just": 1, "id": 1, "create_connect": 1, "request": 1, "multipart_messag": 1, "html_bodi": 1, "mimemultipart": 1, "multipart": 1, "pass": 1, "given": 1, "version": 1, "pathlik": 1, "fail_if_attach_fail": 1, "filepath": 1, "kei": 1, "valu": 1, "restrict": 1, "fail": 1, "them": 1, "read_email": 1, "yield": 1, "accord": 1, "where": 1, "have": 1, "imapcli": 1, "readthedoc": 1, "en": 1, "_modul": 1, "xlist_fold": 1, "broad": 1, "claus": 1, "catch": 1, "login": 1, "error": 1, "same": 1, "imaplib": 1, "get_info": 1, "response_part": 1, "tupl": 1, "dt_flag": 1, "extract": 1, "receiv": 1, "part": 1, "whether": 1, "convert": 1, "human": 1, "readabl": 1, "inform": 1, "iter": 1, "__str__": 1, "unseen": 1, "search": 1, "form": 1, "api": 1, "contain": 1, "match": 1, "criteria": 1, "method": 1, "debug": 1, "smtp_check": 1, "logger": 1, "log": 1, "deliv": 1, "abil": 1, "second": 1, "wait": 1, "result": 1, "enabl": 1, "check": 1, "bring": 1, "your": 1, "own": 1, "clearli": 1, "mx": 1, "record": 1, "temporari": 1, "emailaddress": 1, "validateaddress": 1, "split": 1, "domin": 1, "further": 1, "idna": 1, "internation": 1, "string": 1, "ipv4address": 1, "ipv6address": 1, "get_mx_record": 1, "mail": 1, "exchang": 1, "fqdn": 1, "fulli": 1, "qualifi": 1, "ip": 1, "authorit": 1, "non": 1, "section": 1, "addressformaterror": 1, "invaliddomain": 1, "notmailserv": 1, "unresponsivemailserv": 1, "unrespons": 1, "egressconfig": 1, "_case_sensit": 1, "_env_prefix": 1, "_env_fil": 1, "dotenvtyp": 1, "posixpath": 1, "_env_file_encod": 1, "_env_nested_delimit": 1, "_secrets_dir": 1, "emailstr": 1, "10": 1, "configur": 1, "pydant": 1, "share": 1, "across": 1, "modul": 1, "new": 1, "pars": 1, "input": 1, "data": 1, "validationerror": 1, "pydantic_cor": 1, "cannot": 1, "__init__": 1, "__pydantic_self__": 1, "common": 1, "self": 1, "first": 1, "allow": 1, "field": 1, "env_prefix": 1, "extra": 1, "model_config": 1, "classvar": 1, "settingsconfigdict": 1, "arbitrary_types_allow": 1, "case_sensit": 1, "env_file_encod": 1, "env_nested_delimit": 1, "protected_namespac": 1, "model_": 1, "settings_": 1, "secrets_dir": 1, "validate_default": 1, "should": 1, "conform": 1, "configdict": 1, "model_field": 1, "fieldinfo": 1, "annot": 1, "metadata": 1, "about": 1, "defin": 1, "map": 1, "__fields__": 1, "v1": 1, "qualnam": 1, "start": 1, "boundari": 1, "enum": 1, "wrapper": 1, "ingressconfig": 1, "inbox": 1, "imap": 1, "while": 1, "NOT": 1, "seen": 1, "static": 1, "retriev": 1, "small": 1, "size": 1, "smaller": 1, "particular": 1, "present": 1, "choos": 1, "draft": 1, "spam": 1, "star": 1, "trash": 1, "turn": 1, "insert": 1, "pair": 1, "member": 1, "count": 1, "un": 1, "index": 1, "page": 1}, "objects": {"gmailconnector.models": [[1, 0, 0, "-", "config"], [1, 0, 0, "-", "options"], [1, 0, 0, "-", "responder"]], "gmailconnector.models.config": [[1, 1, 1, "", "EgressConfig"], [1, 1, 1, "", "Encryption"], [1, 1, 1, "", "IngressConfig"], [1, 1, 1, "", "SMSGatewayModel"]], "gmailconnector.models.config.EgressConfig": [[1, 1, 1, "", "Config"], [1, 2, 1, "", "encryption"], [1, 2, 1, "", "gmail_host"], [1, 2, 1, "", "gmail_pass"], [1, 2, 1, "", "gmail_user"], [1, 2, 1, "", "model_config"], [1, 2, 1, "", "model_fields"], [1, 2, 1, "", "timeout"]], "gmailconnector.models.config.EgressConfig.Config": [[1, 2, 1, "", "env_file"], [1, 2, 1, "", "env_prefix"], [1, 2, 1, "", "extra"]], "gmailconnector.models.config.Encryption": [[1, 2, 1, "", "SSL"], [1, 2, 1, "", "TLS"]], "gmailconnector.models.config.IngressConfig": [[1, 1, 1, "", "Config"], [1, 2, 1, "", "folder"], [1, 2, 1, "", "gmail_host"], [1, 2, 1, "", "gmail_pass"], [1, 2, 1, "", "gmail_user"], [1, 2, 1, "", "model_config"], [1, 2, 1, "", "model_fields"], [1, 2, 1, "", "timeout"]], "gmailconnector.models.config.IngressConfig.Config": [[1, 2, 1, "", "env_file"], [1, 2, 1, "", "env_prefix"], [1, 2, 1, "", "extra"]], "gmailconnector.models.config.SMSGatewayModel": [[1, 2, 1, "", "att"], [1, 2, 1, "", "boost"], [1, 2, 1, "", "cricket"], [1, 2, 1, "", "model_config"], [1, 2, 1, "", "model_fields"], [1, 2, 1, "", "tmobile"], [1, 2, 1, "", "uscellular"], [1, 2, 1, "", "verizon"]], "gmailconnector.models.options": [[1, 1, 1, "", "Category"], [1, 1, 1, "", "Condition"], [1, 1, 1, "", "Folder"]], "gmailconnector.models.options.Category": [[1, 2, 1, "", "all"], [1, 2, 1, "", "flagged"], [1, 2, 1, "", "not_deleted"], [1, 2, 1, "", "seen"], [1, 2, 1, "", "unseen"]], "gmailconnector.models.options.Condition": [[1, 3, 1, "", "since"], [1, 3, 1, "", "small"], [1, 3, 1, "", "subject"], [1, 3, 1, "", "text"]], "gmailconnector.models.options.Folder": [[1, 2, 1, "", "all"], [1, 2, 1, "", "drafts"], [1, 2, 1, "", "important"], [1, 2, 1, "", "inbox"], [1, 2, 1, "", "sent"], [1, 2, 1, "", "spam"], [1, 2, 1, "", "starred"], [1, 2, 1, "", "trash"]], "gmailconnector.models.responder": [[1, 1, 1, "", "Email"], [1, 1, 1, "", "Response"]], "gmailconnector.models.responder.Response": [[1, 4, 1, "", "body"], [1, 4, 1, "", "count"], [1, 4, 1, "", "extra"], [1, 3, 1, "", "json"], [1, 4, 1, "", "ok"], [1, 4, 1, "", "status"]], "gmailconnector": [[1, 0, 0, "-", "read_email"], [1, 0, 0, "-", "send_email"], [1, 0, 0, "-", "send_sms"], [1, 0, 0, "-", "sms_deleter"]], "gmailconnector.read_email": [[1, 1, 1, "", "ReadEmail"]], "gmailconnector.read_email.ReadEmail": [[1, 4, 1, "", "authenticate"], [1, 3, 1, "", "create_ssl_connection"], [1, 3, 1, "", "get_info"], [1, 3, 1, "", "instantiate"], [1, 3, 1, "", "read_mail"]], "gmailconnector.send_email": [[1, 1, 1, "", "SendEmail"], [1, 5, 1, "", "validate_email"]], "gmailconnector.send_email.SendEmail": [[1, 4, 1, "", "authenticate"], [1, 3, 1, "", "create_connection"], [1, 3, 1, "", "create_ssl_connection"], [1, 3, 1, "", "create_tls_connection"], [1, 3, 1, "", "multipart_message"], [1, 3, 1, "", "send_email"]], "gmailconnector.send_sms": [[1, 1, 1, "", "SendSMS"]], "gmailconnector.send_sms.SendSMS": [[1, 4, 1, "", "authenticate"], [1, 3, 1, "", "create_ssl_connection"], [1, 3, 1, "", "create_tls_connection"], [1, 3, 1, "", "send_sms"]], "gmailconnector.sms_deleter": [[1, 1, 1, "", "DeleteSent"]], "gmailconnector.sms_deleter.DeleteSent": [[1, 3, 1, "", "create_ssl_connection"], [1, 3, 1, "", "delete_sent"], [1, 3, 1, "", "thread_executor"]], "gmailconnector.validator": [[1, 0, 0, "-", "address"], [1, 0, 0, "-", "domain"], [1, 0, 0, "-", "exceptions"], [1, 0, 0, "-", "validate_email"]], "gmailconnector.validator.address": [[1, 1, 1, "", "EmailAddress"]], "gmailconnector.validator.address.EmailAddress": [[1, 4, 1, "", "domain"], [1, 4, 1, "", "email"], [1, 4, 1, "", "user"]], "gmailconnector.validator.domain": [[1, 5, 1, "", "get_mx_records"]], "gmailconnector.validator.exceptions": [[1, 6, 1, "", "AddressFormatError"], [1, 6, 1, "", "InvalidDomain"], [1, 6, 1, "", "NotMailServer"], [1, 6, 1, "", "UnresponsiveMailServer"]], "gmailconnector.validator.validate_email": [[1, 5, 1, "", "validate_email"]]}, "objtypes": {"0": "py:module", "1": "py:class", "2": "py:attribute", "3": "py:method", "4": "py:property", "5": "py:function", "6": "py:exception"}, "objnames": {"0": ["py", "module", "Python module"], "1": ["py", "class", "Python class"], "2": ["py", "attribute", "Python attribute"], "3": ["py", "method", "Python method"], "4": ["py", "property", "Python property"], "5": ["py", "function", "Python function"], "6": ["py", "exception", "Python exception"]}, "titleterms": {"gmail": [0, 1], "connector": [0, 1], "instal": 0, "env": 0, "var": 0, "usag": 0, "send": [0, 1], "sm": [0, 1], "addit": 0, "arg": 0, "email": [0, 1], "read": [0, 1], "lint": 0, "releas": 0, "note": 0, "pypi": 0, "modul": 0, "runbook": 0, "licens": 0, "copyright": 0, "welcom": 1, "": 1, "document": 1, "me": 1, "delet": 1, "sent": 1, "valid": 1, "address": 1, "domain": 1, "except": 1, "model": 1, "config": 1, "option": 1, "respond": 1, "indic": 1, "tabl": 1}, "envversion": {"sphinx.domains.c": 2, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 6, "sphinx.domains.index": 1, "sphinx.domains.javascript": 2, "sphinx.domains.math": 2, "sphinx.domains.python": 3, "sphinx.domains.rst": 2, "sphinx.domains.std": 2, "sphinx": 56}}) \ No newline at end of file diff --git a/gmailconnector/__init__.py b/gmailconnector/__init__.py index 822a823..e176f93 100644 --- a/gmailconnector/__init__.py +++ b/gmailconnector/__init__.py @@ -11,4 +11,4 @@ from .validator.address import EmailAddress # noqa: F401 from .validator.validate_email import validate_email # noqa: F401 -version = "1.0.1" +version = "1.0.2" diff --git a/gmailconnector/models/config.py b/gmailconnector/models/config.py index c24d150..a790eb1 100644 --- a/gmailconnector/models/config.py +++ b/gmailconnector/models/config.py @@ -46,8 +46,6 @@ class EgressConfig(BaseSettings): gmail_user: EmailStr gmail_pass: str - recipient: Union[EmailStr, None] = None - phone: Union[str, None] = Field(None, pattern="\\d{10}$") gmail_host: str = "smtp.gmail.com" encryption: Encryption = Encryption.TLS timeout: int = 10 diff --git a/gmailconnector/send_email.py b/gmailconnector/send_email.py index de01c47..c7ebd59 100644 --- a/gmailconnector/send_email.py +++ b/gmailconnector/send_email.py @@ -234,12 +234,16 @@ def send_email( attachments = ( [attachment] if isinstance(attachment, str) - else attachment if attachment else [] + else attachment + if attachment + else [] ) filenames = ( [filename] if isinstance(filename, str) - else filename if filename else [] + else filename + if filename + else [] ) msg = self.multipart_message( diff --git a/gmailconnector/send_sms.py b/gmailconnector/send_sms.py index 3f262ed..a1cb46e 100644 --- a/gmailconnector/send_sms.py +++ b/gmailconnector/send_sms.py @@ -123,19 +123,14 @@ def send_sms( Response: A custom response object with properties: ok, status and body to the user. """ - if phone: - self.env.phone = phone - self.env = EgressConfig(**self.env.__dict__) - elif not self.env.phone: - raise ValueError( - '\n\tcannot proceed without phone number' - ) + if not all((phone, len(phone) == 10)): + raise ValueError("\n\tcannot proceed without a valid phone number") if not sms_gateway: sms_gateway = SMSGateway.tmobile if not country_code: country_code = "+1" if COUNTRY_CODE.match(country_code): - to = country_code + self.env.phone + "@" + sms_gateway + to = country_code + phone + "@" + sms_gateway else: raise ValueError( f"\n\tcountry code should match the pattern {COUNTRY_CODE.pattern}" diff --git a/gmailconnector/validator/validate_email.py b/gmailconnector/validator/validate_email.py index ef6363b..3e3bdd0 100644 --- a/gmailconnector/validator/validate_email.py +++ b/gmailconnector/validator/validate_email.py @@ -7,8 +7,12 @@ from ..models.responder import Response from .address import EmailAddress from .domain import get_mx_records -from .exceptions import (AddressFormatError, InvalidDomain, NotMailServer, - UnresponsiveMailServer) +from .exceptions import ( + AddressFormatError, + InvalidDomain, + NotMailServer, + UnresponsiveMailServer, +) formatter = logging.Formatter(fmt="%(levelname)s\t %(message)s") diff --git a/release_notes.rst b/release_notes.rst index d982430..29a947c 100644 --- a/release_notes.rst +++ b/release_notes.rst @@ -1,6 +1,11 @@ Release Notes ============= +v1.0.2 (06/05/2024) +------------------- +- Removes complexity with phone number validation +- Improved code readability + v1.0.1 (05/26/2024) ------------------- - Includes a retry logic for occasional errors while sending emails