Packe jeden Vorgangseintrag im Übergabe-ZIP in einen eigenen Titelordner.
Hauptdatei, Anlagen und Belege liegen darin zusammen; der Exportname folgt dem angezeigten Titel mit Original-Endung. E-Mails behalten ihren bestehenden Ordner, ohne doppelte Titel-Ebene für Korrespondenz. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
2b23992a1a
commit
8b74e63417
2 files changed
+29
-15
No files matched your search
@@ -588,18 +588,20 @@ def _emit_email(node, folder, add, rewrite, entries, loaded, notice_for, generat
|
||||
|
||||
|
||||
def _emit_loose(node, prefix, add, entries, loaded, notice_for, generated: str, chosen: set[str]) -> None:
|
||||
bundle = _binding_bundle(prefix, node) if node.kind == "binding" else prefix
|
||||
if node.kind == "binding" and node.id in loaded and node.content_kind != "email":
|
||||
payload = loaded[node.id]
|
||||
if node.content_kind == "note":
|
||||
path = add(prefix + [f"{_segment(node.title)}.md"], _note_markdown(node, str(payload), generated).encode("utf-8"))
|
||||
path = add(bundle + [f"{_segment(node.title)}.md"], _note_markdown(node, str(payload), generated).encode("utf-8"))
|
||||
entries.append(_entry(node, path, [], None))
|
||||
elif isinstance(payload, FilePayload):
|
||||
path = add(prefix + [payload.filename], payload.data)
|
||||
entries.append(_entry(node, path, [(payload.filename, path)], None))
|
||||
name = _handover_filename(node, payload.filename)
|
||||
path = add(bundle + [name], payload.data)
|
||||
entries.append(_entry(node, path, [(name, path)], None))
|
||||
if node.kind == "binding":
|
||||
for child in node.children:
|
||||
if child.kind == "annotation" and child.id in loaded and not (node.content_kind == "email" and node.id in loaded):
|
||||
path = add(prefix + [_annotation_filename(child, prefix)], _annotation_markdown(child).encode("utf-8"))
|
||||
path = add(bundle + [_annotation_filename(child, bundle)], _annotation_markdown(child).encode("utf-8"))
|
||||
entries.append(_entry(child, path, [], None))
|
||||
elif node.kind == "annotation" and node.id in loaded:
|
||||
path = add(prefix + [_annotation_filename(node, prefix)], _annotation_markdown(node).encode("utf-8"))
|
||||
@@ -608,9 +610,22 @@ def _emit_loose(node, prefix, add, entries, loaded, notice_for, generated: str,
|
||||
_emit_related(node, prefix, add, entries, loaded, notice_for, chosen, generated)
|
||||
|
||||
|
||||
def _host_bundle(prefix: list[str], host: ExportNode) -> list[str]:
|
||||
"""Correspondence files stay under the host title, not a shared chapter folder."""
|
||||
return prefix + [_segment(host.title)]
|
||||
def _binding_bundle(prefix: list[str], host: ExportNode) -> list[str]:
|
||||
"""One folder per entry; the main file and correspondence sit inside it."""
|
||||
if host.kind == "binding" and host.content_kind == "email":
|
||||
return list(prefix)
|
||||
if host.kind == "binding":
|
||||
return [*prefix, _segment(host.title)]
|
||||
return list(prefix)
|
||||
|
||||
|
||||
def _handover_filename(node: ExportNode, original: str) -> str:
|
||||
"""Readable name for recipients; file bytes stay unchanged."""
|
||||
stem = _segment(node.title)
|
||||
suffix = PurePosixPath(original or "").suffix
|
||||
if suffix:
|
||||
return f"{stem}{suffix}"
|
||||
return stem or _file_segment(original)
|
||||
|
||||
|
||||
def _related_bucket(node: ExportNode) -> str:
|
||||
@@ -627,7 +642,7 @@ def _related_bucket(node: ExportNode) -> str:
|
||||
|
||||
|
||||
def _emit_related(node, prefix, add, entries, loaded, notice_for, chosen, generated: str) -> None:
|
||||
bundle = _host_bundle(prefix, node)
|
||||
bundle = _binding_bundle(prefix, node)
|
||||
for child in node.children:
|
||||
if child.kind == "attachment" and child.id in chosen and child.id in loaded:
|
||||
_emit_one(child, bundle + ["Anlagen"], add, entries, loaded, notice_for, generated)
|
||||
|
||||
Reference in new issue
Block a user