diff --git a/slpkg/configs.py b/slpkg/configs.py index 02e7abe8..b5e62840 100644 --- a/slpkg/configs.py +++ b/slpkg/configs.py @@ -2,7 +2,9 @@ # -*- coding: utf-8 -*- +import os import json + from dataclasses import dataclass @@ -47,41 +49,44 @@ class Configs: wget_options = '-c -N' ''' Overwrite with user configuration. ''' - with open(f'{etc_path}/{prog_name}.json', 'r') as conf: - config = json.load(conf) + config_file: str = f'{etc_path}/{prog_name}.json' + if os.path.isfile(config_file): - # OS architecture by default - os_arch: str = config['os_arch'] + with open(config_file, 'r') as conf: + config = json.load(conf) - # All necessary paths - tmp_path: str = config['tmp_path'] - tmp_slpkg: str = config['tmp_slpkg'] - build_path: str = config['build_path'] - lib_path: str = config['lib_path'] - etc_path: str = config['etc_path'] - db_path: str = config['db_path'] - sbo_repo_path: str = config['sbo_repo_path'] - log_packages: str = config['log_packages'] + # OS architecture by default + os_arch: str = config['os_arch'] - # Database name - database: str = config['database'] + # All necessary paths + tmp_path: str = config['tmp_path'] + tmp_slpkg: str = config['tmp_slpkg'] + build_path: str = config['build_path'] + lib_path: str = config['lib_path'] + etc_path: str = config['etc_path'] + db_path: str = config['db_path'] + sbo_repo_path: str = config['sbo_repo_path'] + log_packages: str = config['log_packages'] - # Repository details - repo_version: str = config['repo_version'] - sbo_url: str = config['sbo_url'] - sbo_txt: str = config['sbo_txt'] - tar_suffix: str = config['tar_suffix'] - pkg_suffix: str = config['pkg_suffix'] - repo_tag: str = config['repo_tag'] + # Database name + database: str = config['database'] - # Slackware commands - installpkg: str = config['installpkg'] - reinstall: str = config['reinstall'] - removepkg: str = config['removepkg'] + # Repository details + repo_version: str = config['repo_version'] + sbo_url: str = config['sbo_url'] + sbo_txt: str = config['sbo_txt'] + tar_suffix: str = config['tar_suffix'] + pkg_suffix: str = config['pkg_suffix'] + repo_tag: str = config['repo_tag'] - # Other configs - colors: str = config['colors'] - wget_options: str = config['wget_options'] + # Slackware commands + installpkg: str = config['installpkg'] + reinstall: str = config['reinstall'] + removepkg: str = config['removepkg'] + + # Other configs + colors: str = config['colors'] + wget_options: str = config['wget_options'] @classmethod def colour(cls): @@ -90,6 +95,7 @@ class Configs: 'GREEN': '', 'YELLOW': '', 'CYAN': '', + 'BLUE': '', 'GREY': '', 'ENDC': '' } diff --git a/slpkg/version.py b/slpkg/version.py index 52e83386..a7067ebf 100644 --- a/slpkg/version.py +++ b/slpkg/version.py @@ -4,10 +4,12 @@ from dataclasses import dataclass +from slpkg.configs import Configs + @dataclass class Version: - prog_name: str = 'slpkg' + prog_name: str = Configs.prog_name version_info: tuple = (4, 1, 0) version: str = '{0}.{1}.{2}'.format(*version_info) license: str = 'MIT License'