mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-03 06:56:44 +01:00
Improving code for Python 3
Signed-off-by: Dimitris Zlatanidis <d.zlatanidis@gmail.com>
This commit is contained in:
parent
81c86a5620
commit
27d4ba5419
3 changed files with 29 additions and 17 deletions
|
@ -33,8 +33,7 @@ def search_pkg(name, repo):
|
||||||
"""Search if package exists in PACKAGES.TXT file
|
"""Search if package exists in PACKAGES.TXT file
|
||||||
and return the name.
|
and return the name.
|
||||||
"""
|
"""
|
||||||
PACKAGES_TXT = Utils().read_file(_meta_.lib_path + "{0}_repo/"
|
PACKAGES_TXT = Utils().read_file(_meta_.lib_path + f"{repo}_repo/PACKAGES.TXT")
|
||||||
"PACKAGES.TXT".format(repo))
|
|
||||||
names = Utils().package_name(PACKAGES_TXT)
|
names = Utils().package_name(PACKAGES_TXT)
|
||||||
blacklist = BlackList().packages(pkgs=names, repo=repo)
|
blacklist = BlackList().packages(pkgs=names, repo=repo)
|
||||||
for line in PACKAGES_TXT.splitlines():
|
for line in PACKAGES_TXT.splitlines():
|
||||||
|
|
|
@ -137,14 +137,17 @@ class Initialization:
|
||||||
self.down(log, ChangeLog_txt, repo_name)
|
self.down(log, ChangeLog_txt, repo_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, repo_name)
|
||||||
self.merge(lib, "PACKAGES.TXT", ["core/PACKAGES.TXT",
|
merge = self.merge_stable
|
||||||
"extra/PACKAGES.TXT",
|
if self.meta.slack_rel == "current":
|
||||||
"pasture/PACKAGES.TXT",
|
merge = self.merge_current
|
||||||
"patches/PACKAGES.TXT"])
|
merge(lib, "PACKAGES.TXT", ["core/PACKAGES.TXT",
|
||||||
self.merge(lib, "CHECKSUMS.md5", ["core/CHECKSUMS.md5",
|
"extra/PACKAGES.TXT",
|
||||||
"extra/CHECKSUMS.md5",
|
"pasture/PACKAGES.TXT",
|
||||||
"pasture/CHECKSUMS.md5",
|
"patches/PACKAGES.TXT"])
|
||||||
"patches/CHECKSUMS_md5"])
|
merge(lib, "CHECKSUMS.md5", ["core/CHECKSUMS.md5",
|
||||||
|
"extra/CHECKSUMS.md5",
|
||||||
|
"pasture/CHECKSUMS.md5",
|
||||||
|
"patches/CHECKSUMS_md5"])
|
||||||
|
|
||||||
def sbo(self):
|
def sbo(self):
|
||||||
"""Creating sbo local library
|
"""Creating sbo local library
|
||||||
|
@ -682,7 +685,17 @@ class Initialization:
|
||||||
self.down(lib_path, FILELIST_TXT, repo)
|
self.down(lib_path, FILELIST_TXT, repo)
|
||||||
self.down(log_path, ChangeLog_txt, repo)
|
self.down(log_path, ChangeLog_txt, repo)
|
||||||
|
|
||||||
def merge(self, path, outfile, infiles):
|
def merge_stable(self, path, outfile, infiles):
|
||||||
|
"""Merge files
|
||||||
|
"""
|
||||||
|
with open(path + outfile, 'w') as out_f:
|
||||||
|
for i in infiles:
|
||||||
|
if os.path.isfile(f"{path}{i}"):
|
||||||
|
with open(path + i, "r") as in_f:
|
||||||
|
for line in in_f:
|
||||||
|
out_f.write(line)
|
||||||
|
|
||||||
|
def merge_current(self, path, outfile, infiles):
|
||||||
"""Merge files
|
"""Merge files
|
||||||
"""
|
"""
|
||||||
code = "utf-8"
|
code = "utf-8"
|
||||||
|
|
|
@ -38,17 +38,17 @@ def mirrors(name, location):
|
||||||
repo = Repo().slack()
|
repo = Repo().slack()
|
||||||
if _meta_.arch == "x86_64":
|
if _meta_.arch == "x86_64":
|
||||||
if rel == "stable":
|
if rel == "stable":
|
||||||
http = repo + "slackware64-{0}/{1}{2}".format(ver, location, name)
|
http = f"{repo}slackware64-{ver}/{location}{name}"
|
||||||
else:
|
else:
|
||||||
http = repo + "slackware64-{0}/{1}{2}".format(rel, location, name)
|
http = f"{repo}slackware64-{rel}/{location}{name}"
|
||||||
elif _meta_.arch.startswith("arm"):
|
elif _meta_.arch.startswith("arm"):
|
||||||
if rel == "stable":
|
if rel == "stable":
|
||||||
http = repo + "slackwarearm-{0}/{1}{2}".format(ver, location, name)
|
http = f"{repo}slackwarearm-{ver}/{location}{name}"
|
||||||
else:
|
else:
|
||||||
http = repo + "slackwarearm-{0}/{1}{2}".format(rel, location, name)
|
http = f"{repo}slackwarearm-{rel}/{location}{name}"
|
||||||
else:
|
else:
|
||||||
if rel == "stable":
|
if rel == "stable":
|
||||||
http = repo + "slackware-{0}/{1}{2}".format(ver, location, name)
|
http = f"{repo}slackware-{ver}/{location}{name}"
|
||||||
else:
|
else:
|
||||||
http = repo + "slackware-{0}/{1}{2}".format(rel, location, name)
|
http = f"{repo}slackware-{rel}/{location}{name}"
|
||||||
return http
|
return http
|
||||||
|
|
Loading…
Reference in a new issue