rework config mechanism
This commit is contained in:
@@ -13,7 +13,8 @@ import pytz
|
||||
from pprint import pprint
|
||||
from dateutil import parser
|
||||
|
||||
MAILDIR = "/home/yannik/mail/INBOX.Mailinglisten.FSMI/"
|
||||
import generate
|
||||
|
||||
CONFIG_FILE = "generator.conf"
|
||||
|
||||
def decode_header(header):
|
||||
@@ -24,8 +25,12 @@ def decode_header(header):
|
||||
return decoded_header[0].decode(encoding, errors="replace") if isinstance(decoded_header[0], bytes) else decoded_header[0]
|
||||
|
||||
if __name__ == "__main__":
|
||||
config = yaml.full_load(open(CONFIG_FILE))
|
||||
in_mbox = mailbox.Maildir(MAILDIR)
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--config", "-c", default=CONFIG_FILE)
|
||||
args = parser.parse_args()
|
||||
|
||||
config = generate.get_config(args.config)
|
||||
in_mbox = mailbox.Maildir(config["top_inbox_maildir"])
|
||||
out_mbox = mailbox.mbox(config["top_mbox_file"])
|
||||
|
||||
out_mbox.clear()
|
||||
@@ -33,7 +38,7 @@ if __name__ == "__main__":
|
||||
buffer = []
|
||||
|
||||
timezone = pytz.timezone("Europe/Berlin")
|
||||
last_fsr_date = datetime.date.fromisoformat(open("data/last_date").read().strip())
|
||||
last_fsr_date = datetime.date.fromisoformat(open(config["last_date_file"]).read().strip())
|
||||
last_fsr_datetime = datetime.datetime.combine(last_fsr_date, datetime.time(17, 30), timezone)
|
||||
|
||||
for message in in_mbox:
|
||||
|
||||
Reference in New Issue
Block a user