arelle.PluginManager

See COPYRIGHT.md for copyright information.

based on pull request 4

Module Contents

Classes

Functions

init

reset

orderedPluginConfig

save

close

logPluginTrace

If plugin trace file logging is configured, logs message to it. Only logs to controller logger if log is an error.

modulesWithNewerFileDates

freshenModuleInfos

normalizeModuleFilename

Attempts to find python script as plugin entry point. A value will be returned if moduleFilename exists as-is, if moduleFilename is a directory containing init.py, or if moduleFilename with .py extension added exists

getModuleFilename

parsePluginInfo

moduleModuleInfo

Generates a module info dict based on the provided moduleURL or entryPoint Exactly one of “moduleURL” or “entryPoint” must be provided, otherwise a RuntimeError will be thrown.

moduleInfo

_get_name_dir_prefix

Get the name, directory and prefix of a module.

_get_location

Get the file name of a plugin.

_find_and_load_module

Load a module based on name and directory.

loadModule

pluginClassMethods

addPluginModule

Discover plugin entry points with given name.

reloadPluginModule

removePluginModule

addPluginModuleInfo

Given a dictionary containing module information, loads plugin info into pluginConfig

Data

API

arelle.PluginManager.PLUGIN_TRACE_FILE

None

arelle.PluginManager.PLUGIN_TRACE_LEVEL

None

arelle.PluginManager.pluginJsonFile

None

arelle.PluginManager.pluginConfig: dict | None

None

arelle.PluginManager.pluginConfigChanged

False

arelle.PluginManager.pluginTraceFileLogger

None

arelle.PluginManager.modulePluginInfos

None

arelle.PluginManager.pluginMethodsForClasses

None

arelle.PluginManager._cntlr

None

arelle.PluginManager._pluginBase

None

arelle.PluginManager.EMPTYLIST

[]

arelle.PluginManager._ERROR_MESSAGE_IMPORT_TEMPLATE

‘Unable to load module {}’

arelle.PluginManager.init(cntlr: arelle.Cntlr.Cntlr, loadPluginConfig: bool = True) None
arelle.PluginManager.reset() None
arelle.PluginManager.orderedPluginConfig()
arelle.PluginManager.save(cntlr: arelle.Cntlr.Cntlr) None
arelle.PluginManager.close()
arelle.PluginManager.logPluginTrace(message: str, level: Number) None

If plugin trace file logging is configured, logs message to it. Only logs to controller logger if log is an error.

Parameters:
  • message – Message to be logged

  • level – Log level of message (e.g. logging.INFO)

arelle.PluginManager.modulesWithNewerFileDates()
arelle.PluginManager.freshenModuleInfos()
arelle.PluginManager.normalizeModuleFilename(moduleFilename: str) str | None

Attempts to find python script as plugin entry point. A value will be returned if moduleFilename exists as-is, if moduleFilename is a directory containing init.py, or if moduleFilename with .py extension added exists

Parameters:

moduleFilename

Returns:

Normalized filename, if exists

arelle.PluginManager.getModuleFilename(moduleURL: str, reload: bool, normalize: bool, base: str | None) tuple[str | None, importlib.metadata.EntryPoint | None]
arelle.PluginManager.parsePluginInfo(moduleURL: str, moduleFilename: str, entryPoint: importlib.metadata.EntryPoint | None) dict | None
arelle.PluginManager.moduleModuleInfo(moduleURL: str | None = None, entryPoint: importlib.metadata.EntryPoint | None = None, reload: bool = False, parentImportsSubtree: bool = False) dict | None

Generates a module info dict based on the provided moduleURL or entryPoint Exactly one of “moduleURL” or “entryPoint” must be provided, otherwise a RuntimeError will be thrown.

When moduleURL is provided, it will be treated as a file path and will attempt to be normalized and mapped to an existing plugin based on file location. If moduleURL fails to be mapped to an existing plugin on its own, it will instead be used to search for an entry point. If found, this function will proceed as if that entry point was provided for entryPoint.

When entryPoint is provided, it’s location and other details will be used to generate the module info dictionary.

Parameters:
  • moduleURL – A URL that loosely maps to the file location of a plugin (may be transformed)

  • entryPoint – An EntryPoint instance

  • reload

  • parentImportsSubtree

Returns:

s

arelle.PluginManager.moduleInfo(pluginInfo)
arelle.PluginManager._get_name_dir_prefix(controller: arelle.Cntlr.Cntlr, pluginBase: str, moduleURL: str, packagePrefix: str = '') tuple[str, str, str] | tuple[None, None, None]

Get the name, directory and prefix of a module.

arelle.PluginManager._get_location(moduleDir: str, moduleName: str) str

Get the file name of a plugin.

arelle.PluginManager._find_and_load_module(moduleDir: str, moduleName: str) types.ModuleType | None

Load a module based on name and directory.

arelle.PluginManager.loadModule(moduleInfo: dict[str, Any], packagePrefix: str = '') None
arelle.PluginManager.pluginClassMethods(className: str) Iterator[collections.abc.Callable[..., Any]]
arelle.PluginManager.addPluginModule(name: str) dict[str, Any] | None

Discover plugin entry points with given name.

Parameters:

name – The name to search for

Returns:

The module information dictionary, if added. Otherwise, None.

arelle.PluginManager.reloadPluginModule(name)
arelle.PluginManager.removePluginModule(name)
arelle.PluginManager.addPluginModuleInfo(plugin_module_info: dict[str, Any]) dict[str, Any] | None

Given a dictionary containing module information, loads plugin info into pluginConfig

Parameters:

plugin_module_info – Dictionary of module info fields. See comment block in PluginManager.py for structure.

Returns:

The module information dictionary, if added. Otherwise, None.

arelle.PluginManager._entryPointRefCache: list[arelle.PluginManager.EntryPointRef] | None

None

arelle.PluginManager._entryPointRefAliasCache: dict[str, list[arelle.PluginManager.EntryPointRef]] | None

None

arelle.PluginManager._entryPointRefSearchTermEndings

[‘/init.py’, ‘.py/’]

class arelle.PluginManager.EntryPointRef
aliases: set[str]

None

entryPoint: importlib.metadata.EntryPoint | None

None

moduleFilename: str | None

None

moduleInfo: dict | None

None

createModuleInfo() dict | None

Creates a module information dictionary from the entry point ref.

Returns:

A module inforomation dictionary

static fromEntryPoint(entryPoint: importlib.metadata.EntryPoint) arelle.PluginManager.EntryPointRef | None

Given an entry point, retrieves the subset of information from pluginInfo necessary to determine if the entry point should be imported as a plugin.

Parameters:

entryPoint

Returns:

static fromFilepath(filepath: str, entryPoint: importlib.metadata.EntryPoint | None = None) arelle.PluginManager.EntryPointRef | None

Given a filepath, retrieves a subset of information from pluginInfo necessary to determine if the entry point should be imported as a plugin.

Parameters:
  • filepath – Path to plugin, can be a directory or .py filepath

  • entryPoint – Optional entry point information to include in aliases/moduleInfo

Returns:

static discoverAll() list[arelle.PluginManager.EntryPointRef]

Retrieve all plugin entry points, cached on first run.

Returns:

List of all discovered entry points.

static _discoverBuiltIn(entryPointRefs: list[arelle.PluginManager.EntryPointRef], directory: str) list[arelle.PluginManager.EntryPointRef]

Recursively retrieve all plugin entry points in the given directory.

Parameters:
  • entryPointRefs – Working list of entry point refs to append to.

  • directory – Directory to search for entry points within.

Returns:

List of discovered entry points.

static _discoverInstalled() list[arelle.PluginManager.EntryPointRef]

Retrieve all installed plugin entry points.

Returns:

List of all discovered entry points.

static get(search: str) arelle.PluginManager.EntryPointRef | None

Retrieve an entry point ref with a matching name or alias. May return None of no matches are found. Throws an exception if multiple entry point refs match the search term.

Parameters:

search – Only retrieve entry point matching the given search text.

Returns:

Matching entry point ref, if found.

static _normalizePluginSearchTerm(search: str) str

Normalizes the given search term or searchable text by: Making slashes consistent Removing common endings

Parameters:

search – Search term or searchable text

Returns:

Normalized string

static search(search: str) list[arelle.PluginManager.EntryPointRef] | None

Retrieve entry point module information matching provided search text. A map of aliases to matching entry points is cached on the first run.

Parameters:

search – Only retrieve entry points matching the given search text.

Returns:

List of matching module infos.