refactor: rename folder structure, and small enhancements

main
Steve Nyemba 1 week ago
parent 89e15a79fa
commit ce4382e08f

@ -1,5 +1,5 @@
#!/usr/bin/env python
from plugins import cli
from plugin_ix import cli
if __name__ == '__main__' :
cli.app()

@ -1,5 +1,5 @@
__author__="steve l. nyemba<steve@the-phi.com>"
__version__="0.8"
__version__="1.0"
__app_name__="plugin-ix"
__license__="""
Copyright 2025, Steve L. Nyemba <steve@the-phi.com>

@ -20,7 +20,7 @@ from enum import Enum
from rich import print
# from rich.console import Console
from rich.table import Table
import plugins
import plugin_ix
app = typer.Typer()
# app_e = typer.Typer() #-- handles etl (run, generate)
# app_x = typer.Typer() #-- handles plugins (list,add, test)
@ -42,7 +42,7 @@ def inspect (file: Annotated[str,typer.Argument(help="python file that contains
"""
This function allows plugin management / testing
"""
loader = plugins.Loader()
loader = plugin_ix.Loader()
if loader.load(file=file,decorator= decorator) :
n = len(loader._modules.keys())
print (f"""{CHECK_MARK} Found {n} functions in [bold]{file}[/bold]""")
@ -58,11 +58,11 @@ def add_registry(
"""
This function will add/override a file to the registry
"""
# reg = plugins.Registry(rg_file)
loader = plugins.Loader(file=python_file)
# reg = plugin_ix.Registry(rg_file)
loader = plugin_ix.Loader(file=python_file)
if loader.get() :
_names = list(loader.get().keys())
reg = plugins.Registry(registry_folder)
reg = plugin_ix.Registry(registry_folder)
reg.set(python_file,_names)
print (f"""{CHECK_MARK} Import was [bold]successful[/bold] into {reg._folder}""")
else:
@ -82,13 +82,13 @@ def to_Table(df: pd.DataFrame):
return table
@appr.command(name="list")
def list_registry(
folder:str=typer.Option(default=os.environ.get('REGISTRY_FOLDER',None),help="path of the plugin registry folder")):
#folder: Annotated[str,typer.Argument(help="registry folder where")]=plugins.REGISTRY_PATH) :
folder:str=typer.Option(default=os.environ.get('REGISTRY_FOLDER',None),help="path of the plugin registry folder. You can also provide the file name")):
#folder: Annotated[str,typer.Argument(help="registry folder where")]=plugin_ix.REGISTRY_PATH) :
"""
This function will summarize the registry in a table
"""
try:
reg = plugins.Registry(folder)
reg = plugin_ix.Registry(folder)
print (to_Table(reg.stats()))
except Exception as e :

@ -20,6 +20,13 @@ class Registry :
"""
self._folder = folder if folder else os.environ.get('REGISTRY_FOLDER',None)
self._filename = os.sep.join([self._folder,'plugins-registry.json'])
#
# Let us refactor this in case the user decided to provide a file name instead
if os.path.isfile(self._folder) :
_name = self._folder.split(os.sep)[-1].strip()
self._folder = os.sep.join(self._folder.split(os.sep)[:-1]).strip()
self._filename = os.sep.join([self._folder,_name])
print (' *** ',_name,self._folder)
# self._context = self._folder.split(os.sep)[-1]
self._reader = reader
self._data = {}
@ -89,8 +96,13 @@ class Registry :
return _name in self._data[_file]['content']
return False
def get(self,_key):
"""
_key is either file.funcName, _funcName@file
"""
if '@' in _key :
_name,_file = _key.split('@')
elif '.' in _key :
_file,_name = _key.split('.')
else:
_name = _key
_file = None

@ -8,7 +8,7 @@ _args = {
"name":meta.__app_name__,
"version":meta.__version__,
"author":meta.__author__,
"packages": find_packages(include=['meta','plugins']),
"packages": find_packages(include=['meta','plugin_ix']),
"scripts":["bin/plugin-ix"]
}

Loading…
Cancel
Save