diff --git a/slpkg/views/ascii.py b/slpkg/views/ascii.py index 3c832c7c..ad511b0f 100644 --- a/slpkg/views/ascii.py +++ b/slpkg/views/ascii.py @@ -8,35 +8,35 @@ from slpkg.configs import Configs @dataclass -class Ascii: +class Ascii(Configs): """ ascii characters. """ - vertical_line = '│' - horizontal_line = '─' - horizontal_vertical = '┼' - upper_right_corner = '┐' - lower_left_corner = '└' - lower_right_corner = '┘' - upper_left_corner = '┌' - horizontal_and_up = '┴' - horizontal_and_down = '┬' - vertical_and_right = '├' - vertical_and_left = '┤' + 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 = '┤' - configs = Configs - colors = configs.colour - color = colors() - bold = color['bold'] - blue = color['blue'] - green = color['green'] - cyan = color['cyan'] - red = color['red'] - yellow = color['yellow'] - violet = color['violet'] - endc = color['endc'] - bgreen = f'{bold}{green}' - bred = f'{bold}{red}' + self.color = self.colour() + self.bold = self.color['bold'] + self.blue = self.color['blue'] + self.green = self.color['green'] + self.cyan = self.color['cyan'] + self.red = self.color['red'] + self.yellow = self.color['yellow'] + self.violet = self.color['violet'] + self.endc = self.color['endc'] + self.bgreen = f'{self.bold}{self.green}' + self.bred = f'{self.bold}{self.red}' - columns, rows = shutil.get_terminal_size() + self.columns, self.rows = shutil.get_terminal_size() def draw_package_title_box(self, message, title): """ Drawing package title box. """ diff --git a/slpkg/views/cli_menu.py b/slpkg/views/cli_menu.py index 0cac788a..8aafc994 100644 --- a/slpkg/views/cli_menu.py +++ b/slpkg/views/cli_menu.py @@ -4,11 +4,11 @@ from slpkg.configs import Configs -class Usage: +class Usage(Configs): def __init__(self): - colors = Configs.colour - color = colors() + super(Configs, self).__init__() + color = self.colour() self.bold = color['bold'] self.red = color['red'] diff --git a/slpkg/views/view_package.py b/slpkg/views/view_package.py index 2ce2cce0..58afbfd7 100644 --- a/slpkg/views/view_package.py +++ b/slpkg/views/view_package.py @@ -9,17 +9,16 @@ from slpkg.models.models import SBoTable from slpkg.models.models import session as Session -class ViewPackage: +class ViewPackage(Configs): """ View the repository packages. """ def __init__(self): + super(Configs, self).__init__() self.session = Session - self.configs = Configs - self.colors = self.configs.colour def package(self, packages: list): """ View the packages from the repository. """ - color = self.colors() + color = self.colour() green = color['green'] blue = color['blue'] yellow = color['yellow'] @@ -42,9 +41,9 @@ class ViewPackage: SBoTable.location ).filter(SBoTable.name == package).first() - readme = self.http_request(f'{self.configs.sbo_repo_url}/{info[9]}/{info[0]}/README') + readme = self.http_request(f'{self.sbo_repo_url}/{info[9]}/{info[0]}/README') - info_file = self.http_request(f'{self.configs.sbo_repo_url}/{info[9]}/{info[0]}/{info[0]}.info') + info_file = self.http_request(f'{self.sbo_repo_url}/{info[9]}/{info[0]}/{info[0]}.info') maintainer, email, homepage = '', '', '' for line in info_file.data.decode().splitlines(): @@ -61,17 +60,17 @@ class ViewPackage: f'Version: {green}{info[1]}{endc}\n' f'Requires: {green}{deps}{endc}\n' f'Homepage: {blue}{homepage}{endc}\n' - f'Download SlackBuild: {blue}{self.configs.sbo_repo_url}/{info[9]}/{info[0]}' - f'{self.configs.sbo_tar_suffix}{endc}\n' + f'Download SlackBuild: {blue}{self.sbo_repo_url}/{info[9]}/{info[0]}' + f'{self.sbo_tar_suffix}{endc}\n' f'Download sources: {blue}{info[3]}{endc}\n' f'Download_x86_64 sources: {blue}{info[4]}{endc}\n' f'Md5sum: {yellow}{info[5]}{endc}\n' f'Md5sum_x86_64: {yellow}{info[6]}{endc}\n' f'Files: {green}{info[7]}{endc}\n' f'Description: {green}{info[8]}{endc}\n' - f'Slackware: {cyan}{self.configs.sbo_repo_url.split("/")[-1]}{endc}\n' + f'Slackware: {cyan}{self.sbo_repo_url.split("/")[-1]}{endc}\n' f'Category: {red}{info[9]}{endc}\n' - f'SBo url: {blue}{self.configs.sbo_repo_url}/{info[9]}/{info[0]}{endc}\n' + f'SBo url: {blue}{self.sbo_repo_url}/{info[9]}/{info[0]}{endc}\n' f'Maintainer: {yellow}{maintainer}{endc}\n' f'Email: {yellow}{email}{endc}\n' f'\nREADME: {cyan}{readme.data.decode()}{endc}')