def register_views(self, *views, citations=None): if citations is None: citations = () else: citations = tuple(citations) for view in views: if not isinstance(view, type): raise TypeError("%r should be a class." % view) is_format = False if issubclass(view, FormatBase): is_format = True name = get_view_name(view) if name in self.views: raise NameError("View %r is already registered by this " "plugin." % name) self.views[name] = ViewRecord(name=name, view=view, plugin=self, citations=citations) if is_format: self.formats[name] = FormatRecord(format=view, plugin=self)
def __init__(self, view_type): self._pm = sdk.PluginManager() self._view_type = view_type self._view_name = util.get_view_name(self._view_type) self._record = None if self._view_name in self._pm.views: self._record = self._pm.views[self._view_name]
def register_views(self, *views, citations=None): if citations is None: citations = () else: citations = tuple(citations) for view in views: if not isinstance(view, type): raise TypeError("%r should be a class." % view) is_format = False if issubclass(view, FormatBase): is_format = True name = get_view_name(view) if name in self.views: raise NameError("View %r is already registered by this " "plugin." % name) self.views[name] = ViewRecord( name=name, view=view, plugin=self, citations=citations) if is_format: self.formats[name] = FormatRecord(format=view, plugin=self)