Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

relative-addons-system-2.4.2.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

relative_addons_system-2.4.2-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file relative-addons-system-2.4.2.tar.gz.

File metadata

File hashes

Hashes for relative-addons-system-2.4.2.tar.gz
Algorithm Hash digest
SHA256 24469953784554eb7f8385bade6585dbafb4f5cc3688aef855f8a0aefd1d44d7
MD5 e27c463eec1f21ed87aee44acacf1c5a
BLAKE2b-256 d79b90251481e18b16e12a0f715c6d8fab96aa906e7e96d1470959c5c0164785

See more details on using hashes here.

Provenance

File details

Details for the file relative_addons_system-2.4.2-py3-none-any.whl.

File metadata

File hashes

Hashes for relative_addons_system-2.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bd9bc430b3f62a3b6d9c6576210786767914a3b968a07ea73502d67a9f180728
MD5 ea12bb7cc774068862fbabdec20241fe
BLAKE2b-256 897e864d822c8a04d37288ceb0414235929252e610bbc96403781ccb57e29a84

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page