|
|
- from os.path import join, abspath, isfile, dirname, exists
- from os import listdir
- from shutil import copyfile
- import logging
- logger = logging.getLogger('Prismedia')
-
-
- def overwrite_or_not(question):
- while True:
- reply = str(input(question + ' (Yes/[No]): ') or "No").lower().strip()
- if reply[:1] == 'y':
- return True
- if reply[:1] == 'n':
- return False
-
-
- def genconfig():
- path = join(dirname(__file__), 'config')
- files = [f for f in listdir(path) if isfile(join(path, f))]
-
- for f in files:
- final_f = f.replace(".sample", "")
- overwrite = True
- if exists(final_f):
- overwrite = overwrite_or_not(final_f + " already exists. Do you want to overwrite it?")
-
- if overwrite:
- copyfile(join(path, f), final_f)
- logger.info(str(final_f) + " correctly generated, you may now edit it to fill your credentials.")
-
-
- if __name__ == '__main__':
- genconfig()
|