def figures(self): ''' figure ID is just the ID of the component, in case some psycopath decides to put two CVSS diagrams in the same report ''' from writehat.lib.figure import ImageModel figure = ImageModel(caption=self.default_name) figure.id = self.id return [figure]
def figures(self): if self._figure_objects is None: self._figure_objects = [] from writehat.lib.figure import ImageModel log.debug(f'called {self.className}.figures()') # figures from markdown fields come first for field in self._meta.get_fields(): try: if field.markdown is True: data = getattr(self, field.name) for figure_dict in list_figures(data): try: figure = ImageModel.get(id=figure_dict['id']) except ImageModel.DoesNotExist: continue figure.size = figure_dict.get('size', 100) figure.caption = figure_dict.get('caption', '') log.debug(' figure found (within finding): ' + figure.caption) self._figure_objects.append(figure) except AttributeError: continue for figure in self.figures_ending: self._figure_objects.append(figure) for figure in self._figure_objects: figure._finding_object = self return self._figure_objects
def background(self): if self.backgroundImageID: try: return ImageModel.get(id=self.backgroundImageID) except ImageModel.DoesNotExist: pass
def logo(self): if self.logoImageID: try: return ImageModel.get(id=self.logoImageID) except ImageModel.DoesNotExist: pass
def figures(self): ''' Iterate through each markdown field and look for inline figures ''' if self._figure_objects is None: self._figure_objects = [] from writehat.lib.figure import ImageModel for fieldname, data in self: if self.is_markdown(fieldname): for figure_dict in list_figures(data): figure_id = figure_dict['id'] try: figure = ImageModel.get(id=figure_id) except ImageModel.DoesNotExist: log.error( f'Cannot find figure with id {figure_id}') continue figure.size = figure_dict.get('size', 100) figure.caption = figure_dict.get('caption', '') self._figure_objects.append(figure) return self._figure_objects