fnp
/
librarian.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add support for addition cover logos.
[librarian.git]
/
librarian
/
book2anything.py
diff --git
a/librarian/book2anything.py
b/librarian/book2anything.py
index
0dcfd33
..
948d9fd
100755
(executable)
--- a/
librarian/book2anything.py
+++ b/
librarian/book2anything.py
@@
-4,12
+4,14
@@
# This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
# This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
+from __future__ import print_function, unicode_literals
+
import os.path
import optparse
import os.path
import optparse
-
+import six
from librarian import DirDocProvider, ParseError
from librarian.parser import WLDocument
from librarian import DirDocProvider, ParseError
from librarian.parser import WLDocument
-from librarian.cover import
DefaultEbookC
over
+from librarian.cover import
make_c
over
class Option(object):
class Option(object):
@@
-92,17
+94,20
@@
class Book2Anything(object):
# Add cover support, if any.
if cls.uses_cover:
if options.image_cache:
# Add cover support, if any.
if cls.uses_cover:
if options.image_cache:
- def cover_class(*args, **kwargs):
- return
DefaultEbookCover(
image_cache=options.image_cache, *args, **kwargs)
+ def cover_class(
book_info,
*args, **kwargs):
+ return
make_cover(book_info,
image_cache=options.image_cache, *args, **kwargs)
transform_args['cover'] = cover_class
elif not cls.cover_optional or options.with_cover:
transform_args['cover'] = cover_class
elif not cls.cover_optional or options.with_cover:
- transform_args['cover'] =
DefaultEbookC
over
+ transform_args['cover'] =
make_c
over
# Do some real work
try:
for main_input in input_filenames:
if options.verbose:
# Do some real work
try:
for main_input in input_filenames:
if options.verbose:
- print main_input
+ print(main_input)
+
+ if isinstance(main_input, six.binary_type):
+ main_input = main_input.decode('utf-8')
# Where to find input?
if cls.uses_provider:
# Where to find input?
if cls.uses_provider:
@@
-126,9
+131,9
@@
class Book2Anything(object):
doc.save_output_file(output, output_file, options.output_dir, options.make_dir, cls.ext)
doc.save_output_file(output, output_file, options.output_dir, options.make_dir, cls.ext)
- except ParseError
,
e:
- print
'%(file)s:%(name)s:%(message)s' % {
+ except ParseError
as
e:
+ print
(
'%(file)s:%(name)s:%(message)s' % {
'file': main_input,
'name': e.__class__.__name__,
'message': e
'file': main_input,
'name': e.__class__.__name__,
'message': e
- }
+ }
)