import os
'''
def handle_uploaded_file(csv_file):
    csv_file_name = str(csv_file)
    data_path = config.getInstance().requireConfig("data_path")
    path = os.path.join(data_path, csv_file_name)
    with open(path, 'wb+') as destination:
        for chunk in csv_file.chunks():
            destination.write(chunk)
'''
def aktualisiere_config(config, data):
    if data["briefpapier"]:
        uploaded_file = data["briefpapier"]
        data_path = config.requireConfig("data_path")
        # copy briefpapier into data_path
        with open(os.path.join(data_path, uploaded_file.name), 'wb+') as destination:
            for chunk in uploaded_file.chunks():
                destination.write(chunk)
        config.set_config("briefpapier", uploaded_file.name)
    
    if data["basisbeitrag"]:
        config.set_config("beitrag_basis", data["basisbeitrag"])
        
    if data["zusatzbeitrag"]:
        config.set_config("beitrag_zusatz", data["zusatzbeitrag"])
    
def erstellepdf(text):
    with open(r'G:\SVBaL\python\eh_util\eh_app\test.tex', 'w') as f: # öffnet ein neues Dokument mit dem Namen test.tex
        f.write(text) # schreibt in dieses neue Dokument
        
    # TODO: AUfruf PDF latex tex -> pdf
