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.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57d9a89045b43608d910169550c60563960c74ac3da41180cbc37ba5f76048b6 |
|
MD5 | 71abf991c1cb3e353fa7064910c8e822 |
|
BLAKE2b-256 | 804b318d7f5f40a1ac5ada7b839709d0fd80d1f4d028b9f292564122fd90cae5 |
Close
Hashes for relative_addons_system-2.4.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbde8fbd472a5b699af98afc5fa301909d8b64c6368bf861e0ce792fce4b272f |
|
MD5 | 1802de4f66eed7a3c251446626a63bba |
|
BLAKE2b-256 | 4d59748cf113ec1d1f7b8e8721557366df82f52897d98303013fea452de0819b |