Overview
Comment: | doc additions, add params for setup and gui, fix flit sample |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
93aac201515248d5ceb9bdf723aff53c |
User & Date: | mario on 2022-10-31 12:56:46 |
Other Links: | manifest | tags |
Context
2022-10-31
| ||
18:56 | add pacakge disovery, and additional comment styles (different languages) check-in: f03780244f user: mario tags: trunk | |
12:56 | doc additions, add params for setup and gui, fix flit sample check-in: 93aac20151 user: mario tags: trunk | |
06:12 | updated template to mimick RTD theme (barely) check-in: e12fd2f3f3 user: mario tags: trunk | |
Changes
Modified html/depends.html from [ee1c309587] to [8dad0b793d].
︙ | |||
46 47 48 49 50 51 52 | 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | + + + - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + + + + + + + + + + + | helper might want to auto-tick them on, etc. This example is just meant for probing downloadable plugins.</p> <p>The .valid() helper only asserts the api: string, or skips existing modules, and if they're more recent. While .depends() compares minimum versions against existing modules.</p> <p>In practice there's little need for full-blown dependency resolving for application-level modules.</p> <table> <thead> <tr> |
︙ | |||
97 98 99 100 101 102 103 | 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | - + + + + + + + + + + + + + + + + + + + + + + | <dd> <div class="desc"><p>Single comparison</p></div> </dd> <dt id="pluginconf.depends.Check.depends"><code class="name flex"> <span>def <span class="ident">depends</span></span>(<span>self, plugin)</span> </code></dt> <dd> |
︙ | |||
125 126 127 128 129 130 131 | 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | - + + + + + + + + + + + + + + + + + + + + + + | </dd> <dt id="pluginconf.depends.Check.valid"><code class="name flex"> <span>def <span class="ident">valid</span></span>(<span>self, new_plugin)</span> </code></dt> <dd> <div class="desc"><p>Plugin pre-screening from online repository stream. Fields are $name, $file, $dist, api, id, depends, etc |
︙ |
Modified html/flit.html from [560905addb] to [f4ec8aad3f].
︙ | |||
26 27 28 29 30 31 32 | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | - + | <p>monkeypatches flit to use pluginconf sources for packaging with a <code>pyproject.toml</code> like:</p> <table> <tr><th>pyproject.toml</th> <th>foobar/__init__.py</th></tr> <tr><td><code><pre> [build-system] |
︙ |
Modified html/gui.html from [bd7e7636e7] to [8c9d3bdc20].
︙ | |||
44 45 46 47 48 49 50 | 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | - + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | <dd> <div class="desc"><p>checkbox for plugin name</p></div> </dd> <dt id="pluginconf.gui.plugin_layout"><code class="name flex"> <span>def <span class="ident">plugin_layout</span></span>(<span>pmd_list, config, plugin_states, opt_label=False)</span> </code></dt> <dd> |
︙ |
Modified html/index.html from [62873924d5] to [bd45e395b2].
︙ | |||
86 87 88 89 90 91 92 | 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | - - + + - - + - + | <section> <h2 class="section-title" id="header-functions">Functions</h2> <dl> <dt id="pluginconf.add_plugin_defaults"><code class="name flex"> <span>def <span class="ident">add_plugin_defaults</span></span>(<span>conf_options, conf_plugins, meta, module='')</span> </code></dt> <dd> |
︙ | |||
145 146 147 148 149 150 151 | 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | - + | <th></th> </tr> </thead> <tbody> <tr> <td><strong>Returns</strong></td> <td>dict</td> |
︙ |
Modified html/setup.html from [6a9e752056] to [e6c6068172].
︙ | |||
45 46 47 48 49 50 51 | 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | + + + - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + | </dd> <dt id="pluginconf.setup.setup"><code class="name flex"> <span>def <span class="ident">setup</span></span>(<span>filename=None, debug=False, **kwargs)</span> </code></dt> <dd> <div class="desc"><p>Wrapper around <code>setuptools.setup()</code> which adds some defaults and plugin meta data import, with some shortcut parameters:</p> <table> <thead> <tr> |
︙ |
Modified pluginconf/__init__.py from [66c11c0c8c] to [5e7e9e9afe].
︙ | |||
9 10 11 12 13 14 15 | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | - + | # classifiers: documentation # depends: 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/ |
︙ | |||
250 251 252 253 254 255 256 | 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | - + | """ This is a trivial wrapper to assemble a complete dictionary of available/installed plugins. It associates each plugin name with a its meta{} fields. | Parameters | | | |-------------|---------|---------------------------------| |
︙ | |||
555 556 557 558 559 560 561 | 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 | - - + + - - - + + | return {k: w for k, w in kwargs.items() if w is not None} # Add plugin defaults to conf.* store # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ def add_plugin_defaults(conf_options, conf_plugins, meta, module=""): """ |
︙ |
Modified pluginconf/bind.py from [ce733ed382] to [fcff8bd0e5].
1 2 3 4 5 6 7 8 9 10 11 | 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 | - + - + | # encoding: utf-8 # api: pluginconf ##type: loader # title: plugin loader # description: implements a trivial unified namespace importer # version: 0.1 # state: alpha # priority: optional # # Most basic plugin management/loader. It unifies meta data retrieval # and instantiation. It still doesn't dictate a plugin API or config |
︙ | |||
37 38 39 40 41 42 43 | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | - + + + - + - - - - + + + + + + + + + + + + + + + + + | # pluginconf.bind.defaults(conf) # # Instantiate plugin modules based on load conf[plugins] state: # # for module in pluginconf.bind.load_enabled(conf): # module.register(main_window) # |
︙ | |||
93 94 95 96 97 98 99 | 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | - + + | mod.init() ### Find by type for name, pmd in pluginconf.bind.find(type="effect").items(): mod = pluginconf.bind.load(name) if pmd.category == "menu": |
︙ | |||
148 149 150 151 152 153 154 | 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | - + | |-------------|------------|-------------------------------| | module | module/str | Package basename to later load plugins from | | path | str | Bind directory or pyz/zip bundle to plugin_base. | | **Returns** | None | - | Module should be a package, as in a directory and init `plugins/__init__.py`. Ideally this module was already imported in main. But parameter may be a string. |
︙ | |||
276 277 278 279 280 281 282 283 284 285 | 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 | + + + + + + + + + + + + + + | @staticmethod def defaults(): """ *return* defaults for isolated plugin structure 🧩 🧾 """ conf = {"plugins": {}} defaults(conf) return conf def _enable_cache(state=True): """ Reduce plugin_meta() lookup costs, suitable for repeat find() calls """ if hasattr(pluginconf.plugin_meta, "__wrapped__"): if state: return pluginconf.plugin_meta = pluginconf.plugin_meta.__wrapped__ elif state: decorator = functools.lru_cache(maxsize=None) pluginconf.plugin_meta = decorator(pluginconf.plugin_meta) def _dirname(file): """ absolute dirname for file """ return os.path.dirname(os.path.realpath(file)) |
Modified pluginconf/depends.py from [f7f101f5bf] to [b7808bf08a].
︙ | |||
56 57 58 59 60 61 62 | 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | - - + + - - + - - + + - - + - - + + - - + - - - + | The .valid() helper only asserts the api: string, or skips existing modules, and if they're more recent. While .depends() compares minimum versions against existing modules. In practice there's little need for full-blown dependency resolving for application-level modules. |
︙ | |||
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | + + + + + + - + + + + + + + | self.have[alias] = self.have[name] def valid(self, new_plugin): """ Plugin pre-screening from online repository stream. Fields are $name, $file, $dist, api, id, depends, etc Exclude installed or for newer-version presence. | Parameters | | | |-------------|---------|------------------------------------------------------| | new_plugin | dict | online properties of available plugin | | **Returns** | bool | is updatatable | """ if not "$name" in new_plugin: self.log.warning(".valid() checks online plugin lists, requires $name") name = new_plugin.get("$name", "__invalid") have_ver = self.have.get(name, {}).get("version", "0") if name.find("__") == 0: self.log.debug("wrong/no id") elif new_plugin.get("api") not in self.api: self.log.debug("not in allowed APIs") elif {new_plugin.get("status"), new_plugin.get("priority")} & {"obsolete", "broken"}: self.log.debug("wrong status (obsolete/broken)") elif have_ver >= new_plugin.get("version", "0.0"): self.log.debug("newer version already installed") else: return True return False def depends(self, plugin): """ |
︙ |
Modified pluginconf/flit.py from [4725663a44] to [7e6be741f0].
︙ | |||
33 34 35 36 37 38 39 | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | - + | `pyproject.toml` like: <table> <tr><th>pyproject.toml</th> <th>foobar/__init__.py</th></tr> <tr><td><code><pre> [build-system] |
︙ |
Modified pluginconf/gui.py from [fd35fa0517] to [579f93bf8f].
︙ | |||
48 49 50 51 52 53 54 | 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | - - + + - - + - - + - - + - - + - - + - - + - - - + + - - - | Reads *.py files and crafts a settings dialog from meta data. Where `plugin_states{}` is usually an entry in `config{}` itself. Depending on plugin and option names, it might even be a flat/shared namespace for both. Per default you'd set `files=["plugins/*.py", __file__]` to be read. But with `files=[]` it's possible to provide a `plugins=pluginconf.get_plugin_meta()` or prepared plugin/options dict instead. |
︙ | |||
110 111 112 113 114 115 116 | 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | - + | if plugins.get(key): plugin_states[key] = val return True #print(config, plugin_states) def plugin_layout(pmd_list, config, plugin_states, opt_label=False): |
︙ |
Modified pluginconf/setup.py from [a5d9b67dec] to [69618d8a4a].
︙ | |||
199 200 201 202 203 204 205 | 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | - - + + - - + - - + - - + | @pluginconf.renamed_arguments({"fn": "filename"}) def setup(filename=None, debug=False, **kwargs): """ Wrapper around `setuptools.setup()` which adds some defaults and plugin meta data import, with some shortcut parameters: |
︙ |