From 935908b786d8389fee6093df203942173e5d24bc Mon Sep 17 00:00:00 2001 From: Rory Hinnen Date: Sun, 31 May 2026 11:03:34 -0500 Subject: [PATCH] kinda works --- .git_ignore | 3 +- src/epubmaker/__main__.py | 603 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 605 insertions(+), 1 deletion(-) diff --git a/.git_ignore b/.git_ignore index e43b0f9..4b7f1d8 100644 --- a/.git_ignore +++ b/.git_ignore @@ -1 +1,2 @@ -.DS_Store +*.DS_Store +*__pycache__ diff --git a/src/epubmaker/__main__.py b/src/epubmaker/__main__.py index e69de29..31c0da6 100644 --- a/src/epubmaker/__main__.py +++ b/src/epubmaker/__main__.py @@ -0,0 +1,603 @@ +import sys, os, argparse +from uuid import uuid4 +from shutil import rmtree, copy +from datetime import datetime +import subprocess + + +class Name: + def __init__(self): + self.first = "" + self.last = "" + + +class Series: + def __init__(self): + self.number = "" + self.name = "" + + +class Image: + def __init__(self): + self.name = "" + self.type = "" + self.alt = "" + self.caption = "" + + +class Section: + def __init__(self): + self.type = "" + # types: + # cover + # toc + # copyright-page + # dedication + # text + # foreward + # notes + # acknowledments + # style + # title + self.name = "" + self.title = "" + self.body = "" + + +class Book: + def __init__(self): + self.filename = "" + self.title = "" + self.titlesort = "" + self.series = Series() + self.author = [] + self.artist = Name() + self.editor = Name() + self.publisher = "" + self.copyright = "" + self.subjects = "" + self.style = "" + self.directory = "" + self.isbn = "" + self.uuid = "" + self.source = "" + self.images = [] + self.sections = [] + self.cover = Image() + self.publishDate = "" + + +def extract(line): + if line.startswith("\n' + else: + imageCode = '
\n' + imageCode += ' ' + image.alt + '\n' + imageCode += ' \n' + imageCode += '

' + image.caption + '

\n' + imageCode += '
\n
\n' + book.sections[-1].body += imageCode + case _: + pass + + +def findStyle(line): + global book + stylesheetFile = line.split(' ')[2].split('=')[1].replace('"','').replace('>','').strip() + contents = "" + with open(stylesheetFile) as file: + for line in file: + if line != '' and not line.strip().startswith("/*"): + contents += line + book.style = contents + print("found style") + + + +def parseBook(): + global book, inSection + filename = book.filename + if verbose: + print("Parsing {}".format(filename)) + with open(filename) as source: + for line in source: + if line.startswith('