Last active
December 14, 2015 02:09
-
-
Save mikew/5011984 to your computer and use it in GitHub Desktop.
How to get Log, Dict, XML, et al from Plex plugin __init__.py to Shared/Libraries
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Contents/Code/__init__.py | |
| import bridge | |
| import library | |
| to_export = dict(Log = Log, Dict = Dict) | |
| bridge.init(**to_export) | |
| def Start(): | |
| library.test() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Contents/Libraries/Shared/bridge.py | |
| config = dict() | |
| def init(**kwargs): | |
| global config | |
| for key, value in kwargs.iteritems(): | |
| if key in config: continue | |
| config[key] = value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Contents/Libraries/Shared/library.py | |
| import bridge | |
| def test(): | |
| # this will log to com.plexapp.plugin.foo.log | |
| bridge.config['Dict']['foo'] = 'bar' | |
| bridge.config['Log']('Dict[foo] is %s' % config['Dict']['foo']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment