Index: pluginconf.py ================================================================== --- pluginconf.py +++ pluginconf.py @@ -1,14 +1,15 @@ # encoding: UTF-8 # api: python -# type: handler +# type: extract # category: io # title: Plugin configuration # description: Read meta data, pyz/package contents, module locating -# version: 0.6.9 +# version: 0.7.0 # priority: core -# docs: http://fossil.include-once.org/streamtuner2/wiki/plugin+meta+data +# 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. @@ -80,15 +81,27 @@ import sys import os import re import pkgutil import inspect -from compat2and3 import find_executable try: - from compat2and3 import gzip_decode + 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", @@ -224,11 +237,11 @@ # def plugin_meta_extract(src="", fn=None, literal=False): # Defaults meta = { - "id": os.path.splitext(os.path.basename(fn or "")), + "id": os.path.splitext(os.path.basename(fn or ""))[0], "fn": fn, "api": "python", "type": "module", "category": None, "priority": None, @@ -282,10 +295,11 @@ "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