Skip to content

Commit

Permalink
feat: add metadata for reproducible generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Rotzbua authored and florianfesti committed Apr 4, 2024
1 parent b4517a9 commit 4910862
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions boxes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ def __init__(self) -> None:
"cli": "",
"cli_short": "",
"creation_date": datetime.datetime.now(),
"reproducible": False, # If True output does not contain variable content like creation date.
}

# Dummy attribute for static analytic tools. Will be overwritten by `argparser` at runtime.
Expand Down
9 changes: 6 additions & 3 deletions boxes/drawing.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,8 @@ def _add_metadata(self, root) -> None:
w.text = '\n'

self._addTag(w, 'dc:title', title)
self._addTag(w, 'dc:date', creation_date)
if not md["reproducible"]:
self._addTag(w, 'dc:date', creation_date)

if "url" in md and md["url"]:
self._addTag(w, 'dc:source', md["url"])
Expand Down Expand Up @@ -472,7 +473,8 @@ def _add_metadata(self, root) -> None:
if md["description"]:
txt += """\n\n{description}\n\n""".format(**md)
txt += """\nCreated with Boxes.py (https://festi.info/boxes.py)\n"""
txt += f"""Creation date: {creation_date}\n"""
if not md["reproducible"]:
txt += f"""Creation date: {creation_date}\n"""

txt += "Command line (remove spaces between dashes): %s\n" % md["cli_short"]

Expand Down Expand Up @@ -612,7 +614,8 @@ def _metadata(self) -> str:

desc = ""
desc += "%%Title: Boxes.py - {group} - {name}\n".format(**md)
desc += f'%%CreationDate: {md["creation_date"].strftime("%Y-%m-%d %H:%M:%S")}\n'
if not md["reproducible"]:
desc += f'%%CreationDate: {md["creation_date"].strftime("%Y-%m-%d %H:%M:%S")}\n'
desc += f'%%Keywords: boxes.py, laser, laser cutter\n'
desc += f'%%Creator: {md.get("url") or md["cli"]}\n'
desc += "%%CreatedBy: Boxes.py (https://festi.info/boxes.py)\n"
Expand Down

0 comments on commit 4910862

Please sign in to comment.