mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Correct merge trunk
This commit is contained in:
parent
bd4e2bb25f
commit
4ad0b4745a
@ -28,10 +28,6 @@ FIELDS = ['all', 'author_sort', 'authors', 'comments',
|
|||||||
TEMPLATE_ALLOWED_FIELDS = [ 'author_sort', 'authors', 'id', 'isbn', 'pubdate',
|
TEMPLATE_ALLOWED_FIELDS = [ 'author_sort', 'authors', 'id', 'isbn', 'pubdate',
|
||||||
'publisher', 'series_index', 'series', 'tags', 'timestamp', 'title', 'uuid' ]
|
'publisher', 'series_index', 'series', 'tags', 'timestamp', 'title', 'uuid' ]
|
||||||
|
|
||||||
#Allowed fields for template
|
|
||||||
TEMPLATE_ALLOWED_FIELDS = [ 'author_sort', 'authors', 'id', 'isbn', 'pubdate',
|
|
||||||
'publisher', 'series_index', 'series', 'tags', 'timestamp', 'title', 'uuid' ]
|
|
||||||
|
|
||||||
class CSV_XML(CatalogPlugin):
|
class CSV_XML(CatalogPlugin):
|
||||||
'CSV/XML catalog generator'
|
'CSV/XML catalog generator'
|
||||||
|
|
||||||
@ -130,11 +126,7 @@ class CSV_XML(CatalogPlugin):
|
|||||||
item = item.replace(u'\n',u' ')
|
item = item.replace(u'\n',u' ')
|
||||||
|
|
||||||
outstr.append(u'"%s"' % unicode(item).replace('"','""'))
|
outstr.append(u'"%s"' % unicode(item).replace('"','""'))
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
outfile.write(u','.join(outstr) + u'\n')
|
outfile.write(u','.join(outstr) + u'\n')
|
||||||
outfile.close()
|
outfile.close()
|
||||||
|
|
||||||
@ -216,11 +208,7 @@ class BIBTEX(CatalogPlugin):
|
|||||||
'Available fields: %s.\n'
|
'Available fields: %s.\n'
|
||||||
"Default: '%%default'\n"
|
"Default: '%%default'\n"
|
||||||
"Applies to: BIBTEX output format")%', '.join(FIELDS)),
|
"Applies to: BIBTEX output format")%', '.join(FIELDS)),
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
Option('--sort-by',
|
Option('--sort-by',
|
||||||
default = 'id',
|
default = 'id',
|
||||||
dest = 'sort_by',
|
dest = 'sort_by',
|
||||||
@ -229,11 +217,7 @@ class BIBTEX(CatalogPlugin):
|
|||||||
'Available fields: author_sort, id, rating, size, timestamp, title.\n'
|
'Available fields: author_sort, id, rating, size, timestamp, title.\n'
|
||||||
"Default: '%default'\n"
|
"Default: '%default'\n"
|
||||||
"Applies to: BIBTEX output format")),
|
"Applies to: BIBTEX output format")),
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
Option('--create-citation',
|
Option('--create-citation',
|
||||||
default = 'True',
|
default = 'True',
|
||||||
dest = 'impcit',
|
dest = 'impcit',
|
||||||
@ -242,11 +226,7 @@ class BIBTEX(CatalogPlugin):
|
|||||||
'Boolean value: True, False\n'
|
'Boolean value: True, False\n'
|
||||||
"Default: '%default'\n"
|
"Default: '%default'\n"
|
||||||
"Applies to: BIBTEX output format")),
|
"Applies to: BIBTEX output format")),
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
Option('--citation-template',
|
Option('--citation-template',
|
||||||
default = '{authors}{id}',
|
default = '{authors}{id}',
|
||||||
dest = 'bib_cit',
|
dest = 'bib_cit',
|
||||||
@ -256,11 +236,7 @@ class BIBTEX(CatalogPlugin):
|
|||||||
'Available fields: %s.\n'
|
'Available fields: %s.\n'
|
||||||
"Default: '%%default'\n"
|
"Default: '%%default'\n"
|
||||||
"Applies to: BIBTEX output format")%', '.join(TEMPLATE_ALLOWED_FIELDS)),
|
"Applies to: BIBTEX output format")%', '.join(TEMPLATE_ALLOWED_FIELDS)),
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
Option('--choose-encoding',
|
Option('--choose-encoding',
|
||||||
default = 'utf8',
|
default = 'utf8',
|
||||||
dest = 'bibfile_enc',
|
dest = 'bibfile_enc',
|
||||||
@ -269,11 +245,7 @@ class BIBTEX(CatalogPlugin):
|
|||||||
'Available types: utf8, cp1252, ascii.\n'
|
'Available types: utf8, cp1252, ascii.\n'
|
||||||
"Default: '%default'\n"
|
"Default: '%default'\n"
|
||||||
"Applies to: BIBTEX output format")),
|
"Applies to: BIBTEX output format")),
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
Option('--choose-encoding-configuration',
|
Option('--choose-encoding-configuration',
|
||||||
default = 'strict',
|
default = 'strict',
|
||||||
dest = 'bibfile_enctag',
|
dest = 'bibfile_enctag',
|
||||||
@ -291,46 +263,21 @@ class BIBTEX(CatalogPlugin):
|
|||||||
'Available types: book, misc, mixed.\n'
|
'Available types: book, misc, mixed.\n'
|
||||||
"Default: '%default'\n"
|
"Default: '%default'\n"
|
||||||
"Applies to: BIBTEX output format"))]
|
"Applies to: BIBTEX output format"))]
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
def run(self, path_to_output, opts, db, notification=DummyReporter()):
|
def run(self, path_to_output, opts, db, notification=DummyReporter()):
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
from types import StringType, UnicodeType
|
from types import StringType, UnicodeType
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
from calibre.library.save_to_disk import preprocess_template
|
from calibre.library.save_to_disk import preprocess_template
|
||||||
#Bibtex functions
|
#Bibtex functions
|
||||||
from calibre.utils.bibtex import bibtex_author_format, utf8ToBibtex, ValidateCitationKey
|
from calibre.utils.bibtex import bibtex_author_format, utf8ToBibtex, ValidateCitationKey
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
def create_bibtex_entry(entry, fields, mode, template_citation,
|
def create_bibtex_entry(entry, fields, mode, template_citation,
|
||||||
=======
|
|
||||||
|
|
||||||
def create_bibtex_entry(entry, fields, mode, template_citation,
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
asccii_bibtex = True, citation_bibtex = True):
|
asccii_bibtex = True, citation_bibtex = True):
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
#Bibtex doesn't like UTF-8 but keep unicode until writing
|
#Bibtex doesn't like UTF-8 but keep unicode until writing
|
||||||
#Define starting chain or if book valid strict and not book return a Fail string
|
#Define starting chain or if book valid strict and not book return a Fail string
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
bibtex_entry = []
|
bibtex_entry = []
|
||||||
if mode != "misc" and check_entry_book_valid(entry) :
|
if mode != "misc" and check_entry_book_valid(entry) :
|
||||||
bibtex_entry.append(u'@book{')
|
bibtex_entry.append(u'@book{')
|
||||||
@ -339,20 +286,12 @@ class BIBTEX(CatalogPlugin):
|
|||||||
else :
|
else :
|
||||||
#case strict book
|
#case strict book
|
||||||
return ''
|
return ''
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
if citation_bibtex :
|
if citation_bibtex :
|
||||||
# Citation tag
|
# Citation tag
|
||||||
bibtex_entry.append(make_bibtex_citation(entry, template_citation, asccii_bibtex))
|
bibtex_entry.append(make_bibtex_citation(entry, template_citation, asccii_bibtex))
|
||||||
bibtex_entry = [u' '.join(bibtex_entry)]
|
bibtex_entry = [u' '.join(bibtex_entry)]
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
for field in fields:
|
for field in fields:
|
||||||
item = entry[field]
|
item = entry[field]
|
||||||
#check if the field should be included (none or empty)
|
#check if the field should be included (none or empty)
|
||||||
@ -366,117 +305,54 @@ class BIBTEX(CatalogPlugin):
|
|||||||
|
|
||||||
if field == 'authors' :
|
if field == 'authors' :
|
||||||
bibtex_entry.append(u'author = "%s"' % bibtex_author_format(item))
|
bibtex_entry.append(u'author = "%s"' % bibtex_author_format(item))
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
elif field in ['title', 'publisher', 'cover', 'uuid',
|
elif field in ['title', 'publisher', 'cover', 'uuid',
|
||||||
'author_sort', 'series'] :
|
'author_sort', 'series'] :
|
||||||
bibtex_entry.append(u'%s = "%s"' % (field, utf8ToBibtex(item, asccii_bibtex)))
|
bibtex_entry.append(u'%s = "%s"' % (field, utf8ToBibtex(item, asccii_bibtex)))
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
elif field == 'id' :
|
elif field == 'id' :
|
||||||
bibtex_entry.append(u'calibreid = "%s"' % int(item))
|
bibtex_entry.append(u'calibreid = "%s"' % int(item))
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
elif field == 'rating' :
|
elif field == 'rating' :
|
||||||
bibtex_entry.append(u'rating = "%s"' % int(item))
|
bibtex_entry.append(u'rating = "%s"' % int(item))
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
elif field == 'size' :
|
elif field == 'size' :
|
||||||
bibtex_entry.append(u'%s = "%s octets"' % (field, int(item)))
|
bibtex_entry.append(u'%s = "%s octets"' % (field, int(item)))
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
elif field == 'tags' :
|
elif field == 'tags' :
|
||||||
=======
|
|
||||||
|
|
||||||
elif field == 'tags' :
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
#A list to flatten
|
#A list to flatten
|
||||||
bibtex_entry.append(u'tags = "%s"' % utf8ToBibtex(u', '.join(item), asccii_bibtex))
|
bibtex_entry.append(u'tags = "%s"' % utf8ToBibtex(u', '.join(item), asccii_bibtex))
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
elif field == 'comments' :
|
elif field == 'comments' :
|
||||||
=======
|
|
||||||
|
|
||||||
elif field == 'comments' :
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
#\n removal
|
#\n removal
|
||||||
item = item.replace(u'\r\n',u' ')
|
item = item.replace(u'\r\n',u' ')
|
||||||
item = item.replace(u'\n',u' ')
|
item = item.replace(u'\n',u' ')
|
||||||
bibtex_entry.append(u'note = "%s"' % utf8ToBibtex(item, asccii_bibtex))
|
bibtex_entry.append(u'note = "%s"' % utf8ToBibtex(item, asccii_bibtex))
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
elif field == 'isbn' :
|
elif field == 'isbn' :
|
||||||
# Could be 9, 10 or 13 digits
|
# Could be 9, 10 or 13 digits
|
||||||
bibtex_entry.append(u'isbn = "%s"' % re.sub(u'[\D]', u'', item))
|
bibtex_entry.append(u'isbn = "%s"' % re.sub(u'[\D]', u'', item))
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
elif field == 'formats' :
|
elif field == 'formats' :
|
||||||
item = u', '.join([format.rpartition('.')[2].lower() for format in item])
|
item = u', '.join([format.rpartition('.')[2].lower() for format in item])
|
||||||
bibtex_entry.append(u'formats = "%s"' % item)
|
bibtex_entry.append(u'formats = "%s"' % item)
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
elif field == 'series_index' :
|
elif field == 'series_index' :
|
||||||
bibtex_entry.append(u'volume = "%s"' % int(item))
|
bibtex_entry.append(u'volume = "%s"' % int(item))
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
elif field == 'timestamp' :
|
elif field == 'timestamp' :
|
||||||
bibtex_entry.append(u'timestamp = "%s"' % isoformat(item).partition('T')[0])
|
bibtex_entry.append(u'timestamp = "%s"' % isoformat(item).partition('T')[0])
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
elif field == 'pubdate' :
|
elif field == 'pubdate' :
|
||||||
bibtex_entry.append(u'year = "%s"' % item.year)
|
bibtex_entry.append(u'year = "%s"' % item.year)
|
||||||
<<<<<<< TREE
|
|
||||||
#Messing locale in date string formatting
|
|
||||||
bibtex_entry.append(u'month = "%s"' % utf8ToBibtex(item.strftime("%b").decode(preferred_encoding),
|
|
||||||
=======
|
|
||||||
bibtex_entry.append(u'month = "%s"' % utf8ToBibtex(strftime("%b", item),
|
bibtex_entry.append(u'month = "%s"' % utf8ToBibtex(strftime("%b", item),
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
asccii_bibtex))
|
asccii_bibtex))
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
bibtex_entry = u',\n '.join(bibtex_entry)
|
bibtex_entry = u',\n '.join(bibtex_entry)
|
||||||
bibtex_entry += u' }\n\n'
|
bibtex_entry += u' }\n\n'
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
return bibtex_entry
|
return bibtex_entry
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
def check_entry_book_valid(entry):
|
def check_entry_book_valid(entry):
|
||||||
#Check that the required fields are ok for a book entry
|
#Check that the required fields are ok for a book entry
|
||||||
for field in ['title', 'authors', 'publisher'] :
|
for field in ['title', 'authors', 'publisher'] :
|
||||||
@ -488,24 +364,12 @@ class BIBTEX(CatalogPlugin):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def make_bibtex_citation(entry, template_citation, asccii_bibtex):
|
def make_bibtex_citation(entry, template_citation, asccii_bibtex):
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
#define a function to replace the template entry by its value
|
#define a function to replace the template entry by its value
|
||||||
def tpl_replace(objtplname) :
|
def tpl_replace(objtplname) :
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
tpl_field = re.sub(u'[\{\}]', u'', objtplname.group())
|
tpl_field = re.sub(u'[\{\}]', u'', objtplname.group())
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
if tpl_field in TEMPLATE_ALLOWED_FIELDS :
|
if tpl_field in TEMPLATE_ALLOWED_FIELDS :
|
||||||
if tpl_field in ['pubdate', 'timestamp'] :
|
if tpl_field in ['pubdate', 'timestamp'] :
|
||||||
tpl_field = isoformat(entry[tpl_field]).partition('T')[0]
|
tpl_field = isoformat(entry[tpl_field]).partition('T')[0]
|
||||||
@ -517,66 +381,34 @@ class BIBTEX(CatalogPlugin):
|
|||||||
tpl_field = entry[tpl_field]
|
tpl_field = entry[tpl_field]
|
||||||
return tpl_field
|
return tpl_field
|
||||||
else:
|
else:
|
||||||
<<<<<<< TREE
|
|
||||||
return u''
|
return u''
|
||||||
=======
|
|
||||||
return u''
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
|
|
||||||
if len(template_citation) >0 :
|
if len(template_citation) >0 :
|
||||||
<<<<<<< TREE
|
|
||||||
tpl_citation = utf8ToBibtex(ValidateCitationKey(re.sub(u'\{[^{}]*\}',
|
tpl_citation = utf8ToBibtex(ValidateCitationKey(re.sub(u'\{[^{}]*\}',
|
||||||
=======
|
|
||||||
tpl_citation = utf8ToBibtex(ValidateCitationKey(re.sub(u'\{[^{}]*\}',
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
tpl_replace, template_citation)), asccii_bibtex)
|
tpl_replace, template_citation)), asccii_bibtex)
|
||||||
|
|
||||||
if len(tpl_citation) >0 :
|
if len(tpl_citation) >0 :
|
||||||
return tpl_citation
|
return tpl_citation
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
if len(entry["isbn"]) > 0 :
|
if len(entry["isbn"]) > 0 :
|
||||||
template_citation = u'%s' % re.sub(u'[\D]',u'', entry["isbn"])
|
template_citation = u'%s' % re.sub(u'[\D]',u'', entry["isbn"])
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
else :
|
else :
|
||||||
template_citation = u'%s' % str(entry["id"])
|
template_citation = u'%s' % str(entry["id"])
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
if asccii_bibtex :
|
if asccii_bibtex :
|
||||||
return ValidateCitationKey(template_citation.encode('ascii', 'replace'))
|
return ValidateCitationKey(template_citation.encode('ascii', 'replace'))
|
||||||
else :
|
else :
|
||||||
return ValidateCitationKey(template_citation)
|
return ValidateCitationKey(template_citation)
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
self.fmt = path_to_output.rpartition('.')[2]
|
self.fmt = path_to_output.rpartition('.')[2]
|
||||||
self.notification = notification
|
self.notification = notification
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
# Combobox options
|
# Combobox options
|
||||||
bibfile_enc = ['utf8', 'cp1252', 'ascii']
|
bibfile_enc = ['utf8', 'cp1252', 'ascii']
|
||||||
bibfile_enctag = ['strict', 'replace', 'ignore', 'backslashreplace']
|
bibfile_enctag = ['strict', 'replace', 'ignore', 'backslashreplace']
|
||||||
bib_entry = ['mixed', 'misc', 'book']
|
bib_entry = ['mixed', 'misc', 'book']
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
# Needed beacause CLI return str vs int by widget
|
# Needed beacause CLI return str vs int by widget
|
||||||
try:
|
try:
|
||||||
bibfile_enc = bibfile_enc[opts.bibfile_enc]
|
bibfile_enc = bibfile_enc[opts.bibfile_enc]
|
||||||
@ -615,17 +447,9 @@ class BIBTEX(CatalogPlugin):
|
|||||||
log(" Fields: %s" % ', '.join(FIELDS[1:]))
|
log(" Fields: %s" % ', '.join(FIELDS[1:]))
|
||||||
else:
|
else:
|
||||||
log(" Fields: %s" % opts_dict['fields'])
|
log(" Fields: %s" % opts_dict['fields'])
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
log(" Output file will be encoded in %s with %s flag" % (bibfile_enc, bibfile_enctag))
|
log(" Output file will be encoded in %s with %s flag" % (bibfile_enc, bibfile_enctag))
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
log(" BibTeX entry type is %s with a citation like '%s' flag" % (bib_entry, opts_dict['bib_cit']))
|
log(" BibTeX entry type is %s with a citation like '%s' flag" % (bib_entry, opts_dict['bib_cit']))
|
||||||
|
|
||||||
# If a list of ids are provided, don't use search_text
|
# If a list of ids are provided, don't use search_text
|
||||||
@ -639,28 +463,16 @@ class BIBTEX(CatalogPlugin):
|
|||||||
|
|
||||||
# Get the requested output fields as a list
|
# Get the requested output fields as a list
|
||||||
fields = self.get_output_fields(opts)
|
fields = self.get_output_fields(opts)
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
if not len(data):
|
if not len(data):
|
||||||
log.error("\nNo matching database entries for search criteria '%s'" % opts.search_text)
|
log.error("\nNo matching database entries for search criteria '%s'" % opts.search_text)
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
#Entries writing after Bibtex formating (or not)
|
#Entries writing after Bibtex formating (or not)
|
||||||
if bibfile_enc != 'ascii' :
|
if bibfile_enc != 'ascii' :
|
||||||
asccii_bibtex = False
|
asccii_bibtex = False
|
||||||
else :
|
else :
|
||||||
asccii_bibtex = True
|
asccii_bibtex = True
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
#Check and go to default in case of bad CLI
|
#Check and go to default in case of bad CLI
|
||||||
if isinstance(opts.impcit, (StringType, UnicodeType)) :
|
if isinstance(opts.impcit, (StringType, UnicodeType)) :
|
||||||
if opts.impcit == 'False' :
|
if opts.impcit == 'False' :
|
||||||
@ -672,62 +484,30 @@ class BIBTEX(CatalogPlugin):
|
|||||||
citation_bibtex= True
|
citation_bibtex= True
|
||||||
else :
|
else :
|
||||||
citation_bibtex= opts.impcit
|
citation_bibtex= opts.impcit
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
template_citation = preprocess_template(opts.bib_cit)
|
template_citation = preprocess_template(opts.bib_cit)
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
#Open output and write entries
|
#Open output and write entries
|
||||||
outfile = codecs.open(path_to_output, 'w', bibfile_enc, bibfile_enctag)
|
outfile = codecs.open(path_to_output, 'w', bibfile_enc, bibfile_enctag)
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
#File header
|
#File header
|
||||||
nb_entries = len(data)
|
nb_entries = len(data)
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
#check in book strict if all is ok else throw a warning into log
|
#check in book strict if all is ok else throw a warning into log
|
||||||
if bib_entry == 'book' :
|
if bib_entry == 'book' :
|
||||||
nb_books = len(filter(check_entry_book_valid, data))
|
nb_books = len(filter(check_entry_book_valid, data))
|
||||||
if nb_books < nb_entries :
|
if nb_books < nb_entries :
|
||||||
log(" WARNING: only %d entries in %d are book compatible" % (nb_books, nb_entries))
|
log(" WARNING: only %d entries in %d are book compatible" % (nb_books, nb_entries))
|
||||||
nb_entries = nb_books
|
nb_entries = nb_books
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
outfile.write(u'%%%Calibre catalog\n%%%{0} entries in catalog\n\n'.format(nb_entries))
|
outfile.write(u'%%%Calibre catalog\n%%%{0} entries in catalog\n\n'.format(nb_entries))
|
||||||
outfile.write(u'@preamble{"This catalog of %d entries was generated by calibre on %s"}\n\n'
|
outfile.write(u'@preamble{"This catalog of %d entries was generated by calibre on %s"}\n\n'
|
||||||
% (nb_entries, nowf().strftime("%A, %d. %B %Y %H:%M").decode(preferred_encoding)))
|
% (nb_entries, nowf().strftime("%A, %d. %B %Y %H:%M").decode(preferred_encoding)))
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
for entry in data:
|
for entry in data:
|
||||||
<<<<<<< TREE
|
|
||||||
outfile.write(create_bibtex_entry(entry, fields, bib_entry, template_citation,
|
outfile.write(create_bibtex_entry(entry, fields, bib_entry, template_citation,
|
||||||
=======
|
|
||||||
outfile.write(create_bibtex_entry(entry, fields, bib_entry, template_citation,
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
asccii_bibtex, citation_bibtex))
|
asccii_bibtex, citation_bibtex))
|
||||||
<<<<<<< TREE
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> MERGE-SOURCE
|
|
||||||
outfile.close()
|
outfile.close()
|
||||||
|
|
||||||
class EPUB_MOBI(CatalogPlugin):
|
class EPUB_MOBI(CatalogPlugin):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user