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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -35,7 +35,7 @@ class UpdateRepository:
data = CreateData() data = CreateData()
data.insert_sbo_table() 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}' file = f'{dir}/{txt_file}'
if path.exists(file): if path.exists(file):
os.remove(file) os.remove(file)

View file

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