Vorlage für Integration in anderen Code

This commit is contained in:
hubobel 2022-02-25 16:33:33 +01:00
parent dd1f762564
commit 8cd1c84e97

View file

@ -1,20 +1,34 @@
import json import json
import os import os
import sys import sys
conf = os.path.basename(sys.argv[0]) appname = os.path.basename(sys.argv[0])
conf = conf.replace(".py", ".conf") appname = appname.replace(".py", ".conf")
if os.path.isfile(conf) is False: absFilePath = os.path.abspath(__file__)
print(conf + ' scheint es nicht zu geben.') absFilePath = absFilePath.replace(".py", ".conf")
print('Ich lege eine neue Datei '+ conf + ' an.')
passw={"mail_pass": "","mail_user": "",
"mail_host": "", if os.path.isfile(absFilePath) is False:
"mail_folder": "", print(appname + ' scheint es nicht zu geben.')
"Chat_ID": "","TOKEN": "" print('Ich lege eine neue Datei ' + appname + ' an.')
} passw={'mail':
print(str(conf)+ ' bitte entsprechend befüllen.') {
with open(conf, 'w') as fp: "mail_pass": "",
"mail_user": "",
"mail_host": "",
"mail_folder": ""
},
'Telegram':
{
"Chat_ID": "322673713",
"TOKEN": "680737840:AAEaa7Vxl_kZz_LWS1_S-lH6Eda7HXqu6Y4"
}
}
print(str(appname) + ' bitte entsprechend befüllen.')
with open(absFilePath, 'w') as fp:
json.dump(passw, fp, sort_keys=True, indent=4) json.dump(passw, fp, sort_keys=True, indent=4)
quit() quit()
else: else:
with open(conf) as file: with open(absFilePath) as file:
passw = json.load(file) passw = json.load(file)