Skip to content

Commit

Permalink
epub writer: do not change existing uuid info value
Browse files Browse the repository at this point in the history
  • Loading branch information
ilius committed Jan 8, 2025
1 parent 417a9ac commit ac4df1d
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions pyglossary/plugins/ebook_epub2/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
from pyglossary.glossary_types import WriterGlossaryType


def newUUID() -> str:
import uuid

return str(uuid.uuid4()).replace("-", "")


class Writer(EbookWriter):
# these class attrs are only in Epub
# MIMETYPE_CONTENTS, CONTAINER_XML_CONTENTS
Expand Down Expand Up @@ -162,17 +168,14 @@ class Writer(EbookWriter):
COVER_TEMPLATE = '<meta name="cover" content="{cover}" />'

def __init__(self, glos: WriterGlossaryType) -> None:
import uuid

idStr = os.getenv("EPUB_UUID")
if not idStr:
idStr = str(uuid.uuid4()).replace("-", "")

glos.setInfo(
"uuid",
os.getenv("EPUB_UUID") or glos.getInfo("uuid") or newUUID(),
)
EbookWriter.__init__(
self,
glos,
)
glos.setInfo("uuid", idStr)

@classmethod
def cls_get_prefix(
Expand Down

0 comments on commit ac4df1d

Please sign in to comment.