Updated for read configs

This commit is contained in:
Dimitris Zlatanidis 2024-04-13 15:02:12 +03:00
parent 8046b98027
commit d9ffa06652
6 changed files with 120 additions and 122 deletions

View file

@ -2,7 +2,7 @@
### 5.0.6 - 13/04/2024
- Update:
* Updated to read repositories.toml values file even they are lower or uppercase
* Updated to read configuration values file even they are lower or uppercase
### 5.0.5 - 12/04/2024
- Added:

View file

@ -14,6 +14,4 @@
# Example: PACKAGES = ["python2", "^python3-build$"].
[BLACKLIST]
PACKAGES = []

View file

@ -27,7 +27,7 @@ class Blacklist(Configs):
if self.blacklist_file_toml.is_file():
try:
with open(self.blacklist_file_toml, 'rb') as black:
packages: tuple = tuple(tomli.load(black)['BLACKLIST']['PACKAGES'])
packages: tuple = tuple({k.lower(): v for k, v in tomli.load(black).items()})
except (tomli.TOMLDecodeError, KeyError) as error:
self.toml_errors.raise_toml_error_message(error, self.blacklist_file_toml)

View file

@ -73,46 +73,46 @@ class Configs:
config_path_file = Path(etc_path, f'{prog_name}.toml')
if config_path_file.exists():
with open(config_path_file, 'rb') as conf:
configs = tomli.load(conf)
configs = {k.lower(): v for k, v in tomli.load(conf).items()}
if configs:
config = configs['CONFIGS']
config = {k.lower(): v for k, v in configs['configs'].items()}
os_arch: str = config['OS_ARCH']
download_only_path: Path = Path(config['DOWNLOAD_ONLY_PATH'])
ask_question: bool = config['ASK_QUESTION']
installpkg: str = config['INSTALLPKG']
reinstall: str = config['REINSTALL']
removepkg: str = config['REMOVEPKG']
colors: bool = config['COLORS']
makeflags: str = config['MAKEFLAGS']
gpg_verification: bool = config['GPG_VERIFICATION']
checksum_md5: bool = config['CHECKSUM_MD5']
dialog: bool = config['DIALOG']
new_packages: bool = config['NEW_PACKAGES']
removed_packages: bool = config['REMOVED_PACKAGES']
downloader: str = config['DOWNLOADER']
wget_options: str = config['WGET_OPTIONS']
curl_options: str = config['CURL_OPTIONS']
lftp_get_options: str = config['LFTP_GET_OPTIONS']
lftp_mirror_options: str = config['LFTP_MIRROR_OPTIONS']
ascii_characters: bool = config['ASCII_CHARACTERS']
file_list_suffix: str = config['FILE_LIST_SUFFIX']
parallel_downloads: bool = config['PARALLEL_DOWNLOADS']
maximum_parallel: int = config['MAXIMUM_PARALLEL']
progress_bar: bool = config['PROGRESS_BAR']
progress_spinner: str = config['PROGRESS_SPINNER']
spinner_color: str = config['SPINNER_COLOR']
border_color: str = config['BORDER_COLOR']
process_log: bool = config['PROCESS_LOG']
os_arch: str = config['os_arch']
download_only_path: Path = Path(config['download_only_path'])
ask_question: bool = config['ask_question']
installpkg: str = config['installpkg']
reinstall: str = config['reinstall']
removepkg: str = config['removepkg']
colors: bool = config['colors']
makeflags: str = config['makeflags']
gpg_verification: bool = config['gpg_verification']
checksum_md5: bool = config['checksum_md5']
dialog: bool = config['dialog']
new_packages: bool = config['new_packages']
removed_packages: bool = config['removed_packages']
downloader: str = config['downloader']
wget_options: str = config['wget_options']
curl_options: str = config['curl_options']
lftp_get_options: str = config['lftp_get_options']
lftp_mirror_options: str = config['lftp_mirror_options']
ascii_characters: bool = config['ascii_characters']
file_list_suffix: str = config['file_list_suffix']
parallel_downloads: bool = config['parallel_downloads']
maximum_parallel: int = config['maximum_parallel']
progress_bar: bool = config['progress_bar']
progress_spinner: str = config['progress_spinner']
spinner_color: str = config['spinner_color']
border_color: str = config['border_color']
process_log: bool = config['process_log']
urllib_retries: Any = config['URLLIB_RETRIES']
urllib_redirect: Any = config['URLLIB_REDIRECT']
urllib_timeout: float = config['URLLIB_TIMEOUT']
urllib_retries: Any = config['urllib_retries']
urllib_redirect: Any = config['urllib_redirect']
urllib_timeout: float = config['urllib_timeout']
proxy_address: str = config['PROXY_ADDRESS']
proxy_username: str = config['PROXY_USERNAME']
proxy_password: str = config['PROXY_PASSWORD']
proxy_address: str = config['proxy_address']
proxy_username: str = config['proxy_username']
proxy_password: str = config['proxy_password']
except (KeyError, tomli.TOMLDecodeError) as error:
toml_errors.raise_toml_error_message(error, toml_file='/etc/slpkg/slpkg.toml')

View file

@ -34,7 +34,7 @@ class Repositories:
sbo_repo_name: str = 'sbo'
sbo_repo_path: Path = Path(repositories_path, sbo_repo_name)
sbo_repo_mirror: str = ''
sbo_repo_slackbuilds: str = 'SLACKBUILDS.TXT'
sbo_repo_slackbuilds: str = 'slackBUILDS.TXT'
sbo_repo_changelog: str = 'ChangeLog.txt'
sbo_repo_tag: str = '_SBo'
sbo_repo_tar_suffix: str = '.tar.gz'
@ -43,7 +43,7 @@ class Repositories:
ponce_repo_name: str = 'ponce'
ponce_repo_path: Path = Path(repositories_path, ponce_repo_name)
ponce_repo_mirror: str = ''
ponce_repo_slackbuilds: str = 'SLACKBUILDS.TXT'
ponce_repo_slackbuilds: str = 'slackBUILDS.TXT'
ponce_repo_changelog: str = 'ChangeLog.txt'
ponce_repo_tag: str = '_SBo'
ponce_repo_tar_suffix: str = '.tar.gz'
@ -223,157 +223,157 @@ class Repositories:
with open(repositories_toml_file, 'rb') as repo:
repos_config = tomli.load(repo)
repos_config = utils.convert_dict_keys_to_upper(repos_config)
repos_config = utils.convert_dict_keys_to_lower(repos_config)
default_repository: str = repos_config['DEFAULT']['REPO'].lower()
default_repository: str = repos_config['default']['repo'].lower()
sbo_repo: bool = repos_config['SBO']['ENABLE']
sbo_repo_url: str = repos_config['SBO']['MIRROR']
sbo_repo_version: str = repos_config['SBO']['VERSION']
sbo_repo: bool = repos_config['sbo']['enable']
sbo_repo_url: str = repos_config['sbo']['mirror']
sbo_repo_version: str = repos_config['sbo']['version']
sbo_repo_mirror: str = f'{sbo_repo_url}{sbo_repo_version}/'
ponce_repo: bool = repos_config['PONCE']['ENABLE']
ponce_repo_mirror: str = repos_config['PONCE']['MIRROR']
ponce_repo: bool = repos_config['ponce']['enable']
ponce_repo_mirror: str = repos_config['ponce']['mirror']
slack_repo: bool = repos_config['SLACK']['ENABLE']
slack_repo_url: str = repos_config['SLACK']['MIRROR']
slack_repo_version: str = repos_config['SLACK']['VERSION']
slack_repo_arch: str = repos_config['SLACK']['ARCH']
slack_repo: bool = repos_config['slack']['enable']
slack_repo_url: str = repos_config['slack']['mirror']
slack_repo_version: str = repos_config['slack']['version']
slack_repo_arch: str = repos_config['slack']['arch']
slack_arch: str = ''
if slack_repo_arch == 'x86_64':
slack_arch: str = '64'
slack_repo_mirror_packages: str = f'{slack_repo_url}slackware{slack_arch}-{slack_repo_version}/'
slack_repo_mirror_changelog: str = f'{slack_repo_url}slackware{slack_arch}-{slack_repo_version}/'
slack_extra_repo: bool = repos_config['SLACK_EXTRA']['ENABLE']
slack_extra_repo_url: str = repos_config['SLACK_EXTRA']['MIRROR']
slack_extra_repo_version: str = repos_config['SLACK_EXTRA']['VERSION']
slack_extra_repo_arch: str = repos_config['SLACK_EXTRA']['ARCH']
slack_extra_repo: bool = repos_config['slack_extra']['enable']
slack_extra_repo_url: str = repos_config['slack_extra']['mirror']
slack_extra_repo_version: str = repos_config['slack_extra']['version']
slack_extra_repo_arch: str = repos_config['slack_extra']['arch']
slack_extra_arch: str = ''
if slack_extra_repo_arch == 'x86_64':
slack_extra_arch: str = '64'
slack_extra_repo_branch: str = repos_config['SLACK_EXTRA']['BRANCH']
slack_extra_repo_branch: str = repos_config['slack_extra']['branch']
slack_extra_repo_mirror_packages: str = (f'{slack_extra_repo_url}slackware{slack_extra_arch}-'
f'{slack_extra_repo_version}/{slack_extra_repo_branch}/')
slack_extra_repo_mirror_changelog: str = (f'{slack_extra_repo_url}slackware{slack_extra_arch}-'
f'{slack_extra_repo_version}/')
slack_patches_repo: bool = repos_config['SLACK_PATCHES']['ENABLE']
slack_patches_repo_url: str = repos_config['SLACK_PATCHES']['MIRROR']
slack_patches_repo_version: str = repos_config['SLACK_PATCHES']['VERSION']
slack_patches_repo_arch: str = repos_config['SLACK_PATCHES']['ARCH']
slack_patches_repo: bool = repos_config['slack_patches']['enable']
slack_patches_repo_url: str = repos_config['slack_patches']['mirror']
slack_patches_repo_version: str = repos_config['slack_patches']['version']
slack_patches_repo_arch: str = repos_config['slack_patches']['arch']
slack_patches_arch: str = ''
if slack_patches_repo_arch == 'x86_64':
slack_patches_arch: str = '64'
slack_patches_repo_branch: str = repos_config['SLACK_PATCHES']['BRANCH']
slack_patches_repo_branch: str = repos_config['slack_patches']['branch']
slack_patches_repo_mirror_packages: str = (f'{slack_patches_repo_url}slackware{slack_patches_arch}-'
f'{slack_patches_repo_version}/{slack_patches_repo_branch}/')
slack_patches_repo_mirror_changelog: str = (f'{slack_patches_repo_url}slackware{slack_patches_arch}-'
f'{slack_patches_repo_version}/')
alien_repo: bool = repos_config['ALIEN']['ENABLE']
alien_repo_url: str = repos_config['ALIEN']['MIRROR']
alien_repo_version: str = repos_config['ALIEN']['VERSION']
alien_repo_arch: str = repos_config['ALIEN']['ARCH']
alien_repo: bool = repos_config['alien']['enable']
alien_repo_url: str = repos_config['alien']['mirror']
alien_repo_version: str = repos_config['alien']['version']
alien_repo_arch: str = repos_config['alien']['arch']
alien_repo_mirror_packages: str = f'{alien_repo_url}{alien_repo_version}/{alien_repo_arch}/'
alien_repo_mirror_changelog: str = alien_repo_url
multilib_repo: bool = repos_config['MULTILIB']['ENABLE']
multilib_repo_url: str = repos_config['MULTILIB']['MIRROR']
multilib_repo_version: str = repos_config['MULTILIB']['VERSION']
multilib_repo: bool = repos_config['multilib']['enable']
multilib_repo_url: str = repos_config['multilib']['mirror']
multilib_repo_version: str = repos_config['multilib']['version']
multilib_repo_mirror_packages: str = f'{multilib_repo_url}{multilib_repo_version}/'
multilib_repo_mirror_changelog: str = multilib_repo_url
restricted_repo: bool = repos_config['RESTRICTED']['ENABLE']
restricted_repo_url: str = repos_config['RESTRICTED']['MIRROR']
restricted_repo_version: str = repos_config['RESTRICTED']['VERSION']
restricted_repo_arch: str = repos_config['RESTRICTED']['ARCH']
restricted_repo: bool = repos_config['restricted']['enable']
restricted_repo_url: str = repos_config['restricted']['mirror']
restricted_repo_version: str = repos_config['restricted']['version']
restricted_repo_arch: str = repos_config['restricted']['arch']
restricted_repo_mirror_packages: str = (f'{restricted_repo_url}{restricted_repo_version}/'
f'{restricted_repo_arch}/')
restricted_repo_mirror_changelog: str = restricted_repo_url
gnome_repo: bool = repos_config['GNOME']['ENABLE']
gnome_repo_url: str = repos_config['GNOME']['MIRROR']
gnome_repo_version: str = repos_config['GNOME']['VERSION']
gnome_repo_arch: str = repos_config['GNOME']['ARCH']
gnome_repo: bool = repos_config['gnome']['enable']
gnome_repo_url: str = repos_config['gnome']['mirror']
gnome_repo_version: str = repos_config['gnome']['version']
gnome_repo_arch: str = repos_config['gnome']['arch']
gnome_repo_mirror_packages: str = f'{gnome_repo_url}{gnome_repo_version}/{gnome_repo_arch}/'
gnome_repo_mirror_changelog: str = f'{gnome_repo_url}{gnome_repo_version}/{gnome_repo_arch}/'
msb_repo: bool = repos_config['MSB']['ENABLE']
msb_repo_url: str = repos_config['MSB']['MIRROR']
msb_repo_version: str = repos_config['MSB']['VERSION']
msb_repo_branch: str = repos_config['MSB']['BRANCH']
msb_repo_arch: str = repos_config['MSB']['ARCH']
msb_repo: bool = repos_config['msb']['enable']
msb_repo_url: str = repos_config['msb']['mirror']
msb_repo_version: str = repos_config['msb']['version']
msb_repo_branch: str = repos_config['msb']['branch']
msb_repo_arch: str = repos_config['msb']['arch']
msb_repo_mirror_packages: str = f'{msb_repo_url}{msb_repo_version}/{msb_repo_branch}/{msb_repo_arch}/'
msb_repo_mirror_changelog: str = msb_repo_url
csb_repo: bool = repos_config['CSB']['ENABLE']
csb_repo_url: str = repos_config['CSB']['MIRROR']
csb_repo_version: str = repos_config['CSB']['VERSION']
csb_repo_arch: str = repos_config['CSB']['ARCH']
csb_repo: bool = repos_config['csb']['enable']
csb_repo_url: str = repos_config['csb']['mirror']
csb_repo_version: str = repos_config['csb']['version']
csb_repo_arch: str = repos_config['csb']['arch']
csb_repo_mirror_packages: str = f'{csb_repo_url}{csb_repo_version}/{csb_repo_arch}/'
csb_repo_mirror_changelog: str = csb_repo_url
conraid_repo: bool = repos_config['CONRAID']['ENABLE']
conraid_repo_url: str = repos_config['CONRAID']['MIRROR']
conraid_repo_arch: str = repos_config['CONRAID']['ARCH']
conraid_repo_version: str = repos_config['CONRAID']['VERSION']
conraid_repo: bool = repos_config['conraid']['enable']
conraid_repo_url: str = repos_config['conraid']['mirror']
conraid_repo_arch: str = repos_config['conraid']['arch']
conraid_repo_version: str = repos_config['conraid']['version']
conraid_arch: str = ''
if conraid_repo_arch == 'x86_64':
conraid_arch: str = '64'
conraid_repo_mirror_packages: str = f'{conraid_repo_url}slackware{conraid_arch}-{conraid_repo_version}/'
conraid_repo_mirror_changelog: str = f'{conraid_repo_url}slackware{conraid_arch}-{conraid_repo_version}/'
slackdce_repo: bool = repos_config['SLACKDCE']['ENABLE']
slackdce_repo_url: str = repos_config['SLACKDCE']['MIRROR']
slackdce_repo_version: str = repos_config['SLACKDCE']['VERSION']
slackdce_repo_arch: str = repos_config['SLACKDCE']['ARCH']
slackdce_repo: bool = repos_config['slackdce']['enable']
slackdce_repo_url: str = repos_config['slackdce']['mirror']
slackdce_repo_version: str = repos_config['slackdce']['version']
slackdce_repo_arch: str = repos_config['slackdce']['arch']
slackdce_repo_mirror_packages: str = f'{slackdce_repo_url}{slackdce_repo_version}/{slackdce_repo_arch}/'
slackdce_repo_mirror_changelog: str = f'{slackdce_repo_url}{slackdce_repo_version}/{slackdce_repo_arch}/'
slackonly_repo: bool = repos_config['SLACKONLY']['ENABLE']
slackonly_repo_url: str = repos_config['SLACKONLY']['MIRROR']
slackonly_repo_version: str = repos_config['SLACKONLY']['VERSION']
slackonly_repo_arch: str = repos_config['SLACKONLY']['ARCH']
slackonly_repo: bool = repos_config['slackonly']['enable']
slackonly_repo_url: str = repos_config['slackonly']['mirror']
slackonly_repo_version: str = repos_config['slackonly']['version']
slackonly_repo_arch: str = repos_config['slackonly']['arch']
slackonly_repo_mirror_packages: str = f'{slackonly_repo_url}{slackonly_repo_version}-{slackonly_repo_arch}/'
slackonly_repo_mirror_changelog: str = (f'{slackonly_repo_url}{slackonly_repo_version}-'
f'{slackonly_repo_arch}/')
salix_repo: bool = repos_config['SALIX']['ENABLE']
salix_repo_url: str = repos_config['SALIX']['MIRROR']
salix_repo_arch: str = repos_config['SALIX']['ARCH']
salix_repo_version: str = repos_config['SALIX']['VERSION']
salix_repo: bool = repos_config['salix']['enable']
salix_repo_url: str = repos_config['salix']['mirror']
salix_repo_arch: str = repos_config['salix']['arch']
salix_repo_version: str = repos_config['salix']['version']
salix_repo_mirror_packages: str = f'{salix_repo_url}{salix_repo_arch}/{salix_repo_version}/'
salix_repo_mirror_changelog: str = f'{salix_repo_url}{salix_repo_arch}/{salix_repo_version}/'
salix_extra_repo: bool = repos_config['SALIX_EXTRA']['ENABLE']
salix_extra_repo_url: str = repos_config['SALIX_EXTRA']['MIRROR']
salix_extra_repo_arch: str = repos_config['SALIX_EXTRA']['ARCH']
salix_extra_repo_branch: str = repos_config['SALIX_EXTRA']['BRANCH']
salix_extra_repo_version: str = repos_config['SALIX_EXTRA']['VERSION']
salix_extra_repo: bool = repos_config['salix_extra']['enable']
salix_extra_repo_url: str = repos_config['salix_extra']['mirror']
salix_extra_repo_arch: str = repos_config['salix_extra']['arch']
salix_extra_repo_branch: str = repos_config['salix_extra']['branch']
salix_extra_repo_version: str = repos_config['salix_extra']['version']
salix_extra_repo_mirror_packages: str = (f'{salix_extra_repo_url}{salix_extra_repo_arch}/'
f'{salix_extra_repo_branch}-{salix_extra_repo_version}/')
salix_extra_repo_mirror_changelog: str = (f'{salix_extra_repo_url}{salix_extra_repo_arch}/'
f'{salix_extra_repo_branch}-{salix_extra_repo_version}/')
slackel_repo: bool = repos_config['SLACKEL']['ENABLE']
slackel_repo_url: str = repos_config['SLACKEL']['MIRROR']
slackel_repo_arch: str = repos_config['SLACKEL']['ARCH']
slackel_repo_version: str = repos_config['SLACKEL']['VERSION']
slackel_repo: bool = repos_config['slackel']['enable']
slackel_repo_url: str = repos_config['slackel']['mirror']
slackel_repo_arch: str = repos_config['slackel']['arch']
slackel_repo_version: str = repos_config['slackel']['version']
slackel_repo_mirror_packages: str = f'{slackel_repo_url}{slackel_repo_arch}/{slackel_repo_version}/'
slackel_repo_mirror_changelog: str = f'{slackel_repo_url}{slackel_repo_arch}/{slackel_repo_version}/'
slint_repo: bool = repos_config['SLINT']['ENABLE']
slint_repo_url: str = repos_config['SLINT']['MIRROR']
slint_repo_arch: str = repos_config['SLINT']['ARCH']
slint_repo_version: str = repos_config['SLINT']['VERSION']
slint_repo: bool = repos_config['slint']['enable']
slint_repo_url: str = repos_config['slint']['mirror']
slint_repo_arch: str = repos_config['slint']['arch']
slint_repo_version: str = repos_config['slint']['version']
slint_repo_mirror_packages: str = f'{slint_repo_url}{slint_repo_arch}/slint-{slint_repo_version}/'
slint_repo_mirror_changelog: str = f'{slint_repo_url}{slint_repo_arch}/slint-{slint_repo_version}/'
pprkut_repo: bool = repos_config['PPRKUT']['ENABLE']
pprkut_repo_url: str = repos_config['PPRKUT']['MIRROR']
pprkut_repo_version: str = repos_config['PPRKUT']['VERSION']
pprkut_repo_arch: str = repos_config['PPRKUT']['ARCH']
pprkut_repo: bool = repos_config['pprkut']['enable']
pprkut_repo_url: str = repos_config['pprkut']['mirror']
pprkut_repo_version: str = repos_config['pprkut']['version']
pprkut_repo_arch: str = repos_config['pprkut']['arch']
pprkut_repo_mirror_packages: str = f'{pprkut_repo_url}{pprkut_repo_version}/{pprkut_repo_arch}/'
pprkut_repo_mirror_changelog: str = f'{pprkut_repo_url}{pprkut_repo_version}/{pprkut_repo_arch}/'
except (tomli.TOMLDecodeError, KeyError) as error:

View file

@ -222,11 +222,11 @@ class Utilities(Configs):
matching_packages: list = [pkg for pkg in packages if re.search(pattern, pkg)]
return matching_packages
def convert_dict_keys_to_upper(self, d):
def convert_dict_keys_to_lower(self, d):
new_dict = {}
for key, value in d.items():
if isinstance(value, dict):
value = self.convert_dict_keys_to_upper(value)
new_dict[key.upper()] = value
value = self.convert_dict_keys_to_lower(value)
new_dict[key.lower()] = value
return new_dict