mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Added title and author sort key support to html2lrf
This commit is contained in:
parent
5cb12c364e
commit
0caca9fe4c
@ -37,7 +37,7 @@ from libprs500.lrf.html.BeautifulSoup import BeautifulSoup, Comment, Tag, \
|
|||||||
from libprs500.lrf.pylrs.pylrs import Paragraph, CR, Italic, ImageStream, TextBlock, \
|
from libprs500.lrf.pylrs.pylrs import Paragraph, CR, Italic, ImageStream, TextBlock, \
|
||||||
ImageBlock, JumpButton, CharButton, \
|
ImageBlock, JumpButton, CharButton, \
|
||||||
Bold, Space, Plot, Image, BlockSpace,\
|
Bold, Space, Plot, Image, BlockSpace,\
|
||||||
RuledLine
|
RuledLine, BookSetting
|
||||||
from libprs500.lrf.pylrs.pylrs import Span as _Span
|
from libprs500.lrf.pylrs.pylrs import Span as _Span
|
||||||
from libprs500.lrf import ConversionError, option_parser, Book
|
from libprs500.lrf import ConversionError, option_parser, Book
|
||||||
from libprs500 import extract
|
from libprs500 import extract
|
||||||
@ -934,9 +934,13 @@ def process_file(path, options):
|
|||||||
print >>sys.stderr, "WARNING: You don't have PIL installed. ",
|
print >>sys.stderr, "WARNING: You don't have PIL installed. ",
|
||||||
'Cover and thumbnails wont work'
|
'Cover and thumbnails wont work'
|
||||||
pass
|
pass
|
||||||
args = dict(font_delta=options.font_delta, title=options.title, \
|
title = (options.title, options.title_sort)
|
||||||
author=options.author, sourceencoding='utf8',\
|
author = (options.author, options.author_sort)
|
||||||
freetext=options.freetext, category=options.category)
|
args = dict(font_delta=options.font_delta, title=title, \
|
||||||
|
author=author, sourceencoding='utf8',\
|
||||||
|
freetext=options.freetext, category=options.category,
|
||||||
|
booksetting=BookSetting(dpi=10*options.dpi,screenheight=800,
|
||||||
|
screenwidth=600))
|
||||||
if tpath:
|
if tpath:
|
||||||
args['thumbnail'] = tpath
|
args['thumbnail'] = tpath
|
||||||
header = None
|
header = None
|
||||||
@ -988,6 +992,10 @@ def main():
|
|||||||
parser.add_option('--dpi', action='store', type='int', default=166, dest='dpi',
|
parser.add_option('--dpi', action='store', type='int', default=166, dest='dpi',
|
||||||
help='''The DPI of the target device. Default is 166 for the
|
help='''The DPI of the target device. Default is 166 for the
|
||||||
Sony PRS 500''')
|
Sony PRS 500''')
|
||||||
|
parser.add_option('--title-sort', action='store', default='', dest='title_sort',
|
||||||
|
help='Sort key for the title')
|
||||||
|
parser.add_option('--author-sort', action='store', default='', dest='author_sort',
|
||||||
|
help='Sort key for the author')
|
||||||
options, args = parser.parse_args()
|
options, args = parser.parse_args()
|
||||||
if len(args) != 1:
|
if len(args) != 1:
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
|
@ -50,7 +50,7 @@ from pylrf import (LrfWriter, LrfObject, LrfTag, LrfToc,
|
|||||||
STREAM_FORCE_COMPRESSED)
|
STREAM_FORCE_COMPRESSED)
|
||||||
|
|
||||||
DEFAULT_SOURCE_ENCODING = "cp1252" # defualt is us-windows character set
|
DEFAULT_SOURCE_ENCODING = "cp1252" # defualt is us-windows character set
|
||||||
DEFAULT_GENREADING = "f" # default is yes to lrf, no to lrs
|
DEFAULT_GENREADING = "fs" # default is yes to both lrf and lrs
|
||||||
|
|
||||||
|
|
||||||
class LrsError(Exception):
|
class LrsError(Exception):
|
||||||
@ -90,13 +90,13 @@ def ElementWithReading(tag, text, reading=False):
|
|||||||
elif isinstance(text, basestring):
|
elif isinstance(text, basestring):
|
||||||
readingText = text
|
readingText = text
|
||||||
else:
|
else:
|
||||||
# assumed to be a sequence of (name, sortas)
|
# assumed to be a sequence of (name, sortas)
|
||||||
readingText = text[1]
|
readingText = text[1]
|
||||||
text = text[0]
|
text = text[0]
|
||||||
|
|
||||||
|
|
||||||
if not reading:
|
if not reading:
|
||||||
readingText = ""
|
readingText = ""
|
||||||
|
|
||||||
return ElementWithText(tag, text, reading=readingText)
|
return ElementWithText(tag, text, reading=readingText)
|
||||||
|
|
||||||
|
|
||||||
@ -723,7 +723,7 @@ class BookInfo(object):
|
|||||||
bi.append(pi)
|
bi.append(pi)
|
||||||
|
|
||||||
|
|
||||||
def toElement(self, se, reading=False):
|
def toElement(self, se, reading=True):
|
||||||
bi = Element("BookInfo")
|
bi = Element("BookInfo")
|
||||||
bi.append(ElementWithReading("Title", self.title, reading=reading))
|
bi.append(ElementWithReading("Title", self.title, reading=reading))
|
||||||
bi.append(ElementWithReading("Author", self.author, reading=reading))
|
bi.append(ElementWithReading("Author", self.author, reading=reading))
|
||||||
@ -1038,7 +1038,7 @@ class StyleDefault(LrsAttributes):
|
|||||||
|
|
||||||
class BookSetting(LrsAttributes):
|
class BookSetting(LrsAttributes):
|
||||||
def __init__(self, **settings):
|
def __init__(self, **settings):
|
||||||
defaults = dict(bindingdirection="Lr", dpi="1600",
|
defaults = dict(bindingdirection="Lr", dpi="1660",
|
||||||
screenheight="800", screenwidth="600", colordepth="24")
|
screenheight="800", screenwidth="600", colordepth="24")
|
||||||
LrsAttributes.__init__(self, defaults, **settings)
|
LrsAttributes.__init__(self, defaults, **settings)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user