relative-addons-system


Namerelative-addons-system JSON
Version 2.6.0 PyPI version JSON
download
home_page
SummaryEasier way to manage your project addons
upload_time2023-10-22 12:28:39
maintainer
docs_urlNone
authorYoungTitanium
requires_python>=3.10
licenseCopyright 2022 kuyugama(youngtitanium) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords addons system relative requirement dependency addon
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Relative Addons System
**This is a special system that allows you to manage your addons in runtime.**

**The library has caching that allows it to work faster**

## Definitions
**Addon** - directory that contains `addon.json` and `__init__.py`  
**addon.json** is a `json` file that describes addon and must contain `name`, `author`, 
`description` and `version`(strings)


## Usage examples
```python
from pathlib import Path

from RelativeAddonsSystem import RelativeAddonsSystem, Addon, AddonMeta

# Init addons system
system = RelativeAddonsSystem(Path(__file__).parent / "addons", auto_install_requirements=True)

# 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 installed their dependencies if they were not already installed.**

**We can also disable or enable addons:**

```python
from pathlib import Path

from RelativeAddonsSystem import RelativeAddonsSystem, Addon

# Init addons system
system = RelativeAddonsSystem(Path(__file__).parent / "addons", auto_install_requirements=True)

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 and re-import the module (useful when we have updated your addon):_**
```python
from pathlib import Path

from RelativeAddonsSystem import RelativeAddonsSystem, Addon

# Init addons system
system = RelativeAddonsSystem(Path(__file__).parent / "addons", auto_install_requirements=True)

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
```

**_We can also change the metadata in your code:_**
```python
from pathlib import Path

from RelativeAddonsSystem import RelativeAddonsSystem, Addon, AddonMeta

# Init addons system
system = RelativeAddonsSystem(Path(__file__).parent / "addons", auto_install_requirements=True)

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()
```

**_Or set specific data into the addon's storage:_**
```python
from pathlib import Path

from RelativeAddonsSystem import RelativeAddonsSystem, Addon
from RelativeAddonsSystem.utils import Storage

# Init addons system
system = RelativeAddonsSystem(Path(__file__).parent / "addons", auto_install_requirements=True)

addons: list[Addon] = system.get_enabled_addons() # get all enabled addons

if len(addons) > 0:
    addon: Addon = addons[0] # first addon from list
    
    # Loaded the ADDON_DIR/ADDON_NAME-storage.json file
    storage: Storage = addon.get_storage()

    storage.set("api_version", "1.2")

    storage.save()
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "relative-addons-system",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "",
    "keywords": "addons,system,relative,requirement,dependency,addon",
    "author": "YoungTitanium",
    "author_email": "\"kuyugama(youngtitanium)\" <mail.kuyugama@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/eb/24/fcbfe6220cf749bf0166b31a66a5a6cb0c031c77e1309cccff9816ea3c31/relative-addons-system-2.6.0.tar.gz",
    "platform": null,
    "description": "# Relative Addons System\r\n**This is a special system that allows you to manage your addons in runtime.**\r\n\r\n**The library has caching that allows it to work faster**\r\n\r\n## Definitions\r\n**Addon** - directory that contains `addon.json` and `__init__.py`  \r\n**addon.json** is a `json` file that describes addon and must contain `name`, `author`, \r\n`description` and `version`(strings)\r\n\r\n\r\n## Usage examples\r\n```python\r\nfrom pathlib import Path\r\n\r\nfrom RelativeAddonsSystem import RelativeAddonsSystem, Addon, AddonMeta\r\n\r\n# Init addons system\r\nsystem = RelativeAddonsSystem(Path(__file__).parent / \"addons\", auto_install_requirements=True)\r\n\r\n# return list of Addon objects\r\naddons: list[Addon] = system.get_all_addons()\r\n\r\nif len(addons) < 1:\r\n    print(\"No addons found\")\r\nelse:\r\n    for addon in addons:\r\n        # loaded meta(AddonMeta) from ADDON_DIR/addon.json\r\n        meta: AddonMeta = addon.meta\r\n        \r\n        print(\"Working with\", meta.name, \"at\", addon.path.absolute())\r\n        \r\n        # Check dependencies\r\n        if not addon.check_requirements(alert=False):\r\n            print(\"Installing addon dependencies\")\r\n            # Install dependencies\r\n            installed: list[str] = addon.install_requirements()\r\n            print(\"Successfully installed addon dependencies (\", \", \".join(installed), \")\")\r\n        else:\r\n            print(\"Addon dependencies already satisfied\")\r\n        \r\n        # Get addon module\r\n        module = addon.module # ADDON_DIR / __init__.py module\r\n        ...\r\n```\r\n\r\n**In this example, we have listed all addons and installed their dependencies if they were not already installed.**\r\n\r\n**We can also disable or enable addons:**\r\n\r\n```python\r\nfrom pathlib import Path\r\n\r\nfrom RelativeAddonsSystem import RelativeAddonsSystem, Addon\r\n\r\n# Init addons system\r\nsystem = RelativeAddonsSystem(Path(__file__).parent / \"addons\", auto_install_requirements=True)\r\n\r\naddons: list[Addon] = system.get_enabled_addons() # get all enabled addons\r\n\r\nif len(addons) > 0:\r\n    addon: Addon = addons[0] # first addon from list\r\n    addon.disable() # disable addon\r\n    \r\n    ...\r\n    \r\n    addon.enable() # enable addon\r\n```\r\n\r\n**_Or import and re-import the module (useful when we have updated your addon):_**\r\n```python\r\nfrom pathlib import Path\r\n\r\nfrom RelativeAddonsSystem import RelativeAddonsSystem, Addon\r\n\r\n# Init addons system\r\nsystem = RelativeAddonsSystem(Path(__file__).parent / \"addons\", auto_install_requirements=True)\r\n\r\naddons: list[Addon] = system.get_enabled_addons() # get all enabled addons\r\n\r\nif len(addons) > 0:\r\n    addon: Addon = addons[0] # first addon from list\r\n    \r\n    module = addon.module\r\n    \r\n    ... # Work with module\r\n\r\n    # Reimport module\r\n    module = addon.reload_module()\r\n    \r\n    ... # Work with module\r\n```\r\n\r\n**_We can also change the metadata in your code:_**\r\n```python\r\nfrom pathlib import Path\r\n\r\nfrom RelativeAddonsSystem import RelativeAddonsSystem, Addon, AddonMeta\r\n\r\n# Init addons system\r\nsystem = RelativeAddonsSystem(Path(__file__).parent / \"addons\", auto_install_requirements=True)\r\n\r\naddons: list[Addon] = system.get_enabled_addons() # get all enabled addons\r\n\r\nif len(addons) > 0:\r\n    addon: Addon = addons[0] # first addon from list\r\n    \r\n    meta: AddonMeta = addon.meta\r\n\r\n    meta.set(\"version\", \"1.2\")\r\n\r\n    meta.save()\r\n```\r\n\r\n**_Or set specific data into the addon's storage:_**\r\n```python\r\nfrom pathlib import Path\r\n\r\nfrom RelativeAddonsSystem import RelativeAddonsSystem, Addon\r\nfrom RelativeAddonsSystem.utils import Storage\r\n\r\n# Init addons system\r\nsystem = RelativeAddonsSystem(Path(__file__).parent / \"addons\", auto_install_requirements=True)\r\n\r\naddons: list[Addon] = system.get_enabled_addons() # get all enabled addons\r\n\r\nif len(addons) > 0:\r\n    addon: Addon = addons[0] # first addon from list\r\n    \r\n    # Loaded the ADDON_DIR/ADDON_NAME-storage.json file\r\n    storage: Storage = addon.get_storage()\r\n\r\n    storage.set(\"api_version\", \"1.2\")\r\n\r\n    storage.save()\r\n```\r\n",
    "bugtrack_url": null,
    "license": "Copyright 2022 kuyugama(youngtitanium)  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  ",
    "summary": "Easier way to manage your project addons",
    "version": "2.6.0",
    "project_urls": {
        "Homepage": "https://github.com/youngtitanium/RelativeAddonsSystem"
    },
    "split_keywords": [
        "addons",
        "system",
        "relative",
        "requirement",
        "dependency",
        "addon"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b1a8f25eae6a877e2833f68873e4b39d11e41fe32a05d2e2800955aaa7957fe2",
                "md5": "f764075fb267397469f890f5c7bc6542",
                "sha256": "c20c2615bf43e731d2f1ed016c19aa6e74d1453bdebd6f18af6a952cd6b2d936"
            },
            "downloads": -1,
            "filename": "relative_addons_system-2.6.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f764075fb267397469f890f5c7bc6542",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 13236,
            "upload_time": "2023-10-22T12:28:37",
            "upload_time_iso_8601": "2023-10-22T12:28:37.563471Z",
            "url": "https://files.pythonhosted.org/packages/b1/a8/f25eae6a877e2833f68873e4b39d11e41fe32a05d2e2800955aaa7957fe2/relative_addons_system-2.6.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "eb24fcbfe6220cf749bf0166b31a66a5a6cb0c031c77e1309cccff9816ea3c31",
                "md5": "313ba5b002bb0b91d0b9319acb7c5b54",
                "sha256": "193ee25403d7a0de3050b7784d7f848271952d4c5e135655821fcfa6d5b953dc"
            },
            "downloads": -1,
            "filename": "relative-addons-system-2.6.0.tar.gz",
            "has_sig": false,
            "md5_digest": "313ba5b002bb0b91d0b9319acb7c5b54",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 11909,
            "upload_time": "2023-10-22T12:28:39",
            "upload_time_iso_8601": "2023-10-22T12:28:39.035671Z",
            "url": "https://files.pythonhosted.org/packages/eb/24/fcbfe6220cf749bf0166b31a66a5a6cb0c031c77e1309cccff9816ea3c31/relative-addons-system-2.6.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-22 12:28:39",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "youngtitanium",
    "github_project": "RelativeAddonsSystem",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "relative-addons-system"
}
        
Elapsed time: 0.13150s