sampledoc 0.1.0__tar.gz → 0.2.0__tar.gz
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.
- {sampledoc-0.1.0 → sampledoc-0.2.0}/CHANGELOG.md +9 -1
- {sampledoc-0.1.0 → sampledoc-0.2.0}/PKG-INFO +19 -1
- {sampledoc-0.1.0 → sampledoc-0.2.0}/README.md +18 -0
- {sampledoc-0.1.0 → sampledoc-0.2.0}/src/sampledoc/__init__.py +1 -1
- {sampledoc-0.1.0 → sampledoc-0.2.0}/src/sampledoc/odf.py +28 -2
- {sampledoc-0.1.0 → sampledoc-0.2.0}/tests/golden.json +15 -15
- {sampledoc-0.1.0 → sampledoc-0.2.0}/tests/test_samples.py +21 -0
- {sampledoc-0.1.0 → sampledoc-0.2.0}/.gitignore +0 -0
- {sampledoc-0.1.0 → sampledoc-0.2.0}/LICENSE +0 -0
- {sampledoc-0.1.0 → sampledoc-0.2.0}/pyproject.toml +0 -0
- {sampledoc-0.1.0 → sampledoc-0.2.0}/src/sampledoc/__main__.py +0 -0
- {sampledoc-0.1.0 → sampledoc-0.2.0}/src/sampledoc/_language.py +0 -0
- {sampledoc-0.1.0 → sampledoc-0.2.0}/src/sampledoc/_table.py +0 -0
- {sampledoc-0.1.0 → sampledoc-0.2.0}/src/sampledoc/cli.py +0 -0
- {sampledoc-0.1.0 → sampledoc-0.2.0}/src/sampledoc/languages/cs.json +0 -0
- {sampledoc-0.1.0 → sampledoc-0.2.0}/src/sampledoc/languages/de.json +0 -0
- {sampledoc-0.1.0 → sampledoc-0.2.0}/src/sampledoc/languages/en.json +0 -0
- {sampledoc-0.1.0 → sampledoc-0.2.0}/src/sampledoc/languages/es.json +0 -0
- {sampledoc-0.1.0 → sampledoc-0.2.0}/src/sampledoc/languages/et.json +0 -0
- {sampledoc-0.1.0 → sampledoc-0.2.0}/src/sampledoc/languages/fr.json +0 -0
- {sampledoc-0.1.0 → sampledoc-0.2.0}/src/sampledoc/languages/hi.json +0 -0
- {sampledoc-0.1.0 → sampledoc-0.2.0}/src/sampledoc/languages/it.json +0 -0
- {sampledoc-0.1.0 → sampledoc-0.2.0}/src/sampledoc/languages/ja.json +0 -0
- {sampledoc-0.1.0 → sampledoc-0.2.0}/src/sampledoc/languages/pl.json +0 -0
- {sampledoc-0.1.0 → sampledoc-0.2.0}/src/sampledoc/languages/pt-BR.json +0 -0
- {sampledoc-0.1.0 → sampledoc-0.2.0}/src/sampledoc/languages/ru.json +0 -0
- {sampledoc-0.1.0 → sampledoc-0.2.0}/src/sampledoc/languages/sv.json +0 -0
- {sampledoc-0.1.0 → sampledoc-0.2.0}/src/sampledoc/languages/tr.json +0 -0
- {sampledoc-0.1.0 → sampledoc-0.2.0}/src/sampledoc/languages/zh.json +0 -0
- {sampledoc-0.1.0 → sampledoc-0.2.0}/src/sampledoc/names.py +0 -0
- {sampledoc-0.1.0 → sampledoc-0.2.0}/src/sampledoc/ooxml.py +0 -0
- {sampledoc-0.1.0 → sampledoc-0.2.0}/src/sampledoc/pdf.py +0 -0
- {sampledoc-0.1.0 → sampledoc-0.2.0}/src/sampledoc/plain.py +0 -0
- {sampledoc-0.1.0 → sampledoc-0.2.0}/src/sampledoc/py.typed +0 -0
- {sampledoc-0.1.0 → sampledoc-0.2.0}/tests/fingerprint.py +0 -0
|
@@ -7,6 +7,13 @@ generated sample is listed, because it changes every screenshot taken of it.
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.2.0] - 2026-12-06
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- The budget's totals are formulas, so editing a figure updates them. They
|
|
15
|
+
show the same numbers as before.
|
|
16
|
+
|
|
10
17
|
## [0.1.0] - 2026-11-14
|
|
11
18
|
|
|
12
19
|
First release, extracted from the `make-screenshot-documents.py` scripts of
|
|
@@ -33,5 +40,6 @@ OpenDocument.droid and OpenDocument.ios.
|
|
|
33
40
|
- `screenshot-names.json` now always nests languages under `"languages"` (the
|
|
34
41
|
Android layout). The iOS script wrote them at the top level.
|
|
35
42
|
|
|
36
|
-
[Unreleased]: https://github.com/opendocument-app/sampledoc/compare/v0.
|
|
43
|
+
[Unreleased]: https://github.com/opendocument-app/sampledoc/compare/v0.2.0...HEAD
|
|
44
|
+
[0.2.0]: https://github.com/opendocument-app/sampledoc/compare/v0.1.0...v0.2.0
|
|
37
45
|
[0.1.0]: https://github.com/opendocument-app/sampledoc/releases/tag/v0.1.0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: sampledoc
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: Small, localized, byte-for-byte reproducible sample office documents (ODF, OOXML, PDF, CSV, TXT).
|
|
5
5
|
Project-URL: Homepage, https://opendocument.app/
|
|
6
6
|
Project-URL: Source, https://github.com/opendocument-app/sampledoc
|
|
@@ -46,6 +46,24 @@ It was built to give app-store screenshots of
|
|
|
46
46
|
in the language of each store listing, and is just as useful as test fixtures
|
|
47
47
|
for anything that opens office files.
|
|
48
48
|
|
|
49
|
+
<table>
|
|
50
|
+
<tr>
|
|
51
|
+
<td align="center"><img src="https://raw.githubusercontent.com/opendocument-app/sampledoc/main/docs/images/sample-text-en.png" width="200" alt="The quarterly report, sample-text-en.odt"></td>
|
|
52
|
+
<td align="center"><img src="https://raw.githubusercontent.com/opendocument-app/sampledoc/main/docs/images/sample-sheet-en.png" width="200" alt="The budget spreadsheet, sample-sheet-en.ods"></td>
|
|
53
|
+
<td align="center"><img src="https://raw.githubusercontent.com/opendocument-app/sampledoc/main/docs/images/sample-word-de.png" width="200" alt="The service agreement in German, sample-word-de.docx"></td>
|
|
54
|
+
<td align="center"><img src="https://raw.githubusercontent.com/opendocument-app/sampledoc/main/docs/images/sample-paper-en.png" width="200" alt="The invoice, sample-paper-en.pdf"></td>
|
|
55
|
+
</tr>
|
|
56
|
+
<tr>
|
|
57
|
+
<td align="center"><code>sample-text-en.odt</code></td>
|
|
58
|
+
<td align="center"><code>sample-sheet-en.ods</code></td>
|
|
59
|
+
<td align="center"><code>sample-word-de.docx</code></td>
|
|
60
|
+
<td align="center"><code>sample-paper-en.pdf</code></td>
|
|
61
|
+
</tr>
|
|
62
|
+
</table>
|
|
63
|
+
|
|
64
|
+
<sub>First pages as rendered by LibreOffice. Regenerate with
|
|
65
|
+
<code>scripts/render-readme-images.sh</code>.</sub>
|
|
66
|
+
|
|
49
67
|
## Install
|
|
50
68
|
|
|
51
69
|
```sh
|
|
@@ -17,6 +17,24 @@ It was built to give app-store screenshots of
|
|
|
17
17
|
in the language of each store listing, and is just as useful as test fixtures
|
|
18
18
|
for anything that opens office files.
|
|
19
19
|
|
|
20
|
+
<table>
|
|
21
|
+
<tr>
|
|
22
|
+
<td align="center"><img src="https://raw.githubusercontent.com/opendocument-app/sampledoc/main/docs/images/sample-text-en.png" width="200" alt="The quarterly report, sample-text-en.odt"></td>
|
|
23
|
+
<td align="center"><img src="https://raw.githubusercontent.com/opendocument-app/sampledoc/main/docs/images/sample-sheet-en.png" width="200" alt="The budget spreadsheet, sample-sheet-en.ods"></td>
|
|
24
|
+
<td align="center"><img src="https://raw.githubusercontent.com/opendocument-app/sampledoc/main/docs/images/sample-word-de.png" width="200" alt="The service agreement in German, sample-word-de.docx"></td>
|
|
25
|
+
<td align="center"><img src="https://raw.githubusercontent.com/opendocument-app/sampledoc/main/docs/images/sample-paper-en.png" width="200" alt="The invoice, sample-paper-en.pdf"></td>
|
|
26
|
+
</tr>
|
|
27
|
+
<tr>
|
|
28
|
+
<td align="center"><code>sample-text-en.odt</code></td>
|
|
29
|
+
<td align="center"><code>sample-sheet-en.ods</code></td>
|
|
30
|
+
<td align="center"><code>sample-word-de.docx</code></td>
|
|
31
|
+
<td align="center"><code>sample-paper-en.pdf</code></td>
|
|
32
|
+
</tr>
|
|
33
|
+
</table>
|
|
34
|
+
|
|
35
|
+
<sub>First pages as rendered by LibreOffice. Regenerate with
|
|
36
|
+
<code>scripts/render-readme-images.sh</code>.</sub>
|
|
37
|
+
|
|
20
38
|
## Install
|
|
21
39
|
|
|
22
40
|
```sh
|
|
@@ -6,6 +6,8 @@ from xml.sax.saxutils import escape
|
|
|
6
6
|
|
|
7
7
|
from ._table import ACCENT, RULE, table, zipped
|
|
8
8
|
|
|
9
|
+
COLUMNS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
|
10
|
+
|
|
9
11
|
NAMESPACES = " ".join(
|
|
10
12
|
[
|
|
11
13
|
'xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"',
|
|
@@ -86,6 +88,15 @@ def paragraph_style(
|
|
|
86
88
|
</style:style>"""
|
|
87
89
|
|
|
88
90
|
|
|
91
|
+
class Sum(int):
|
|
92
|
+
"""A total the sheet computes: SUM over a range, cached as the figure it adds up to."""
|
|
93
|
+
|
|
94
|
+
def __new__(cls, value: int, cells: str):
|
|
95
|
+
total = super().__new__(cls, value)
|
|
96
|
+
total.cells = cells
|
|
97
|
+
return total
|
|
98
|
+
|
|
99
|
+
|
|
89
100
|
def odf_row(cells: list, style: str | None = None) -> str:
|
|
90
101
|
"""One row of an ODF table, as the report and the sheet both write it.
|
|
91
102
|
|
|
@@ -95,7 +106,13 @@ def odf_row(cells: list, style: str | None = None) -> str:
|
|
|
95
106
|
marked = f' table:style-name="{style}"' if style else ""
|
|
96
107
|
out = [" <table:table-row>"]
|
|
97
108
|
for cell in cells:
|
|
98
|
-
if isinstance(cell,
|
|
109
|
+
if isinstance(cell, Sum):
|
|
110
|
+
out.append(
|
|
111
|
+
f' <table:table-cell{marked} table:formula="of:=SUM([.{cell.cells}])"'
|
|
112
|
+
f' office:value-type="float" office:value="{cell}">'
|
|
113
|
+
f"<text:p>{cell}</text:p></table:table-cell>"
|
|
114
|
+
)
|
|
115
|
+
elif isinstance(cell, int):
|
|
99
116
|
out.append(
|
|
100
117
|
f' <table:table-cell{marked} office:value-type="float" office:value="{cell}">'
|
|
101
118
|
f"<text:p>{cell}</text:p></table:table-cell>"
|
|
@@ -196,9 +213,18 @@ def sheet(words: dict) -> str:
|
|
|
196
213
|
|
|
197
214
|
head, body, foot = table(words, columns=6)
|
|
198
215
|
|
|
216
|
+
# the totals are formulas, so an edit above them moves them; the cached values
|
|
217
|
+
# are the figures they always showed
|
|
218
|
+
last = COLUMNS[len(head) - 2]
|
|
219
|
+
body = [line[:-1] + [Sum(line[-1], f"B{row}:.{last}{row}")] for row, line in enumerate(body, 2)]
|
|
220
|
+
end = len(body) + 1
|
|
221
|
+
foot = [foot[0]] + [
|
|
222
|
+
Sum(value, f"{COLUMNS[at]}2:.{COLUMNS[at]}{end}") for at, value in enumerate(foot[1:], 1)
|
|
223
|
+
]
|
|
224
|
+
|
|
199
225
|
overview = [odf_row(head, "ceHead")] + [odf_row(line) for line in body] + [odf_row(foot, "ceTotal")]
|
|
200
226
|
costs = [odf_row([words["item"], words["total"]], "ceHead")]
|
|
201
|
-
costs += [odf_row([line[0], line[-1]]) for line in body]
|
|
227
|
+
costs += [odf_row([line[0], int(line[-1])]) for line in body]
|
|
202
228
|
|
|
203
229
|
tables = []
|
|
204
230
|
for name, rows, columns in (
|
|
@@ -74,21 +74,21 @@
|
|
|
74
74
|
"sample-rows-sv.csv": "f86a4a55f29f801eafb60a81e1502d15316e33c72eba29151076d60a73612b51",
|
|
75
75
|
"sample-rows-tr.csv": "48ed712cdd4c730b0c4db72166efb0431ccdc1e7690b301f87e14d04fa4c3615",
|
|
76
76
|
"sample-rows-zh.csv": "0ffdd92a3057d99ec203e26e6c4dbd8e26be7fc225ede043ace7b9b90909e716",
|
|
77
|
-
"sample-sheet-cs.ods": "zip:
|
|
78
|
-
"sample-sheet-de.ods": "zip:
|
|
79
|
-
"sample-sheet-en.ods": "zip:
|
|
80
|
-
"sample-sheet-es.ods": "zip:
|
|
81
|
-
"sample-sheet-et.ods": "zip:
|
|
82
|
-
"sample-sheet-fr.ods": "zip:
|
|
83
|
-
"sample-sheet-hi.ods": "zip:
|
|
84
|
-
"sample-sheet-it.ods": "zip:
|
|
85
|
-
"sample-sheet-ja.ods": "zip:
|
|
86
|
-
"sample-sheet-pl.ods": "zip:
|
|
87
|
-
"sample-sheet-pt-BR.ods": "zip:
|
|
88
|
-
"sample-sheet-ru.ods": "zip:
|
|
89
|
-
"sample-sheet-sv.ods": "zip:
|
|
90
|
-
"sample-sheet-tr.ods": "zip:
|
|
91
|
-
"sample-sheet-zh.ods": "zip:
|
|
77
|
+
"sample-sheet-cs.ods": "zip:9994be44567c16ded329105f13cfb961d54c70e835f3d43114644b429c314e17",
|
|
78
|
+
"sample-sheet-de.ods": "zip:2ac0e901e97e50f08c1f80408ea67dc8c0d0dedbfddcca54a57a9fffdb7d0fb7",
|
|
79
|
+
"sample-sheet-en.ods": "zip:65f7262c992ac5dcd8e51ad8e8d0f7174fd4c54e49d80014356671894c363410",
|
|
80
|
+
"sample-sheet-es.ods": "zip:62ee81b4e9af14af7dc630bd8110af3c691d241b1243bfbca497344a4f6c0a8f",
|
|
81
|
+
"sample-sheet-et.ods": "zip:788e81c83fd80c0ab9b22e3137257ab2996bae7caaf9971e91152a6b673c7ff9",
|
|
82
|
+
"sample-sheet-fr.ods": "zip:b88f75ae2d654ea72ec48ab505710fb3965a4e896cdc3489ff9821bb55d08ef4",
|
|
83
|
+
"sample-sheet-hi.ods": "zip:52caa0fd3b5899d15ea0a69a13e112dcea0bdfe9e5326f7de466e2df4135fd8d",
|
|
84
|
+
"sample-sheet-it.ods": "zip:8048c84e04057fe38fcad4cf1def3fa54b70b59750ce9917fcfa993729f6faaa",
|
|
85
|
+
"sample-sheet-ja.ods": "zip:93f36c37fe07d78856d9931ec3f76ba844dc1ee8c0543d4b22a7ff1dc8c8247d",
|
|
86
|
+
"sample-sheet-pl.ods": "zip:b8500a170524d52d40bf5b9f6db08324fd01dcb1ebff2ae99432b19718ad5501",
|
|
87
|
+
"sample-sheet-pt-BR.ods": "zip:9bbf0cdfe749e0b8a7620b72563fa74b45123a50a11a0714c52568ced2d5fee5",
|
|
88
|
+
"sample-sheet-ru.ods": "zip:edc07822de2d469c2e2f1c24f1485501522a2b95e9d299cf7e6c6cbd812f15dc",
|
|
89
|
+
"sample-sheet-sv.ods": "zip:20802bfdab26bac68cfb43156a693033b560839aab54419803d97dd253e0f73b",
|
|
90
|
+
"sample-sheet-tr.ods": "zip:235ec058cfee51afcf123c28dc3520b2cb3aa7ea37fc71739bb07f110e9239c0",
|
|
91
|
+
"sample-sheet-zh.ods": "zip:dfb0dd84c2e539795e3fdcb316858a048b3e0038c7f4a8071e6fb7a62ea5e26c",
|
|
92
92
|
"sample-slides-cs.odp": "zip:bb0967ae58b16ca73928bfe5bc5ebfe8346f3b9794a1eb057357252412768ea3",
|
|
93
93
|
"sample-slides-de.odp": "zip:5d37a74eae5e6f3fe01f1e80e4ad4d04d2f0165aafd4c683d8691d134c4dfe6a",
|
|
94
94
|
"sample-slides-en.odp": "zip:3b20fd96c7eb282c6937fa29c0fdca5442aa576b23ba843deb0ab30c8bf9c842",
|
|
@@ -56,6 +56,27 @@ def test_odf_package(sample, language):
|
|
|
56
56
|
ElementTree.fromstring(archive.read(name))
|
|
57
57
|
|
|
58
58
|
|
|
59
|
+
def test_sheet_totals_are_sums_of_what_they_show():
|
|
60
|
+
"""The budget's totals are formulas, cached as the figures they add up to."""
|
|
61
|
+
table = "{urn:oasis:names:tc:opendocument:xmlns:table:1.0}"
|
|
62
|
+
office = "{urn:oasis:names:tc:opendocument:xmlns:office:1.0}"
|
|
63
|
+
with zipfile.ZipFile(io.BytesIO(document("sheet", "en"))) as archive:
|
|
64
|
+
overview, costs = ElementTree.fromstring(archive.read("content.xml")).iter(f"{table}table")
|
|
65
|
+
|
|
66
|
+
grid = [
|
|
67
|
+
[(cell.get(f"{table}formula"), cell.get(f"{office}value")) for cell in row.iter(f"{table}table-cell")]
|
|
68
|
+
for row in overview.iter(f"{table}table-row")
|
|
69
|
+
]
|
|
70
|
+
value = lambda column, row: float(grid[row - 1][column][1]) # noqa: E731
|
|
71
|
+
for row in range(2, len(grid)):
|
|
72
|
+
assert grid[row - 1][-1][0] == f"of:=SUM([.B{row}:.G{row}])"
|
|
73
|
+
assert value(7, row) == sum(value(column, row) for column in range(1, 7))
|
|
74
|
+
for column, letter in enumerate("BCDEFGH", 1):
|
|
75
|
+
assert grid[-1][column][0] == f"of:=SUM([.{letter}2:.{letter}{len(grid) - 1}])"
|
|
76
|
+
assert value(column, len(grid)) == sum(value(column, row) for row in range(2, len(grid)))
|
|
77
|
+
assert not any(cell.get(f"{table}formula") for cell in costs.iter(f"{table}table-cell"))
|
|
78
|
+
|
|
79
|
+
|
|
59
80
|
@pytest.mark.parametrize("language", languages())
|
|
60
81
|
@pytest.mark.parametrize("sample", ["word", "cells", "deck"])
|
|
61
82
|
def test_ooxml_package(sample, language):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|