Check-in [7127c48419]
Overview
Comment: | Removed module_list() ordering, which is now handled by uikit.appstate. Documented plugin_meta() options, split out plugin_meta_extract() code. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
7127c4841975c0a1fe79d035a00ea294 |
User & Date: | mario on 2015-04-04 01:45:33 |
Other Links: | manifest | tags |
Context
2015-04-04
| ||
01:46 | Removed duplicate category entries for internet_radio plugin. check-in: 3d794f312d user: mario tags: trunk | |
01:45 | Removed module_list() ordering, which is now handled by uikit.appstate. Documented plugin_meta() options, split out plugin_meta_extract() code. check-in: 7127c48419 user: mario tags: trunk | |
01:44 | Removed remains of [stop] button handling. Fixed url param in homepage channel callback. check-in: 5692e6ae5d user: mario tags: trunk | |
Changes
Modified config.py from [81150f5776] to [f0017cbe55].
︙ | ︙ | |||
289 290 291 292 293 294 295 | else: return str(bin) except: pass # Search through ./channels/ and get module basenames. | | | < < < < < < > | > > > | > > > > > | > > > > > > | > | | | | | | > > | < | | | 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 | else: return str(bin) except: pass # Search through ./channels/ and get module basenames. # (Reordering channel tabs is now done by uikit.apply_state.) # def module_list(): # Should list plugins within zips as well as local paths ls = pkgutil.iter_modules([conf.share+"/channels", "channels"]) return [name for loader,name,ispkg in ls] # Plugin meta data extraction # # Extremely crude version for Python and streamtuner2 plugin usage. # But can fetch from different sources: # ยท fn= to read from literal files, out of a .pyzip package # ยท src= to extract from pre-read script code # ยท module= utilizes pkgutil to read # ยท frame= automatically extract comment header from caller # def plugin_meta(fn=None, src=None, module=None, frame=1): # try via pkgutil first if module: fn = module src = pkgutil.get_data("channels", fn+".py") # get source directly from caller elif not src and not fn: module = inspect.getmodule(sys._getframe(frame)) fn = inspect.getsourcefile(module) src = inspect.getcomments(module) # within zip archive or dir? elif fn: zip = rx.zipfn.match(fn) if zip and zipfile.is_zipfile(zip.group(1)): src = zipfile.ZipFile(zip.group(1), "r").read(zip.group(2)) else: src = open(fn).read(4096) return plugin_meta_extract(src, fn) # Actual comment extraction logic def plugin_meta_extract(src="", fn="", literal=False): # defaults meta = { "id": os.path.basename(fn or "").split(".")[0], "fn": fn, "title": fn, "description": "no description", "config": [], "type": "module", "api": "python", "doc": "" } # extract coherent comment block, split doc section if not literal: src = rx.comment.search(src) if not src: __print__(dbg.ERR, "Couldn't read source meta information", fn) return meta src = src.group(0) src = rx.hash.sub("", src).strip() # split comment block if src.find("\n\n") > 0: src, meta["doc"] = src.split("\n\n", 1) # key:value fields into dict for field in rx.keyval.findall(src): meta[field[0]] = field[1].strip() meta["config"] = plugin_meta_config(meta.get("config") or "") return meta # Unpack config: structures def plugin_meta_config(str): config = [] for entry in rx.config.findall(str): opt = { "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) |
︙ | ︙ |