From 085b88b00ab4a6aa4e08e44546b91ac6d906f497 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Tue, 7 Mar 2023 22:04:07 +0200 Subject: [PATCH] Added the file pattern in the config --- ChangeLog.txt | 1 + configs/slpkg.toml | 2 ++ slpkg/configs.py | 6 ++++++ slpkg/main.py | 5 ++++- 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 0f2ce148..48aa5e1f 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,6 +1,7 @@ 4.5.6 - 07/03/2023 Added: - Ignore comments for list.pkgs files (Thanks to rizitis) +- The file pattern in the config file Updated: - Ponce repository diff --git a/configs/slpkg.toml b/configs/slpkg.toml index f41c48fb..81f86d17 100644 --- a/configs/slpkg.toml +++ b/configs/slpkg.toml @@ -28,6 +28,8 @@ # Set false to all the questions. If set false option --yes will not work. # Default is true. [true/false]. ASK_QUESTION = true + # Pass your file pattern here, instead, you can use '--file-pattern=' option. + FILE_PATTERN = "" # SLACKBUILDS.ORG REPOSITORY CONFIGS. SBO_REPO_PATH = "/var/lib/slpkg/repositories/sbo/" diff --git a/slpkg/configs.py b/slpkg/configs.py index 26771d7b..3839f5b6 100644 --- a/slpkg/configs.py +++ b/slpkg/configs.py @@ -97,6 +97,9 @@ class Configs: # Set false to all the questions. ask_question: bool = True + # Pass the file pattern here. + file_pattern_conf: str = "" + # Load configurations from the file. load = LoadConfigs() configs = load.file(etc_path, prog_name) @@ -167,6 +170,9 @@ class Configs: # File suffix for list packages. file_list_suffix: str = config['FILE_LIST_SUFFIX'] + # Pass the file pattern here. + file_pattern_conf: str = config['FILE_PATTERN'] + except KeyError as error: raise SystemExit(f"\nKeyError: {error}: in the configuration file '/etc/slpkg/slpkg.toml'.\n" f"\nIf you have upgraded the '{prog_name}' probably you need to run:\n" diff --git a/slpkg/main.py b/slpkg/main.py index 64c09047..1c3c1ab1 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -34,13 +34,16 @@ class Argparse(Configs): self.args: list = args self.flags: list = [] self.directory = self.tmp_slpkg - self.file_pattern: str = f'*{self.repo_tag}' self.dialogbox = DialogBox() self.utils = Utilities() self.usage = Usage() self.check = Check() self.form_configs = FormConfigs() + self.file_pattern: str = f'*{self.repo_tag}' + if self.file_pattern_conf: + self.file_pattern = self.file_pattern_conf + if len(self.args) == 0: self.usage.help_short()