From d3965080da8822c1a8018d0540b75862740f3559 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 17 Nov 2023 08:15:14 +0530 Subject: [PATCH] Remove deprecated utcfromtimestamp in kindle driver The use for generate_annotation_html is safe since it is just used to get a formatted date via strftime. No idea about its use in clippings, this is also unmaintained code, so roll the dice :) --- src/calibre/devices/kindle/driver.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/calibre/devices/kindle/driver.py b/src/calibre/devices/kindle/driver.py index 3b72b9b200..93fa1bd0bf 100644 --- a/src/calibre/devices/kindle/driver.py +++ b/src/calibre/devices/kindle/driver.py @@ -8,9 +8,10 @@ from calibre.devices.kindle.apnx import APNXBuilder Device driver for Amazon's Kindle ''' -import datetime, os, re, json, hashlib, errno +import os, re, json, hashlib, errno from calibre.constants import DEBUG, filesystem_encoding +from calibre.utils.date import utcfromtimestamp from calibre.devices.interface import OpenPopupMessage from calibre.devices.kindle.bookmark import Bookmark from calibre.devices.usbms.driver import USBMS @@ -218,9 +219,9 @@ class KINDLE(USBMS): mc_path = get_my_clippings(storage, bookmarked_books) if mc_path: - timestamp = datetime.datetime.utcfromtimestamp(os.path.getmtime(mc_path)) + timestamp = utcfromtimestamp(os.path.getmtime(mc_path)) bookmarked_books['clippings'] = self.UserAnnotation(type='kindle_clippings', - value=dict(path=mc_path,timestamp=timestamp)) + value=dict(path=mc_path, timestamp=timestamp)) # This returns as job.result in gui2.ui.annotations_fetched(self,job) return bookmarked_books @@ -229,7 +230,7 @@ class KINDLE(USBMS): from calibre.ebooks.BeautifulSoup import BeautifulSoup # Returns
...
last_read_location = bookmark.last_read_location - timestamp = datetime.datetime.utcfromtimestamp(bookmark.timestamp) + timestamp = utcfromtimestamp(bookmark.timestamp) percent_read = bookmark.percent_read ka_soup = BeautifulSoup()