Beispiel #1
0
 def object_extend(self,
                   obj: Note,
                   args: Dict,
                   locale: GrampsLocale = glocale) -> Note:
     """Extend note attributes as needed."""
     if "formats" in args:
         formats_allowed = [
             fmt.lower() for fmt in args["formats"]
             if fmt.lower() in set(self.FORMATS_SUPPORTED)
         ]
         if args.get("format_options"):
             try:
                 format_options = json.loads(args["format_options"])
             except json.JSONDecodeError:
                 abort(400)
         else:
             format_options = None
         obj.formatted = {
             fmt: self.get_formatted_note(note=obj,
                                          fmt=fmt,
                                          options=format_options)
             for fmt in formats_allowed
         }
     if "extend" in args:
         obj.extended = get_extended_attributes(self.db_handle, obj, args)
     return obj