Module marksman.helpers
A module that defines various helper functions to avoid repeatition of code
Functions
def configure_email() ‑> tuple
-
Help the use configure the settings for emailing
Returns
tuple
- (SENDER_EMAIL, SENDER_AUTH, SMTP_HOST, SMTP_PORT, INST_NAME)
def display_table(title: str, headers: Iterable, table_list: Iterable) ‑> NoneType
-
Display data in tabular format
Args
title
:str
- the title of the data
headers
:Iterable
- headings or the first row
table_list
:Iterable
- the 2D Matrix or list of rows
def ensure_parent(filename: str) ‑> NoneType
-
Ensures that the parent folder of a file exists
Args
filename
:str
- the file name
def handle_choice(choices: dict) ‑> NoneType
-
Provides the user with a menu and executes apt function based on user choice
Args
choices
:dict
- Dictionary containing the option strings as keys
and the functions to execute when that option is selected as values. - this function is specific to my use case and not generic - the number of choices in the dict is expected to be one or two and not large - all choice str are meant to have unique prefix chars - this handler does not resolve prefix collisions, the first come first server
def intify(string: str) ‑> int
-
Converts a string to int if possible
Args
string
:str
- input string
Returns
int
orstr
- output int or string
def load_template() ‑> str
-
Loads the template file, or provides the default template
Returns
str
- the template string
def not_empty(inp: str) ‑> str
-
Disallows empty inputs
Args
inp
:str
- input string
Returns
str
- the same input string is returned. If input string is empty, quits the program.
def save_email_config(thing: str, env_var: str, value: str) ‑> NoneType
-
Prompts the use to save a particular configuration related to email
Args
thing
:str
- the thing concerned
env_var
:str
- the name of the environment variable dedicated for that thing
value
:str
- the value of the thing