mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Book polishing: Apply null comments
Book polishing: Do not leave behind the old comments when updating metadata if the comments have been deleted in calibre.
This commit is contained in:
parent
0394f6d01f
commit
d32a1c7bb7
@ -30,7 +30,8 @@ class ContainerException(OCFException):
|
|||||||
|
|
||||||
class Container(dict):
|
class Container(dict):
|
||||||
def __init__(self, stream=None):
|
def __init__(self, stream=None):
|
||||||
if not stream: return
|
if not stream:
|
||||||
|
return
|
||||||
soup = BeautifulStoneSoup(stream.read())
|
soup = BeautifulStoneSoup(stream.read())
|
||||||
container = soup.find(name=re.compile(r'container$', re.I))
|
container = soup.find(name=re.compile(r'container$', re.I))
|
||||||
if not container:
|
if not container:
|
||||||
@ -256,7 +257,8 @@ def update_metadata(opf, mi, apply_null=False, update_timestamp=False):
|
|||||||
langs = []
|
langs = []
|
||||||
for lc in mi.languages:
|
for lc in mi.languages:
|
||||||
lc2 = lang_as_iso639_1(lc)
|
lc2 = lang_as_iso639_1(lc)
|
||||||
if lc2: lc = lc2
|
if lc2:
|
||||||
|
lc = lc2
|
||||||
langs.append(lc)
|
langs.append(lc)
|
||||||
mi.languages = langs
|
mi.languages = langs
|
||||||
|
|
||||||
@ -270,6 +272,8 @@ def update_metadata(opf, mi, apply_null=False, update_timestamp=False):
|
|||||||
opf.tags = []
|
opf.tags = []
|
||||||
if not getattr(mi, 'isbn', None):
|
if not getattr(mi, 'isbn', None):
|
||||||
opf.isbn = None
|
opf.isbn = None
|
||||||
|
if not getattr(mi, 'comments', None):
|
||||||
|
opf.comments = None
|
||||||
if update_timestamp and mi.timestamp is not None:
|
if update_timestamp and mi.timestamp is not None:
|
||||||
opf.timestamp = mi.timestamp
|
opf.timestamp = mi.timestamp
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user