Skip to content

Commit 2791264

Browse files
committed
fix relative path import
1 parent 57355b8 commit 2791264

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

comicepub/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .comicepub import ComicEpub

comicepub/comicepub.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
import uuid
44
import datetime
55
from typing import Tuple, List
6-
from comicepub.render import render_mimetype
7-
from comicepub.render import render_container_xml
8-
from comicepub.render import render_navigation_documents_xhtml
9-
from comicepub.render import render_standard_opf
10-
from comicepub.render import render_xhtml
11-
from comicepub.render import get_fixed_layout_jp_css
126
from mimetypes import MimeTypes
7+
from .render import render_mimetype
8+
from .render import render_container_xml
9+
from .render import render_navigation_documents_xhtml
10+
from .render import render_standard_opf
11+
from .render import render_xhtml
12+
from .render import get_fixed_layout_jp_css
1313

1414

1515
class ComicEpub:

comicepub/render.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1+
import os
12
from jinja2 import Environment
23
from typing import List, Tuple
34

45

56
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:
78
return f.read()
89

910

1011
def render_mimetype():
11-
return get_content_from_file('./comicepub/template/mimetype')
12+
return get_content_from_file('./template/mimetype')
1213

1314

1415
def render_container_xml():
15-
return get_content_from_file('./comicepub/template/container.xml')
16+
return get_content_from_file('./template/container.xml')
1617

1718

1819
def render_standard_opf(
@@ -28,7 +29,7 @@ def render_standard_opf(
2829
manifest_xhtmls: List[Tuple[str, str]],
2930
manifest_spines: List[str],
3031
) -> str:
31-
template = get_content_from_file('./comicepub/template/standard.opf')
32+
template = get_content_from_file('./template/standard.opf')
3233
return Environment().from_string(template).render(
3334
uuid=uuid,
3435
title=title,
@@ -48,7 +49,7 @@ def render_navigation_documents_xhtml(
4849
title: str,
4950
nav_items: List[Tuple[str, str]],
5051
) -> str:
51-
template = get_content_from_file('./comicepub/template/navigation-documents.xhtml')
52+
template = get_content_from_file('./template/navigation-documents.xhtml')
5253
return Environment().from_string(template).render(
5354
title=title,
5455
nav_items=nav_items,
@@ -63,7 +64,7 @@ def render_xhtml(
6364
view_height: int,
6465
cover: bool = False,
6566
) -> str:
66-
template = get_content_from_file('./comicepub/template/p.xhtml')
67+
template = get_content_from_file('./template/p.xhtml')
6768
return Environment().from_string(template).render(
6869
title=title,
6970
image_id=image_id,
@@ -75,4 +76,4 @@ def render_xhtml(
7576

7677

7778
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

Comments
 (0)