Added config for ascii

This commit is contained in:
Dimitris Zlatanidis 2023-01-29 22:25:29 +02:00
parent c50d97862e
commit 1fd5476845
5 changed files with 42 additions and 14 deletions

View file

@ -1,6 +1,7 @@
4.5.3 - 27/01/2023
Added:
- Short options
- New configuration for ascii characters
4.5.2 - 21/01/2023
BugFixed:

View file

@ -70,4 +70,9 @@
# If silent mode is true,
# do not print the commands as they are executed.
# Default is true. [true/false]
silent_mode = true
silent_mode = true
# Choose ascii printable characters.
# If true use the extended characters otherwise the basic ones.
# Default is true. [true/false]
ascii_characters = true

View file

@ -77,6 +77,11 @@ class Configs:
# Choose the view mode
silent_mode: str = True
# Choose ascii characters.
# If True use extended else basic.
ascii_characters = True
# Load configurations from the file.
load = LoadConfigs()
configs = load.file(etc_path, prog_name)
config = configs['configs']
@ -124,6 +129,10 @@ class Configs:
# Choose the view mode
silent_mode: str = config['silent_mode']
# Choose ascii characters. Extended or basic.
ascii_characters: str = config['ascii_characters']
except KeyError as error:
raise SystemExit(f"\nKeyError: {error}: in the configuration file '/etc/slpkg/slpkg.toml'.\n"
f"\nIf you have upgraded the '{prog_name}' probably you need to run:\n"

View file

@ -63,7 +63,7 @@ class FormConfigs(Configs):
def check_configs(self, configs: dict, tags: list) -> bool:
""" Check for true of false values. """
for key, value in zip(configs['configs'].keys(), tags):
if key in ['colors', 'dialog', 'silent_mode'] and value not in ['true', 'false']:
if key in ['colors', 'dialog', 'silent_mode', 'ascii_characters'] and value not in ['true', 'false']:
self.dialogbox.msgbox(f"\nError value for {key}. It must be 'true' or 'false'\n", height=7, width=60)
return False
return True
@ -81,6 +81,6 @@ class FormConfigs(Configs):
for key, value in zip(configs['configs'].keys(), tags):
if line.lstrip().startswith(key):
line = f' {key} = "{value}"\n'
if line.lstrip().startswith(('colors =', 'dialog =', 'silent_mode =')):
if line.lstrip().startswith(('colors =', 'dialog =', 'silent_mode =', 'ascii_characters =')):
line = line.replace('"', '')
patch_toml.write(line)

View file

@ -10,17 +10,30 @@ class Ascii(Configs):
""" ascii characters. """
def __init__(self):
super(Configs, self).__init__()
self.vertical_line = ''
self.horizontal_line = ''
self.horizontal_vertical = ''
self.upper_right_corner = ''
self.lower_left_corner = ''
self.lower_right_corner = ''
self.upper_left_corner = ''
self.horizontal_and_up = ''
self.horizontal_and_down = ''
self.vertical_and_right = ''
self.vertical_and_left = ''
self.vertical_line = '|'
self.horizontal_line = '='
self.horizontal_vertical = '+'
self.upper_right_corner = '+'
self.lower_left_corner = '+'
self.lower_right_corner = '+'
self.upper_left_corner = '+'
self.horizontal_and_up = '+'
self.horizontal_and_down = '+'
self.vertical_and_right = '+'
self.vertical_and_left = '+'
if self.ascii_characters:
self.vertical_line = ''
self.horizontal_line = ''
self.horizontal_vertical = ''
self.upper_right_corner = ''
self.lower_left_corner = ''
self.lower_right_corner = ''
self.upper_left_corner = ''
self.horizontal_and_up = ''
self.horizontal_and_down = ''
self.vertical_and_right = ''
self.vertical_and_left = ''
self.color = self.colour()
self.bold = self.color['bold']