Permalink
Browse files

Fix for hook manifest issue (#403)

* Fix: wrong type for "hooks"
* Fix: _json_path is not set for hook_scripts
* Fix: manifest extend() does not include hooks / hook_scripts
* Fix: added missing hook to tutorial sample code
  • Loading branch information...
timlehr authored and ssteinbach committed Dec 19, 2018
1 parent 68ab344 commit 8dcde4e37dd6fdaf9bb3e27878c056b5653041e9
Showing with 14 additions and 7 deletions.
  1. +3 −2 docs/tutorials/write-a-hookscript.md
  2. +11 −5 opentimelineio/plugins/manifest.py
@@ -33,12 +33,13 @@ To create a new OTIO hook script, you need to create a file myhooks.py. Then add
"OTIO_SCHEMA" : "HookScript.1",
"name" : "example hook",
"execution_scope" : "in process",
"filepath" : "example.py"
"filepath" : "myhooks.py"
}
],
"hooks" : {
"pre_adapter_write" : ["example hook"],
"post_adapter_read" : []
"post_adapter_read" : [],
"post_media_linker" : []
}
}
```
@@ -89,7 +89,7 @@ def __init__(self):
self.source_files = []

# hook system stuff
self.hooks = []
self.hooks = {}
self.hook_scripts = []

adapters = core.serializable_field(
@@ -109,7 +109,7 @@ def __init__(self):
)
hooks = core.serializable_field(
"hooks",
type([]),
type({}),
"Hooks that hooks scripts can be attached to."
)
hook_scripts = core.serializable_field(
@@ -127,11 +127,17 @@ def extend(self, another_manifest):
self.adapters.extend(another_manifest.adapters)
self.schemadefs.extend(another_manifest.schemadefs)
self.media_linkers.extend(another_manifest.media_linkers)
self.hook_scripts.extend(another_manifest.hook_scripts)

for trigger_name, hooks in another_manifest.hooks.items():
if trigger_name in self.hooks:
self.hooks[trigger_name].extend(hooks)

def _update_plugin_source(self, path):
"""Track the source .json for a given adapter."""

for thing in (self.adapters + self.schemadefs + self.media_linkers):
for thing in (self.adapters + self.schemadefs
+ self.media_linkers + self.hook_scripts):
thing._json_path = path

def from_filepath(self, suffix):
@@ -217,8 +223,8 @@ def load_manifest():
plugin_manifest = plugin_entry_point.plugin_manifest()
except AttributeError:
if not pkg_resources.resource_exists(
plugin.module_name,
'plugin_manifest.json'
plugin.module_name,
'plugin_manifest.json'
):
raise
manifest_stream = pkg_resources.resource_stream(

0 comments on commit 8dcde4e

Please sign in to comment.