Make code more readable

This commit is contained in:
Dimitris Zlatanidis 2022-05-30 22:10:22 +03:00
parent 1c82614c21
commit 40759022fb
2 changed files with 26 additions and 27 deletions

View file

@ -24,7 +24,7 @@
from slpkg.messages import Msg from slpkg.messages import Msg
from slpkg.arguments import usage from slpkg.arguments import usage
from slpkg.init import Initialization from slpkg.init import Init
from slpkg.__metadata__ import MetaData as _meta_ from slpkg.__metadata__ import MetaData as _meta_
@ -41,7 +41,7 @@ class Updates:
self.st = "" self.st = ""
self.count_repo = 0 self.count_repo = 0
self.count_news = 0 self.count_news = 0
self._init = Initialization(True) self._init = Init(True)
self.all_repos = { self.all_repos = {
"slack": self._init.slack, "slack": self._init.slack,
"sbo": self._init.sbo, "sbo": self._init.sbo,

View file

@ -37,7 +37,7 @@ from slpkg.slack.slack_version import slack_ver
from slpkg.models.models import SBoTable, session from slpkg.models.models import SBoTable, session
class Initialization(Utils): class Init(Utils):
"""Slpkg initialization starts all from here. """Slpkg initialization starts all from here.
Creates local package lists and updates or upgrades these. Creates local package lists and updates or upgrades these.
""" """
@ -94,7 +94,6 @@ class Initialization(Utils):
repo = Repo().custom_repository()[name] repo = Repo().custom_repository()[name]
log = self.log_path + name + "/" log = self.log_path + name + "/"
lib = self.lib_path + f"{name}_repo/" lib = self.lib_path + f"{name}_repo/"
repo_name = log[:-1].split("/")[-1]
lib_file = "PACKAGES.TXT" lib_file = "PACKAGES.TXT"
# lst_file = "" # lst_file = ""
md5_file = "CHECKSUMS.md5" md5_file = "CHECKSUMS.md5"
@ -106,18 +105,18 @@ class Initialization(Utils):
ChangeLog_txt = f"{repo}{log_file}" ChangeLog_txt = f"{repo}{log_file}"
if self.check: if self.check:
return self.checks_logs(log, ChangeLog_txt) return self.checks_logs(log, ChangeLog_txt)
self.down(lib, PACKAGES_TXT, repo_name) self.down(lib, PACKAGES_TXT, name)
self.down(lib, CHECKSUMS_MD5, repo_name) self.down(lib, CHECKSUMS_MD5, name)
self.down(log, ChangeLog_txt, repo_name) self.down(log, ChangeLog_txt, name)
self.remote(log, ChangeLog_txt, lib, PACKAGES_TXT, CHECKSUMS_MD5, self.remote(log, ChangeLog_txt, lib, PACKAGES_TXT, CHECKSUMS_MD5,
FILELIST_TXT, repo_name) FILELIST_TXT, name)
def slack(self): def slack(self):
"""Creating slack local libraries """Creating slack local libraries
""" """
log = self.log_path + "slack/" log = self.log_path + "slack/"
lib = self.lib_path + "slack_repo/" lib = self.lib_path + "slack_repo/"
repo_name = log[:-1].split("/")[-1] repo_name = Init.slack.__name__
lib_file = "PACKAGES.TXT" lib_file = "PACKAGES.TXT"
# lst_file = "" # lst_file = ""
md5_file = "CHECKSUMS.md5" md5_file = "CHECKSUMS.md5"
@ -159,7 +158,7 @@ class Initialization(Utils):
repo = self.def_repos_dict["sbo"] repo = self.def_repos_dict["sbo"]
log = self.log_path + "sbo/" log = self.log_path + "sbo/"
lib = self.lib_path + "sbo_repo/" lib = self.lib_path + "sbo_repo/"
repo_name = log[:-1].split("/")[-1] repo_name = Init.sbo.__name__
lib_file = "SLACKBUILDS.TXT" lib_file = "SLACKBUILDS.TXT"
# lst_file = "" # lst_file = ""
# md5_file = "" # md5_file = ""
@ -182,7 +181,7 @@ class Initialization(Utils):
repo = self.def_repos_dict["rlw"] repo = self.def_repos_dict["rlw"]
log = self.log_path + "rlw/" log = self.log_path + "rlw/"
lib = self.lib_path + "rlw_repo/" lib = self.lib_path + "rlw_repo/"
repo_name = log[:-1].split("/")[-1] repo_name = Init.rlw.__name__
lib_file = "PACKAGES.TXT" lib_file = "PACKAGES.TXT"
# lst_file = "" # lst_file = ""
md5_file = "CHECKSUMS.md5" md5_file = "CHECKSUMS.md5"
@ -208,7 +207,7 @@ class Initialization(Utils):
repo = self.def_repos_dict["alien"] repo = self.def_repos_dict["alien"]
log = self.log_path + "alien/" log = self.log_path + "alien/"
lib = self.lib_path + "alien_repo/" lib = self.lib_path + "alien_repo/"
repo_name = log[:-1].split("/")[-1] repo_name = Init.alien.__name__
lib_file = "PACKAGES.TXT" lib_file = "PACKAGES.TXT"
# lst_file = "" # lst_file = ""
md5_file = "CHECKSUMS.md5" md5_file = "CHECKSUMS.md5"
@ -237,7 +236,7 @@ class Initialization(Utils):
repo = self.def_repos_dict["slacky"] repo = self.def_repos_dict["slacky"]
log = self.log_path + "slacky/" log = self.log_path + "slacky/"
lib = self.lib_path + "slacky_repo/" lib = self.lib_path + "slacky_repo/"
repo_name = log[:-1].split("/")[-1] repo_name = Init.slacky.__name__
lib_file = "PACKAGES.TXT" lib_file = "PACKAGES.TXT"
# lst_file = "" # lst_file = ""
md5_file = "CHECKSUMS.md5" md5_file = "CHECKSUMS.md5"
@ -264,7 +263,7 @@ class Initialization(Utils):
repo = self.def_repos_dict["conrad"] repo = self.def_repos_dict["conrad"]
log = self.log_path + "conrad/" log = self.log_path + "conrad/"
lib = self.lib_path + "conrad_repo/" lib = self.lib_path + "conrad_repo/"
repo_name = log[:-1].split("/")[-1] repo_name = Init.conrad.__name__
lib_file = "PACKAGES.TXT" lib_file = "PACKAGES.TXT"
# lst_file = "" # lst_file = ""
md5_file = "CHECKSUMS.md5" md5_file = "CHECKSUMS.md5"
@ -289,7 +288,7 @@ class Initialization(Utils):
repo = self.def_repos_dict["slonly"] repo = self.def_repos_dict["slonly"]
log = self.log_path + "slonly/" log = self.log_path + "slonly/"
lib = self.lib_path + "slonly_repo/" lib = self.lib_path + "slonly_repo/"
repo_name = log[:-1].split("/")[-1] repo_name = Init.slonly.__name__
lib_file = "PACKAGES.TXT" lib_file = "PACKAGES.TXT"
# lst_file = "" # lst_file = ""
md5_file = "CHECKSUMS.md5" md5_file = "CHECKSUMS.md5"
@ -319,7 +318,7 @@ class Initialization(Utils):
repo = self.def_repos_dict["ktown"] repo = self.def_repos_dict["ktown"]
log = self.log_path + "ktown/" log = self.log_path + "ktown/"
lib = self.lib_path + "ktown_repo/" lib = self.lib_path + "ktown_repo/"
repo_name = log[:-1].split("/")[-1] repo_name = Init.ktown.__name__
lib_file = "PACKAGES.TXT" lib_file = "PACKAGES.TXT"
# lst_file = "" # lst_file = ""
md5_file = "CHECKSUMS.md5" md5_file = "CHECKSUMS.md5"
@ -344,7 +343,7 @@ class Initialization(Utils):
repo = self.def_repos_dict["multi"] repo = self.def_repos_dict["multi"]
log = self.log_path + "multi/" log = self.log_path + "multi/"
lib = self.lib_path + "multi_repo/" lib = self.lib_path + "multi_repo/"
repo_name = log[:-1].split("/")[-1] repo_name = Init.multi.__name__
lib_file = "PACKAGES.TXT" lib_file = "PACKAGES.TXT"
# lst_file = "" # lst_file = ""
md5_file = "CHECKSUMS.md5" md5_file = "CHECKSUMS.md5"
@ -371,7 +370,7 @@ class Initialization(Utils):
repo = self.def_repos_dict["slacke"] repo = self.def_repos_dict["slacke"]
log = self.log_path + "slacke/" log = self.log_path + "slacke/"
lib = self.lib_path + "slacke_repo/" lib = self.lib_path + "slacke_repo/"
repo_name = log[:-1].split("/")[-1] repo_name = Init.slacke.__name__
lib_file = "PACKAGES.TXT" lib_file = "PACKAGES.TXT"
# lst_file = "" # lst_file = ""
md5_file = "CHECKSUMS.md5" md5_file = "CHECKSUMS.md5"
@ -402,7 +401,7 @@ class Initialization(Utils):
repo = self.def_repos_dict["salix"] repo = self.def_repos_dict["salix"]
log = self.log_path + "salix/" log = self.log_path + "salix/"
lib = self.lib_path + "salix_repo/" lib = self.lib_path + "salix_repo/"
repo_name = log[:-1].split("/")[-1] repo_name = Init.salix.__name__
lib_file = "PACKAGES.TXT" lib_file = "PACKAGES.TXT"
# lst_file = "" # lst_file = ""
md5_file = "CHECKSUMS.md5" md5_file = "CHECKSUMS.md5"
@ -429,7 +428,7 @@ class Initialization(Utils):
repo = self.def_repos_dict["slackl"] repo = self.def_repos_dict["slackl"]
log = self.log_path + "slackl/" log = self.log_path + "slackl/"
lib = self.lib_path + "slackl_repo/" lib = self.lib_path + "slackl_repo/"
repo_name = log[:-1].split("/")[-1] repo_name = Init.slackl.__name__
lib_file = "PACKAGES.TXT" lib_file = "PACKAGES.TXT"
# lst_file = "" # lst_file = ""
md5_file = "CHECKSUMS.md5" md5_file = "CHECKSUMS.md5"
@ -455,7 +454,7 @@ class Initialization(Utils):
repo = self.def_repos_dict["rested"] repo = self.def_repos_dict["rested"]
log = self.log_path + "rested/" log = self.log_path + "rested/"
lib = self.lib_path + "rested_repo/" lib = self.lib_path + "rested_repo/"
repo_name = log[:-1].split("/")[-1] repo_name = Init.rested.__name__
lib_file = "PACKAGES.TXT" lib_file = "PACKAGES.TXT"
# lst_file = "" # lst_file = ""
md5_file = "CHECKSUMS.md5" md5_file = "CHECKSUMS.md5"
@ -481,7 +480,7 @@ class Initialization(Utils):
repo = self.def_repos_dict["msb"] repo = self.def_repos_dict["msb"]
log = self.log_path + "msb/" log = self.log_path + "msb/"
lib = self.lib_path + "msb_repo/" lib = self.lib_path + "msb_repo/"
repo_name = log[:-1].split("/")[-1] repo_name = Init.msb.__name__
lib_file = "PACKAGES.TXT" lib_file = "PACKAGES.TXT"
# lst_file = "" # lst_file = ""
md5_file = "CHECKSUMS.md5" md5_file = "CHECKSUMS.md5"
@ -512,7 +511,7 @@ class Initialization(Utils):
repo = self.def_repos_dict["csb"] repo = self.def_repos_dict["csb"]
log = self.log_path + "csb/" log = self.log_path + "csb/"
lib = self.lib_path + "csb_repo/" lib = self.lib_path + "csb_repo/"
repo_name = log[:-1].split("/")[-1] repo_name = Init.csb.__name__
lib_file = "PACKAGES.TXT" lib_file = "PACKAGES.TXT"
# lst_file = "" # lst_file = ""
md5_file = "CHECKSUMS.md5" md5_file = "CHECKSUMS.md5"
@ -542,7 +541,7 @@ class Initialization(Utils):
repo = self.def_repos_dict["connos"] repo = self.def_repos_dict["connos"]
log = self.log_path + "connos/" log = self.log_path + "connos/"
lib = self.lib_path + "connos_repo/" lib = self.lib_path + "connos_repo/"
repo_name = log[:-1].split("/")[-1] repo_name = Init.connos.__name__
lib_file = "PACKAGES.TXT" lib_file = "PACKAGES.TXT"
# lst_file = "" # lst_file = ""
md5_file = "CHECKSUMS.md5" md5_file = "CHECKSUMS.md5"
@ -569,7 +568,7 @@ class Initialization(Utils):
repo = self.def_repos_dict["mles"] repo = self.def_repos_dict["mles"]
log = self.log_path + "mles/" log = self.log_path + "mles/"
lib = self.lib_path + "mles_repo/" lib = self.lib_path + "mles_repo/"
repo_name = log[:-1].split("/")[-1] repo_name = Init.mles.__name__
lib_file = "PACKAGES.TXT" lib_file = "PACKAGES.TXT"
# lst_file = "" # lst_file = ""
md5_file = "CHECKSUMS.md5" md5_file = "CHECKSUMS.md5"
@ -727,10 +726,10 @@ class Update:
continue continue
self.done_msg(repo) self.done_msg(repo)
if repo in default: if repo in default:
getattr(Initialization(False), repo)() getattr(Init(False), repo)()
print(self.done, end="") print(self.done, end="")
elif repo in custom: elif repo in custom:
Initialization(False).custom(repo) Init(False).custom(repo)
print(self.done, end="") print(self.done, end="")
else: else:
print(self.error, end="") print(self.error, end="")