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