Overview
Comment: | ad PluginMeta dict wrapper for briefer property access |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
9427b32486c0cf73aac38d335664819f |
User & Date: | mario on 2022-10-28 07:06:52 |
Other Links: | manifest | tags |
Context
2022-10-28
| ||
07:07 | argument pylint change check-in: 5c58c55164 user: mario tags: trunk | |
07:06 | ad PluginMeta dict wrapper for briefer property access check-in: 9427b32486 user: mario tags: trunk | |
2022-10-27
| ||
10:43 | pylint fixes, doc additions check-in: a88ee41164 user: mario tags: trunk | |
Changes
Modified pluginconf/__init__.py from [874773144e] to [a475a4da70].
1 2 3 4 5 6 | # encoding: utf-8 # api: python ##type: extract # category: config # title: Plugin configuration # description: Read meta data, pyz/package contents, module locating | | > > > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | # encoding: utf-8 # api: python ##type: extract # category: config # title: Plugin configuration # description: Read meta data, pyz/package contents, module locating # version: 0.7.9 # state: stable # classifiers: documentation # depends: python:pluginconf (>=0.5, <1.0), python >= 2.7 # suggests: python:flit, python:PySimpleGUI # license: PD # priority: core # api-docs: https://fossil.include-once.org/pluginspec/doc/trunk/html/index.html # docs: https://fossil.include-once.org/pluginspec/ # url: http://fossil.include-once.org/streamtuner2/wiki/plugin+meta+data # config: - # format: off # pylint: disable=invalid-name # console-scripts: flit-pluginconf=pluginconf.flit:main, pluginconf.flit=pluginconf.flit:main # # Provides plugin lookup and meta data extraction utility functions. # It's used to abstract module+option management in applications. # For consolidating internal use and external/tool accessibility. # # The key:value format is language-agnostic. It's basically YAML in # a topmost script comment. For Python only # hash comments though. |
︙ | ︙ | |||
65 66 67 68 69 70 71 | # # Generally this scheme concerns itself more with plugin basenames. # That is: module scripts in a package like `ext.plg1` and `ext.plg2`. # It can be initialized by injecting the plugin-package basename into # plugin_base = []. The associated paths will be used for module # lookup via pkgutil.iter_modules(). # | | | | < | | > | 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | # # Generally this scheme concerns itself more with plugin basenames. # That is: module scripts in a package like `ext.plg1` and `ext.plg2`. # It can be initialized by injecting the plugin-package basename into # plugin_base = []. The associated paths will be used for module # lookup via pkgutil.iter_modules(). # # Ideally a designated reference base_module should be extended with # new lookup locations via `module.__path__ += ["./local"]` for exmple. # Plugin loading thus becomes as simple as __import__("ext.local"). # # Using a plugin_state config dictionary in most cases can just list # module basenames, if there's only one namespace to manage. (Plugin # names unique across project.) """ Plugin meta extraction and module lookup""" import sys import os import re |
︙ | ︙ | |||
351 352 353 354 355 356 357 | src, meta["doc"] = src.split("\n\n", 1) # Turn key:value lines into dictionary for field in rx.keyval.findall(src): meta[field[0].replace("-", "_")] = field[1].strip() meta["config"] = plugin_meta_config(meta.get("config") or "") | > > > > > > > > > > > > > > | | 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | src, meta["doc"] = src.split("\n\n", 1) # Turn key:value lines into dictionary for field in rx.keyval.findall(src): meta[field[0].replace("-", "_")] = field[1].strip() meta["config"] = plugin_meta_config(meta.get("config") or "") return PluginMeta(meta) # Dict wrapper # ‾‾‾‾‾‾‾‾‾‾‾‾ class PluginMeta(dict): """ Plugin meta data, convenience dict with property access """ def __getattr__(self, key): """ Return [key] for .property access, else None """ return self.get(key) def __hasattr__(self, key): """ Return [key] for .property access, else None """ return key in self # Unpack config: structures # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ def plugin_meta_config(src): """ Further breaks up the meta['config'] descriptor. |
︙ | ︙ |