diff --git a/ChangeLog.txt b/ChangeLog.txt index 448c9e0e..8ac25c89 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,6 +1,8 @@ 4.3.2 - 28/11/2022 Fixed: - Remove multiple packages with dependencies +Updated: +- Switch to python toml to load configuration files 4.3.1 - 26/11/2022 Added: diff --git a/README.rst b/README.rst index e63ecddb..bc4223c9 100644 --- a/README.rst +++ b/README.rst @@ -20,8 +20,8 @@ Requirements .. code-block:: bash - SQLAlchemy>=1.4.36 - PyYAML>=6.0 + SQLAlchemy >= 1.4.36 + toml >= 0.10.2 Install ------- @@ -79,10 +79,10 @@ Configuration files .. code-block:: bash - /etc/slpkg/slpkg.yml + /etc/slpkg/slpkg.toml General configuration of slpkg - /etc/slpkg/blacklist.yml + /etc/slpkg/blacklist.toml Blacklist of packages Donate diff --git a/configs/blacklist.yml b/configs/blacklist.toml similarity index 51% rename from configs/blacklist.yml rename to configs/blacklist.toml index decdc33a..5473a87d 100644 --- a/configs/blacklist.yml +++ b/configs/blacklist.toml @@ -1,4 +1,6 @@ -blacklist: +[blacklist] # Add packages and separate them with commas. - packages: ["%README%",] + packages = [ + "%README%" + ] diff --git a/configs/slpkg.yml b/configs/slpkg.toml similarity index 61% rename from configs/slpkg.yml rename to configs/slpkg.toml index b08b28ef..d6d294bb 100644 --- a/configs/slpkg.yml +++ b/configs/slpkg.toml @@ -1,52 +1,52 @@ -configs: +[configs] # OS architecture by default. - os_arch: x86_64 + os_archi = "x86_64" # Tmp path for slpkg. - tmp_slpkg: /tmp/slpkg + tmp_slpkg = "/tmp/slpkg" # Path for building source and the script - build_path: /tmp/slpkg/build + build_path = "/tmp/slpkg/build" # This path working only with the command download. - download_only: /tmp/slpkg + download_only = "/tmp/slpkg" # The path that the SLACKBUILDS.TXT file downloaded. - sbo_repo_path: /var/lib/slpkg/repository + sbo_repo_pathi = "/var/lib/slpkg/repository" # The name of the database. Default name is 'database.slpkg'. - database: database.slpkg + database = "database.slpkg" # Slackbuilds.org repository url. - sbo_repo_url: http://slackbuilds.org/slackbuilds/15.0 + sbo_repo_url = "http://slackbuilds.org/slackbuilds/15.0" # The SLACKBUILDS.TXT repository file. - sbo_txt: SLACKBUILDS.TXT + sbo_txt = "SLACKBUILDS.TXT" # The ChangeLog.txt file. - chglog_txt: ChangeLog.txt + chglog_txt = "ChangeLog.txt" # The sbo tar suffix. - sbo_tar_suffix: .tar.gz + sbo_tar_suffix = ".tar.gz" # The sbo repository tag. - sbo_repo_tag: _SBo + sbo_repo_tag = "_SBo" # Slackware install command. Alternative you can # use 'installpkg', if you want. - installpkg: upgradepkg --install-new + installpkg = "upgradepkg --install-new" # Upgrade or reinstall slackware command. - reinstall: upgradepkg --reinstall + reinstall = "upgradepkg --reinstall" # Slackware command to remove packages. - removepkg: removepkg + removepkg = "removepkg" # Cli menu colors configs. Default is off. [on/off] - colors: off + colors = "off" # Wget downloader options. # -c, --continue: resume getting a partially-downloaded file. # -N, --timestamping: don't re-retrieve files unless newer # than local. - wget_options: -c -N + wget_options = "-c -N" diff --git a/man/slpkg.1 b/man/slpkg.1 index f3aa9a84..23020b8d 100644 --- a/man/slpkg.1 +++ b/man/slpkg.1 @@ -110,9 +110,9 @@ Print version and exit. .RE .SH CONFIGURATION FILES .P -Configuration file in the /etc/slpkg/slpkg.yml file. +Configuration file in the /etc/slpkg/slpkg.toml file. .RE -Blacklist file in the /etc/slpkg/blacklist.yml file. +Blacklist file in the /etc/slpkg/blacklist.toml file. .SH REPORT BUGS .P Please report any found to https://gitlab.com/dslackw/slpkg/-/issues. diff --git a/requirements.txt b/requirements.txt index d06364b9..6523a208 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ SQLAlchemy>=1.4.36 -PyYAML>=6.0 +toml>=0.10.2 diff --git a/setup.cfg b/setup.cfg index 6e8656d0..6a95e28b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -39,7 +39,7 @@ packages = python_requires = >=3.7 install_requires = SQLAlchemy >= 1.4.36 - PyYAML >= 6.0 + toml >= 0.10.2 include_package_data = True [options.packages.find] diff --git a/slackbuild/doinst.sh b/slackbuild/doinst.sh index 063dd5a8..bade992d 100644 --- a/slackbuild/doinst.sh +++ b/slackbuild/doinst.sh @@ -8,8 +8,8 @@ config() { fi } -config etc/slpkg/slpkg.yml.new -config etc/slpkg/blacklist.yml.new +config etc/slpkg/slpkg.toml.new +config etc/slpkg/blacklist.toml.new if [ -x /usr/bin/update-desktop-database ]; then /usr/bin/update-desktop-database -q usr/share/applications >/dev/null 2>&1 diff --git a/slackbuild/slpkg.SlackBuild b/slackbuild/slpkg.SlackBuild index 93000c36..6eb7c132 100755 --- a/slackbuild/slpkg.SlackBuild +++ b/slackbuild/slpkg.SlackBuild @@ -98,8 +98,8 @@ find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | gr # Install configuration files and creating lib directory mkdir -p $PKG/etc/$PRGNAM -install -D -m0644 configs/slpkg.yml $PKG/etc/slpkg/slpkg.yml.new -install -D -m0645 configs/blacklist.yml $PKG/etc/slpkg/blacklist.yml.new +install -D -m0644 configs/slpkg.toml $PKG/etc/slpkg/slpkg.toml.new +install -D -m0645 configs/blacklist.toml $PKG/etc/slpkg/blacklist.toml.new mkdir -p $PKG/usr/man/man1 cp man/slpkg.1 $PKG/usr/man/man1 diff --git a/slpkg/blacklist.py b/slpkg/blacklist.py index fc74b05f..1fcfeed4 100644 --- a/slpkg/blacklist.py +++ b/slpkg/blacklist.py @@ -3,7 +3,7 @@ import os -import yaml +import tomli from dataclasses import dataclass from slpkg.configs import Configs @@ -15,7 +15,7 @@ class Blacklist: etc_path: str = Configs.etc_path def get(self): - file = f'{self.etc_path}/blacklist.yml' + file = f'{self.etc_path}/blacklist.toml' if os.path.isfile(file): - with open(file, 'r') as black: - return yaml.safe_load(black)['blacklist']['packages'] + with open(file, 'rb') as black: + return tomli.load(black)['blacklist']['packages'] diff --git a/slpkg/checks.py b/slpkg/checks.py index c973ff49..0061a0d2 100644 --- a/slpkg/checks.py +++ b/slpkg/checks.py @@ -70,7 +70,7 @@ class Check: if packages: raise SystemExit( f'\nThe packages \'{", ".join(packages)}\' is blacklisted.\n' - f'Please edit the blacklist.yml file in {self.etc_path} ' + f'Please edit the blacklist.toml file in {self.etc_path} ' 'folder.\n') def database(self): diff --git a/slpkg/configs.py b/slpkg/configs.py index d3905606..787e2de4 100644 --- a/slpkg/configs.py +++ b/slpkg/configs.py @@ -3,7 +3,7 @@ import os -import yaml +import tomli from dataclasses import dataclass @@ -51,13 +51,12 @@ class Configs: wget_options = '-c -N' ''' Overwrite with user configuration. ''' - config_file: str = f'{etc_path}/{prog_name}.yml' + config_file: str = f'{etc_path}/{prog_name}.toml' if os.path.isfile(config_file): - with open(config_file, 'r') as conf: - configs = yaml.safe_load(conf) + with open(config_file, 'rb') as conf: + configs = tomli.load(conf) try: - config = configs['configs'] # OS architecture by default diff --git a/slpkg/views/cli_menu.py b/slpkg/views/cli_menu.py index 15457d5c..6824728e 100644 --- a/slpkg/views/cli_menu.py +++ b/slpkg/views/cli_menu.py @@ -39,7 +39,7 @@ def usage(status: int): f' {YELLOW}--skip-installed{ENDC} Skip installed packages.\n', ' -h, --help Show this message and exit.', ' -v, --version Print version and exit.\n', - 'Edit the configuration file in the /etc/slpkg/slpkg.yml.', + 'Edit the configuration file in the /etc/slpkg/slpkg.toml.', 'If you need more information try to use slpkg manpage.'] for opt in args: