1
+ import os
1
2
from jinja2 import Environment
2
3
from typing import List , Tuple
3
4
4
5
5
6
def get_content_from_file (path ):
6
- with open (path , 'r' ) as f :
7
+ with open (os . path . join ( os . path . dirname ( __file__ ), path ) , 'r' ) as f :
7
8
return f .read ()
8
9
9
10
10
11
def render_mimetype ():
11
- return get_content_from_file ('./comicepub/ template/mimetype' )
12
+ return get_content_from_file ('./template/mimetype' )
12
13
13
14
14
15
def render_container_xml ():
15
- return get_content_from_file ('./comicepub/ template/container.xml' )
16
+ return get_content_from_file ('./template/container.xml' )
16
17
17
18
18
19
def render_standard_opf (
@@ -28,7 +29,7 @@ def render_standard_opf(
28
29
manifest_xhtmls : List [Tuple [str , str ]],
29
30
manifest_spines : List [str ],
30
31
) -> str :
31
- template = get_content_from_file ('./comicepub/ template/standard.opf' )
32
+ template = get_content_from_file ('./template/standard.opf' )
32
33
return Environment ().from_string (template ).render (
33
34
uuid = uuid ,
34
35
title = title ,
@@ -48,7 +49,7 @@ def render_navigation_documents_xhtml(
48
49
title : str ,
49
50
nav_items : List [Tuple [str , str ]],
50
51
) -> str :
51
- template = get_content_from_file ('./comicepub/ template/navigation-documents.xhtml' )
52
+ template = get_content_from_file ('./template/navigation-documents.xhtml' )
52
53
return Environment ().from_string (template ).render (
53
54
title = title ,
54
55
nav_items = nav_items ,
@@ -63,7 +64,7 @@ def render_xhtml(
63
64
view_height : int ,
64
65
cover : bool = False ,
65
66
) -> str :
66
- template = get_content_from_file ('./comicepub/ template/p.xhtml' )
67
+ template = get_content_from_file ('./template/p.xhtml' )
67
68
return Environment ().from_string (template ).render (
68
69
title = title ,
69
70
image_id = image_id ,
@@ -75,4 +76,4 @@ def render_xhtml(
75
76
76
77
77
78
def get_fixed_layout_jp_css ():
78
- return get_content_from_file ('./comicepub/ template/fixed-layout-jp.css' )
79
+ return get_content_from_file ('./template/fixed-layout-jp.css' )
0 commit comments