Added some comments

This commit is contained in:
Dimitris Zlatanidis 2022-12-21 11:19:47 +02:00
parent 7b4ebd55c3
commit 59f3849d17
14 changed files with 30 additions and 0 deletions

View file

@ -15,6 +15,7 @@ class Blacklist:
self.configs = Configs
def get(self):
""" Reads the blacklist file. """
file = f'{self.configs.etc_path}/blacklist.toml'
if os.path.isfile(file):
with open(file, 'rb') as black:

View file

@ -15,6 +15,7 @@ class CheckUpdates:
self.configs = Configs
def check(self):
""" Checks the ChangeLogs and returns True or False. """
print('Checking for news in the Changelog.txt file...')
local_date = 0
local_chg_txt = (f'{self.configs.sbo_repo_path}/'

View file

@ -14,6 +14,7 @@ class Md5sum:
self.flags = flags
def check(self, path: str, source: str, checksum: str, name: str):
""" Checksum the source. """
filename = f'{path}/{source.split("/")[-1]}'
md5 = self.read_file(filename)
@ -30,5 +31,6 @@ class Md5sum:
@staticmethod
def read_file(filename: str):
""" Reads the text file. """
with open(filename, 'rb') as f:
return f.read()

View file

@ -15,6 +15,7 @@ class CleanLogsDependencies:
self.session = Session
def clean(self):
""" Deletes the log table from the database. """
dependencies = self.session.query(
LogsDependencies.name, LogsDependencies.requires).all()

View file

@ -15,6 +15,7 @@ class CreateData:
self.session = Session
def insert_sbo_table(self):
""" Install the data. """
sbo_tags = [
'SLACKBUILD NAME:',
'SLACKBUILD LOCATION:',
@ -57,5 +58,6 @@ class CreateData:
@staticmethod
def read_file(file: str):
""" Reades the text file. """
with open(file, 'r', encoding='utf-8') as f:
return f.readlines()

View file

@ -13,6 +13,7 @@ class Requires:
self.name = name
def resolve(self) -> list:
""" Resolve the dependencies. """
requires = SBoQueries(self.name).requires()
for req in requires:

View file

@ -18,6 +18,7 @@ class Download:
self.session = Session
def packages(self, slackbuilds: list):
""" Download the package only. """
view = ViewMessage(self.flags)
view.download_packages(slackbuilds)
view.question()

View file

@ -14,5 +14,6 @@ class Wget:
self.wget_options: str = Configs.wget_options
def download(self, path: str, url: str):
""" Wget downloader. """
subprocess.call(f'wget {self.wget_options} --directory-prefix={path}'
f' {url}', shell=True)

View file

@ -16,6 +16,7 @@ class FindInstalled:
self.color = colors()
def find(self, packages: list):
""" Find the packages. """
matching = []
print(f'The list below shows the installed packages '
@ -28,6 +29,7 @@ class FindInstalled:
self.matched(matching)
def matched(self, matching: list):
""" Print the matched packages. """
if matching:
for package in matching:
print(f'{self.color["cyan"]}{package}{self.color["endc"]}')

View file

@ -21,9 +21,11 @@ class SBoQueries:
self.name = ''
def names(self):
""" Returns all the slackbuilds. """
return list(self._names_grabbing())
def slackbuild(self):
""" Returns a slackbuild. """
sbo = self.session.query(
SBoTable.name).filter(SBoTable.name == self.name).first()
@ -32,6 +34,7 @@ class SBoQueries:
return ''
def location(self):
""" Returns the category of a slackbuild. """
location = self.session.query(
SBoTable.location).filter(SBoTable.name == self.name).first()
@ -40,6 +43,7 @@ class SBoQueries:
return ''
def sources(self):
""" Returns the source of a slackbuild. """
source, source64 = self.session.query(
SBoTable.download, SBoTable.download64).filter(
SBoTable.name == self.name).first()
@ -49,6 +53,7 @@ class SBoQueries:
return ''
def requires(self):
""" Returns the requirements of a slackbuild. """
requires = self.session.query(
SBoTable.requires).filter(
SBoTable.name == self.name).first()
@ -62,6 +67,7 @@ class SBoQueries:
return ''
def version(self):
""" Returns the version of a slackbuild. """
version = self.session.query(
SBoTable.version).filter(
SBoTable.name == self.name).first()
@ -71,6 +77,7 @@ class SBoQueries:
return ''
def checksum(self):
""" Returns the source checkcum. """
md5sum, md5sum64, = [], []
mds5, md5s64 = self.session.query(
SBoTable.md5sum, SBoTable.md5sum64).filter(
@ -86,6 +93,7 @@ class SBoQueries:
return ''
def description(self):
""" Returns the slackbuild description. """
desc = self.session.query(
SBoTable.short_description).filter(
SBoTable.name == self.name).first()
@ -95,6 +103,7 @@ class SBoQueries:
return ''
def files(self):
""" Returns the files of a slackbuild. """
files = self.session.query(
SBoTable.files).filter(
SBoTable.name == self.name).first()
@ -104,11 +113,13 @@ class SBoQueries:
return ''
def _chose_arch(self, arch, arch64):
""" Choosing the right arch. """
if self.configs.os_arch == 'x86_64' and arch64:
return arch64
return arch
def _names_grabbing(self):
""" Generate and returns all the slackbuilds. """
names = self.session.query(SBoTable.name).all()
for n in names:
yield n[0]

View file

@ -13,6 +13,7 @@ class SearchPackage:
self.colors = Configs.colour
def package(self, packages):
""" Searching and print the matched slackbuilds. """
color = self.colors()
cyan = color['cyan']
endc = color['endc']

View file

@ -23,6 +23,7 @@ class UpdateRepository:
self.session = Session
def sbo(self):
""" Updated the sbo repository. """
view = ViewMessage('')
check_updates = CheckUpdates()
@ -50,10 +51,12 @@ class UpdateRepository:
@staticmethod
def delete_file(folder: str, txt_file: str):
""" Delete the file. """
file = f'{folder}/{txt_file}'
if path.exists(file):
os.remove(file)
def delete_sbo_data(self):
""" Delete the table from the database. """
self.session.query(SBoTable).delete()
self.session.commit()

View file

@ -18,6 +18,7 @@ class Usage:
self.endc = color['endc']
def help_short(self):
""" Prints the short menu. """
args = (
f'Usage: {Configs.prog_name} [{self.yellow}OPTIONS{self.endc}] [{self.cyan}COMMAND{self.endc}] <packages>\n'
f'\n slpkg [{self.yellow}OPTIONS{self.endc}] [--yes, --jobs, --resolve-off, --reinstall, --skip-installed]\n'
@ -30,6 +31,7 @@ class Usage:
raise SystemExit()
def help(self, status: int):
""" Prints the main menu. """
args = [
f'{self.bold}USAGE:{self.endc} {Configs.prog_name} [{self.yellow}OPTIONS{self.endc}] [{self.cyan}COMMAND{self.endc}] <packages>\n',
f'{self.bold}DESCRIPTION:{self.endc}',

View file

@ -13,6 +13,7 @@ class Version:
self.homepage: str = 'https://dslackw.gitlab.io/slpkg'
def view(self):
""" Prints the version. """
print(f'Version: {self.version}\n'
f'Author: {self.author}\n'
f'License: {self.license}\n'