Skip to content

Commit

Permalink
Merge pull request #1 from PixarAnimationStudios/master
Browse files Browse the repository at this point in the history
Fix for hook manifest issue (AcademySoftwareFoundation#403)
  • Loading branch information
timlehr committed Dec 30, 2018
2 parents 68ab344 + 8dcde4e commit 00b9738
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
5 changes: 3 additions & 2 deletions docs/tutorials/write-a-hookscript.md
Expand Up @@ -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" : []
}
}
```
Expand Down
16 changes: 11 additions & 5 deletions opentimelineio/plugins/manifest.py
Expand Up @@ -89,7 +89,7 @@ def __init__(self):
self.source_files = []

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

adapters = core.serializable_field(
Expand All @@ -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(
Expand All @@ -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):
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 00b9738

Please sign in to comment.