mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2024-12-26 09:58:31 +01:00
Updated for ascii
This commit is contained in:
parent
cd4c902c59
commit
b440eff5f4
4 changed files with 63 additions and 36 deletions
|
@ -4,6 +4,7 @@
|
|||
from progress.spinner import PixelSpinner
|
||||
|
||||
from slpkg.configs import Configs
|
||||
from slpkg.views.ascii import Ascii
|
||||
from slpkg.queries import SBoQueries
|
||||
|
||||
|
||||
|
@ -14,6 +15,11 @@ class Dependees:
|
|||
self.packages = packages
|
||||
self.flags = flags
|
||||
self.configs = Configs
|
||||
self.ascii = Ascii()
|
||||
self.llc = self.ascii.lower_left_corner
|
||||
self.hl = self.ascii.horizontal_line
|
||||
self.var = self.ascii.vertical_and_right
|
||||
self.colors = self.configs.colour
|
||||
self.colors = self.configs.colour
|
||||
self.color = self.colors()
|
||||
self.bold = self.color['bold']
|
||||
|
@ -43,13 +49,13 @@ class Dependees:
|
|||
found.append(sbo)
|
||||
dependees[package] = found
|
||||
|
||||
last = ' └─'
|
||||
last = f' {self.llc}{self.hl}'
|
||||
print('\n')
|
||||
if dependees:
|
||||
for key, value in dependees.items():
|
||||
print(f'{self.yellow}{key}{self.endc}')
|
||||
print(end=f'\r{last}')
|
||||
char = ' ├─'
|
||||
char = f' {self.var}{self.hl}'
|
||||
|
||||
for i, v in enumerate(value, start=1):
|
||||
if i == len(value):
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from slpkg.configs import Configs
|
||||
from slpkg.views.ascii import Ascii
|
||||
from slpkg.dependencies import Requires
|
||||
|
||||
|
||||
|
@ -10,19 +11,21 @@ class Tracking:
|
|||
|
||||
def __init__(self):
|
||||
self.configs = Configs
|
||||
self.ascii = Ascii()
|
||||
self.llc = self.ascii.lower_left_corner
|
||||
self.hl = self.ascii.horizontal_line
|
||||
self.colors = self.configs.colour
|
||||
self.color = self.colors()
|
||||
self.cyan = self.color['cyan']
|
||||
self.grey = self.color['grey']
|
||||
self.yellow = self.color['yellow']
|
||||
self.endc = self.color['endc']
|
||||
|
||||
def packages(self, packages: list):
|
||||
""" Prints the packages dependencies. """
|
||||
color = self.colors()
|
||||
cyan = color['cyan']
|
||||
grey = color['grey']
|
||||
yellow = color['yellow']
|
||||
endc = color['endc']
|
||||
|
||||
print(f"The list below shows the packages with dependencies:\n")
|
||||
|
||||
char = ' └─'
|
||||
char = f' {self.llc}{self.hl}'
|
||||
for i, package in enumerate(packages):
|
||||
requires = Requires(package).resolve()
|
||||
how_many = len(requires)
|
||||
|
@ -30,6 +33,6 @@ class Tracking:
|
|||
if not requires:
|
||||
requires = ['No dependencies']
|
||||
|
||||
print(f'{yellow}{package}{endc}')
|
||||
print(f'{char} {cyan}{" ".join([req for req in requires])}{endc}')
|
||||
print(f'\n{grey}{how_many} dependencies for {package}{endc}\n')
|
||||
print(f'{self.yellow}{package}{self.endc}')
|
||||
print(f'{char} {self.cyan}{" ".join([req for req in requires])}{self.endc}')
|
||||
print(f'\n{self.grey}{how_many} dependencies for {package}{self.endc}\n')
|
||||
|
|
19
slpkg/views/ascii.py
Normal file
19
slpkg/views/ascii.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
||||
@dataclass
|
||||
class Ascii:
|
||||
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 = '┤'
|
|
@ -6,6 +6,7 @@ import shutil
|
|||
from typing import Any
|
||||
|
||||
from slpkg.configs import Configs
|
||||
from slpkg.views.ascii import Ascii
|
||||
from slpkg.queries import SBoQueries
|
||||
from slpkg.utilities import Utilities
|
||||
from slpkg.blacklist import Blacklist
|
||||
|
@ -14,19 +15,6 @@ from slpkg.models.models import LogsDependencies
|
|||
from slpkg.models.models import session as Session
|
||||
|
||||
|
||||
# '│' 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
|
||||
|
||||
|
||||
class ViewMessage:
|
||||
""" Print some messages before. """
|
||||
|
||||
|
@ -50,34 +38,45 @@ class ViewMessage:
|
|||
self.endc = self.color['endc']
|
||||
self.installed_packages = []
|
||||
self.columns, self.rows = shutil.get_terminal_size()
|
||||
self.ascii = Ascii()
|
||||
self.ulc = self.ascii.upper_left_corner
|
||||
self.hl = self.ascii.horizontal_line
|
||||
self.urc = self.ascii.upper_right_corner
|
||||
self.vl = self.ascii.vertical_line
|
||||
self.var = self.ascii.vertical_and_right
|
||||
self.val = self.ascii.vertical_and_left
|
||||
self.llc = self.ascii.lower_left_corner
|
||||
self.lrc = self.ascii.lower_right_corner
|
||||
|
||||
def draw_title_box(self, message, title):
|
||||
""" Drawing title message. """
|
||||
middle_title = int((self.columns / 2) - len(title) + 2)
|
||||
print(f'{self.bgreen}┌' + '─' * (self.columns - 2) + '┐')
|
||||
print('│' + ' ' * middle_title + f'{title}' + ' ' * (self.columns - middle_title - len(title) - 2) + f'│')
|
||||
print(f'{self.bgreen}{self.ulc}' + f'{self.hl}' * (self.columns - 2) + f'{self.urc}')
|
||||
print(f'{self.vl}' + ' ' * middle_title + f'{title}' + ' ' * (self.columns - middle_title - len(title) - 2) +
|
||||
f'{self.vl}')
|
||||
self.draw_middle_line()
|
||||
print(f'│{self.endc} {message}' + ' ' * (self.columns - len(message) - 3) + f'{self.bgreen}│')
|
||||
print(f'{self.vl}{self.endc} {message}' + ' ' * (self.columns - len(message) - 3) + f'{self.bgreen}{self.vl}')
|
||||
self.draw_middle_line()
|
||||
print(f'{self.bgreen}│{self.endc} Package:' + ' ' * 27 + 'Version:' + ' ' * (self.columns - 51) +
|
||||
f'Size{self.bgreen} │{self.endc}')
|
||||
print(f'{self.bgreen}{self.vl}{self.endc} Package:' + ' ' * 27 + 'Version:' + ' ' * (self.columns - 51) +
|
||||
f'Size{self.bgreen} {self.vl}{self.endc}')
|
||||
|
||||
def draw_middle_line(self):
|
||||
""" Drawing a middle line. """
|
||||
print(f'{self.bgreen}├' + '─' * (self.columns - 2) + f'┤')
|
||||
print(f'{self.bgreen}{self.var}' + f'{self.hl}' * (self.columns - 2) + f'{self.val}')
|
||||
|
||||
def draw_dependency_line(self):
|
||||
""" Drawing the dependencies line. """
|
||||
print(f'{self.bgreen}│{self.endc} Dependencies:' + ' ' * (self.columns - 16) + f'{self.bgreen}│{self.endc}')
|
||||
print(f'{self.bgreen}{self.vl}{self.endc} Dependencies:' + ' ' * (self.columns - 16) +
|
||||
f'{self.bgreen}{self.vl}{self.endc}')
|
||||
|
||||
def view_packages(self, package, version):
|
||||
""" Printing the main packages. """
|
||||
print(f'{self.bgreen}│ {self.bcyan}{package}{self.endc}' + ' ' * (35 - len(package)) + f'{version}' +
|
||||
' ' * ((self.columns - 37) - len(version) - 1) + f'{self.bgreen}│{self.endc}')
|
||||
print(f'{self.bgreen}{self.vl} {self.bcyan}{package}{self.endc}' + ' ' * (35 - len(package)) + f'{version}' +
|
||||
' ' * ((self.columns - 37) - len(version) - 1) + f'{self.bgreen}{self.vl}{self.endc}')
|
||||
|
||||
def draw_bottom_line(self):
|
||||
""" Drawing the bottom line. """
|
||||
print(f'{self.bold}{self.green}└' + f'─' * (self.columns - 2) + f'┘{self.endc}')
|
||||
print(f'{self.bold}{self.green}{self.llc}' + f'{self.hl}' * (self.columns - 2) + f'{self.lrc}{self.endc}')
|
||||
|
||||
def view_skipping_packages(self, sbo, version):
|
||||
print(f'[ {self.yellow}Skipping{self.endc} ] {sbo}-{version} {self.red}(already installed){self.endc}')
|
||||
|
@ -233,7 +232,7 @@ class ViewMessage:
|
|||
|
||||
for dep in dependencies:
|
||||
print(f'{self.cyan}{dep[0]}{self.endc}')
|
||||
print(f' └─{self.cyan} {dep[1]}{self.endc}\n')
|
||||
print(f' {self.llc}{self.hl}{self.cyan} {dep[1]}{self.endc}\n')
|
||||
print('Note: After cleaning you should remove them one by one.')
|
||||
|
||||
def question(self):
|
||||
|
|
Loading…
Reference in a new issue