# Path: plugin.py
# class Plugin:
# class PluginManager:
# class Documents:
#     def __init__(self):
#     def user(self):
#     def process(self, request):
#     def unload(self):
#     def __init__(self):
#     def load_plugin(self, name, reload=False):
#     def get_plugins(self):
#     def send_request(self, plugin, request):
#     def __init__(self, plugin: Plugin):
#     def set_document_type(self, name: str):
#     def set_document_table(self, table):
#     def get(self, pid):
#     def list(self, owner):
#     def create(self, pdoc: PluginDocument):
#     def update(pdoc: PluginDocument):
#     def delete(self, pdoc: PluginDocument):


from os import listdir, path
from plugin import Plugin, plugin_manager
            plugin_manager.load_plugin(p)

    @property
    def auto_load_list(self) -> list:
        with open(Plugins.auto_load_list_file) as f:
            return eval(f.read())

    @auto_load_list.setter
    def auto_load_list(self, val):
        with open(Plugins.auto_load_list_file, 'w') as f:
            f.write(repr(val))

    def process(self, request):
        return getattr(self, request['action'])(**request)

    def list(self, **_):
        result = {}
        ds = {}
        loaded = plugin_manager.get_plugins()
        for f in listdir(plugin_manager.plugin_directory):
            if path.isdir(f):
                name = f
            else:
                name, _, postfix = f.rpartition('.')
                if postfix not in ('py', 'pyc', 'pyd'):
                    continue
            if name.startswith('_'):
                continue
            state = name in loaded
            if state:

# Path: plugin.py
# class Plugin:
# class PluginManager:
# class Documents:
#     def __init__(self):
#     def user(self):
#     def process(self, request):
#     def unload(self):
#     def __init__(self):
#     def load_plugin(self, name, reload=False):
#     def get_plugins(self):
#     def send_request(self, plugin, request):
#     def __init__(self, plugin: Plugin):
#     def set_document_type(self, name: str):
#     def set_document_table(self, table):
#     def get(self, pid):
#     def list(self, owner):
#     def create(self, pdoc: PluginDocument):
#     def update(pdoc: PluginDocument):
#     def delete(self, pdoc: PluginDocument):


# Path: plugins/plugins/plugins.py
from os import listdir, path
from plugin import Plugin, plugin_manager

            plugin_manager.load_plugin(p)

    @property
    def auto_load_list(self) -> list:
        with open(Plugins.auto_load_list_file) as f:
            return eval(f.read())

    @auto_load_list.setter
    def auto_load_list(self, val):
        with open(Plugins.auto_load_list_file, 'w') as f:
            f.write(repr(val))

    def process(self, request):
        return getattr(self, request['action'])(**request)

    def list(self, **_):
        result = {}
        ds = {}
        loaded = plugin_manager.get_plugins()
        for f in listdir(plugin_manager.plugin_directory):
            if path.isdir(f):
                name = f
            else:
                name, _, postfix = f.rpartition('.')
                if postfix not in ('py', 'pyc', 'pyd'):
                    continue
            if name.startswith('_'):
                continue
            state = name in loaded
            if state:

                ds[name] = plugin_manager.get_plugins()[name].description