rename plugins dirs

This commit is contained in:
Nick Sweeting 2024-09-24 01:34:27 -07:00
parent 8713091e73
commit e8f1264954
No known key found for this signature in database
28 changed files with 31 additions and 31 deletions

View file

@ -36,17 +36,17 @@ assert ARCHIVE_DIR == CONFIG.ARCHIVE_DIR
def find_plugins_in_dir(plugins_dir: Path, prefix: str) -> Dict[str, Path]: def find_plugins_in_dir(plugins_dir: Path, prefix: str) -> Dict[str, Path]:
"""{"pkg_plugins.pip": "/app/archivebox/pkg_plugins/pip", "user_plugins.other": "/data/user_plugins/other",...}""" """{"plugins_pkg.pip": "/app/archivebox/plugins_pkg/pip", "user_plugins.other": "/data/user_plugins/other",...}"""
return { return {
f"{prefix}.{plugin_entrypoint.parent.name}": plugin_entrypoint.parent f"{prefix}.{plugin_entrypoint.parent.name}": plugin_entrypoint.parent
for plugin_entrypoint in sorted(plugins_dir.glob("*/apps.py")) # key=get_plugin_order # Someday enforcing plugin import order may be required, but right now it's not needed for plugin_entrypoint in sorted(plugins_dir.glob("*/apps.py")) # key=get_plugin_order # Someday enforcing plugin import order may be required, but right now it's not needed
} }
PLUGIN_DIRS = { PLUGIN_DIRS = {
'sys_plugins': PACKAGE_DIR / 'sys_plugins', 'plugins_sys': PACKAGE_DIR / 'plugins_sys',
'pkg_plugins': PACKAGE_DIR / 'pkg_plugins', 'plugins_pkg': PACKAGE_DIR / 'plugins_pkg',
'auth_plugins': PACKAGE_DIR / 'auth_plugins', 'plugins_auth': PACKAGE_DIR / 'plugins_auth',
'extractor_plugins': PACKAGE_DIR / 'extractor_plugins', 'plugins_extractor': PACKAGE_DIR / 'plugins_extractor',
'user_plugins': DATA_DIR / 'user_plugins', 'user_plugins': DATA_DIR / 'user_plugins',
} }
INSTALLED_PLUGINS = {} INSTALLED_PLUGINS = {}
@ -144,7 +144,7 @@ AUTHENTICATION_BACKENDS = [
'django.contrib.auth.backends.ModelBackend', 'django.contrib.auth.backends.ModelBackend',
] ]
from ..auth_plugins.ldap.settings import LDAP_CONFIG from ..plugins_auth.ldap.settings import LDAP_CONFIG
if LDAP_CONFIG.LDAP_ENABLED: if LDAP_CONFIG.LDAP_ENABLED:
AUTH_LDAP_BIND_DN = LDAP_CONFIG.LDAP_BIND_DN AUTH_LDAP_BIND_DN = LDAP_CONFIG.LDAP_BIND_DN
@ -559,7 +559,7 @@ LOGGING = {
"handlers": ["default", "logfile"], "handlers": ["default", "logfile"],
"level": "DEBUG", "level": "DEBUG",
}, },
"extractor_plugins": { "plugins_extractor": {
"handlers": ["default", "logfile"], "handlers": ["default", "logfile"],
"level": "DEBUG", "level": "DEBUG",
}, },

View file

@ -11,11 +11,11 @@ class BaseAdminDataView(BaseHook):
# verbose_name: str = 'Data View' # verbose_name: str = 'Data View'
# route: str = '/npm/installed/' # route: str = '/npm/installed/'
# view: str = 'pkg_plugins.npm.admin.installed_list_view' # view: str = 'plugins_pkg.npm.admin.installed_list_view'
# items: Dict[str, str] = { # items: Dict[str, str] = {
# "name": "installed_npm_pkg", # "name": "installed_npm_pkg",
# 'route': '<str:key>/', # 'route': '<str:key>/',
# 'view': 'pkg_plugins.npm.admin.installed_detail_view', # 'view': 'plugins_pkg.npm.admin.installed_detail_view',
# } # }
def register(self, settings, parent_plugin=None): def register(self, settings, parent_plugin=None):

View file

@ -26,11 +26,11 @@ class BaseHook(BaseModel):
# django imports AppConfig, models, migrations, admins, etc. for all installed apps # django imports AppConfig, models, migrations, admins, etc. for all installed apps
# django then calls AppConfig.ready() on each installed app... # django then calls AppConfig.ready() on each installed app...
pkg_plugins.npm.NpmPlugin().AppConfig.ready() # called by django plugins_pkg.npm.NpmPlugin().AppConfig.ready() # called by django
pkg_plugins.npm.NpmPlugin().register(settings) -> plugins_pkg.npm.NpmPlugin().register(settings) ->
pkg_plugins.npm.NpmConfigSet().register(settings) plugins_pkg.npm.NpmConfigSet().register(settings)
plugantic.base_configset.BaseConfigSet().register(settings) plugantic.base_configset.BaseConfigSet().register(settings)
plugantic.base_hook.BaseHook().register(settings, parent_plugin=pkg_plugins.npm.NpmPlugin()) plugantic.base_hook.BaseHook().register(settings, parent_plugin=plugins_pkg.npm.NpmPlugin())
... ...
... ...
@ -74,17 +74,17 @@ class BaseHook(BaseModel):
@property @property
def hook_module(self) -> str: def hook_module(self) -> str:
"""e.g. extractor_plugins.singlefile.apps.SinglefileConfigSet""" """e.g. plugins_extractor.singlefile.apps.SinglefileConfigSet"""
return f'{self.__module__}.{self.__class__.__name__}' return f'{self.__module__}.{self.__class__.__name__}'
@property @property
def hook_file(self) -> Path: def hook_file(self) -> Path:
"""e.g. extractor_plugins.singlefile.apps.SinglefileConfigSet""" """e.g. plugins_extractor.singlefile.apps.SinglefileConfigSet"""
return Path(inspect.getfile(self.__class__)) return Path(inspect.getfile(self.__class__))
@property @property
def plugin_module(self) -> str: def plugin_module(self) -> str:
"""e.g. extractor_plugins.singlefile""" """e.g. plugins_extractor.singlefile"""
return f"{self.__module__}.{self.__class__.__name__}".split("archivebox.", 1)[-1].rsplit(".apps.", 1)[0] return f"{self.__module__}.{self.__class__.__name__}".split("archivebox.", 1)[-1].rsplit(".apps.", 1)[0]
@property @property

View file

@ -61,14 +61,14 @@ class BasePlugin(BaseModel):
def plugin_module(self) -> str: # DottedImportPath def plugin_module(self) -> str: # DottedImportPath
""" " """ "
Dotted import path of the plugin's module (after its loaded via settings.INSTALLED_APPS). Dotted import path of the plugin's module (after its loaded via settings.INSTALLED_APPS).
e.g. 'archivebox.pkg_plugins.npm.apps.NpmPlugin' -> 'pkg_plugins.npm' e.g. 'archivebox.plugins_pkg.npm.apps.NpmPlugin' -> 'plugins_pkg.npm'
""" """
return f"{self.__module__}.{self.__class__.__name__}".split("archivebox.", 1)[-1].rsplit('.apps.', 1)[0] return f"{self.__module__}.{self.__class__.__name__}".split("archivebox.", 1)[-1].rsplit('.apps.', 1)[0]
@property @property
def plugin_module_full(self) -> str: # DottedImportPath def plugin_module_full(self) -> str: # DottedImportPath
"""e.g. 'archivebox.pkg_plugins.npm.apps.NpmPlugin'""" """e.g. 'archivebox.plugins_pkg.npm.apps.NpmPlugin'"""
return f"{self.__module__}.{self.__class__.__name__}" return f"{self.__module__}.{self.__class__.__name__}"
# @computed_field # @computed_field
@ -84,7 +84,7 @@ class BasePlugin(BaseModel):
# preserve references to original default objects, # preserve references to original default objects,
# pydantic deepcopies them by default which breaks mutability # pydantic deepcopies them by default which breaks mutability
# see https://github.com/pydantic/pydantic/issues/7608 # see https://github.com/pydantic/pydantic/issues/7608
# if we dont do this, then sys_plugins.base.CORE_CONFIG != settings.CONFIGS.CoreConfig for example # if we dont do this, then plugins_sys.base.CORE_CONFIG != settings.CONFIGS.CoreConfig for example
# and calling .__init__() on one of them will not update the other # and calling .__init__() on one of them will not update the other
self.hooks = self.model_fields['hooks'].default self.hooks = self.model_fields['hooks'].default

View file

@ -1,4 +1,4 @@
__package__ = 'archivebox.auth_plugins.ldap' __package__ = 'archivebox.plugins_auth.ldap'
import inspect import inspect
@ -14,7 +14,7 @@ from plugantic.base_plugin import BasePlugin
from plugantic.base_hook import BaseHook from plugantic.base_hook import BaseHook
from plugantic.base_binary import BaseBinary, BaseBinProvider from plugantic.base_binary import BaseBinary, BaseBinProvider
from pkg_plugins.pip.apps import SYS_PIP_BINPROVIDER, VENV_PIP_BINPROVIDER from plugins_pkg.pip.apps import SYS_PIP_BINPROVIDER, VENV_PIP_BINPROVIDER
from .settings import LDAP_CONFIG, LDAP_LIB from .settings import LDAP_CONFIG, LDAP_LIB

View file

@ -1,4 +1,4 @@
__package__ = 'archivebox.auth_plugins.ldap' __package__ = 'archivebox.plugins_auth.ldap'
import sys import sys

View file

@ -23,8 +23,8 @@ from plugantic.base_binary import BaseBinary, env
from plugantic.base_hook import BaseHook from plugantic.base_hook import BaseHook
# Depends on Other Plugins: # Depends on Other Plugins:
from pkg_plugins.puppeteer.apps import PUPPETEER_BINPROVIDER from plugins_pkg.puppeteer.apps import PUPPETEER_BINPROVIDER
from pkg_plugins.playwright.apps import PLAYWRIGHT_BINPROVIDER from plugins_pkg.playwright.apps import PLAYWRIGHT_BINPROVIDER
CHROMIUM_BINARY_NAMES_LINUX = [ CHROMIUM_BINARY_NAMES_LINUX = [

View file

@ -1,4 +1,4 @@
__package__ = 'archivebox.extractor_plugins.singlefile' __package__ = 'archivebox.plugins_extractor.singlefile'
from pathlib import Path from pathlib import Path
from typing import List, Dict, Optional, ClassVar from typing import List, Dict, Optional, ClassVar
@ -19,8 +19,8 @@ from plugantic.base_queue import BaseQueue
from plugantic.base_hook import BaseHook from plugantic.base_hook import BaseHook
# Depends on Other Plugins: # Depends on Other Plugins:
from sys_plugins.base.apps import ARCHIVING_CONFIG from plugins_sys.base.apps import ARCHIVING_CONFIG
from pkg_plugins.npm.apps import SYS_NPM_BINPROVIDER, LIB_NPM_BINPROVIDER from plugins_pkg.npm.apps import SYS_NPM_BINPROVIDER, LIB_NPM_BINPROVIDER
###################### Config ########################## ###################### Config ##########################

View file

@ -10,7 +10,7 @@ from plugantic.base_configset import BaseConfigSet, ConfigSectionName
from plugantic.base_binary import BaseBinary, env, apt, brew from plugantic.base_binary import BaseBinary, env, apt, brew
from plugantic.base_hook import BaseHook from plugantic.base_hook import BaseHook
from pkg_plugins.pip.apps import pip from plugins_pkg.pip.apps import pip
###################### Config ########################## ###################### Config ##########################

View file

@ -1,4 +1,4 @@
__package__ = 'archivebox.pkg_plugins.npm' __package__ = 'archivebox.plugins_pkg.npm'
from pathlib import Path from pathlib import Path
from typing import List, Optional from typing import List, Optional

View file

@ -27,7 +27,7 @@ from plugantic.base_binary import BaseBinary, BaseBinProvider, env
# from plugantic.base_queue import BaseQueue # from plugantic.base_queue import BaseQueue
from plugantic.base_hook import BaseHook from plugantic.base_hook import BaseHook
from pkg_plugins.pip.apps import SYS_PIP_BINPROVIDER, VENV_PIP_BINPROVIDER, LIB_PIP_BINPROVIDER from plugins_pkg.pip.apps import SYS_PIP_BINPROVIDER, VENV_PIP_BINPROVIDER, LIB_PIP_BINPROVIDER
###################### Config ########################## ###################### Config ##########################

View file

@ -25,7 +25,7 @@ from plugantic.base_binary import BaseBinary, BaseBinProvider, env
from plugantic.base_hook import BaseHook from plugantic.base_hook import BaseHook
# Depends on Other Plugins: # Depends on Other Plugins:
from pkg_plugins.npm.apps import LIB_NPM_BINPROVIDER, SYS_NPM_BINPROVIDER from plugins_pkg.npm.apps import LIB_NPM_BINPROVIDER, SYS_NPM_BINPROVIDER
###################### Config ########################## ###################### Config ##########################