mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-18 10:26:29 +01:00
Updated for no case
This commit is contained in:
parent
639ad89d24
commit
87791b2305
5 changed files with 20 additions and 48 deletions
|
@ -1,6 +1,6 @@
|
||||||
# This is the general configuration file of slpkg:
|
# This is the general configuration file of slpkg:
|
||||||
# /etc/slpkg/slpkg.toml
|
# /etc/slpkg/slpkg.toml
|
||||||
# Updated: 20/03/2024, Version: 5.0.0
|
# Updated: 27/03/2024, Version: 5.0.0
|
||||||
|
|
||||||
[CONFIGS]
|
[CONFIGS]
|
||||||
|
|
||||||
|
@ -57,8 +57,7 @@ ASK_QUESTION = true
|
||||||
PARALLEL_DOWNLOADS = false
|
PARALLEL_DOWNLOADS = false
|
||||||
|
|
||||||
# If progress bar is true, it does not print the commands as they
|
# If progress bar is true, it does not print the commands as they
|
||||||
# are executed.
|
# are executed. Default is false. [true/false]
|
||||||
# Default is false. [true/false]
|
|
||||||
PROGRESS_BAR = false
|
PROGRESS_BAR = false
|
||||||
|
|
||||||
# There are 5 predefined spinners for the progress bar.
|
# There are 5 predefined spinners for the progress bar.
|
||||||
|
@ -75,10 +74,6 @@ SPINNER_COLOR = "green"
|
||||||
# Default is bold_green.
|
# Default is bold_green.
|
||||||
BORDER_COLOR = "bold_green"
|
BORDER_COLOR = "bold_green"
|
||||||
|
|
||||||
# Enable or disable case-sensitive pattern matching.
|
|
||||||
# Default is true. [true/false]
|
|
||||||
CASE_SENSITIVE = true
|
|
||||||
|
|
||||||
# Keep process log files on /var/log/slpkg/ folder.
|
# Keep process log files on /var/log/slpkg/ folder.
|
||||||
# Default is true. [true/false]
|
# Default is true. [true/false]
|
||||||
PROCESS_LOG = true
|
PROCESS_LOG = true
|
||||||
|
|
|
@ -52,7 +52,6 @@ class Configs:
|
||||||
progress_spinner: str = 'pixel'
|
progress_spinner: str = 'pixel'
|
||||||
spinner_color: str = 'green'
|
spinner_color: str = 'green'
|
||||||
border_color: str = 'bold_green'
|
border_color: str = 'bold_green'
|
||||||
case_sensitive: bool = True
|
|
||||||
process_log: bool = True
|
process_log: bool = True
|
||||||
|
|
||||||
urllib_retries: Any = False
|
urllib_retries: Any = False
|
||||||
|
@ -98,7 +97,6 @@ class Configs:
|
||||||
progress_spinner: str = config['PROGRESS_SPINNER']
|
progress_spinner: str = config['PROGRESS_SPINNER']
|
||||||
spinner_color: str = config['SPINNER_COLOR']
|
spinner_color: str = config['SPINNER_COLOR']
|
||||||
border_color: str = config['BORDER_COLOR']
|
border_color: str = config['BORDER_COLOR']
|
||||||
case_sensitive: bool = config['CASE_SENSITIVE']
|
|
||||||
process_log: bool = config['PROCESS_LOG']
|
process_log: bool = config['PROCESS_LOG']
|
||||||
|
|
||||||
urllib_retries: Any = config['URLLIB_RETRIES']
|
urllib_retries: Any = config['URLLIB_RETRIES']
|
||||||
|
|
|
@ -77,11 +77,6 @@ class Menu(Configs):
|
||||||
self.flag_search
|
self.flag_search
|
||||||
)
|
)
|
||||||
|
|
||||||
self.flag_no_cases: tuple = (
|
|
||||||
self.flag_no_case,
|
|
||||||
self.flag_short_no_case
|
|
||||||
)
|
|
||||||
|
|
||||||
self.options: tuple = (
|
self.options: tuple = (
|
||||||
self.flag_yes,
|
self.flag_yes,
|
||||||
self.flag_short_yes,
|
self.flag_short_yes,
|
||||||
|
@ -481,9 +476,7 @@ class Menu(Configs):
|
||||||
if len(self.args) >= 2:
|
if len(self.args) >= 2:
|
||||||
self.data: dict = self.load_data.load(self.repository)
|
self.data: dict = self.load_data.load(self.repository)
|
||||||
packages: list = self.is_file_list_packages()
|
packages: list = self.is_file_list_packages()
|
||||||
|
packages: list = self.utils.case_insensitive_pattern_matching(packages, self.data, self.flags)
|
||||||
if self.utils.is_option(self.flag_no_cases, self.flags) or not self.case_sensitive:
|
|
||||||
packages: list = self.utils.case_insensitive_pattern_matching(packages, self.data)
|
|
||||||
|
|
||||||
if self.utils.is_option(self.flag_searches, self.flags):
|
if self.utils.is_option(self.flag_searches, self.flags):
|
||||||
packages: list = self.choose.packages(self.data, packages, command)
|
packages: list = self.choose.packages(self.data, packages, command)
|
||||||
|
@ -507,9 +500,7 @@ class Menu(Configs):
|
||||||
if len(self.args) >= 2:
|
if len(self.args) >= 2:
|
||||||
self.data: dict = self.load_data.load(self.repository)
|
self.data: dict = self.load_data.load(self.repository)
|
||||||
packages: list = self.is_file_list_packages()
|
packages: list = self.is_file_list_packages()
|
||||||
|
packages: list = self.utils.case_insensitive_pattern_matching(packages, self.data, self.flags)
|
||||||
if self.utils.is_option(self.flag_no_cases, self.flags) or not self.case_sensitive:
|
|
||||||
packages: list = self.utils.case_insensitive_pattern_matching(packages, self.data)
|
|
||||||
|
|
||||||
if self.utils.is_option(self.flag_searches, self.flags):
|
if self.utils.is_option(self.flag_searches, self.flags):
|
||||||
packages: list = self.choose.packages(self.data, packages, command)
|
packages: list = self.choose.packages(self.data, packages, command)
|
||||||
|
@ -531,9 +522,7 @@ class Menu(Configs):
|
||||||
if len(self.args) >= 2:
|
if len(self.args) >= 2:
|
||||||
self.data: dict = self.load_data.load(self.repository)
|
self.data: dict = self.load_data.load(self.repository)
|
||||||
packages: list = self.is_file_list_packages()
|
packages: list = self.is_file_list_packages()
|
||||||
|
packages: list = self.utils.case_insensitive_pattern_matching(packages, self.data, self.flags)
|
||||||
if self.utils.is_option(self.flag_no_cases, self.flags) or not self.case_sensitive:
|
|
||||||
packages: list = self.utils.case_insensitive_pattern_matching(packages, self.data)
|
|
||||||
|
|
||||||
if self.utils.is_option(self.flag_searches, self.flags):
|
if self.utils.is_option(self.flag_searches, self.flags):
|
||||||
packages: list = self.choose.packages(self.data, packages, command)
|
packages: list = self.choose.packages(self.data, packages, command)
|
||||||
|
@ -565,13 +554,10 @@ class Menu(Configs):
|
||||||
|
|
||||||
if len(self.args) >= 2:
|
if len(self.args) >= 2:
|
||||||
packages: list = self.is_file_list_packages()
|
packages: list = self.is_file_list_packages()
|
||||||
|
self.data: dict = self.load_data.load(self.repository)
|
||||||
if self.utils.is_option(self.flag_no_cases, self.flags) or not self.case_sensitive:
|
packages: list = self.utils.case_insensitive_pattern_matching(packages, self.data, self.flags)
|
||||||
self.data: dict = self.load_data.load(self.repository)
|
|
||||||
packages: list = self.utils.case_insensitive_pattern_matching(packages, self.data)
|
|
||||||
|
|
||||||
if self.utils.is_option(self.flag_searches, self.flags):
|
if self.utils.is_option(self.flag_searches, self.flags):
|
||||||
self.data: dict = self.load_data.load(self.repository)
|
|
||||||
packages: list = self.choose.packages(self.data, packages, command)
|
packages: list = self.choose.packages(self.data, packages, command)
|
||||||
|
|
||||||
find = FindInstalled(self.flags, packages)
|
find = FindInstalled(self.flags, packages)
|
||||||
|
@ -585,9 +571,7 @@ class Menu(Configs):
|
||||||
if len(self.args) >= 2:
|
if len(self.args) >= 2:
|
||||||
self.data: dict = self.load_data.load(self.repository)
|
self.data: dict = self.load_data.load(self.repository)
|
||||||
packages: list = self.is_file_list_packages()
|
packages: list = self.is_file_list_packages()
|
||||||
|
packages: list = self.utils.case_insensitive_pattern_matching(packages, self.data, self.flags)
|
||||||
if self.utils.is_option(self.flag_no_cases, self.flags) or not self.case_sensitive:
|
|
||||||
packages: list = self.utils.case_insensitive_pattern_matching(packages, self.data)
|
|
||||||
|
|
||||||
if self.utils.is_option(self.flag_searches, self.flags):
|
if self.utils.is_option(self.flag_searches, self.flags):
|
||||||
packages: list = self.choose.packages(self.data, packages, command)
|
packages: list = self.choose.packages(self.data, packages, command)
|
||||||
|
@ -624,9 +608,7 @@ class Menu(Configs):
|
||||||
if len(self.args) >= 2:
|
if len(self.args) >= 2:
|
||||||
self.data: dict = self.load_data.load(self.repository)
|
self.data: dict = self.load_data.load(self.repository)
|
||||||
packages: list = self.is_file_list_packages()
|
packages: list = self.is_file_list_packages()
|
||||||
|
packages: list = self.utils.case_insensitive_pattern_matching(packages, self.data, self.flags)
|
||||||
if self.utils.is_option(self.flag_no_cases, self.flags) or not self.case_sensitive:
|
|
||||||
packages: list = self.utils.case_insensitive_pattern_matching(packages, self.data)
|
|
||||||
|
|
||||||
if self.utils.is_option(self.flag_searches, self.flags):
|
if self.utils.is_option(self.flag_searches, self.flags):
|
||||||
packages: list = self.choose.packages(self.data, packages, command)
|
packages: list = self.choose.packages(self.data, packages, command)
|
||||||
|
@ -644,9 +626,7 @@ class Menu(Configs):
|
||||||
if len(self.args) >= 2:
|
if len(self.args) >= 2:
|
||||||
self.data: dict = self.load_data.load(self.repository)
|
self.data: dict = self.load_data.load(self.repository)
|
||||||
packages: list = self.is_file_list_packages()
|
packages: list = self.is_file_list_packages()
|
||||||
|
packages: list = self.utils.case_insensitive_pattern_matching(packages, self.data, self.flags)
|
||||||
if self.utils.is_option(self.flag_no_cases, self.flags) or not self.case_sensitive:
|
|
||||||
packages: list = self.utils.case_insensitive_pattern_matching(packages, self.data)
|
|
||||||
|
|
||||||
if self.utils.is_option(self.flag_searches, self.flags):
|
if self.utils.is_option(self.flag_searches, self.flags):
|
||||||
packages: list = self.choose.packages(self.data, packages, command)
|
packages: list = self.choose.packages(self.data, packages, command)
|
||||||
|
@ -660,7 +640,7 @@ class Menu(Configs):
|
||||||
|
|
||||||
|
|
||||||
class SubMenu:
|
class SubMenu:
|
||||||
""" Sub menu that separate from the main menu because of
|
""" Submenu that separate from the main menu because of
|
||||||
have no options to manage here. """
|
have no options to manage here. """
|
||||||
|
|
||||||
def __init__(self, args: list):
|
def __init__(self, args: list):
|
||||||
|
|
|
@ -171,16 +171,16 @@ class Utilities(Configs):
|
||||||
for file in os.listdir(folder):
|
for file in os.listdir(folder):
|
||||||
os.chown(Path(folder, file), 0, 0)
|
os.chown(Path(folder, file), 0, 0)
|
||||||
|
|
||||||
@staticmethod
|
def case_insensitive_pattern_matching(self, packages: list, data: dict, flags: list) -> list:
|
||||||
def case_insensitive_pattern_matching(packages: list, data: dict) -> list:
|
|
||||||
""" Case-insensitive pattern matching packages. """
|
""" Case-insensitive pattern matching packages. """
|
||||||
repo_packages: tuple = tuple(data.keys())
|
if self.is_option(('-m', '--no-case'), flags):
|
||||||
for package in packages:
|
repo_packages: tuple = tuple(data.keys())
|
||||||
for pkg in repo_packages:
|
for package in packages:
|
||||||
if package.lower() == pkg.lower():
|
for pkg in repo_packages:
|
||||||
packages.append(pkg)
|
if package.lower() == pkg.lower():
|
||||||
packages.remove(package)
|
packages.append(pkg)
|
||||||
break
|
packages.remove(package)
|
||||||
|
break
|
||||||
return packages
|
return packages
|
||||||
|
|
||||||
def read_json_file(self, file: Path) -> dict:
|
def read_json_file(self, file: Path) -> dict:
|
||||||
|
|
|
@ -46,7 +46,6 @@ class TestConfigs(unittest.TestCase):
|
||||||
self.assertEqual('pixel', self.configs.progress_spinner)
|
self.assertEqual('pixel', self.configs.progress_spinner)
|
||||||
self.assertEqual('green', self.configs.spinner_color)
|
self.assertEqual('green', self.configs.spinner_color)
|
||||||
self.assertEqual('bold_green', self.configs.border_color)
|
self.assertEqual('bold_green', self.configs.border_color)
|
||||||
self.assertEqual(True, self.configs.case_sensitive)
|
|
||||||
self.assertEqual(True, self.configs.process_log)
|
self.assertEqual(True, self.configs.process_log)
|
||||||
|
|
||||||
self.assertEqual(False, self.configs.urllib_retries)
|
self.assertEqual(False, self.configs.urllib_retries)
|
||||||
|
|
Loading…
Reference in a new issue