fix: package data file paths

This commit is contained in:
eneller
2025-01-16 13:08:57 +01:00
parent 37968f03b7
commit a51588d5e9
3 changed files with 17 additions and 7 deletions

1
.gitignore vendored
View File

@@ -418,4 +418,3 @@ wheels/
*.css
*.js
*.txt
!data/*

View File

@@ -11,3 +11,12 @@ dependencies = [
]
[project.scripts]
epub2go = "convert:main"
[tool.setuptools]
include-package-data = true
[tool.setuptools.packages.find]
where = ["src"]
[tool.setuptools.package-data]
"epub2go" = ["../data/*"]

View File

@@ -4,19 +4,21 @@ from urllib.parse import urljoin
from urllib.request import urlopen, urlparse
import os, sys
import importlib.resources as pkg_resources
from pathlib import Path
class GBConvert():
#TODO fix toc / headings
def __init__(self
, url:str
def __init__(self,
url:str,
):
self.dir_root = os.path.dirname(os.path.realpath(__file__))
self.dir_data = os.path.join(os.path.dirname(self.dir_root), "data/")
dir_root = os.path.dirname(os.path.realpath(__file__))
dir_data = os.path.join(os.path.dirname(dir_root), "data/")
self.style_path_drama = os.path.join(dir_data, "drama.css")
self.blocklist = open(os.path.join(dir_data, "blocklist.txt"), 'r').read().splitlines()
self.root = os.path.dirname(url)
self.url = urlparse(self.root)
self.output = self.url.netloc + self.url.path
self.blocklist = open(os.path.join(self.dir_data, "blocklist.txt"), 'r').read().splitlines()
def get_meta(self):
response = requests.get(self.root)
@@ -51,7 +53,7 @@ class GBConvert():
command = f'''pandoc -f html -t epub \
-o "{filename}" \
--reference-location=section \
--css="{os.path.join(self.dir_data, "drama.css")}" \
--css="{self.style_path_drama}" \
--metadata title="{self.title}" \
--metadata author="{self.author}" \
--epub-title-page=false \