Compare commits

..

2 Commits

Author SHA1 Message Date
2fd0163a34 ⚙️ Reads config file 2024-08-21 13:01:47 +02:00
9b5bed321c 🙈 Created .gitignore 2024-08-21 13:00:37 +02:00
2 changed files with 42 additions and 5 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.ini

46
main.py
View File

@ -1,8 +1,45 @@
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():
# Step 1:
# Create an config file from the sample file if there is none,
# then return.
# Read config file if it already existed.
# Reading the config file
config = read_config()
# Step 2:
# Get data from Trello API
@ -20,7 +57,6 @@ def main():
# Step 5:
# Send out the reports via email.
pass
if __name__ == "__main__":