Files
circular-trello-report/main.py
2024-08-21 13:01:47 +02:00

63 lines
1.6 KiB
Python

from configparser import ConfigParser
from shutil import copy
# TODO: Set up actual logging
def log(text: str):
print(text)
def read_config() -> dict:
"""
Returns the contents of config.ini as a a dict, assuming it exists and has
no empty fields.
"""
config = ConfigParser()
# Reads the file and checks if it exists
if config.read('config.ini') == []:
copy("config.ini.sample","config.ini")
log("Creating config.ini file")
exit()
# Creates the dict and removes the "DEFAULTS" section
config_dict = {
key: dict(value) for key,value in dict(config).items()
if key != "DEFAULT"
}
# Checks if every field is filled out
all_filled_out = all(
all(v2 != '' for _,v2 in v1.items())
for _,v1 in config_dict.items()
)
if not all_filled_out:
log("Empty fields in config.ini")
exit()
return config_dict
def main():
# Reading the config file
config = read_config()
# Step 2:
# Get data from Trello API
# - Time each card has been in the step it's in
# - Escalation level
# - Who is assigned (as well as their email)
# Step 3:
# For each card, compare to escalation rules to see if it's at the step
# and escalation level it should be at. If not, flag it.
# Step 4:
# Generate reports for each person, showing their own cards.
# Perhaps a "master report" with every card.
# Step 5:
# Send out the reports via email.
if __name__ == "__main__":
main()