Module pluginconf.bind
Basic plugin loader implementation for flat namespaces. Ties together -pluginconf lookups and config management for plugin loading in apps. -It's rather basic, and subject to change. Does impose a config dict -format, but no storage still.
+Basic plugin loader implementation. Plugins are assumed to reside +in a flat namespace (main difference to module imports). This ties +together pluginconf lookups and config management for plugin loading +in apps. It's rather basic, and subject to change. Does impose a +config dict format, but no storage still.
Usage example
# designate a plugins/*.py package as plugin_base
import plugins
import pluginconf.bind
-pluginconf.bind.base(plugins)
+pluginconf.bind.base(__package__) # or "plugins" etc.
# preset core app settings / load from json, add plugin options
-conf = {
- "plugins": {
- }
-}
+conf = {}
pluginconf.bind.defaults(conf)
# load conf-enabled plugins, and register modules somehow
for mod in pluginconf.bind.load_enabled(conf):
mod.init()
@@ -101,10 +99,16 @@
Ideally this module was already imported in main. But parameter may be a string.
This could be invoked multiple times for the package name to append further
path= arguments (=./contrib/, =/usr/share/app/extenstions/, or a .pyz). Which
is functionally identical to declaring __path__
in the package/__init__.py
.
+
+def cache(state=True)
+
+
+Reduce plugin_meta() lookup costs, suitable for repeat find() calls
+
def defaults(conf)
Traverse installed plugins and expand config dict with presets 🧩 🧾
@@ -289,12 +293,13 @@
Functions
-
+
Index: html/css.mako
==================================================================
--- html/css.mako
+++ html/css.mako
@@ -44,12 +44,14 @@
#footer {
font-size: .75em;
padding: 5px 30px;
border-top: 1px solid #ddd;
text-align: right;
-background:rgb(39, 37, 37);
-color: white;
+
+ /* darker grey */
+ background: #272525;
+ color: white;
}
#footer p {
margin: 0 0 0 1em;
display: inline-block;
}
@@ -267,17 +269,19 @@
}
img {
max-width: 100%;
}
+
+ /* table bgs */
td, th {
-padding: 8px 16px;
-align: left;
+ padding: 8px 16px;
+ align: left;
}
-table tr:nth-child(2n) td, table tr th {
-background: #f0f0ff;
-}
+ table tr:nth-child(2n) td, table tr th {
+ background: #f0f0ff;
+ }
.admonition {
padding: .1em .5em;
margin-bottom: 1em;
}
@@ -313,31 +317,37 @@
width: 25%;
height: 100vh;
overflow: auto;
position: sticky;
top: 0;
-background: #404040;
-background: linear-gradient(#2980B9 0px, #2980B9 120px, #333 125px, #404040 100%);
-color: #ddd;
- }
-#sidebar a {
- color: #bbbbbb;
- transition: color .3s ease-in-out;
-}
-#sidebar a:hover {
- color: #f93;
-}
-#sidebar li li:hover {
- background: #444;
-}
-#sidebar h1 {
-color: white;
-padding-bottom: 10px;
-}
-#sidebar hr {
-color: black;
-}
+
+ /* lighter grey */
+ background: #404040;
+ background: linear-gradient(#2980B9 0px, #2980B9 120px, #333 125px, #404040 100%);
+ color: #ddd;
+ font-size: 1em;
+ }
+
+ /* light links */
+ #sidebar a {
+ color: #bbbbbb;
+ transition: color .3s ease-in-out;
+ }
+ #sidebar a:hover {
+ color: #f93;
+ }
+ #sidebar li li:hover {
+ background: #444;
+ }
+ #sidebar h1 {
+ color: white;
+ padding-bottom: 10px;
+ }
+ #sidebar hr {
+ color: black;
+ }
+
#content {
width: 70%;
max-width: 100ch;
padding: 3em 4em;
border-left: 1px solid #ddd;
@@ -353,11 +363,11 @@
flex-direction: row-reverse;
justify-content: flex-end;
}
.toc ul ul,
#index ul {
- padding-left: 1.5em;
+ padding-left: 0.5em;
}
.toc > ul > li {
margin-top: .5em;
}
}
Index: html/depends.html
==================================================================
--- html/depends.html
+++ html/depends.html
@@ -7,12 +7,12 @@
pluginconf.depends API documentation
-
-
+
+
Index: html/flit.html
==================================================================
--- html/flit.html
+++ html/flit.html
@@ -3,17 +3,16 @@
pluginconf.flit API documentation
-
+
-
-
+
+
@@ -21,12 +20,11 @@
Module pluginconf.flit
-monkeypatches flit to use pluginconf sources for packaging with a
-pyproject.toml
like:
+Hijacks flit to use pluginconf sources. (It's a hack, but builds work.)
pyproject.toml
foobar/__init__.py
[build-system]
Index: html/gui.html
==================================================================
--- html/gui.html
+++ html/gui.html
@@ -7,12 +7,12 @@
pluginconf.gui API documentation
-
-
+
+
Index: html/index.html
==================================================================
--- html/index.html
+++ html/index.html
@@ -7,12 +7,12 @@
pluginconf API documentation
-
-
+
+
@@ -38,30 +38,35 @@
Sub-modules
pluginconf.bind
-
-
Basic plugin loader implementation for flat namespaces. Ties together
-pluginconf lookups and config management for plugin loading in apps.
-It's rather …
+Basic plugin loader implementation. Plugins are assumed to reside
+in a flat namespace (main difference to module imports). This ties
+together …
pluginconf.depends
-
Dependency validation and consistency checker for updates
pluginconf.flit
-
-
monkeypatches flit to use pluginconf sources for packaging with a
-pyproject.toml
like: …
+Hijacks flit to use pluginconf sources. (It's a hack, but builds work.) …
pluginconf.gui
-
PySimpleGUI window to populate config dict via plugin options …
pluginconf.setup
-
Expands setuptools.setup() with automatic package description lookup
+
+pluginconf.store
+-
+
Implements a rudimentary JSON config store, and convenient dict with
+.property access (PluginMeta
). Though you might simply
+use the …
Global variables
@@ -152,11 +157,11 @@
-def get_data(filename, decode=False, gzip=False, file_root=None)
+def get_data(filename, decode=False, gzip=False, file_root=None, warn=True)
Fetches file content from install path or from within PYZ
archive. This is just an alias and convenience wrapper for
pkgutil.get_data().
@@ -232,11 +237,11 @@
Extract plugin meta data block from specified source.
-Parameters
+
@@ -269,11 +274,11 @@
max_length
list
Maximum size to read from files (6K default).
-Returns
+🔙
dict
Extracted comment fields, with config: preparsed
@@ -308,10 +313,14 @@
Absent .field
access resolves to ""
.
Ancestors
- builtins.dict
+Subclasses
+
+- ConfStore
+