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 -*- # -*- coding: utf-8 -*-
import os
import json import json
from dataclasses import dataclass from dataclasses import dataclass
@ -47,41 +49,44 @@ class Configs:
wget_options = '-c -N' wget_options = '-c -N'
''' Overwrite with user configuration. ''' ''' Overwrite with user configuration. '''
with open(f'{etc_path}/{prog_name}.json', 'r') as conf: config_file: str = f'{etc_path}/{prog_name}.json'
config = json.load(conf) if os.path.isfile(config_file):
# OS architecture by default with open(config_file, 'r') as conf:
os_arch: str = config['os_arch'] config = json.load(conf)
# All necessary paths # OS architecture by default
tmp_path: str = config['tmp_path'] os_arch: str = config['os_arch']
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']
# Database name # All necessary paths
database: str = config['database'] 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 # Database name
repo_version: str = config['repo_version'] database: str = config['database']
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']
# Slackware commands # Repository details
installpkg: str = config['installpkg'] repo_version: str = config['repo_version']
reinstall: str = config['reinstall'] sbo_url: str = config['sbo_url']
removepkg: str = config['removepkg'] 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 # Slackware commands
colors: str = config['colors'] installpkg: str = config['installpkg']
wget_options: str = config['wget_options'] reinstall: str = config['reinstall']
removepkg: str = config['removepkg']
# Other configs
colors: str = config['colors']
wget_options: str = config['wget_options']
@classmethod @classmethod
def colour(cls): def colour(cls):
@ -90,6 +95,7 @@ class Configs:
'GREEN': '', 'GREEN': '',
'YELLOW': '', 'YELLOW': '',
'CYAN': '', 'CYAN': '',
'BLUE': '',
'GREY': '', 'GREY': '',
'ENDC': '' 'ENDC': ''
} }

View file

@ -4,10 +4,12 @@
from dataclasses import dataclass from dataclasses import dataclass
from slpkg.configs import Configs
@dataclass @dataclass
class Version: class Version:
prog_name: str = 'slpkg' prog_name: str = Configs.prog_name
version_info: tuple = (4, 1, 0) version_info: tuple = (4, 1, 0)
version: str = '{0}.{1}.{2}'.format(*version_info) version: str = '{0}.{1}.{2}'.format(*version_info)
license: str = 'MIT License' license: str = 'MIT License'