mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-02-06 08:46:21 +01:00
Updated for typing
This commit is contained in:
parent
6e2a57378a
commit
9e7402cd8b
9 changed files with 16 additions and 14 deletions
|
@ -29,7 +29,7 @@ class Md5sum:
|
|||
view.question()
|
||||
|
||||
@staticmethod
|
||||
def read_file(filename: str):
|
||||
def read_file(filename: str) -> bytes:
|
||||
""" Reads the text file. """
|
||||
with open(filename, 'rb') as f:
|
||||
return f.read()
|
||||
|
|
|
@ -10,7 +10,7 @@ from dataclasses import dataclass
|
|||
|
||||
class LoadConfigs:
|
||||
@staticmethod
|
||||
def file(path, file):
|
||||
def file(path: str, file: str) -> dict:
|
||||
try:
|
||||
""" Load the configs from the file. """
|
||||
config_file: str = f'{path}/{file}.toml'
|
||||
|
|
|
@ -56,7 +56,7 @@ class CreateData:
|
|||
self.session.commit()
|
||||
|
||||
@staticmethod
|
||||
def read_file(file: str):
|
||||
def read_file(file: str) -> list:
|
||||
""" Reads the text file. """
|
||||
with open(file, 'r', encoding='utf-8') as f:
|
||||
return f.readlines()
|
||||
|
|
|
@ -18,7 +18,8 @@ class DialogBox:
|
|||
self.d = Dialog(dialog="dialog")
|
||||
self.d.set_background_title(f'{self.configs.prog_name} {Version().version} - Software Package Manager')
|
||||
|
||||
def checklist(self, text, title, height, width, list_height, choices, packages):
|
||||
def checklist(self, text: str, title: str, height: int, width: int,
|
||||
list_height: int, choices: list, packages: list):
|
||||
""" Display a checklist box. """
|
||||
if self.configs.dialog:
|
||||
code, tags = self.d.checklist(text, title=title, height=height, width=width,
|
||||
|
@ -29,7 +30,7 @@ class DialogBox:
|
|||
|
||||
return code, tags
|
||||
|
||||
def mixedform(self, text, title, elements, height, width):
|
||||
def mixedform(self, text: str, title: str, elements: list, height: int, width: int):
|
||||
""" Display a mixedform box. """
|
||||
if self.configs.dialog:
|
||||
code, tags = self.d.mixedform(text=text, title=title, elements=elements,
|
||||
|
@ -40,12 +41,12 @@ class DialogBox:
|
|||
|
||||
return code, tags
|
||||
|
||||
def msgbox(self, text, height, width):
|
||||
def msgbox(self, text: str, height: int, width: int):
|
||||
""" Display a message box. """
|
||||
if self.configs.dialog:
|
||||
self.d.msgbox(text, height, width)
|
||||
|
||||
def textbox(self, text, height, width):
|
||||
def textbox(self, text: str, height: int, width: int):
|
||||
""" Display a text box. """
|
||||
if self.configs.dialog:
|
||||
self.d.textbox(text, height, width)
|
||||
|
|
|
@ -61,7 +61,7 @@ class FormConfigs:
|
|||
self.dialog.textbox(self.config_file, 40, 60)
|
||||
self.edit()
|
||||
|
||||
def check_configs(self, configs, tags):
|
||||
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'] and value not in ['true', 'false']:
|
||||
|
@ -74,7 +74,7 @@ class FormConfigs:
|
|||
with open(self.config_file, 'r') as toml_file:
|
||||
self.orig_configs = toml_file.readlines()
|
||||
|
||||
def write_file(self, configs, tags):
|
||||
def write_file(self, configs: dict, tags: list):
|
||||
""" Write the new values to the config file. """
|
||||
self.read_file()
|
||||
with open(self.config_file, 'w') as patch_toml:
|
||||
|
|
|
@ -75,7 +75,7 @@ class Slackbuilds:
|
|||
|
||||
self.install_order.extend(self.dependencies)
|
||||
|
||||
def choose_dependencies(self, dependencies):
|
||||
def choose_dependencies(self, dependencies: list):
|
||||
""" Choose packages for install. """
|
||||
height = 10
|
||||
width = 70
|
||||
|
|
|
@ -12,7 +12,7 @@ class Tracking:
|
|||
self.configs = Configs
|
||||
self.colors = self.configs.colour
|
||||
|
||||
def packages(self, packages):
|
||||
def packages(self, packages: list):
|
||||
""" Prints the packages dependencies. """
|
||||
color = self.colors()
|
||||
cyan = color['cyan']
|
||||
|
|
|
@ -17,7 +17,7 @@ from slpkg.models.models import session as Session
|
|||
class UpdateRepository:
|
||||
""" Deletes and install the data. """
|
||||
|
||||
def __init__(self, flags):
|
||||
def __init__(self, flags: list):
|
||||
self.flags = flags
|
||||
self.configs = Configs
|
||||
self.session = Session
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
from typing import Any
|
||||
|
||||
from slpkg.configs import Configs
|
||||
from slpkg.queries import SBoQueries
|
||||
|
@ -65,7 +66,7 @@ class ViewMessage:
|
|||
version = SBoQueries(sbo).version()
|
||||
self._view_download(sbo, version)
|
||||
|
||||
def remove_packages(self, packages: list):
|
||||
def remove_packages(self, packages: list) -> Any:
|
||||
""" View remove packages. """
|
||||
slackbuilds, dependencies, deps = [], [], []
|
||||
for pkg in packages:
|
||||
|
@ -100,7 +101,7 @@ class ViewMessage:
|
|||
|
||||
return self.installed_packages, dependencies
|
||||
|
||||
def choose_dependencies_for_remove(self, dependencies):
|
||||
def choose_dependencies_for_remove(self, dependencies: list) -> list:
|
||||
""" Choose packages for remove. """
|
||||
height = 10
|
||||
width = 70
|
||||
|
|
Loading…
Add table
Reference in a new issue