def show_bookmarks(self): bs = Bookmark.get_all() if bs.exists(): for row_info in bs: image_path = row_info.pop('image_path', '') if image_path and os.path.exists(image_path): image_fp = Image.open(image_path) row_info.update(image_fp=image_fp) self.add_one_row(**row_info)
def add_bookmark(self): url = self.url_entry.get() url = analyzer.init_start_url(url) req = requests.get(url) result = analyzer.get_thread_info(url, req) kwargs = result.as_dict() query = kwargs.copy() if result.has_image: image_name = result.image_url.rsplit('/', 1)[-1] path = os.path.join(self.save_to_prefix, image_name) kwargs.update(image_save_to=path) query.update(image_path=path) query.pop('image_url', '') query.pop('image_fp', '') Bookmark.create(**query) self.master.add_bookmark(**kwargs) # clear entry self.url_entry.set('')
def delete(self): Bookmark.delete_by_id(self.database_id) self.destroy()