Easier way to manage your project addons
Project description
Relative Addons System
This is special system which allow you to manage your addons
Addon is a folder with addon.json
and __init__.py
files
Example:
from pathlib import Path
from RelativeAddonsSystem import RelativeAddonsSystem, Addon, AddonMeta
# Init addons system
system = RelativeAddonsSystem(Path(__file__).parent / "addons")
# return list of Addon objects
addons: list[Addon] = system.get_all_addons()
if len(addons) < 1:
print("No addons found")
else:
for addon in addons:
# loaded meta(AddonMeta) from ADDON_DIR/addon.json
meta: AddonMeta = addon.meta
print("Working with", meta.name, "at", addon.path.absolute())
# Check dependencies
if not addon.check_requirements(alert=False):
print("Installing addon dependencies")
# Install dependencies
installed: list[str] = addon.install_requirements()
print("Successfully installed addon dependencies (", ", ".join(installed), ")")
else:
print("Addon dependencies already satisfied")
# Get addon module
module = addon.module # ADDON_DIR / __init__.py module
...
In this example, we have listed all addons and install their dependencies if they are not installed
You can also disable or enable addons:
from pathlib import Path
from RelativeAddonsSystem import RelativeAddonsSystem, Addon
# Init addons system
system = RelativeAddonsSystem(Path(__file__).parent / "addons")
addons: list[Addon] = system.get_enabled_addons() # get all enabled addons
if len(addons) > 0:
addon: Addon = addons[0] # first addon from list
addon.disable() # disable addon
...
addon.enable() # enable addon
Or import, reimport(Useful when you updated your addon) module:
from pathlib import Path
from RelativeAddonsSystem import RelativeAddonsSystem, Addon
# Init addons system
system = RelativeAddonsSystem(Path(__file__).parent / "addons")
addons: list[Addon] = system.get_enabled_addons() # get all enabled addons
if len(addons) > 0:
addon: Addon = addons[0] # first addon from list
module = addon.module
... # Work with module
# Reimport module
module = addon.reload_module()
... # Work with module
You can also change the meta in your code:
from pathlib import Path
from RelativeAddonsSystem import RelativeAddonsSystem, Addon, AddonMeta
# Init addons system
system = RelativeAddonsSystem(Path(__file__).parent / "addons")
addons: list[Addon] = system.get_enabled_addons() # get all enabled addons
if len(addons) > 0:
addon: Addon = addons[0] # first addon from list
meta: AddonMeta = addon.meta
meta.set("version", "1.2")
meta.save()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for relative-addons-system-2.4.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 084846de788a8b0a0535ff255716963fd3153757d26fd8e3f681e46096cfaed4 |
|
MD5 | b8c49868dcf308661875b6c4b916b1e9 |
|
BLAKE2b-256 | c6c81af4eeaf5a7763fb2dab475fb7fdd4bf7d028a329e4e4abf7f9049774487 |
Close
Hashes for relative_addons_system-2.4.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ba456f6d843c04d3f325922cddab9afd1e451564e0d6f3fc6684cf5e5497c98 |
|
MD5 | 8bba075df4926d28c9d6e823c6bccf1d |
|
BLAKE2b-256 | 87cd5d4245bcc4476e49bf7b8dfd39372cc7a30680b94c670e8d4649c26cbd07 |