Updated typing

This commit is contained in:
Dimitris Zlatanidis 2022-06-18 20:10:47 +03:00
parent bc7621fff9
commit 95acb826ed
8 changed files with 15 additions and 15 deletions

View file

@ -14,7 +14,7 @@ class Check:
log_packages: str = Metadata.log_packages
repo_tag: str = Metadata.repo_tag
def exists(self, slackbuilds):
def exists(self, slackbuilds: list):
''' Checking if the slackbuild exists in the repository. '''
self.database()
packages = []
@ -27,14 +27,14 @@ class Check:
raise SystemExit(f'\nPackages {", ".join(packages)} '
'does not exists.\n')
def unsupported(self, slackbuilds):
def unsupported(self, slackbuilds: list):
''' Checking for unsupported slackbuilds. '''
for sbo in slackbuilds:
sources = SBoQueries(sbo).sources()
if 'UNSUPPORTED' in sources:
raise SystemExit(f'\nPackage {sbo} unsupported by arch.\n')
def installed(self, slackbuilds):
def installed(self, slackbuilds: list):
''' Checking for installed packages. '''
for package in os.listdir(self.log_packages):
for sbo in slackbuilds:
@ -42,7 +42,7 @@ class Check:
return
raise SystemExit('\nNot found packages for remove.\n')
def blacklist(self, slackbuilds):
def blacklist(self, slackbuilds: list):
''' Checking for packages on the blacklist and removing them. '''
black = Blacklist()
for package in black.get():

View file

@ -15,7 +15,7 @@ class Md5sum:
flags: str
build_path: str = Metadata.build_path
def check(self, source, checksum, name):
def check(self, source: str, checksum: str, name: str):
path = f'{self.build_path}/{name}'
filename = f'{path}/{source.split("/")[-1]}'
@ -31,6 +31,6 @@ class Md5sum:
view = ViewMessage()
view.question(self.flags)
def read_file(self, filename):
def read_file(self, filename: str):
with open(filename, 'rb') as f:
return f.read()

View file

@ -4,7 +4,7 @@
from slpkg.metadata import Metadata
def usage(status):
def usage(status: int):
args = [f'Usage: {Metadata.prog_name} [OPTIONS] [packages]\n',
' Packaging tool that interacts with the SBo repository.\n',
'Options:',

View file

@ -58,6 +58,6 @@ class CreateData:
self.session.commit()
def read_file(self, file):
def read_file(self, file: str):
with open(file, "r", encoding="utf-8") as f:
return f.readlines()

View file

@ -71,7 +71,7 @@ class RemovePackages:
LogsDependencies.name == pkg).delete()
self.session.commit()
def view_installed_packages(self, name):
def view_installed_packages(self, name: str):
''' View and creates list with packages for remove. '''
installed = os.listdir(self.log_packages)
color = self.color()

View file

@ -116,7 +116,7 @@ class Slackbuilds:
if '--resolve-off' not in self.flags:
self.logging_installed_dependencies(sbo)
def logging_installed_dependencies(self, name):
def logging_installed_dependencies(self, name: str):
''' Logging installed dependencies and used for remove. '''
exist = self.session.query(LogsDependencies.name).filter(
LogsDependencies.name == name).first()
@ -135,7 +135,7 @@ class Slackbuilds:
self.session.add(deps)
self.session.commit()
def install_package(self, package):
def install_package(self, package: str):
''' Install the packages that before created in the tmp directory. '''
execute = self.installpkg
if ('--reinstall' in self.flags or
@ -162,7 +162,7 @@ class Slackbuilds:
if stdout > 0:
raise SystemExit(stdout)
def download_sources(self, name, sources: str):
def download_sources(self, name: str, sources: str):
''' Download the sources. '''
wget = Wget()
path = f'{self.build_path}/{name}'

View file

@ -35,7 +35,7 @@ class UpdateRepository:
data = CreateData()
data.insert_sbo_table()
def delete_file(self, dir, txt_file):
def delete_file(self, dir: str, txt_file: str):
file = f'{dir}/{txt_file}'
if path.exists(file):
os.remove(file)

View file

@ -38,7 +38,7 @@ class ViewMessage:
version = SBoQueries(sbo).version()
self._view_packages(sbo, version)
def _view_packages(self, sbo, version):
def _view_packages(self, sbo: str, version: str):
color = self.colors()
if self.utils.is_installed(f'{sbo}-{version}-'):
@ -62,7 +62,7 @@ class ViewMessage:
print(f'{color["GREEN"]} {d}{color["ENDC"]}')
print()
def question(self, flags):
def question(self, flags: list):
if '--yes' not in flags:
answer = input('\nDo you want to continue [y/N]: ')
print()