Add ticket toggle var and get_simple_string func

* get_simple_string() will be used for backup prefixes
This commit is contained in:
2Shirt 2018-05-17 17:57:45 -06:00
parent 5ea499d6ff
commit 3114b72178
2 changed files with 12 additions and 0 deletions

View file

@ -196,6 +196,8 @@ def extract_item(item, filter='', silent=False):
def get_ticket_number():
"""Get TicketNumber from user, save in LogDir, and return as str."""
if not ENABLED_TICKET_NUMBERS:
return None
ticket_number = None
while ticket_number is None:
_input = input('Enter ticket number: ')
@ -208,6 +210,15 @@ def get_ticket_number():
f.write(ticket_number)
return ticket_number
def get_simple_string(prompt='Enter string'):
"""Get string from user (only alphanumeric/space chars) and return as str."""
simple_string = None
while simple_string is None:
_input = input('{}: '.format(prompt))
if re.match(r'^(\w|-| )+$', _input, re.ASCII):
simple_string = _input.strip()
return simple_string
def human_readable_size(size, decimals=0):
"""Convert size in bytes to a human-readable format and return a str."""
# Prep string formatting

View file

@ -2,6 +2,7 @@
# Features
ENABLED_UPLOAD_DATA = False
ENABLED_TICKET_NUMBERS = False
# STATIC VARIABLES (also used by BASH and BATCH files)
## NOTE: There are no spaces around the = for easier parsing in BASH and BATCH