+ def add_jsonld_namespaces(self, context):
+ '''Add shortcut namespaces to a context
+
+ Only needs to be run on the top-most context
+ '''
+ context.update(ENCODED_NAMESPACES)
+
+ def create_jsonld_context(self, obj, default_base):
+ '''Synthesize the context for a encoded type
+
+ self.contexts[None] = default context attributes added to any type
+ self.contexts[type] = context attributes for this type.
+ '''
+ context = {'@base': urljoin(default_base, obj['@id']),
+ '@vocab': self.get_schema_url(obj)}
+ # add in defaults
+ context.update(self.contexts[None])
+ for t in obj['@type']:
+ if t in self.contexts:
+ context.update(self.contexts[t])
+ return context
+