@@ -109,6 +109,7 @@ def __str__(self):
109
109
110
110
# Items
111
111
112
+
112
113
class EpubItem (object ):
113
114
"""
114
115
Base class for the items in a book.
@@ -320,7 +321,8 @@ def add_item(self, item):
320
321
321
322
def get_body_content (self ):
322
323
"""
323
- Returns content of BODY element for this HTML document. Content will be of type 'str' (Python 2) or 'bytes' (Python 3).
324
+ Returns content of BODY element for this HTML document. Content will be of type 'str' (Python 2)
325
+ or 'bytes' (Python 3).
324
326
325
327
:Returns:
326
328
Returns content of this document.
@@ -350,7 +352,8 @@ def get_body_content(self):
350
352
351
353
def get_content (self , default = None ):
352
354
"""
353
- Returns content for this document as HTML string. Content will be of type 'str' (Python 2) or 'bytes' (Python 3).
355
+ Returns content for this document as HTML string. Content will be of type 'str' (Python 2)
356
+ or 'bytes' (Python 3).
354
357
355
358
:Args:
356
359
- default: Default value for the content if it is not defined.
@@ -540,7 +543,9 @@ def reset(self):
540
543
'cover' : COVER_XML
541
544
}
542
545
543
- self .add_metadata ('OPF' , 'generator' , '' , {'name' : 'generator' , 'content' : 'Ebook-lib %s' % '.' .join ([str (s ) for s in VERSION ])})
546
+ self .add_metadata ('OPF' , 'generator' , '' , {
547
+ 'name' : 'generator' , 'content' : 'Ebook-lib %s' % '.' .join ([str (s ) for s in VERSION ])
548
+ })
544
549
545
550
# default to using a randomly-unique identifier if one is not specified manually
546
551
self .set_identifier (str (uuid .uuid4 ()))
@@ -1033,7 +1038,9 @@ def _get_nav(self, item):
1033
1038
1034
1039
# for now this just handles css files and ignores others
1035
1040
for _link in item .links :
1036
- _lnk = etree .SubElement (head , 'link' , {"href" : _link .get ('href' , '' ), "rel" : "stylesheet" , "type" : "text/css" })
1041
+ _lnk = etree .SubElement (head , 'link' , {
1042
+ "href" : _link .get ('href' , '' ), "rel" : "stylesheet" , "type" : "text/css"
1043
+ })
1037
1044
1038
1045
body = etree .SubElement (root , 'body' )
1039
1046
nav = etree .SubElement (body , 'nav' , {'{%s}type' % NAMESPACES ['EPUB' ]: 'toc' , 'id' : 'id' })
@@ -1100,7 +1107,10 @@ def _create_section(itm, items):
1100
1107
_title = elem .get ('title' , '' )
1101
1108
1102
1109
guide_type = elem .get ('type' , '' )
1103
- a_item = etree .SubElement (li_item , 'a' , {'{%s}type' % NAMESPACES ['EPUB' ]: guide_to_landscape_map .get (guide_type , guide_type ), 'href' : os .path .relpath (_href , nav_dir_name )})
1110
+ a_item = etree .SubElement (li_item , 'a' , {
1111
+ '{%s}type' % NAMESPACES ['EPUB' ]: guide_to_landscape_map .get (guide_type , guide_type ),
1112
+ 'href' : os .path .relpath (_href , nav_dir_name )
1113
+ })
1104
1114
a_item .text = _title
1105
1115
1106
1116
tree_str = etree .tostring (nav_xml , pretty_print = True , encoding = 'utf-8' , xml_declaration = True )
@@ -1137,7 +1147,9 @@ def _create_section(itm, items, uid):
1137
1147
if isinstance (item , tuple ) or isinstance (item , list ):
1138
1148
section , subsection = item [0 ], item [1 ]
1139
1149
1140
- np = etree .SubElement (itm , 'navPoint' , {'id' : section .get_id () if isinstance (section , EpubHtml ) else 'sep_%d' % uid })
1150
+ np = etree .SubElement (itm , 'navPoint' , {
1151
+ 'id' : section .get_id () if isinstance (section , EpubHtml ) else 'sep_%d' % uid
1152
+ })
1141
1153
nl = etree .SubElement (np , 'navLabel' )
1142
1154
nt = etree .SubElement (nl , 'text' )
1143
1155
nt .text = section .title
@@ -1381,7 +1393,6 @@ def _load_manifest(self):
1381
1393
ei .media_type = media_type
1382
1394
1383
1395
ei .content = self .read_file (zip_path .join (self .opf_dir , ei .get_name ()))
1384
- # r.get('properties')
1385
1396
1386
1397
self .book .add_item (ei )
1387
1398
@@ -1410,7 +1421,7 @@ def _get_children(elems, n, nid):
1410
1421
return (Section (label , href = content ),
1411
1422
children )
1412
1423
else :
1413
- return ( Link (content , label , nid ) )
1424
+ return Link (content , label , nid )
1414
1425
1415
1426
self .book .toc = _get_children (nav_map , 0 , '' )
1416
1427
0 commit comments