Exemple #1
0
 def load_book_annotations(self, calibre_book_data=None):
     amap = self.current_book_data['annotations_map']
     path = os.path.join(self.current_book_data['base'], 'calibre-book-annotations.json')
     if os.path.exists(path):
         with open(path, 'rb') as f:
             raw = f.read()
         merge_annotations(parse_annotations(raw), amap)
     path = os.path.join(annotations_dir, self.current_book_data['annotations_path_key'])
     if os.path.exists(path):
         with open(path, 'rb') as f:
             raw = f.read()
         merge_annotations(parse_annotations(raw), amap)
     if calibre_book_data is None:
         bld = self.current_book_data['book_library_details']
         if bld is not None:
             lib_amap = load_annotations_map_from_library(bld)
             sau = get_session_pref('sync_annots_user', default='')
             if sau:
                 other_amap = load_annotations_map_from_library(bld, user_type='web', user=sau)
                 if other_amap:
                     merge_annotations(other_amap, lib_amap)
             if lib_amap:
                 for annot_type, annots in iteritems(lib_amap):
                     merge_annotations(annots, amap)
     else:
         for annot_type, annots in iteritems(calibre_book_data['annotations_map']):
             merge_annotations(annots, amap)
Exemple #2
0
 def load_book_annotations(self):
     amap = self.current_book_data['annotations_map']
     path = os.path.join(self.current_book_data['base'], 'calibre-book-annotations.json')
     if os.path.exists(path):
         with open(path, 'rb') as f:
             raw = f.read()
         merge_annotations(json_loads(raw), amap)
     path = os.path.join(annotations_dir, self.current_book_data['annotations_path_key'])
     if os.path.exists(path):
         with open(path, 'rb') as f:
             raw = f.read()
         merge_annotations(parse_annotations(raw), amap)