Browse files

Adding metadata plug-in

  • Loading branch information...
mottosso committed Oct 3, 2014
1 parent 138eb7a commit 076c50ee98fc147e23cdaac4a0c2743cdbafbd81
Showing with 77 additions and 0 deletions.
  1. +11 −0 napoleon/
  2. +66 −0 napoleon/plugins/
@@ -0,0 +1,11 @@
"""Wrap Open Metadata"""
import logging
import openmetadata
log = logging.getLogger('openmetadata')
write = lambda path, key, value: openmetadata.write(path, key, value)
read = lambda path, key:, key)
@@ -0,0 +1,66 @@
import os
import pyblish.api
import napoleon.plugin
import napoleon.metadata
class ExtractNapoleonMetadata(napoleon.plugin.Extractor):
"""Extract all available metadata about each instance"""
families = ["*"]
hosts = ['maya']
version = (0, 1, 0)
# Ignored
blacklist = ['commit_dir',
def process_instance(self, instance):
commit_dir ='commit_dir')
if not commit_dir:
commit_dir = self.compute_commit_directory(instance)
if not os.path.exists(commit_dir):
data =
for key, value in
data['context/' + key] = value
self.write(commit_dir, data)
def write(self, path, data, prefix=''):
"""Write data, ignoring errors"""
for key, value in data.iteritems():
if key.startswith("__") or key in self.blacklist:
try:"Extracting \"%s\"" % key)
key=prefix + key,
except Exception:
self.log.debug("Could not extract: %s" % key)
def parse_description(self, data):
"""Look for `notesAsDescription` flag and use notes when appropriate"""
notes_as_description = data.pop('notesAsDescription', False)
notes = data.pop('notes', None)
if notes and notes_as_description:
data['description'] = notes
def parse_source(self, data):
"""Treat `current_file` as source for instance"""
source = data.pop('context/current_file', None)
data['source'] = source

0 comments on commit 076c50e

Please sign in to comment.