mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #1156432 (no isbn in bib catalog export)
This commit is contained in:
parent
1d46d096f8
commit
dff74b9314
@ -53,8 +53,8 @@ def author_to_author_sort(author, method=None):
|
||||
if method == u'copy':
|
||||
return author
|
||||
|
||||
prefixes = set([x.lower() for x in tweaks['author_name_prefixes']])
|
||||
prefixes |= set([x+u'.' for x in prefixes])
|
||||
prefixes = set([y.lower() for y in tweaks['author_name_prefixes']])
|
||||
prefixes |= set([y+u'.' for y in prefixes])
|
||||
while True:
|
||||
if not tokens:
|
||||
return author
|
||||
@ -64,8 +64,8 @@ def author_to_author_sort(author, method=None):
|
||||
else:
|
||||
break
|
||||
|
||||
suffixes = set([x.lower() for x in tweaks['author_name_suffixes']])
|
||||
suffixes |= set([x+u'.' for x in suffixes])
|
||||
suffixes = set([y.lower() for y in tweaks['author_name_suffixes']])
|
||||
suffixes |= set([y+u'.' for y in suffixes])
|
||||
|
||||
suffix = u''
|
||||
while True:
|
||||
@ -358,3 +358,12 @@ def check_isbn(isbn):
|
||||
return check_isbn13(isbn)
|
||||
return None
|
||||
|
||||
def format_isbn(isbn):
|
||||
cisbn = check_isbn(isbn)
|
||||
if not cisbn:
|
||||
return isbn
|
||||
i = cisbn
|
||||
if len(i) == 10:
|
||||
return '-'.join((i[:2], i[2:6], i[6:9], i[9]))
|
||||
return '-'.join((i[:3], i[3:5], i[5:9], i[9:12], i[12]))
|
||||
|
||||
|
@ -5,7 +5,7 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2012, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import re, codecs
|
||||
import re, codecs, os
|
||||
from collections import namedtuple
|
||||
from types import StringType, UnicodeType
|
||||
|
||||
@ -14,6 +14,7 @@ from calibre.customize import CatalogPlugin
|
||||
from calibre.library.catalogs import FIELDS, TEMPLATE_ALLOWED_FIELDS
|
||||
from calibre.customize.conversion import DummyReporter
|
||||
from calibre.constants import preferred_encoding
|
||||
from calibre.ebooks.metadata import format_isbn
|
||||
|
||||
|
||||
class BIBTEX(CatalogPlugin):
|
||||
@ -114,6 +115,8 @@ class BIBTEX(CatalogPlugin):
|
||||
from calibre.utils.date import now as nowf
|
||||
from calibre.utils.logging import default_log as log
|
||||
|
||||
library_name = os.path.basename(db.library_path)
|
||||
|
||||
def create_bibtex_entry(entry, fields, mode, template_citation,
|
||||
bibtexdict, db, citation_bibtex=True, calibre_files=True):
|
||||
|
||||
@ -142,6 +145,8 @@ class BIBTEX(CatalogPlugin):
|
||||
item = repr(item)
|
||||
elif field == 'title_sort':
|
||||
item = entry['sort']
|
||||
elif field == 'library_name':
|
||||
item = library_name
|
||||
else:
|
||||
item = entry[field]
|
||||
|
||||
@ -183,7 +188,7 @@ class BIBTEX(CatalogPlugin):
|
||||
|
||||
elif field == 'isbn' :
|
||||
# Could be 9, 10 or 13 digits
|
||||
bibtex_entry.append(u'isbn = "%s"' % re.sub(u'[0-9xX]', u'', item))
|
||||
bibtex_entry.append(u'isbn = "%s"' % format_isbn(item))
|
||||
|
||||
elif field == 'formats' :
|
||||
#Add file path if format is selected
|
||||
|
@ -3626,7 +3626,6 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
||||
if data['datatype'] == 'series':
|
||||
FIELDS.add('%d_index'%x)
|
||||
data = []
|
||||
library_name = os.path.basename(self.library_path)
|
||||
for record in self.data:
|
||||
if record is None: continue
|
||||
db_id = record[self.FIELD_MAP['id']]
|
||||
@ -3650,7 +3649,6 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
||||
x['cover'] = os.path.join(path, 'cover.jpg')
|
||||
if not record[self.FIELD_MAP['cover']]:
|
||||
x['cover'] = None
|
||||
x['library_name'] = library_name
|
||||
formats = self.formats(record[self.FIELD_MAP['id']], index_is_id=True)
|
||||
if formats:
|
||||
for fmt in formats.split(','):
|
||||
|
Loading…
x
Reference in New Issue
Block a user