Fixed capped default choice, removed old py2 code
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
"""Utility functions."""
|
||||
|
||||
import configparser
|
||||
import contextlib
|
||||
import datetime
|
||||
import getpass
|
||||
@@ -13,10 +14,6 @@ import string
|
||||
import subprocess
|
||||
import sys
|
||||
import uuid
|
||||
try:
|
||||
import configparser
|
||||
except ImportError:
|
||||
import ConfigParser as configparser
|
||||
|
||||
from . import config_dict_template
|
||||
from .compatibility_matrix import APP_INCOMPATIBILITY
|
||||
@@ -35,12 +32,7 @@ class FatalError(Exception):
|
||||
|
||||
def user_input(message):
|
||||
"""Ask something to the user."""
|
||||
try:
|
||||
from builtins import input
|
||||
except ImportError:
|
||||
answer = raw_input(message)
|
||||
else:
|
||||
answer = input(message)
|
||||
answer = input(message)
|
||||
return answer
|
||||
|
||||
|
||||
@@ -323,8 +315,8 @@ def validate(value, config_entry):
|
||||
return True
|
||||
|
||||
|
||||
def get_entry_value(entry, interactive, config):
|
||||
default_entry = entry("default")
|
||||
def get_entry_value(entry: dict, interactive: bool, config: configparser.ConfigParser) -> string:
|
||||
default_entry = entry["default"]
|
||||
if type(default_entry) is type(list()):
|
||||
default_value = check_if_condition(config, default_entry)
|
||||
if callable(default_entry):
|
||||
@@ -481,7 +473,7 @@ def validate_backup_path(path: str, silent_mode: bool):
|
||||
if not path_exists:
|
||||
if not silent_mode:
|
||||
create_dir = input(
|
||||
f"\"{path}\" doesn't exist, would you like to create it? [Y/n]\n"
|
||||
f"\"{path}\" doesn't exist, would you like to create it? [y/N]\n"
|
||||
).lower()
|
||||
|
||||
if silent_mode or (not silent_mode and create_dir.startswith("y")):
|
||||
@@ -496,7 +488,7 @@ def validate_backup_path(path: str, silent_mode: bool):
|
||||
if len(os.listdir(path)) != 0:
|
||||
if not silent_mode:
|
||||
delete_dir = input(
|
||||
"Warning: backup directory is not empty, it will be purged if you continue... [Y/n]\n").lower()
|
||||
"Warning: backup directory is not empty, it will be purged if you continue... [y/N]\n").lower()
|
||||
|
||||
if silent_mode or (not silent_mode and delete_dir.startswith("y")):
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user