Code Documentation¶
This is where all code relevant to the project will be documented. This part of the documentation is mainly for the developers working on the project.
Utility Module API Documentation¶
Parse¶
-
utils.parse.process_arguments()¶ Processes command line arguments
Parameters: None (None) – There are no parameters for this function Returns: (options, args) – Contains option parameters and argument parameters in a Key-Value pair Note: must be parsed using vars(...) to get a Python dictionary
Return type: tuple
-
utils.parse.process_message(message_file)¶ Reads message from a file
Parameters: message_file (string) – Path to file containing the message Returns: message – String with contents of file Return type: string
-
utils.parse.process_receipients(receipients_csv)¶ Reads receipients from a file
Parameters: receipients_csv (string) – Path to a csv containing receipients in format:
name, email
Returns: receipients – Dictionary with keys - name
Return type: dict
Sendmail¶
-
utils.sendmail.create_message(receipient, subject, message)¶ Creates a message to be emailed, formats if replacement strings included in the message
Currently supported replacement strings include
- $name - replaced by name from csv
- $greeting - randomly chosen greeting from ‘greetings’ array
Parameters: - receipient (dict) –
Contains receipient information, specifically
- name
- subject (string) – The subject of the email
- message (dict) – Contains the message in both plaintext and html format
Returns: msg – email message to be sent
Return type: email.mime.multipart.MIMEMultipart
Server¶
-
utils.server.connect_to_server()¶ Connects to gmail server
Returns: server – gmail email server Return type: smtplib.SMTP_SSL
-
utils.server.get_credentials()¶ Gets email to be used and credentials to the email
Returns: credentials – Contains keys - password
Return type: dict
-
utils.server.login_to_server(server)¶ Attempts to log in to server until successfully authenticated or quit char is entered
Parameters: server (smtplib.SMTP_SSL) – Server with which to authenticate Returns: (authenticated, credentials[‘email’]) – - authenticated
- Boolean indicated whether client successfully authenticated
- credentials[‘email’]
- Email address of sender
Return type: tuple