1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 | # encoding: UTF-8
# api: python
# type: handler
# category: io
# title: Plugin configuration
# description: Read meta data, pyz/package contents, module locating
# version: 0.6.9
# priority: core
# docs: http://fossil.include-once.org/streamtuner2/wiki/plugin+meta+data
# config: -
#
# 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 |
|
|
>
|
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 | # encoding: UTF-8
# api: python
# type: extract
# category: io
# title: Plugin configuration
# description: Read meta data, pyz/package contents, module locating
# version: 0.7.0
# priority: core
# docs: https://fossil.include-once.org/pluginspec/
# url: http://fossil.include-once.org/streamtuner2/wiki/plugin+meta+data
# config: -
#
# 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 |
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96 |
import sys
import os
import re
import pkgutil
import inspect
from compat2and3 import find_executable
try:
from compat2and3 import gzip_decode
except:
from gzip import decompress as gzip_decode # Py3 only
import zipfile
import argparse
__all__ = [
"get_data", "module_list", "plugin_meta",
"dependency", "add_plugin_defaults"
] |
>
>
>
>
|
>
>
>
>
>
>
|
|
|
>
>
| 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 |
import sys
import os
import re
import pkgutil
import inspect
try:
from distutils.spawn import find_executable
except:
try:
from compat2and3 import find_executable
except:
def find_executable(str):
pass
try:
from gzip import decompress as gzip_decode # Py3 only
except:
try:
from compat2and3 import gzip_decode # st2 stub
except:
def gzip_decode(bytes):
import zlib
return zlib.decompress(bytes, 16 + zlib.MAX_WBITS) # not fully compatible
import zipfile
import argparse
__all__ = [
"get_data", "module_list", "plugin_meta",
"dependency", "add_plugin_defaults"
] |
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236 | # fields from comment. Turns everything into an dict, with
# some stub fields if absent.
#
def plugin_meta_extract(src="", fn=None, literal=False):
# Defaults
meta = {
"id": os.path.splitext(os.path.basename(fn or "")),
"fn": fn,
"api": "python",
"type": "module",
"category": None,
"priority": None,
"version": "0",
"title": fn, |
|
| 235
236
237
238
239
240
241
242
243
244
245
246
247
248
249 | # fields from comment. Turns everything into an dict, with
# some stub fields if absent.
#
def plugin_meta_extract(src="", fn=None, literal=False):
# Defaults
meta = {
"id": os.path.splitext(os.path.basename(fn or ""))[0],
"fn": fn,
"api": "python",
"type": "module",
"category": None,
"priority": None,
"version": "0",
"title": fn, |
280
281
282
283
284
285
286
287
288
289
290
291
292
293 | "type": None,
"name": None,
"description": "",
"value": None
}
for field in rx.options.findall(entry):
opt[field[0]] = (field[1] or field[2] or field[3] or "").strip()
config.append(opt)
return config
# Comment extraction regexps
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
# Pretty crude comment splitting approach. But works |
>
| 293
294
295
296
297
298
299
300
301
302
303
304
305
306
307 | "type": None,
"name": None,
"description": "",
"value": None
}
for field in rx.options.findall(entry):
opt[field[0]] = (field[1] or field[2] or field[3] or "").strip()
#@todo map type:
config.append(opt)
return config
# Comment extraction regexps
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
# Pretty crude comment splitting approach. But works |