mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2024-12-27 09:58:10 +01:00
Added type hints
This commit is contained in:
parent
04122167fe
commit
38cc9dbff9
18 changed files with 35 additions and 35 deletions
|
@ -11,7 +11,7 @@ from slpkg.configs import Configs
|
|||
class Blacklist:
|
||||
""" Reads and returns the blacklist. """
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self) -> list:
|
||||
self.configs = Configs
|
||||
|
||||
def get(self):
|
||||
|
|
|
@ -14,7 +14,7 @@ class CheckUpdates:
|
|||
def __init__(self):
|
||||
self.configs = Configs
|
||||
|
||||
def check(self):
|
||||
def check(self) -> bool:
|
||||
""" Checks the ChangeLogs and returns True or False. """
|
||||
print(end='\rChecking for news in the Changelog.txt file... ')
|
||||
local_date = 0
|
||||
|
|
|
@ -38,7 +38,7 @@ class Check:
|
|||
if 'UNSUPPORTED' in sources:
|
||||
raise SystemExit(f"\nPackage '{sbo}' unsupported by arch.\n")
|
||||
|
||||
def installed(self, slackbuilds: list):
|
||||
def installed(self, slackbuilds: list) -> list:
|
||||
""" Checking for installed packages. """
|
||||
found, not_found = [], []
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ from slpkg.views.views import ViewMessage
|
|||
class Md5sum:
|
||||
""" Checksum the sources. """
|
||||
|
||||
def __init__(self, flags):
|
||||
def __init__(self, flags: list):
|
||||
self.flags = flags
|
||||
|
||||
def check(self, path: str, source: str, checksum: str, name: str):
|
||||
|
|
|
@ -10,7 +10,7 @@ from slpkg.models.models import session as Session
|
|||
class CleanLogsDependencies:
|
||||
""" Cleans the logs from packages. """
|
||||
|
||||
def __init__(self, flags):
|
||||
def __init__(self, flags: list):
|
||||
self.flags = flags
|
||||
self.session = Session
|
||||
|
||||
|
|
|
@ -58,6 +58,6 @@ class CreateData:
|
|||
|
||||
@staticmethod
|
||||
def read_file(file: str):
|
||||
""" Reades the text file. """
|
||||
""" Reads the text file. """
|
||||
with open(file, 'r', encoding='utf-8') as f:
|
||||
return f.readlines()
|
||||
|
|
|
@ -9,7 +9,7 @@ from slpkg.queries import SBoQueries
|
|||
class Dependees:
|
||||
""" Show which packages depend. """
|
||||
|
||||
def __init__(self, packages):
|
||||
def __init__(self, packages: list):
|
||||
self.packages = packages
|
||||
self.configs = Configs
|
||||
self.colors = self.configs.colour
|
||||
|
|
|
@ -9,7 +9,7 @@ class Requires:
|
|||
""" Creates a list of dependencies with
|
||||
the right order to install. """
|
||||
|
||||
def __init__(self, name):
|
||||
def __init__(self, name: str):
|
||||
self.name = name
|
||||
|
||||
def resolve(self) -> list:
|
||||
|
|
|
@ -12,7 +12,7 @@ from slpkg.models.models import session as Session
|
|||
class Download:
|
||||
""" Download the slackbuilds with the sources only. """
|
||||
|
||||
def __init__(self, flags):
|
||||
def __init__(self, flags: list):
|
||||
self.flags: list = flags
|
||||
self.configs = Configs
|
||||
self.session = Session
|
||||
|
|
|
@ -24,7 +24,7 @@ from slpkg.update_repository import UpdateRepository
|
|||
|
||||
class Argparse:
|
||||
|
||||
def __init__(self, args):
|
||||
def __init__(self, args: list):
|
||||
self.args = args
|
||||
self.flags = []
|
||||
self.configs = Configs
|
||||
|
|
|
@ -11,7 +11,7 @@ from slpkg.models.models import session as Session
|
|||
class SBoQueries:
|
||||
""" Queries class for the sbo repository. """
|
||||
|
||||
def __init__(self, name):
|
||||
def __init__(self, name: str):
|
||||
self.name = name
|
||||
self.session = Session
|
||||
self.configs = Configs
|
||||
|
@ -20,12 +20,12 @@ class SBoQueries:
|
|||
if self.name in self.black.get():
|
||||
self.name = ''
|
||||
|
||||
def names(self):
|
||||
def names(self) -> list:
|
||||
""" Returns all the slackbuilds. """
|
||||
names = self.session.query(SBoTable.name).all()
|
||||
return [name[0] for name in names]
|
||||
|
||||
def slackbuild(self):
|
||||
def slackbuild(self) -> str:
|
||||
""" Returns a slackbuild. """
|
||||
sbo = self.session.query(
|
||||
SBoTable.name).filter(SBoTable.name == self.name).first()
|
||||
|
@ -34,7 +34,7 @@ class SBoQueries:
|
|||
return sbo[0]
|
||||
return ''
|
||||
|
||||
def location(self):
|
||||
def location(self) -> str:
|
||||
""" Returns the category of a slackbuild. """
|
||||
location = self.session.query(
|
||||
SBoTable.location).filter(SBoTable.name == self.name).first()
|
||||
|
@ -43,7 +43,7 @@ class SBoQueries:
|
|||
return location[0]
|
||||
return ''
|
||||
|
||||
def sources(self):
|
||||
def sources(self) -> str:
|
||||
""" Returns the source of a slackbuild. """
|
||||
source, source64 = self.session.query(
|
||||
SBoTable.download, SBoTable.download64).filter(
|
||||
|
@ -53,7 +53,7 @@ class SBoQueries:
|
|||
return self._chose_arch(source, source64)
|
||||
return ''
|
||||
|
||||
def requires(self):
|
||||
def requires(self) -> str:
|
||||
""" Returns the requirements of a slackbuild. """
|
||||
requires = self.session.query(
|
||||
SBoTable.requires).filter(
|
||||
|
@ -67,7 +67,7 @@ class SBoQueries:
|
|||
return requires
|
||||
return ''
|
||||
|
||||
def version(self):
|
||||
def version(self) -> str:
|
||||
""" Returns the version of a slackbuild. """
|
||||
version = self.session.query(
|
||||
SBoTable.version).filter(
|
||||
|
@ -77,7 +77,7 @@ class SBoQueries:
|
|||
return version[0]
|
||||
return ''
|
||||
|
||||
def checksum(self):
|
||||
def checksum(self) -> str:
|
||||
""" Returns the source checkcum. """
|
||||
md5sum, md5sum64, = [], []
|
||||
mds5, md5s64 = self.session.query(
|
||||
|
@ -93,7 +93,7 @@ class SBoQueries:
|
|||
return self._chose_arch(md5sum, md5sum64)
|
||||
return ''
|
||||
|
||||
def description(self):
|
||||
def description(self) -> str:
|
||||
""" Returns the slackbuild description. """
|
||||
desc = self.session.query(
|
||||
SBoTable.short_description).filter(
|
||||
|
@ -103,7 +103,7 @@ class SBoQueries:
|
|||
return desc[0]
|
||||
return ''
|
||||
|
||||
def files(self):
|
||||
def files(self) -> str:
|
||||
""" Returns the files of a slackbuild. """
|
||||
files = self.session.query(
|
||||
SBoTable.files).filter(
|
||||
|
@ -113,7 +113,7 @@ class SBoQueries:
|
|||
return files[0]
|
||||
return ''
|
||||
|
||||
def _chose_arch(self, arch, arch64):
|
||||
def _chose_arch(self, arch: str, arch64: str) -> str:
|
||||
""" Choosing the right arch. """
|
||||
if self.configs.os_arch == 'x86_64' and arch64:
|
||||
return arch64
|
||||
|
|
|
@ -13,7 +13,7 @@ from slpkg.models.models import session as Session
|
|||
class RemovePackages:
|
||||
""" Removes installed packages. """
|
||||
|
||||
def __init__(self, packages, flags):
|
||||
def __init__(self, packages: list, flags: list):
|
||||
self.packages = packages
|
||||
self.flags = flags
|
||||
self.session = Session
|
||||
|
|
|
@ -12,7 +12,7 @@ class SearchPackage:
|
|||
def __init__(self):
|
||||
self.colors = Configs.colour
|
||||
|
||||
def package(self, packages):
|
||||
def package(self, packages: list):
|
||||
""" Searching and print the matched slackbuilds. """
|
||||
color = self.colors()
|
||||
cyan = color['cyan']
|
||||
|
|
|
@ -21,7 +21,7 @@ from slpkg.models.models import session as Session
|
|||
class Slackbuilds:
|
||||
""" Download build and install the SlackBuilds. """
|
||||
|
||||
def __init__(self, slackbuilds, flags, install):
|
||||
def __init__(self, slackbuilds: list, flags: list, install: bool):
|
||||
self.slackbuilds = slackbuilds
|
||||
self.flags = flags
|
||||
self.install = install
|
||||
|
|
|
@ -16,7 +16,7 @@ class Utilities:
|
|||
self.configs = Configs
|
||||
self.black = Blacklist()
|
||||
|
||||
def is_installed(self, name: str):
|
||||
def is_installed(self, name: str) -> str:
|
||||
""" Returns the installed package name. """
|
||||
for package in os.listdir(self.configs.log_packages):
|
||||
pkg = self.split_installed_pkg(package)[0]
|
||||
|
@ -52,7 +52,7 @@ class Utilities:
|
|||
if not os.path.isdir(directory):
|
||||
os.makedirs(directory)
|
||||
|
||||
def split_installed_pkg(self, package):
|
||||
def split_installed_pkg(self, package: str) -> list:
|
||||
""" Split the package by the name, version, arch, build and tag. """
|
||||
name = '-'.join(package.split('-')[:-3])
|
||||
version = ''.join(package[len(name):].split('-')[:-2])
|
||||
|
|
|
@ -6,11 +6,11 @@ class Version:
|
|||
""" Print the version. """
|
||||
|
||||
def __init__(self):
|
||||
self.version_info: tuple = (4, 3, 9)
|
||||
self.version: str = '{0}.{1}.{2}'.format(*self.version_info)
|
||||
self.license: str = 'MIT License'
|
||||
self.author: str = 'Dimitris Zlatanidis (dslackw)'
|
||||
self.homepage: str = 'https://dslackw.gitlab.io/slpkg'
|
||||
self.version_info = (4, 3, 9)
|
||||
self.version = '{0}.{1}.{2}'.format(*self.version_info)
|
||||
self.license = 'MIT License'
|
||||
self.author = 'Dimitris Zlatanidis (dslackw)'
|
||||
self.homepage = 'https://dslackw.gitlab.io/slpkg'
|
||||
|
||||
def view(self):
|
||||
""" Prints the version. """
|
||||
|
|
|
@ -18,7 +18,7 @@ class ViewPackage:
|
|||
self.configs = Configs
|
||||
self.colors = self.configs.colour
|
||||
|
||||
def package(self, packages):
|
||||
def package(self, packages: list):
|
||||
""" View the packages from the repository. """
|
||||
color = self.colors()
|
||||
green = color['green']
|
||||
|
@ -78,7 +78,7 @@ class ViewPackage:
|
|||
f'\nREADME: {cyan}{readme.data.decode()}{endc}')
|
||||
|
||||
@staticmethod
|
||||
def http_request(link):
|
||||
def http_request(link: str) -> str:
|
||||
""" Http get request. """
|
||||
http = urllib3.PoolManager()
|
||||
return http.request('GET', link)
|
||||
|
|
|
@ -14,7 +14,7 @@ from slpkg.models.models import session as Session
|
|||
class ViewMessage:
|
||||
""" Print some messages before. """
|
||||
|
||||
def __init__(self, flags):
|
||||
def __init__(self, flags: list):
|
||||
self.flags = flags
|
||||
self.configs = Configs
|
||||
self.colors = self.configs.colour
|
||||
|
@ -170,7 +170,7 @@ class ViewMessage:
|
|||
print(f'\n{color["grey"]}Total {installed + upgraded} packages '
|
||||
f'will be removed.{color["endc"]}')
|
||||
|
||||
def logs_packages(self, dependencies):
|
||||
def logs_packages(self, dependencies: list):
|
||||
""" View the logging packages. """
|
||||
print('The following logs will be removed:\n')
|
||||
color = self.colors()
|
||||
|
|
Loading…
Reference in a new issue