Fixed typos

This commit is contained in:
Dimitris Zlatanidis 2022-05-29 21:33:06 +03:00
parent 6d1934a1d9
commit caafd78aef
29 changed files with 110 additions and 146 deletions

View file

@ -30,7 +30,7 @@ from slpkg.__metadata__ import MetaData as _meta_
class BlackList(Utils): class BlackList(Utils):
"""Blacklist class to add, remove or listed packages """Blacklist class to add, remove or list packages
in blacklist file.""" in blacklist file."""
def __init__(self): def __init__(self):
self.green = _meta_.color["GREEN"] self.green = _meta_.color["GREEN"]
@ -56,8 +56,8 @@ class BlackList(Utils):
yield black yield black
def black_filter(self): def black_filter(self):
"""Return all the installed files that start """Returns all the installed files that start
by the name* by the name
""" """
for read in self.black_conf.splitlines(): for read in self.black_conf.splitlines():
read = read.lstrip() read = read.lstrip()
@ -65,7 +65,7 @@ class BlackList(Utils):
yield read.replace("\n", "") yield read.replace("\n", "")
def black_listed(self): def black_listed(self):
"""Print blacklist packages """Prints blacklist packages
""" """
print("Packages in the blacklist:") print("Packages in the blacklist:")
for black in list(self.black_filter()): for black in list(self.black_filter()):
@ -74,7 +74,7 @@ class BlackList(Utils):
print() print()
def black_add(self, pkgs): def black_add(self, pkgs):
"""Add blacklist packages if not exist """Adds blacklist packages if not exist
""" """
blacklist = list(self.black_filter()) blacklist = list(self.black_filter())
pkgs = set(pkgs) pkgs = set(pkgs)
@ -87,7 +87,7 @@ class BlackList(Utils):
print() print()
def black_remove(self, pkgs): def black_remove(self, pkgs):
"""Remove packages from blacklist """Removes packages from blacklist
""" """
print("Remove packages from the blacklist:") print("Remove packages from the blacklist:")
with open(self.blackfile, "w") as remove: with open(self.blackfile, "w") as remove:

View file

@ -29,7 +29,7 @@ from slpkg.__metadata__ import MetaData as _meta_
def clean_tmp(): def clean_tmp():
"""Delete packages and sources from tmp/ directory """Deletes packages and sources from tmp/ directory
""" """
tmps = [_meta_.tmp_path, # /tmp/slpkg/ tmps = [_meta_.tmp_path, # /tmp/slpkg/
_meta_.build_path, # /tmp/slpkg/build/ _meta_.build_path, # /tmp/slpkg/build/

View file

@ -28,7 +28,7 @@ import os
class DialogUtil: class DialogUtil:
"""Create dialog checklist """Creates dialog checklist
""" """
def __init__(self, *args): def __init__(self, *args):
self.imp_dialog() self.imp_dialog()

View file

@ -51,7 +51,7 @@ class Download(Utils):
self.downder_options = self.meta.downder_options self.downder_options = self.meta.downder_options
def start(self): def start(self):
"""Download files using wget or other downloader. """Download files using wget or other downloaders.
Optional curl, aria2c and httpie Optional curl, aria2c and httpie
""" """
dwn_count = 1 dwn_count = 1
@ -82,7 +82,7 @@ class Download(Utils):
dwn_count += 1 dwn_count += 1
def _make_tarfile(self, output_filename, source_dir): def _make_tarfile(self, output_filename, source_dir):
"""Create .tar.gz file """Creates .tar.gz file
""" """
with tarfile.open(output_filename, "w:gz") as tar: with tarfile.open(output_filename, "w:gz") as tar:
tar.add(source_dir, arcname=os.path.basename(source_dir)) tar.add(source_dir, arcname=os.path.basename(source_dir))
@ -96,7 +96,7 @@ class Download(Utils):
self.dir_prefix = "--dir=" self.dir_prefix = "--dir="
def _check_if_downloaded(self): def _check_if_downloaded(self):
"""Check if file downloaded """Checks if file downloaded
""" """
if not os.path.isfile(self.path + self.file_name): if not os.path.isfile(self.path + self.file_name):
print() print()
@ -109,7 +109,7 @@ class Download(Utils):
raise SystemExit() raise SystemExit()
def _check_certificate(self): def _check_certificate(self):
"""Check for certificates options for wget """Checks for certificates options for wget
""" """
if (self.file_name.startswith("jdk-") and self.repo == "sbo" and if (self.file_name.startswith("jdk-") and self.repo == "sbo" and
self.downder == "wget"): self.downder == "wget"):

View file

@ -29,7 +29,7 @@ from slpkg.__metadata__ import MetaData as _meta_
class FileSize: class FileSize:
"""Check local or remote file size """Checks local or remote file size
""" """
def __init__(self, registry): def __init__(self, registry):
self.meta = _meta_ self.meta = _meta_

View file

@ -47,7 +47,7 @@ class Graph:
] ]
def dependencies(self, deps_dict): def dependencies(self, deps_dict):
"""Generate graph file with depenndencies map tree """Generates graph file with dependencies map tree
""" """
try: try:
import pygraphviz as pgv import pygraphviz as pgv
@ -75,7 +75,7 @@ class Graph:
raise SystemExit() raise SystemExit()
def check_file(self): def check_file(self):
"""Check for file format and type """Checks for file format and type
""" """
try: try:
image_type = f".{self.image.split('.')[1]}" image_type = f".{self.image.split('.')[1]}"
@ -87,7 +87,7 @@ class Graph:
raise SystemExit("slpkg: Error: Image file suffix missing") raise SystemExit("slpkg: Error: Image file suffix missing")
def graph_easy(self): def graph_easy(self):
"""Draw ascii diagram. graph-easy perl module require """Drawing ascii diagram. graph-easy perl module requires
""" """
if not os.path.isfile("/usr/bin/graph-easy"): if not os.path.isfile("/usr/bin/graph-easy"):
print("Require 'graph-easy': Install with 'slpkg -s sbo" print("Require 'graph-easy': Install with 'slpkg -s sbo"
@ -99,7 +99,7 @@ class Graph:
raise SystemExit(1) raise SystemExit(1)
def remove_dot(self): def remove_dot(self):
"""Remove .dot files """Removes .dot files
""" """
if os.path.isfile(f"{self.image}.dot"): if os.path.isfile(f"{self.image}.dot"):
os.remove(f"{self.image}.dot") os.remove(f"{self.image}.dot")

View file

@ -29,7 +29,7 @@ from slpkg.__metadata__ import MetaData as _meta_
def pkg_checksum(binary, repo): def pkg_checksum(binary, repo):
"""Return checksum from CHECKSUMS.md5 file by repository """Returns checksum from CHECKSUMS.md5 file by repository
""" """
md5 = "None" md5 = "None"
if repo == "slack_patches" and _meta_.slack_rel == "stable": if repo == "slack_patches" and _meta_.slack_rel == "stable":

View file

@ -31,7 +31,7 @@ from slpkg.pkg.find import find_package
class PackageHealth: class PackageHealth:
"""Health check installed packages """Health check for the installed packages
""" """
def __init__(self, mode): def __init__(self, mode):
self.mode = mode self.mode = mode
@ -46,7 +46,7 @@ class PackageHealth:
self.cn = 0 self.cn = 0
def packages(self): def packages(self):
"""Get all installed packages from /var/log/packages/ path """Gets all installed packages from /var/log/packages/ path
""" """
self.installed = find_package("", self.pkg_path) self.installed = find_package("", self.pkg_path)
@ -67,7 +67,7 @@ class PackageHealth:
raise SystemExit("\n") raise SystemExit("\n")
def test(self): def test(self):
"""Get started test each package and read file list """Starts testing each package and reading the file list
""" """
self.packages() self.packages()
self.cf = 0 self.cf = 0
@ -86,7 +86,7 @@ class PackageHealth:
self.results() self.results()
def results(self): def results(self):
"""Print results """Prints results
""" """
print() print()
per = int(round((float(self.cf) / (self.cf + self.cn)) * 100)) per = int(round((float(self.cf) / (self.cf + self.cn)) * 100))

View file

@ -38,8 +38,8 @@ from slpkg.slack.slack_version import slack_ver
class Initialization(Utils): class Initialization(Utils):
"""Slpkg initialization start all from here. Create local """Slpkg initialization starts all from here.
package lists and update or upgrade these. Creates local package lists and updates or upgrades these.
""" """
def __init__(self, check): def __init__(self, check):
self.check = check self.check = check
@ -97,7 +97,7 @@ class Initialization(Utils):
os.makedirs(p) os.makedirs(p)
def custom(self, name): def custom(self, name):
"""Creating user select repository local library """Creating user custom repository local library
""" """
repo = Repo().custom_repository()[name] repo = Repo().custom_repository()[name]
log = self.log_path + name + "/" log = self.log_path + name + "/"
@ -599,14 +599,14 @@ class Initialization(Utils):
FILELIST_TXT, repo_name) FILELIST_TXT, repo_name)
def down(self, path, link, repo): def down(self, path, link, repo):
"""Download files """Downloads files
""" """
filename = link.split("/")[-1] filename = link.split("/")[-1]
if not os.path.isfile(path + filename): if not os.path.isfile(path + filename):
Download(path, link.split(), repo).start() Download(path, link.split(), repo).start()
def remote(self, *args): def remote(self, *args):
"""Remove and recreate files """Removes and recreates files
""" """
log_path = args[0] log_path = args[0]
ChangeLog_txt = args[1] ChangeLog_txt = args[1]
@ -642,7 +642,7 @@ class Initialization(Utils):
self.con.commit() self.con.commit()
def merge(self, path, outfile, infiles): def merge(self, path, outfile, infiles):
"""Merge files """Merging files
""" """
code = "utf-8" code = "utf-8"
with open(path + outfile, 'w', encoding=code) as out_f: with open(path + outfile, 'w', encoding=code) as out_f:
@ -655,7 +655,7 @@ class Initialization(Utils):
out_f.write(line) out_f.write(line)
def file_remove(self, path, filename): def file_remove(self, path, filename):
"""Check if filename exists and remove """Checks if filename exists and removes
""" """
if os.path.isfile(path + filename): if os.path.isfile(path + filename):
os.remove(path + filename) os.remove(path + filename)
@ -718,7 +718,7 @@ class Update:
self.error = f"{self.red}Error{self.endc}\n" self.error = f"{self.red}Error{self.endc}\n"
def run(self, repos): def run(self, repos):
"""Update repositories lists """Updates repositories lists
""" """
print("\nCheck and update repositories:\n") print("\nCheck and update repositories:\n")
default = self.meta.default_repositories default = self.meta.default_repositories
@ -772,7 +772,7 @@ def check_exists_repositories(repo):
def check_for_local_repos(repo): def check_for_local_repos(repo):
"""Check if repository is local """Checks if repository is local
""" """
repos_dict = Repo().default_repository() repos_dict = Repo().default_repository()
if repo in repos_dict: if repo in repos_dict:

View file

@ -32,7 +32,7 @@ from slpkg.pkg.find import find_package
def library(repo): def library(repo):
"""Load packages from slpkg library and from local """Loads packages from slpkg library and from local
""" """
utils = Utils() utils = Utils()
pkg_list, packages = [], "" pkg_list, packages = [], ""
@ -59,7 +59,7 @@ def library(repo):
class Regex: class Regex:
"""Grap packages with simple regex using asterisk * """Graps packages with simple regex using asterisk *
with options: starts with string* with options: starts with string*
ends with *string ends with *string
include *string* include *string*
@ -90,7 +90,7 @@ class Regex:
return lib return lib
def add(self, repo, pkg): def add(self, repo, pkg):
"""Split packages by repository """Splits packages by repository
""" """
if repo == "sbo": if repo == "sbo":
return pkg return pkg

View file

@ -30,8 +30,8 @@ from slpkg.pkg.find import find_package
def write_deps(deps_dict): def write_deps(deps_dict):
"""Write dependencies in a log file """Writes dependencies in a log file
into directory `/var/log/slpkg/dep/` into the directory `/var/log/slpkg/dep/`
""" """
for name, dependencies in deps_dict.items(): for name, dependencies in deps_dict.items():
if find_package(f"{name}-", _meta_.pkg_path): if find_package(f"{name}-", _meta_.pkg_path):

View file

@ -25,12 +25,12 @@
import os import os
import sys import sys
from slpkg.clean import clean_tmp
from slpkg.load import Regex from slpkg.load import Regex
from slpkg.desc import PkgDesc from slpkg.desc import PkgDesc
from slpkg.messages import Msg from slpkg.messages import Msg
from slpkg.config import Config from slpkg.config import Config
from slpkg.checks import Updates from slpkg.checks import Updates
from slpkg.clean import clean_tmp
from slpkg.repoinfo import RepoInfo from slpkg.repoinfo import RepoInfo
from slpkg.repolist import RepoList from slpkg.repolist import RepoList
from slpkg.repositories import Repo from slpkg.repositories import Repo
@ -99,7 +99,7 @@ class ArgParse(BlackList):
"-f", "--find" "-f", "--find"
] ]
# checking if repositories exists # checking if the repositories exist
enabled_repos = _meta_.repositories enabled_repos = _meta_.repositories
if len(self.args) > 1: if len(self.args) > 1:
@ -126,7 +126,7 @@ class ArgParse(BlackList):
usage("", 1) usage("", 1)
def command_update(self): def command_update(self):
"""Update package lists repositories """Updates package lists repositories
""" """
update = Update() update = Update()
@ -143,7 +143,7 @@ class ArgParse(BlackList):
usage("", 1) usage("", 1)
def command_upgrade(self): def command_upgrade(self):
"""Recreate repositories package lists """Recreates repositories package lists
""" """
upgrade = Upgrade() upgrade = Upgrade()
@ -185,7 +185,7 @@ class ArgParse(BlackList):
usage("", 1) usage("", 1)
def command_repo_add(self): def command_repo_add(self):
"""Add custom repositories """Adds custom repositories
""" """
if len(self.args) == 3 and self.args[0] == "repo-add": if len(self.args) == 3 and self.args[0] == "repo-add":
Repo().add(self.args[1], self.args[2]) Repo().add(self.args[1], self.args[2])
@ -193,7 +193,7 @@ class ArgParse(BlackList):
usage("", 1) usage("", 1)
def command_repo_remove(self): def command_repo_remove(self):
"""Remove custom repositories """Removes custom repositories
""" """
if len(self.args) == 2 and self.args[0] == "repo-remove": if len(self.args) == 2 and self.args[0] == "repo-remove":
Repo().remove(self.args[1]) Repo().remove(self.args[1])
@ -214,7 +214,7 @@ class ArgParse(BlackList):
usage("", 1) usage("", 1)
def command_health(self): def command_health(self):
"""Check package health """Checks package health
""" """
if len(self.args) == 1 and self.args[0] == "health": if len(self.args) == 1 and self.args[0] == "health":
PackageHealth(mode="").test() PackageHealth(mode="").test()
@ -225,7 +225,7 @@ class ArgParse(BlackList):
usage("", 1) usage("", 1)
def command_deps_status(self): def command_deps_status(self):
"""Print dependencies status """Prints dependencies status
""" """
image = "" image = ""
@ -247,7 +247,7 @@ class ArgParse(BlackList):
usage("", 1) usage("", 1)
def command_new_config(self): def command_new_config(self):
"""Manage .new configuration files """Manages .new configuration files
""" """
if len(self.args) == 1 and self.args[0] == "new-config": if len(self.args) == 1 and self.args[0] == "new-config":
NewConfig().run() NewConfig().run()
@ -307,7 +307,7 @@ class ArgParse(BlackList):
usage("", 1) usage("", 1)
def pkg_upgrade(self): def pkg_upgrade(self):
"""Check and upgrade packages by repository """Checks and upgrade packages by repository
""" """
options = [ options = [
"-c", "-c",
@ -322,7 +322,7 @@ class ArgParse(BlackList):
] ]
flag, skip = self.__pkg_upgrade_flags(flags) flag, skip = self.__pkg_upgrade_flags(flags)
# Remove --checklist flag from args so that works with # Removes --checklist flag from args so that works with
# both conditions # both conditions
# if flags[3] in self.args: # if flags[3] in self.args:
# self.args.remove(flags[3]) # self.args.remove(flags[3])
@ -351,7 +351,7 @@ class ArgParse(BlackList):
usage("", 1) usage("", 1)
def __pkg_upgrade_flags(self, flags): def __pkg_upgrade_flags(self, flags):
"""Manage flags for package upgrade option """Manages flags for the package upgrade option
""" """
# Check for typos or unssuported flags # Check for typos or unssuported flags
for arg in self.args[2:]: for arg in self.args[2:]:
@ -373,7 +373,7 @@ class ArgParse(BlackList):
return flag, skip return flag, skip
def pkg_install(self): def pkg_install(self):
"""Install packages by repository """Installs packages by repository
""" """
flag = [] flag = []
options = [ options = [
@ -451,7 +451,7 @@ class ArgParse(BlackList):
usage("", 1) usage("", 1)
def sbo_network(self): def sbo_network(self):
"""View slackbuilds packages """Views slackbuilds packages
""" """
flag = [] flag = []
options = [ options = [
@ -479,7 +479,7 @@ class ArgParse(BlackList):
usage("sbo", 1) usage("sbo", 1)
def pkg_blacklist(self): def pkg_blacklist(self):
"""Manage blacklist packages """Manages blacklist packages
""" """
options = [ options = [
"-b", "-b",
@ -509,7 +509,7 @@ class ArgParse(BlackList):
usage("", 1) usage("", 1)
def pkg_queue(self): def pkg_queue(self):
"""Manage packages in queue """Manages packages in queue
""" """
queue = QueuePkgs() queue = QueuePkgs()
options = [ options = [
@ -555,7 +555,7 @@ class ArgParse(BlackList):
usage("", 1) usage("", 1)
def bin_install(self): def bin_install(self):
"""Install Slackware binary packages """Installs Slackware binary packages
""" """
packages = self.args[1:] packages = self.args[1:]
options = [ options = [
@ -583,7 +583,7 @@ class ArgParse(BlackList):
usage("", 1) usage("", 1)
def bin_upgrade(self): def bin_upgrade(self):
"""Install-upgrade Slackware binary packages """Installs, upgrades Slackware binary packages
""" """
packages = self.args[1:] packages = self.args[1:]
options = [ options = [
@ -651,7 +651,7 @@ class ArgParse(BlackList):
usage("", 1) usage("", 1)
def bin_find(self): def bin_find(self):
"""Find installed packages """Finds installed packages
""" """
flag = [] flag = []
options = [ options = [
@ -681,7 +681,7 @@ class ArgParse(BlackList):
usage("", 1) usage("", 1)
def pkg_desc(self): def pkg_desc(self):
"""Print slack-desc by repository """Prints slack-desc by repository
""" """
options = [ options = [
"-p", "-p",
@ -722,7 +722,7 @@ class ArgParse(BlackList):
usage("", 1) usage("", 1)
def pkg_find(self): def pkg_find(self):
"""Find packages from all enabled repositories """Finds packages from all the enabled repositories
""" """
flag = [] flag = []
options = [ options = [
@ -743,7 +743,7 @@ class ArgParse(BlackList):
usage("", 1) usage("", 1)
def pkg_contents(self): def pkg_contents(self):
"""Print packages contents """Prints packages contents
""" """
packages = self.args[1:] packages = self.args[1:]
options = [ options = [
@ -757,7 +757,7 @@ class ArgParse(BlackList):
usage("", 1) usage("", 1)
def congiguration(self): def congiguration(self):
"""Manage slpkg configuration file """Manages slpkg configuration file
""" """
options = [ options = [
"-g", "-g",
@ -782,7 +782,7 @@ class ArgParse(BlackList):
usage("", 1) usage("", 1)
def auto_detect(self, args): def auto_detect(self, args):
"""Check for already Slackware binary packages exist """Checks for already Slackware binary packages
""" """
suffixes = [ suffixes = [
".tgz", ".tgz",

View file

@ -39,23 +39,15 @@ class Msg:
self.endc = _meta_.color["ENDC"] self.endc = _meta_.color["ENDC"]
def pkg_not_found(self, bol, pkg, message, eol): def pkg_not_found(self, bol, pkg, message, eol):
"""Print message when package not found
"""
print(f"{bol}No such package {pkg}: {message}{eol}") print(f"{bol}No such package {pkg}: {message}{eol}")
def pkg_found(self, prgnam): def pkg_found(self, prgnam):
"""Print message when package found
"""
print(f"| Package {prgnam} is already installed") print(f"| Package {prgnam} is already installed")
def pkg_installed(self, pkg): def pkg_installed(self, pkg):
"""Print message when package installed
"""
print(f"| Package {pkg} installed") print(f"| Package {pkg} installed")
def build_FAILED(self, prgnam): def build_FAILED(self, prgnam):
"""Print error message if build failed
"""
self.template(78) self.template(78)
print(f"| Some error on the package {prgnam} " print(f"| Some error on the package {prgnam} "
f"[ {self.red}FAILED{self.endc} ]") f"[ {self.red}FAILED{self.endc} ]")
@ -67,59 +59,41 @@ class Msg:
print() # new line at end print() # new line at end
def template(self, max_len): def template(self, max_len):
"""Print template
"""
print("+" + "=" * max_len) print("+" + "=" * max_len)
def checking(self): def checking(self):
"""Message checking
"""
print(f"{self.grey}Checking...{self.endc} ", end="", flush=True) print(f"{self.grey}Checking...{self.endc} ", end="", flush=True)
def reading(self): def reading(self):
"""Message reading
"""
print(f"{self.grey}Reading package lists...{self.endc} ", print(f"{self.grey}Reading package lists...{self.endc} ",
end="", flush=True) end="", flush=True)
def resolving(self): def resolving(self):
"""Message resolving
"""
print(f"{self.grey}Resolving dependencies...{self.endc} ", print(f"{self.grey}Resolving dependencies...{self.endc} ",
end="", flush=True) end="", flush=True)
def done(self): def done(self):
"""Message done
"""
print(f"\b{self.green}Done{self.endc}\n", end="") print(f"\b{self.green}Done{self.endc}\n", end="")
def pkg(self, count): def pkg(self, count):
"""Print singular plural
"""
message = "package" message = "package"
if count > 1: if count > 1:
message = message + "s" message = message + "s"
return message return message
def not_found(self, if_upgrade): def not_found(self, if_upgrade):
"""Message not found packages
"""
if if_upgrade: if if_upgrade:
print("\nNot found packages for upgrade\n") print("\nNot found packages for upgrade\n")
else: else:
print("\nNot found packages for installation\n") print("\nNot found packages for installation\n")
def upg_inst(self, if_upgrade): def upg_inst(self, if_upgrade):
"""Message installing or upgrading
"""
if not if_upgrade: if not if_upgrade:
print("Installing:") print("Installing:")
else: else:
print("Upgrading:") print("Upgrading:")
def answer(self): def answer(self):
"""Message answer
"""
if self.meta.default_answer in ["y", "Y"]: if self.meta.default_answer in ["y", "Y"]:
answer = self.meta.default_answer answer = self.meta.default_answer
else: else:
@ -130,8 +104,6 @@ class Msg:
return answer return answer
def security_pkg(self, pkg): def security_pkg(self, pkg):
"""Warning message for some special reasons
"""
print() print()
self.template(78) self.template(78)
print(f"| {' ' * 27}{self.red}*** WARNING ***{self.endc}") print(f"| {' ' * 27}{self.red}*** WARNING ***{self.endc}")
@ -143,9 +115,6 @@ class Msg:
print() print()
def reference(self, install, upgrade): def reference(self, install, upgrade):
"""Reference list with packages installed
and upgraded
"""
self.template(78) self.template(78)
print(f"| Total {len(install)} {self.pkg(len(install))} installed and " print(f"| Total {len(install)} {self.pkg(len(install))} installed and "
f"{len(upgrade)} {self.pkg(len(upgrade))} upgraded") f"{len(upgrade)} {self.pkg(len(upgrade))} upgraded")
@ -159,8 +128,6 @@ class Msg:
print() print()
def matching(self, packages): def matching(self, packages):
"""Message for matching packages
"""
print(f"\nNot found package with the name " print(f"\nNot found package with the name "
f"[ {self.cyan}{''.join(packages)}{self.endc} ]. " f"[ {self.cyan}{''.join(packages)}{self.endc} ]. "
"Matching packages:\nNOTE: Not dependencies are resolved\n") "Matching packages:\nNOTE: Not dependencies are resolved\n")

View file

@ -32,7 +32,7 @@ from slpkg.__metadata__ import MetaData as _meta_
class NewConfig(Utils): class NewConfig(Utils):
"""Manage .new configuration files """Manages .new configuration files
""" """
def __init__(self): def __init__(self):
self.meta = _meta_ self.meta = _meta_
@ -47,7 +47,7 @@ class NewConfig(Utils):
self.news = [] self.news = []
def run(self): def run(self):
"""print .new configuration files """prints .new configuration files
""" """
self.find_new() self.find_new()
for n in self.news: for n in self.news:
@ -59,7 +59,7 @@ class NewConfig(Utils):
self.choices() self.choices()
def find_new(self): def find_new(self):
"""Find all '.new' files from /etc/ folder """Finds all '.new' files from /etc/ folder
and subfolders and subfolders
""" """
print("Search for .new configuration files:\n") print("Search for .new configuration files:\n")
@ -97,14 +97,14 @@ class NewConfig(Utils):
self.prompt() self.prompt()
def overwrite_all(self): def overwrite_all(self):
"""Overwrite all .new files and keep """Overwrites all .new files and keep
old with suffix .old old with suffix .old
""" """
for n in self.news: for n in self.news:
self._overwrite(n) self._overwrite(n)
def remove_all(self): def remove_all(self):
"""Remove all .new files """Removes all .new files
""" """
for n in self.news: for n in self.news:
self._remove(n) self._remove(n)
@ -131,7 +131,7 @@ class NewConfig(Utils):
raise SystemExit("\n") raise SystemExit("\n")
def question(self, n): def question(self, n):
"""Choose what do to file by file """Chooses what do to file by file
""" """
print() print()
prompt_ask = input(f"{n} [K/O/R/D/M/Q]? ") prompt_ask = input(f"{n} [K/O/R/D/M/Q]? ")
@ -151,7 +151,7 @@ class NewConfig(Utils):
self.quit() self.quit()
def _remove(self, n): def _remove(self, n):
"""Remove one single file """Removes one single file
""" """
if os.path.isfile(n): if os.path.isfile(n):
os.remove(n) os.remove(n)
@ -159,7 +159,7 @@ class NewConfig(Utils):
print(f"File '{n}' removed") print(f"File '{n}' removed")
def _overwrite(self, n): def _overwrite(self, n):
"""Overwrite old file with new and keep file with suffix .old """Overwrites old file with new and keep file with suffix .old
""" """
if os.path.isfile(n[:-4]): if os.path.isfile(n[:-4]):
shutil.copy2(n[:-4], n[:-4] + ".old") shutil.copy2(n[:-4], n[:-4] + ".old")
@ -174,7 +174,7 @@ class NewConfig(Utils):
pass pass
def diff(self, n): def diff(self, n):
"""Print the differences between the two files """Prints the differences between the two files
""" """
if os.path.isfile(n[:-4]): if os.path.isfile(n[:-4]):
diff1 = self.read_file(n[:-4]).splitlines() diff1 = self.read_file(n[:-4]).splitlines()
@ -203,7 +203,7 @@ class NewConfig(Utils):
lines.append(a) lines.append(a)
def merge(self, n): def merge(self, n):
"""Merge new file into old """Merges new file into old
""" """
if os.path.isfile(n[:-4]): if os.path.isfile(n[:-4]):
old = self.read_file(n[:-4]).splitlines() old = self.read_file(n[:-4]).splitlines()

View file

@ -29,7 +29,7 @@ from slpkg.__metadata__ import MetaData as _meta_
class FindFromRepos: class FindFromRepos:
"""Find packages from all enabled repositories """Finds packages from all enabled repositories
""" """
def __init__(self): def __init__(self):
self.cache = "" self.cache = ""
@ -44,7 +44,7 @@ class FindFromRepos:
self.endc = self.meta.color["ENDC"] self.endc = self.meta.color["ENDC"]
def find(self, pkg, flag): def find(self, pkg, flag):
"""Start to find packages and print """Starts to find packages and print
""" """
print(f"Packages with name matching [ {self.cyan}" print(f"Packages with name matching [ {self.cyan}"
f"{', '.join(pkg)}{self.endc} ]\n") f"{', '.join(pkg)}{self.endc} ]\n")
@ -78,8 +78,7 @@ class FindFromRepos:
f"{self.count_repo} repositories.{self.endc}\n") f"{self.count_repo} repositories.{self.endc}\n")
def sbo_version(self, repo, find): def sbo_version(self, repo, find):
""" """Adds version to SBo packages
Add version to SBo packages
""" """
ver = "" ver = ""
if repo == "sbo": if repo == "sbo":

View file

@ -30,7 +30,7 @@ from slpkg.__metadata__ import MetaData as _meta_
def delete_package(path, packages): def delete_package(path, packages):
"""Delete downloaded packages """Deletes downloaded packages
""" """
if _meta_.del_all in ["on", "ON"]: if _meta_.del_all in ["on", "ON"]:
for pkg in packages: for pkg in packages:
@ -38,7 +38,7 @@ def delete_package(path, packages):
def delete_folder(folder): def delete_folder(folder):
"""Delete folder with all files. """Deletes folder with all files.
""" """
if _meta_.del_folder in ["on", "ON"] and os.path.exists(folder): if _meta_.del_folder in ["on", "ON"] and os.path.exists(folder):
shutil.rmtree(folder) shutil.rmtree(folder)

View file

@ -31,7 +31,7 @@ from slpkg.__metadata__ import MetaData as _meta_
class RepoEnable(Utils): class RepoEnable(Utils):
"""Read repositories.conf file and update with new enabled or """Reads repositories.conf file and update with new enabled or
disabled repositories disabled repositories
""" """
def __init__(self): def __init__(self):
@ -77,7 +77,7 @@ Keys: SPACE select or deselect the highlighted repositories,
self.reference() self.reference()
def read_enabled(self): def read_enabled(self):
"""Read enable repositories """Reads enabled repositories
""" """
for line in self.conf.splitlines(): for line in self.conf.splitlines():
line = line.lstrip() line = line.lstrip()
@ -89,7 +89,7 @@ Keys: SPACE select or deselect the highlighted repositories,
self.tag_line = False self.tag_line = False
def read_disabled(self): def read_disabled(self):
"""Read disable repositories """Reads disabled repositories
""" """
for line in self.conf.splitlines(): for line in self.conf.splitlines():
line = line.lstrip() line = line.lstrip()

View file

@ -57,7 +57,7 @@ class RepoInfo(Utils):
def view(self, repo): def view(self, repo):
""" """
View repository information Views repository information
""" """
status = f"{self.red}disabled{self.endc}" status = f"{self.red}disabled{self.endc}"
self.form["Status:"] = status self.form["Status:"] = status
@ -109,7 +109,7 @@ class RepoInfo(Utils):
print(f"{self.green}{key}{self.endc} {value}") print(f"{self.green}{key}{self.endc} {value}")
def repository_data(self, repo): def repository_data(self, repo):
"""Grap data packages """Graps data packages
""" """
sum_pkgs, size, unsize, last_upd = 0, [], [], "" sum_pkgs, size, unsize, last_upd = 0, [], [], ""
f = f"{self.meta.lib_path}{repo}_repo/PACKAGES.TXT" f = f"{self.meta.lib_path}{repo}_repo/PACKAGES.TXT"

View file

@ -29,7 +29,7 @@ from slpkg.__metadata__ import MetaData as _meta_
class Repo(Utils): class Repo(Utils):
"""Manage repositories configuration files """Manages repositories configuration files
""" """
def __init__(self): def __init__(self):
self.meta = _meta_ self.meta = _meta_
@ -43,7 +43,7 @@ class Repo(Utils):
self.default_repository() self.default_repository()
def add(self, repo, url): def add(self, repo, url):
"""Write custom repository name and url in a file """Writes custom repository name and url in a file
""" """
repo_name = [] repo_name = []
if not url.endswith("/"): if not url.endswith("/"):
@ -67,7 +67,7 @@ class Repo(Utils):
print(f"\nRepository '{repo}' successfully added\n") print(f"\nRepository '{repo}' successfully added\n")
def remove(self, repo): def remove(self, repo):
"""Remove custom repository """Removes custom repository
""" """
rem_repo = False rem_repo = False
with open(self.custom_repo_file, "w") as repos: with open(self.custom_repo_file, "w") as repos:
@ -83,7 +83,7 @@ class Repo(Utils):
print(f"\nRepository '{repo}' doesn't exist\n") print(f"\nRepository '{repo}' doesn't exist\n")
def custom_repository(self): def custom_repository(self):
"""Return dictionary with repo name and url (used external) """Returns dictionary with repo name and url (used external)
""" """
custom_dict_repo = {} custom_dict_repo = {}
for line in self.custom_repositories_list.splitlines(): for line in self.custom_repositories_list.splitlines():
@ -93,7 +93,7 @@ class Repo(Utils):
return custom_dict_repo return custom_dict_repo
def default_repository(self): def default_repository(self):
"""Return dictionary with default repo name and url """Returns dictionary with default repo name and url
""" """
default_dict_repo = {} default_dict_repo = {}
for line in self.default_repositories_list.splitlines(): for line in self.default_repositories_list.splitlines():

View file

@ -27,7 +27,7 @@ from slpkg.messages import Msg
def pkg_security(pkgs): def pkg_security(pkgs):
"""Check packages before install or upgrade for security """Checks packages before installing or upgrading for security
reasons. Configuration file in the /etc/slpkg/pkg_security""" reasons. Configuration file in the /etc/slpkg/pkg_security"""
packages, msg, utils = [], Msg(), Utils() packages, msg, utils = [], Msg(), Utils()
security_packages = utils.read_file("/etc/slpkg/pkg_security") security_packages = utils.read_file("/etc/slpkg/pkg_security")

View file

@ -23,7 +23,7 @@
def units(comp_sum, uncomp_sum): def units(comp_sum, uncomp_sum):
"""Calculate package size """Calculates package size
""" """
compressed = round((sum(map(float, comp_sum)) / 1024), 2) compressed = round((sum(map(float, comp_sum)) / 1024), 2)
uncompressed = round((sum(map(float, uncomp_sum)) / 1024), 2) uncompressed = round((sum(map(float, uncomp_sum)) / 1024), 2)

View file

@ -35,8 +35,7 @@ from slpkg.__metadata__ import MetaData as _meta_
def it_self_update(): def it_self_update():
"""Check from GitLab slpkg repository if new version is available """Checks from GitLab slpkg repository if a new version is available
download and update itself
""" """
__new_version__ = "" __new_version__ = ""
repository = "gitlab" repository = "gitlab"

View file

@ -23,8 +23,7 @@
def split_package(package): def split_package(package):
""" """Splits package in name, version
Split package in name, version
arch and build tag. arch and build tag.
""" """
name = ver = arch = build = [] name = ver = arch = build = []

View file

@ -34,7 +34,7 @@ from slpkg.pkg.find import find_package
class DependenciesStatus(Utils): class DependenciesStatus(Utils):
"""Print dependencies status used by packages """Prints dependencies status used by packages
""" """
def __init__(self, image): def __init__(self, image):
self.image = image self.image = image
@ -53,7 +53,7 @@ class DependenciesStatus(Utils):
self.installed = find_package("", self.meta.pkg_path) self.installed = find_package("", self.meta.pkg_path)
def data(self): def data(self):
"""Check all installed packages and create """Checks all installed packages and create
dictionary database dictionary database
""" """
for pkg in self.installed: for pkg in self.installed:
@ -72,7 +72,7 @@ class DependenciesStatus(Utils):
self.count_packages() self.count_packages()
def count_packages(self): def count_packages(self):
"""Count dependencies and packages """Counts dependencies and packages
""" """
packages = [] packages = []
for pkg in self.dmap.values(): for pkg in self.dmap.values():

View file

@ -27,14 +27,14 @@ import getpass
def s_user(): def s_user():
"""Check for root user """Checks for root user
""" """
if getpass.getuser() != "root": if getpass.getuser() != "root":
raise SystemExit("\nslpkg: Error: Must have root privileges\n") raise SystemExit("\nslpkg: Error: Must have root privileges\n")
def virtual_env(): def virtual_env():
"""Check if a virtual enviroment exists """Checks if a virtual enviroment exists
""" """
if "VIRTUAL_ENV" in os.environ.keys(): if "VIRTUAL_ENV" in os.environ.keys():
raise SystemExit("\nslpkg: Error: Please exit from virtual " raise SystemExit("\nslpkg: Error: Please exit from virtual "

View file

@ -39,9 +39,9 @@ from slpkg.binary.dependency import Dependencies
class TrackingDeps(BlackList, Utils): class TrackingDeps(BlackList, Utils):
"""View tree of dependencies and also """Views tree of dependencies and also
highlight packages with color green highlights packages with the colour green
if already installed and color red if already installed and the colour red
if not installed. if not installed.
""" """
def __init__(self, name, repo, flag): def __init__(self, name, repo, flag):
@ -71,7 +71,7 @@ class TrackingDeps(BlackList, Utils):
self.flag[i] = "--graph=" self.flag[i] = "--graph="
def run(self): def run(self):
"""Run tracking dependencies """Runs tracking dependencies
""" """
self.msg.resolving() self.msg.resolving()
self.repositories() self.repositories()
@ -124,7 +124,7 @@ class TrackingDeps(BlackList, Utils):
raise SystemExit("\nNo package was found to match\n") raise SystemExit("\nNo package was found to match\n")
def repositories(self): def repositories(self):
"""Get dependencies by repositories """Gets dependencies by repositories
""" """
if self.repo == "sbo": if self.repo == "sbo":
self.sbo_case_insensitive() self.sbo_case_insensitive()
@ -169,7 +169,7 @@ class TrackingDeps(BlackList, Utils):
Graph(self.image).dependencies(self.deps_dict) Graph(self.image).dependencies(self.deps_dict)
def check_used(self, pkg): def check_used(self, pkg):
"""Check if dependencies used """Checks if dependencies used
""" """
used = [] used = []
dep_path = f"{self.meta.log_path}dep/" dep_path = f"{self.meta.log_path}dep/"
@ -197,7 +197,7 @@ class TrackingDeps(BlackList, Utils):
self.deps_dict[dep] = self.dimensional_list(deps) self.deps_dict[dep] = self.dimensional_list(deps)
def deps_used(self, pkg, used): def deps_used(self, pkg, used):
"""Create dependencies dictionary """Creates dependencies dictionary
""" """
if find_package(f"{pkg}-", self.meta.pkg_path): if find_package(f"{pkg}-", self.meta.pkg_path):
if pkg not in self.deps_dict.values(): if pkg not in self.deps_dict.values():

View file

@ -41,7 +41,7 @@ class URL:
self.http = urllib3.PoolManager() self.http = urllib3.PoolManager()
def get_request(self): def get_request(self):
"""Open url and read """Opens url and read
""" """
try: try:
f = self.http.request('GET', self.link) f = self.http.request('GET', self.link)

View file

@ -29,7 +29,7 @@ from slpkg.splitting import split_package
class Utils: class Utils:
"""Class with usefull utilities """Class with useful utilities
""" """
def case_sensitive(self, lst): def case_sensitive(self, lst):
"""Create dictionary from list with key in lower case """Create dictionary from list with key in lower case
@ -41,7 +41,7 @@ class Utils:
return dictionary return dictionary
def dimensional_list(self, lists): def dimensional_list(self, lists):
"""Create one dimensional list """Creates one dimensional list
""" """
one_list = [] one_list = []
for lst in lists: for lst in lists:
@ -49,7 +49,7 @@ class Utils:
return one_list return one_list
def remove_dbs(self, double): def remove_dbs(self, double):
"""Remove double item from list """Removes double item from list
""" """
return list(OrderedDict.fromkeys(double)) return list(OrderedDict.fromkeys(double))
@ -71,7 +71,7 @@ class Utils:
yield split_package(line[14:].strip())[0] yield split_package(line[14:].strip())[0]
def check_downloaded(self, path, downloaded): def check_downloaded(self, path, downloaded):
"""Check if files downloaded and return downloaded """Checks if files downloaded and return downloaded
packages packages
""" """
for pkg in downloaded: for pkg in downloaded:
@ -79,8 +79,8 @@ class Utils:
yield pkg yield pkg
def read_config(self, config): def read_config(self, config):
"""Read config file and returns first uncomment line """Reads config file and returns first uncomment line
and stop. Used for Slackware mirrors and stops. Used for Slackware mirrors
""" """
for line in config.splitlines(): for line in config.splitlines():
line = line.lstrip() line = line.lstrip()
@ -107,6 +107,6 @@ class Utils:
return "ISO-8859-1" return "ISO-8859-1"
def debug(self, test): def debug(self, test):
"""Function used for print some stuff for debugging """A function used for print some stuff for debugging
""" """
print(test) print(test)

View file

@ -26,7 +26,7 @@ from slpkg.__metadata__ import MetaData as m
def prog_version(): def prog_version():
"""Print version, license and email """Prints version, license and email
""" """
print(f"Version : {m.__version__}\n" print(f"Version : {m.__version__}\n"
f"Licence : {m.__license__}\n" f"Licence : {m.__license__}\n"