Commit 34825230 authored by Roman Alifanov's avatar Roman Alifanov

load modules from /usr/share/tuneit/modules/ but local modules are a priority.

parent 8c1759b4
<?xml version="1.0" encoding="UTF-8"?>
<schemalist gettext-domain="tuneit">
<schema id="ru.ximperlinux.TuneIt" path="/ru.ximperlinux.TuneIt/">
<key name="show_root_modules" type="b">
<default>false</default>
<description>Show modules that require root permissions</description>
</key>
</schema>
</schemalist>
pluginsdir = pkgdatadir / 'modules'
plugins = [
'exampleplug.yml',
'exampleplug',
]
install_data(plugins, install_dir: pluginsdir)
install_subdir(plugins, install_dir: pluginsdir)
......@@ -2,22 +2,31 @@ import os
import yaml
def get_local_share_directory():
def get_local_module_directory():
home_directory = os.path.expanduser("~")
local_share_directory = os.path.join(home_directory, ".local", "share", "tuneit")
return local_share_directory
return os.path.join(home_directory, ".local", "share", "tuneit", "modules")
def get_module_directory():
return "/usr/share/tuneit/modules"
def load_modules():
modules = []
local_share_directory = get_local_share_directory()
modules_directory = os.path.join(local_share_directory, "modules")
if not os.path.exists(modules_directory):
print(f"Директория {modules_directory} не существует")
return modules
modules = load_yaml_files_from_directory(modules_directory)
local_modules_directory = get_local_module_directory()
global_modules_directory = get_module_directory()
all_modules = set(os.listdir(global_modules_directory))
for module_name in os.listdir(local_modules_directory):
module_path = os.path.join(local_modules_directory, module_name)
if os.path.isdir(module_path):
modules += load_yaml_files_from_directory(module_path)
all_modules.discard(module_name)
for module_name in all_modules:
module_path = os.path.join(global_modules_directory, module_name)
if os.path.isdir(module_path):
modules += load_yaml_files_from_directory(module_path)
return modules
def load_yaml_files_from_directory(directory):
......@@ -35,7 +44,6 @@ def load_yaml_files_from_directory(directory):
print(f"Ошибка при чтении файла {file_path}: {e}")
return yaml_data
def merge_categories_by_name(categories_data):
categories_dict = {}
for category_data in categories_data:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment