Browse Source

Add ask_overwirte function to utils in order to be more general and usable in other modules

pull/59/head
LecygneNoir 3 years ago
parent
commit
85f0fe9b6f
2 changed files with 11 additions and 10 deletions
  1. +2
    -10
      prismedia/genconfig.py
  2. +9
    -0
      prismedia/utils.py

+ 2
- 10
prismedia/genconfig.py View File

@ -4,15 +4,7 @@ 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
from . import utils
def genconfig():
path = join(dirname(__file__), 'config')
@ -22,7 +14,7 @@ def genconfig():
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?")
overwrite = utils.ask_overwrite(final_f + " already exists. Do you want to overwrite it?")
if overwrite:
copyfile(join(path, f), final_f)

+ 9
- 0
prismedia/utils.py View File

@ -100,6 +100,15 @@ def getLanguage(language, platform):
return PEERTUBE_LANGUAGE[language.lower()]
def ask_overwrite(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 remove_empty_kwargs(**kwargs):
good_kwargs = {}
if kwargs is not None:

Loading…
Cancel
Save