Browse Source

Better resilience for the genconfig function thanks to happy path and @Zykino suggestion!

tags/v0.12.0^2
LecygneNoir 6 months ago
parent
commit
cf3d4c32c3
1 changed files with 5 additions and 6 deletions
  1. +5
    -6
      prismedia/genconfig.py

+ 5
- 6
prismedia/genconfig.py View File

@ -6,19 +6,18 @@ logger = logging.getLogger('Prismedia')
from . import utils
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 = utils.ask_overwrite(final_f + " already exists. Do you want to overwrite it?")
if exists(final_f) and not utils.ask_overwrite(final_f + " already exists. Do you want to overwrite it?"):
continue
if overwrite:
copyfile(join(path, f), final_f)
logger.info(str(final_f) + " correctly generated, you may now edit it to fill your credentials.")
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__':

Loading…
Cancel
Save