Updated configs

This commit is contained in:
Dimitris Zlatanidis 2022-06-19 22:18:54 +03:00
parent d86716183c
commit cf0a0f1e5f
2 changed files with 38 additions and 30 deletions

View file

@ -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': ''
}

View file

@ -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'