dsh-office-kit 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/assets/skills/office-documents/render_docx.py +7 -0
  2. package/assets/skills/office-documents/scripts/a11y_audit.py +7 -0
  3. package/assets/skills/office-documents/scripts/accept_tracked_changes.py +7 -0
  4. package/assets/skills/office-documents/scripts/add_tracked_replacements.py +7 -0
  5. package/assets/skills/office-documents/scripts/append_blocks.py +7 -0
  6. package/assets/skills/office-documents/scripts/apply_template_styles.py +7 -0
  7. package/assets/skills/office-documents/scripts/captions_and_crossrefs.py +7 -0
  8. package/assets/skills/office-documents/scripts/comments_add.py +7 -0
  9. package/assets/skills/office-documents/scripts/comments_apply_patch.py +7 -0
  10. package/assets/skills/office-documents/scripts/comments_extract.py +7 -0
  11. package/assets/skills/office-documents/scripts/comments_strip.py +7 -0
  12. package/assets/skills/office-documents/scripts/content_controls.py +7 -0
  13. package/assets/skills/office-documents/scripts/core_properties.py +7 -0
  14. package/assets/skills/office-documents/scripts/docx_kit.py +7 -0
  15. package/assets/skills/office-documents/scripts/docx_ooxml_patch.py +7 -0
  16. package/assets/skills/office-documents/scripts/docx_table_to_csv.py +7 -0
  17. package/assets/skills/office-documents/scripts/fields_materialize.py +7 -0
  18. package/assets/skills/office-documents/scripts/fields_report.py +7 -0
  19. package/assets/skills/office-documents/scripts/flatten_ref_fields.py +7 -0
  20. package/assets/skills/office-documents/scripts/footnotes_report.py +7 -0
  21. package/assets/skills/office-documents/scripts/google_docs_title_sanitize.py +7 -0
  22. package/assets/skills/office-documents/scripts/heading_audit.py +7 -0
  23. package/assets/skills/office-documents/scripts/images_audit.py +7 -0
  24. package/assets/skills/office-documents/scripts/insert_note.py +7 -0
  25. package/assets/skills/office-documents/scripts/insert_ref_fields.py +7 -0
  26. package/assets/skills/office-documents/scripts/insert_toc.py +7 -0
  27. package/assets/skills/office-documents/scripts/internal_nav.py +7 -0
  28. package/assets/skills/office-documents/scripts/make_fixtures.py +7 -0
  29. package/assets/skills/office-documents/scripts/merge_docx_append.py +7 -0
  30. package/assets/skills/office-documents/scripts/privacy_scrub.py +7 -0
  31. package/assets/skills/office-documents/scripts/redact_docx.py +7 -0
  32. package/assets/skills/office-documents/scripts/render_and_diff.py +7 -0
  33. package/assets/skills/office-documents/scripts/replace_text.py +7 -0
  34. package/assets/skills/office-documents/scripts/section_audit.py +7 -0
  35. package/assets/skills/office-documents/scripts/set_protection.py +7 -0
  36. package/assets/skills/office-documents/scripts/style_lint.py +7 -0
  37. package/assets/skills/office-documents/scripts/style_normalize.py +7 -0
  38. package/assets/skills/office-documents/scripts/table_geometry.py +7 -0
  39. package/assets/skills/office-documents/scripts/watermark_add.py +7 -0
  40. package/assets/skills/office-documents/scripts/watermark_audit_remove.py +7 -0
  41. package/assets/skills/office-documents/scripts/xlsx_to_docx_table.py +7 -0
  42. package/assets/skills/office-presentations/container_tools/add_slides.py +7 -0
  43. package/assets/skills/office-presentations/container_tools/core_properties.py +7 -0
  44. package/assets/skills/office-presentations/container_tools/create_montage.py +7 -0
  45. package/assets/skills/office-presentations/container_tools/inspect_presentation_layout_geometry.py +7 -0
  46. package/assets/skills/office-presentations/container_tools/inspect_presentation_package_integrity.py +7 -0
  47. package/assets/skills/office-presentations/container_tools/native_chart_title_gate.py +7 -0
  48. package/assets/skills/office-presentations/container_tools/native_quantitative_chart_gate.py +7 -0
  49. package/assets/skills/office-presentations/container_tools/native_table_arithmetic_gate.py +7 -0
  50. package/assets/skills/office-presentations/container_tools/ooxml_helpers.py +7 -0
  51. package/assets/skills/office-presentations/container_tools/preview_render.py +7 -0
  52. package/assets/skills/office-presentations/container_tools/render_slides.py +7 -0
  53. package/assets/skills/office-presentations/container_tools/replace_text.py +7 -0
  54. package/assets/skills/office-presentations/container_tools/template_source_fidelity_gate.py +7 -0
  55. package/assets/skills/office-presentations/template_following_scripts/check_template_fidelity.py +7 -0
  56. package/assets/skills/office-presentations/template_following_scripts/inspect_template_deck.py +7 -0
  57. package/assets/skills/office-presentations/template_following_scripts/make_contact_sheet.py +7 -0
  58. package/assets/skills/office-presentations/template_following_scripts/prepare_template_starter_deck.py +7 -0
  59. package/assets/skills/office-presentations/template_following_scripts/validate_template_plan.py +7 -0
  60. package/assets/skills/office-spreadsheets/container_tools/add_chart.py +7 -0
  61. package/assets/skills/office-spreadsheets/container_tools/add_image.py +7 -0
  62. package/assets/skills/office-spreadsheets/container_tools/append_rows.py +7 -0
  63. package/assets/skills/office-spreadsheets/container_tools/diff_workbooks.py +7 -0
  64. package/assets/skills/office-spreadsheets/container_tools/inspect_workbook.py +7 -0
  65. package/assets/skills/office-spreadsheets/container_tools/recalc_gate.py +19 -7
  66. package/assets/skills/office-spreadsheets/container_tools/set_cells.py +7 -0
  67. package/assets/skills/office-spreadsheets/container_tools/sheet_ops.py +7 -0
  68. package/assets/skills/office-spreadsheets/container_tools/style_cells.py +7 -0
  69. package/assets/skills/shared/check_runtime.py +7 -0
  70. package/dist/index.js +14 -7
  71. package/package.json +1 -1
  72. package/python/office_cli.py +42 -8
@@ -21,6 +21,13 @@ from pathlib import Path
21
21
  sys.path.insert(0, str(Path(__file__).resolve().parent / "scripts"))
22
22
  import docx_kit as kit
23
23
 
24
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
25
+ for _stream in (sys.stdout, sys.stderr):
26
+ try:
27
+ _stream.reconfigure(encoding="utf-8", errors="replace")
28
+ except (AttributeError, ValueError):
29
+ pass
30
+
24
31
 
25
32
  def resize(path: Path, width: int | None, height: int | None) -> None:
26
33
  try:
@@ -19,6 +19,13 @@ from pathlib import Path
19
19
  sys.path.insert(0, str(Path(__file__).resolve().parent))
20
20
  import docx_kit as kit
21
21
 
22
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
23
+ for _stream in (sys.stdout, sys.stderr):
24
+ try:
25
+ _stream.reconfigure(encoding="utf-8", errors="replace")
26
+ except (AttributeError, ValueError):
27
+ pass
28
+
22
29
  GENERIC_LINK_TEXT = {"click here", "here", "link", "this link", "read more"}
23
30
  DETAIL_PARTS = ("word/document.xml", "word/header1.xml", "word/footer1.xml")
24
31
 
@@ -19,6 +19,13 @@ from pathlib import Path
19
19
  sys.path.insert(0, str(Path(__file__).resolve().parent))
20
20
  import docx_kit as kit
21
21
 
22
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
23
+ for _stream in (sys.stdout, sys.stderr):
24
+ try:
25
+ _stream.reconfigure(encoding="utf-8", errors="replace")
26
+ except (AttributeError, ValueError):
27
+ pass
28
+
22
29
  REVISION_TAGS = {
23
30
  "ins": "insertion",
24
31
  "del": "deletion",
@@ -23,6 +23,13 @@ from lxml import etree
23
23
  sys.path.insert(0, str(Path(__file__).resolve().parent))
24
24
  import docx_kit as kit
25
25
 
26
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
27
+ for _stream in (sys.stdout, sys.stderr):
28
+ try:
29
+ _stream.reconfigure(encoding="utf-8", errors="replace")
30
+ except (AttributeError, ValueError):
31
+ pass
32
+
26
33
 
27
34
  def split_pair(raw: str) -> tuple[str, str]:
28
35
  if "=" not in raw:
@@ -27,6 +27,13 @@ sys.path.insert(0, str(Path(__file__).resolve().parent))
27
27
 
28
28
  import docx_kit as kit # noqa: E402
29
29
 
30
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
31
+ for _stream in (sys.stdout, sys.stderr):
32
+ try:
33
+ _stream.reconfigure(encoding="utf-8", errors="replace")
34
+ except (AttributeError, ValueError):
35
+ pass
36
+
30
37
  COUNTER_KEYS = ("headings", "paragraphs", "list_items", "tables", "images", "equations", "equation_fallbacks")
31
38
 
32
39
 
@@ -22,6 +22,13 @@ from lxml import etree
22
22
  sys.path.insert(0, str(Path(__file__).resolve().parent))
23
23
  import docx_kit as kit
24
24
 
25
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
26
+ for _stream in (sys.stdout, sys.stderr):
27
+ try:
28
+ _stream.reconfigure(encoding="utf-8", errors="replace")
29
+ except (AttributeError, ValueError):
30
+ pass
31
+
25
32
 
26
33
  def load_xml(path: Path, part: str):
27
34
  with zipfile.ZipFile(path) as zf:
@@ -21,6 +21,13 @@ from lxml import etree
21
21
  sys.path.insert(0, str(Path(__file__).resolve().parent))
22
22
  import docx_kit as kit
23
23
 
24
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
25
+ for _stream in (sys.stdout, sys.stderr):
26
+ try:
27
+ _stream.reconfigure(encoding="utf-8", errors="replace")
28
+ except (AttributeError, ValueError):
29
+ pass
30
+
24
31
  CAPTION_LABEL = {"table": "Table", "figure": "Figure"}
25
32
 
26
33
 
@@ -22,6 +22,13 @@ from lxml import etree
22
22
  sys.path.insert(0, str(Path(__file__).resolve().parent))
23
23
  import docx_kit as kit
24
24
 
25
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
26
+ for _stream in (sys.stdout, sys.stderr):
27
+ try:
28
+ _stream.reconfigure(encoding="utf-8", errors="replace")
29
+ except (AttributeError, ValueError):
30
+ pass
31
+
25
32
 
26
33
  def comments_root(doc: kit.Docx):
27
34
  if not doc.exists("word/comments.xml"):
@@ -26,6 +26,13 @@ from lxml import etree
26
26
  sys.path.insert(0, str(Path(__file__).resolve().parent))
27
27
  import docx_kit as kit
28
28
 
29
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
30
+ for _stream in (sys.stdout, sys.stderr):
31
+ try:
32
+ _stream.reconfigure(encoding="utf-8", errors="replace")
33
+ except (AttributeError, ValueError):
34
+ pass
35
+
29
36
 
30
37
  def set_body(comment, text: str) -> None:
31
38
  paragraphs = comment.findall(kit.q("p"))
@@ -17,6 +17,13 @@ from pathlib import Path
17
17
  sys.path.insert(0, str(Path(__file__).resolve().parent))
18
18
  import docx_kit as kit
19
19
 
20
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
21
+ for _stream in (sys.stdout, sys.stderr):
22
+ try:
23
+ _stream.reconfigure(encoding="utf-8", errors="replace")
24
+ except (AttributeError, ValueError):
25
+ pass
26
+
20
27
 
21
28
  def anchor_map(doc: kit.Docx) -> dict[str, dict]:
22
29
  found: dict[str, dict] = {}
@@ -17,6 +17,13 @@ from pathlib import Path
17
17
  sys.path.insert(0, str(Path(__file__).resolve().parent))
18
18
  import docx_kit as kit
19
19
 
20
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
21
+ for _stream in (sys.stdout, sys.stderr):
22
+ try:
23
+ _stream.reconfigure(encoding="utf-8", errors="replace")
24
+ except (AttributeError, ValueError):
25
+ pass
26
+
20
27
  MARKERS = ("commentRangeStart", "commentRangeEnd", "commentReference")
21
28
 
22
29
 
@@ -20,6 +20,13 @@ from lxml import etree
20
20
  sys.path.insert(0, str(Path(__file__).resolve().parent))
21
21
  import docx_kit as kit
22
22
 
23
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
24
+ for _stream in (sys.stdout, sys.stderr):
25
+ try:
26
+ _stream.reconfigure(encoding="utf-8", errors="replace")
27
+ except (AttributeError, ValueError):
28
+ pass
29
+
23
30
  TYPE_TAGS = ("text", "richText", "date", "dropDownList", "comboBox", "picture", "checkbox")
24
31
  CONTAINER_TAGS = ("docPartObj", "group", "citation", "bibliography")
25
32
 
@@ -27,6 +27,13 @@ sys.path.insert(0, str(Path(__file__).resolve().parent))
27
27
 
28
28
  import docx_kit as kit # noqa: E402
29
29
 
30
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
31
+ for _stream in (sys.stdout, sys.stderr):
32
+ try:
33
+ _stream.reconfigure(encoding="utf-8", errors="replace")
34
+ except (AttributeError, ValueError):
35
+ pass
36
+
30
37
  TEXT_FIELDS = (
31
38
  "title",
32
39
  "author",
@@ -29,6 +29,13 @@ from pathlib import Path
29
29
 
30
30
  from lxml import etree
31
31
 
32
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
33
+ for _stream in (sys.stdout, sys.stderr):
34
+ try:
35
+ _stream.reconfigure(encoding="utf-8", errors="replace")
36
+ except (AttributeError, ValueError):
37
+ pass
38
+
32
39
  W = "http://schemas.openxmlformats.org/wordprocessingml/2006/main"
33
40
  R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships"
34
41
  A = "http://schemas.openxmlformats.org/drawingml/2006/main"
@@ -26,6 +26,13 @@ from lxml import etree
26
26
  sys.path.insert(0, str(Path(__file__).resolve().parent))
27
27
  import docx_kit as kit
28
28
 
29
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
30
+ for _stream in (sys.stdout, sys.stderr):
31
+ try:
32
+ _stream.reconfigure(encoding="utf-8", errors="replace")
33
+ except (AttributeError, ValueError):
34
+ pass
35
+
29
36
  PKG_REL = "{http://schemas.openxmlformats.org/package/2006/relationships}"
30
37
  REL_HYPERLINK = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"
31
38
 
@@ -19,6 +19,13 @@ from pathlib import Path
19
19
  sys.path.insert(0, str(Path(__file__).resolve().parent))
20
20
  import docx_kit as kit
21
21
 
22
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
23
+ for _stream in (sys.stdout, sys.stderr):
24
+ try:
25
+ _stream.reconfigure(encoding="utf-8", errors="replace")
26
+ except (AttributeError, ValueError):
27
+ pass
28
+
22
29
 
23
30
  def cell_span(cell) -> int:
24
31
  props = cell.find(kit.q("tcPr"))
@@ -19,6 +19,13 @@ from lxml import etree
19
19
  sys.path.insert(0, str(Path(__file__).resolve().parent))
20
20
  import docx_kit as kit
21
21
 
22
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
23
+ for _stream in (sys.stdout, sys.stderr):
24
+ try:
25
+ _stream.reconfigure(encoding="utf-8", errors="replace")
26
+ except (AttributeError, ValueError):
27
+ pass
28
+
22
29
 
23
30
  def freeze(doc: kit.Docx, allowed: set[str]) -> int:
24
31
  flattened = 0
@@ -18,6 +18,13 @@ from pathlib import Path
18
18
  sys.path.insert(0, str(Path(__file__).resolve().parent))
19
19
  import docx_kit as kit
20
20
 
21
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
22
+ for _stream in (sys.stdout, sys.stderr):
23
+ try:
24
+ _stream.reconfigure(encoding="utf-8", errors="replace")
25
+ except (AttributeError, ValueError):
26
+ pass
27
+
21
28
 
22
29
  def main(argv: list[str] | None = None) -> int:
23
30
  parser = argparse.ArgumentParser(description="Report Word fields (TOC, SEQ, REF, PAGEREF, HYPERLINK, ...) in a .docx.")
@@ -19,6 +19,13 @@ from lxml import etree
19
19
  sys.path.insert(0, str(Path(__file__).resolve().parent))
20
20
  import docx_kit as kit
21
21
 
22
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
23
+ for _stream in (sys.stdout, sys.stderr):
24
+ try:
25
+ _stream.reconfigure(encoding="utf-8", errors="replace")
26
+ except (AttributeError, ValueError):
27
+ pass
28
+
22
29
  TARGETS = {"REF", "PAGEREF"}
23
30
 
24
31
 
@@ -18,6 +18,13 @@ from pathlib import Path
18
18
  sys.path.insert(0, str(Path(__file__).resolve().parent))
19
19
  import docx_kit as kit
20
20
 
21
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
22
+ for _stream in (sys.stdout, sys.stderr):
23
+ try:
24
+ _stream.reconfigure(encoding="utf-8", errors="replace")
25
+ except (AttributeError, ValueError):
26
+ pass
27
+
21
28
  PARTS = {"footnote": "word/footnotes.xml", "endnote": "word/endnotes.xml"}
22
29
  SEPARATOR_TYPES = {"separator", "continuationSeparator", "continuationNotice"}
23
30
 
@@ -18,6 +18,13 @@ from pathlib import Path
18
18
  sys.path.insert(0, str(Path(__file__).resolve().parent))
19
19
  import docx_kit as kit
20
20
 
21
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
22
+ for _stream in (sys.stdout, sys.stderr):
23
+ try:
24
+ _stream.reconfigure(encoding="utf-8", errors="replace")
25
+ except (AttributeError, ValueError):
26
+ pass
27
+
21
28
 
22
29
  def leading_region(body, limit: int) -> list:
23
30
  seen = 0
@@ -17,6 +17,13 @@ from pathlib import Path
17
17
  sys.path.insert(0, str(Path(__file__).resolve().parent))
18
18
  import docx_kit as kit
19
19
 
20
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
21
+ for _stream in (sys.stdout, sys.stderr):
22
+ try:
23
+ _stream.reconfigure(encoding="utf-8", errors="replace")
24
+ except (AttributeError, ValueError):
25
+ pass
26
+
20
27
  BOLD_LIKE = ("Heading", "Title")
21
28
  HEADING_SIZE_HALF_POINTS = 26 # 13pt: larger than any body style should be
22
29
 
@@ -20,6 +20,13 @@ from lxml import etree
20
20
  sys.path.insert(0, str(Path(__file__).resolve().parent))
21
21
  import docx_kit as kit
22
22
 
23
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
24
+ for _stream in (sys.stdout, sys.stderr):
25
+ try:
26
+ _stream.reconfigure(encoding="utf-8", errors="replace")
27
+ except (AttributeError, ValueError):
28
+ pass
29
+
23
30
  EMU_PER_INCH = 914400
24
31
  MAX_WIDTH_INCHES = 8.0
25
32
 
@@ -20,6 +20,13 @@ from lxml import etree
20
20
  sys.path.insert(0, str(Path(__file__).resolve().parent))
21
21
  import docx_kit as kit
22
22
 
23
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
24
+ for _stream in (sys.stdout, sys.stderr):
25
+ try:
26
+ _stream.reconfigure(encoding="utf-8", errors="replace")
27
+ except (AttributeError, ValueError):
28
+ pass
29
+
23
30
  PARTS = {"footnote": ("word/footnotes.xml", "footnotes", "footnote", kit.REL_FOOTNOTES), "endnote": ("word/endnotes.xml", "endnotes", "endnote", kit.REL_ENDNOTES)}
24
31
 
25
32
 
@@ -22,6 +22,13 @@ from lxml import etree
22
22
  sys.path.insert(0, str(Path(__file__).resolve().parent))
23
23
  import docx_kit as kit
24
24
 
25
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
26
+ for _stream in (sys.stdout, sys.stderr):
27
+ try:
28
+ _stream.reconfigure(encoding="utf-8", errors="replace")
29
+ except (AttributeError, ValueError):
30
+ pass
31
+
25
32
 
26
33
  def rebuild(paragraph, pattern: re.Pattern, prefix: str) -> int:
27
34
  text = kit.paragraph_text(paragraph)
@@ -20,6 +20,13 @@ from lxml import etree
20
20
  sys.path.insert(0, str(Path(__file__).resolve().parent))
21
21
  import docx_kit as kit
22
22
 
23
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
24
+ for _stream in (sys.stdout, sys.stderr):
25
+ try:
26
+ _stream.reconfigure(encoding="utf-8", errors="replace")
27
+ except (AttributeError, ValueError):
28
+ pass
29
+
23
30
 
24
31
  def level_range(raw: str) -> str:
25
32
  cleaned = raw.replace(" ", "")
@@ -21,6 +21,13 @@ from lxml import etree
21
21
  sys.path.insert(0, str(Path(__file__).resolve().parent))
22
22
  import docx_kit as kit
23
23
 
24
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
25
+ for _stream in (sys.stdout, sys.stderr):
26
+ try:
27
+ _stream.reconfigure(encoding="utf-8", errors="replace")
28
+ except (AttributeError, ValueError):
29
+ pass
30
+
24
31
  TOP_BOOKMARK = "nav_top"
25
32
  BOTTOM_BOOKMARK = "nav_bottom"
26
33
  TOC_BOOKMARK = "nav_toc"
@@ -24,6 +24,13 @@ import docx_kit as kit
24
24
  from docx import Document
25
25
  from docx.shared import Inches
26
26
 
27
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
28
+ for _stream in (sys.stdout, sys.stderr):
29
+ try:
30
+ _stream.reconfigure(encoding="utf-8", errors="replace")
31
+ except (AttributeError, ValueError):
32
+ pass
33
+
27
34
 
28
35
  def base_document(title: str, paragraphs: list[str]) -> Document:
29
36
  document = Document()
@@ -24,6 +24,13 @@ from lxml import etree
24
24
  sys.path.insert(0, str(Path(__file__).resolve().parent))
25
25
  import docx_kit as kit
26
26
 
27
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
28
+ for _stream in (sys.stdout, sys.stderr):
29
+ try:
30
+ _stream.reconfigure(encoding="utf-8", errors="replace")
31
+ except (AttributeError, ValueError):
32
+ pass
33
+
27
34
  CT = "{http://schemas.openxmlformats.org/package/2006/content-types}"
28
35
  W_NS = "{http://schemas.openxmlformats.org/package/2006/relationships}"
29
36
  REL_NUMBERING = kit.REL_NUMBERING
@@ -19,6 +19,13 @@ from lxml import etree
19
19
  sys.path.insert(0, str(Path(__file__).resolve().parent))
20
20
  import docx_kit as kit
21
21
 
22
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
23
+ for _stream in (sys.stdout, sys.stderr):
24
+ try:
25
+ _stream.reconfigure(encoding="utf-8", errors="replace")
26
+ except (AttributeError, ValueError):
27
+ pass
28
+
22
29
  DC = "http://purl.org/dc/elements/1.1/"
23
30
  CP = "http://schemas.openxmlformats.org/package/2006/metadata/core-properties"
24
31
  DCTERMS = "http://purl.org/dc/terms/"
@@ -19,6 +19,13 @@ from pathlib import Path
19
19
  sys.path.insert(0, str(Path(__file__).resolve().parent))
20
20
  import docx_kit as kit
21
21
 
22
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
23
+ for _stream in (sys.stdout, sys.stderr):
24
+ try:
25
+ _stream.reconfigure(encoding="utf-8", errors="replace")
26
+ except (AttributeError, ValueError):
27
+ pass
28
+
22
29
  EMAIL = re.compile(r"[A-Za-z0-9._%+\-]+@[A-Za-z0-9.\-]+\.[A-Za-z]{2,}")
23
30
  PHONE = re.compile(r"(?<!\d)(?:\+\d{1,3}[\s.\-]?)?(?:\(\d{2,4}\)[\s.\-]?)?\d{2,4}[\s.\-]\d{3,4}(?:[\s.\-]\d{3,4})?(?!\d)")
24
31
 
@@ -17,6 +17,13 @@ from pathlib import Path
17
17
  sys.path.insert(0, str(Path(__file__).resolve().parent))
18
18
  import docx_kit as kit
19
19
 
20
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
21
+ for _stream in (sys.stdout, sys.stderr):
22
+ try:
23
+ _stream.reconfigure(encoding="utf-8", errors="replace")
24
+ except (AttributeError, ValueError):
25
+ pass
26
+
20
27
  THRESHOLD = 8
21
28
 
22
29
 
@@ -27,6 +27,13 @@ sys.path.insert(0, str(Path(__file__).resolve().parent))
27
27
 
28
28
  import docx_kit as kit # noqa: E402
29
29
 
30
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
31
+ for _stream in (sys.stdout, sys.stderr):
32
+ try:
33
+ _stream.reconfigure(encoding="utf-8", errors="replace")
34
+ except (AttributeError, ValueError):
35
+ pass
36
+
30
37
 
31
38
  def paragraph_text_nodes(paragraph) -> list:
32
39
  """Every w:t below a paragraph, including runs inside hyperlinks."""
@@ -18,6 +18,13 @@ from pathlib import Path
18
18
  sys.path.insert(0, str(Path(__file__).resolve().parent))
19
19
  import docx_kit as kit
20
20
 
21
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
22
+ for _stream in (sys.stdout, sys.stderr):
23
+ try:
24
+ _stream.reconfigure(encoding="utf-8", errors="replace")
25
+ except (AttributeError, ValueError):
26
+ pass
27
+
21
28
  TWIPS_PER_INCH = 1440
22
29
 
23
30
 
@@ -20,6 +20,13 @@ from lxml import etree
20
20
  sys.path.insert(0, str(Path(__file__).resolve().parent))
21
21
  import docx_kit as kit
22
22
 
23
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
24
+ for _stream in (sys.stdout, sys.stderr):
25
+ try:
26
+ _stream.reconfigure(encoding="utf-8", errors="replace")
27
+ except (AttributeError, ValueError):
28
+ pass
29
+
23
30
  MODES = {
24
31
  "off": None,
25
32
  "none": None,
@@ -19,6 +19,13 @@ from pathlib import Path
19
19
  sys.path.insert(0, str(Path(__file__).resolve().parent))
20
20
  import docx_kit as kit
21
21
 
22
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
23
+ for _stream in (sys.stdout, sys.stderr):
24
+ try:
25
+ _stream.reconfigure(encoding="utf-8", errors="replace")
26
+ except (AttributeError, ValueError):
27
+ pass
28
+
22
29
  MAX_FINDINGS = 50
23
30
  BULLET_TEXT = ("\u2022", "- ", "* ")
24
31
 
@@ -24,6 +24,13 @@ from lxml import etree
24
24
  sys.path.insert(0, str(Path(__file__).resolve().parent))
25
25
  import docx_kit as kit
26
26
 
27
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
28
+ for _stream in (sys.stdout, sys.stderr):
29
+ try:
30
+ _stream.reconfigure(encoding="utf-8", errors="replace")
31
+ except (AttributeError, ValueError):
32
+ pass
33
+
27
34
  HEADING_SPACING = {1: (320, 120), 2: (240, 80), 3: (200, 60)}
28
35
  KEEP_RUN_PROPS = {kit.q("rStyle"), kit.q("rtl"), kit.q("lang")}
29
36
 
@@ -20,6 +20,13 @@ from lxml import etree
20
20
  sys.path.insert(0, str(Path(__file__).resolve().parent))
21
21
  import docx_kit as kit
22
22
 
23
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
24
+ for _stream in (sys.stdout, sys.stderr):
25
+ try:
26
+ _stream.reconfigure(encoding="utf-8", errors="replace")
27
+ except (AttributeError, ValueError):
28
+ pass
29
+
23
30
 
24
31
  def text_width_twips(doc: kit.Docx) -> int:
25
32
  sections = doc.sections()
@@ -17,6 +17,13 @@ from pathlib import Path
17
17
  sys.path.insert(0, str(Path(__file__).resolve().parent))
18
18
  import docx_kit as kit
19
19
 
20
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
21
+ for _stream in (sys.stdout, sys.stderr):
22
+ try:
23
+ _stream.reconfigure(encoding="utf-8", errors="replace")
24
+ except (AttributeError, ValueError):
25
+ pass
26
+
20
27
 
21
28
  def main(argv: list[str] | None = None) -> int:
22
29
  parser = argparse.ArgumentParser(description="Add a VML text watermark to the document header.")
@@ -16,6 +16,13 @@ from pathlib import Path
16
16
  sys.path.insert(0, str(Path(__file__).resolve().parent))
17
17
  import docx_kit as kit
18
18
 
19
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
20
+ for _stream in (sys.stdout, sys.stderr):
21
+ try:
22
+ _stream.reconfigure(encoding="utf-8", errors="replace")
23
+ except (AttributeError, ValueError):
24
+ pass
25
+
19
26
 
20
27
  def main(argv: list[str] | None = None) -> int:
21
28
  parser = argparse.ArgumentParser(description="Report or remove watermarks stored as VML shapes in headers.")
@@ -24,6 +24,13 @@ from docx import Document
24
24
  from docx.enum.table import WD_TABLE_ALIGNMENT
25
25
  from docx.shared import Pt
26
26
 
27
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
28
+ for _stream in (sys.stdout, sys.stderr):
29
+ try:
30
+ _stream.reconfigure(encoding="utf-8", errors="replace")
31
+ except (AttributeError, ValueError):
32
+ pass
33
+
27
34
 
28
35
  def cell_text(value) -> str:
29
36
  if value is None:
@@ -25,6 +25,13 @@ import json
25
25
  import sys
26
26
  from pathlib import Path
27
27
 
28
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
29
+ for _stream in (sys.stdout, sys.stderr):
30
+ try:
31
+ _stream.reconfigure(encoding="utf-8", errors="replace")
32
+ except (AttributeError, ValueError):
33
+ pass
34
+
28
35
  PACKAGE_ROOT = Path(__file__).resolve().parents[4]
29
36
  CLI_DIR = PACKAGE_ROOT / "python"
30
37
  COUNTERS = ("slides", "bullets", "tables", "charts", "images")
@@ -28,6 +28,13 @@ import sys
28
28
  from datetime import datetime, timezone
29
29
  from pathlib import Path
30
30
 
31
+ # Windows consoles default to a legacy code page; every payload is UTF-8 JSON.
32
+ for _stream in (sys.stdout, sys.stderr):
33
+ try:
34
+ _stream.reconfigure(encoding="utf-8", errors="replace")
35
+ except (AttributeError, ValueError):
36
+ pass
37
+
31
38
  FIELDS = ("title", "author", "subject", "keywords", "comments", "category", "last_modified_by")
32
39
 
33
40