opencontracting-nutcracker 0.0.1__py3-none-any.whl
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.
- docs/Makefile +20 -0
- docs/api/index.rst +10 -0
- docs/changelog.rst +13 -0
- docs/conf.py +50 -0
- docs/contributing/index.rst +28 -0
- docs/index.rst +105 -0
- docs/requirements.txt +1 -0
- nutcracker/__init__.py +380 -0
- nutcracker/__main__.py +37 -0
- nutcracker/archive.py +166 -0
- nutcracker/exceptions.py +9 -0
- nutcracker/pdf.py +207 -0
- nutcracker/util.py +57 -0
- nutcracker/word.py +365 -0
- opencontracting_nutcracker-0.0.1.dist-info/METADATA +41 -0
- opencontracting_nutcracker-0.0.1.dist-info/RECORD +20 -0
- opencontracting_nutcracker-0.0.1.dist-info/WHEEL +5 -0
- opencontracting_nutcracker-0.0.1.dist-info/entry_points.txt +2 -0
- opencontracting_nutcracker-0.0.1.dist-info/licenses/LICENSE +29 -0
- opencontracting_nutcracker-0.0.1.dist-info/top_level.txt +3 -0
nutcracker/word.py
ADDED
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
"""Convert word-processing documents, presentations and HTML, with pandoc, textutil (macOS) or LibreOffice."""
|
|
2
|
+
|
|
3
|
+
import io
|
|
4
|
+
import posixpath
|
|
5
|
+
import re
|
|
6
|
+
import xml.etree.ElementTree as ET
|
|
7
|
+
import zipfile
|
|
8
|
+
|
|
9
|
+
from nutcracker.exceptions import ConversionError
|
|
10
|
+
from nutcracker.util import run, which
|
|
11
|
+
|
|
12
|
+
W = "http://schemas.openxmlformats.org/wordprocessingml/2006/main"
|
|
13
|
+
MC = "http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
14
|
+
XML = "http://www.w3.org/XML/1998/namespace"
|
|
15
|
+
|
|
16
|
+
ROMAN = [(1000, "m"), (900, "cm"), (500, "d"), (400, "cd"), (100, "c"), (90, "xc")]
|
|
17
|
+
ROMAN += [(50, "l"), (40, "xl"), (10, "x"), (9, "ix"), (5, "v"), (4, "iv"), (1, "i")]
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def convert_pandoc(path, fmt):
|
|
21
|
+
result = run(["pandoc", "-f", fmt, "-t", "plain", "--wrap=none", "--eol=lf", str(path)])
|
|
22
|
+
if result.returncode:
|
|
23
|
+
raise ConversionError(result.stderr.decode("utf-8", "replace")[:200])
|
|
24
|
+
return [result.stdout.decode("utf-8", "replace")], [""]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def convert_textutil(path):
|
|
28
|
+
result = run(["textutil", "-convert", "txt", "-stdout", str(path)])
|
|
29
|
+
if result.returncode:
|
|
30
|
+
raise ConversionError(result.stderr.decode("utf-8", "replace")[:200])
|
|
31
|
+
return [result.stdout.decode("utf-8", "replace")], [""]
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def convert_libreoffice(path, tmp, fmt):
|
|
35
|
+
"""Convert a file to another format (like "docx") with LibreOffice, and return the new file's path."""
|
|
36
|
+
soffice = which("soffice", "libreoffice")
|
|
37
|
+
if not soffice:
|
|
38
|
+
raise ConversionError(f"textutil (macOS) or LibreOffice is needed to convert {path.suffix} files")
|
|
39
|
+
out = tmp / "libreoffice"
|
|
40
|
+
# A profile per conversion, as LibreOffice won't start while another process uses the default profile.
|
|
41
|
+
profile = (tmp / "libreoffice-profile").absolute().as_uri()
|
|
42
|
+
command = [soffice, f"-env:UserInstallation={profile}", "--headless", "--convert-to", fmt, "--outdir", str(out)]
|
|
43
|
+
result = run([*command, str(path)])
|
|
44
|
+
converted = out / f"{path.stem}.{fmt}"
|
|
45
|
+
if result.returncode or not converted.exists():
|
|
46
|
+
raise ConversionError(f"LibreOffice: {result.stderr.decode('utf-8', 'replace')[:200]}")
|
|
47
|
+
return converted
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def wq(name):
|
|
51
|
+
return f"{{{W}}}{name}"
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def child_val(el, *path):
|
|
55
|
+
"""Return the w:val of a descendant of el, by a path of w: tag names, or None."""
|
|
56
|
+
if el is None:
|
|
57
|
+
return None
|
|
58
|
+
found = el.find("/".join(wq(name) for name in path))
|
|
59
|
+
return None if found is None else found.get(wq("val"))
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def is_on(el):
|
|
63
|
+
"""Return whether a toggle property like w:strike is on."""
|
|
64
|
+
return el is not None and el.get(wq("val"), "true").lower() not in {"0", "false", "off"}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def strike_of(rpr):
|
|
68
|
+
"""Return whether run properties strike through, or None if they don't say."""
|
|
69
|
+
found = [el for tag in ("strike", "dstrike") if rpr is not None and (el := rpr.find(wq(tag))) is not None]
|
|
70
|
+
return any(is_on(el) for el in found) if found else None
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def parse_part(data):
|
|
74
|
+
"""Parse an XML part, registering its namespace prefixes so that it serializes with the same prefixes."""
|
|
75
|
+
root = None
|
|
76
|
+
for event, item in ET.iterparse(io.BytesIO(data), events=("start-ns", "start")): # noqa: S314
|
|
77
|
+
if event == "start-ns":
|
|
78
|
+
if not item[0]:
|
|
79
|
+
raise ValueError("default namespace")
|
|
80
|
+
ET.register_namespace(*item)
|
|
81
|
+
elif root is None:
|
|
82
|
+
root = item
|
|
83
|
+
return root
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def part_targets(z, part):
|
|
87
|
+
"""Map the relationship types of a docx part (like "styles") to member names."""
|
|
88
|
+
folder, name = posixpath.split(part)
|
|
89
|
+
rels = posixpath.join(folder, "_rels", f"{name}.rels")
|
|
90
|
+
if rels not in z.namelist():
|
|
91
|
+
return {}
|
|
92
|
+
targets = {}
|
|
93
|
+
for rel in ET.fromstring(z.read(rels)): # noqa: S314
|
|
94
|
+
target = rel.get("Target") or ""
|
|
95
|
+
if rel.get("TargetMode") != "External" and target:
|
|
96
|
+
path = target.lstrip("/") if target.startswith("/") else posixpath.normpath(posixpath.join(folder, target))
|
|
97
|
+
targets[(rel.get("Type") or "").rsplit("/", 1)[-1]] = path
|
|
98
|
+
return targets
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def read_styles(root):
|
|
102
|
+
"""Return {style ID: style}, with each style's parent, numbering and strikethrough, and the default style IDs."""
|
|
103
|
+
styles, defaults = {}, {}
|
|
104
|
+
if root is None:
|
|
105
|
+
return styles, defaults
|
|
106
|
+
for style in root.iter(wq("style")):
|
|
107
|
+
sid = style.get(wq("styleId"))
|
|
108
|
+
styles[sid] = {
|
|
109
|
+
"based": child_val(style, "basedOn"),
|
|
110
|
+
"num_id": child_val(style, "pPr", "numPr", "numId"),
|
|
111
|
+
"ilvl": child_val(style, "pPr", "numPr", "ilvl"),
|
|
112
|
+
"strike": strike_of(style.find(wq("rPr"))),
|
|
113
|
+
}
|
|
114
|
+
if style.get(wq("default")) in {"1", "true", "on"}:
|
|
115
|
+
defaults[style.get(wq("type"))] = sid
|
|
116
|
+
return styles, defaults
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def style_chain(styles, sid):
|
|
120
|
+
"""Yield a style and its ancestors."""
|
|
121
|
+
seen = set()
|
|
122
|
+
while sid in styles and sid not in seen:
|
|
123
|
+
seen.add(sid)
|
|
124
|
+
yield sid, styles[sid]
|
|
125
|
+
sid = styles[sid]["based"]
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def read_level(lvl):
|
|
129
|
+
def val(tag):
|
|
130
|
+
el = lvl.find(wq(tag))
|
|
131
|
+
if el is None:
|
|
132
|
+
el = lvl.find(f"{{{MC}}}AlternateContent/{{{MC}}}Fallback/{wq(tag)}")
|
|
133
|
+
return None if el is None else el.get(wq("val"))
|
|
134
|
+
|
|
135
|
+
restart = val("lvlRestart")
|
|
136
|
+
return {
|
|
137
|
+
"fmt": val("numFmt") or "decimal",
|
|
138
|
+
"text": val("lvlText") or "",
|
|
139
|
+
"start": int(val("start") or 0),
|
|
140
|
+
"restart": None if restart is None else int(restart),
|
|
141
|
+
"legal": is_on(lvl.find(wq("isLgl"))),
|
|
142
|
+
"suff": val("suff") or "tab",
|
|
143
|
+
"style": child_val(lvl, "pStyle"),
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def read_numbering(root, styles):
|
|
148
|
+
"""Return {numId: (counter key, {ilvl: level}, {ilvl: start override})}."""
|
|
149
|
+
if root is None:
|
|
150
|
+
return {}
|
|
151
|
+
abstracts, links = {}, {}
|
|
152
|
+
for abstract in root.findall(wq("abstractNum")):
|
|
153
|
+
aid = abstract.get(wq("abstractNumId"))
|
|
154
|
+
abstracts[aid] = {int(lvl.get(wq("ilvl"), 0)): read_level(lvl) for lvl in abstract.findall(wq("lvl"))}
|
|
155
|
+
if link := child_val(abstract, "numStyleLink"):
|
|
156
|
+
links[aid] = link
|
|
157
|
+
raw = {num.get(wq("numId")): num for num in root.findall(wq("num"))}
|
|
158
|
+
|
|
159
|
+
def resolve(aid):
|
|
160
|
+
"""Follow a numbering style link to the abstractNum that defines the levels."""
|
|
161
|
+
if aid in links:
|
|
162
|
+
num_id = next((s["num_id"] for _, s in style_chain(styles, links[aid]) if s["num_id"]), None)
|
|
163
|
+
if num_id in raw:
|
|
164
|
+
target = child_val(raw[num_id], "abstractNumId")
|
|
165
|
+
if target != aid and target not in links:
|
|
166
|
+
return target
|
|
167
|
+
return aid
|
|
168
|
+
|
|
169
|
+
nums = {}
|
|
170
|
+
for num_id, num in raw.items():
|
|
171
|
+
aid = resolve(child_val(num, "abstractNumId"))
|
|
172
|
+
levels = dict(abstracts.get(aid, {}))
|
|
173
|
+
starts = {}
|
|
174
|
+
for override in num.findall(wq("lvlOverride")):
|
|
175
|
+
ilvl = int(override.get(wq("ilvl"), 0))
|
|
176
|
+
if (lvl := override.find(wq("lvl"))) is not None:
|
|
177
|
+
levels[ilvl] = read_level(lvl)
|
|
178
|
+
if (start := child_val(override, "startOverride")) is not None:
|
|
179
|
+
starts[ilvl] = int(start)
|
|
180
|
+
levels[ilvl] = {**levels.get(ilvl, read_level(ET.Element("lvl"))), "start": int(start)}
|
|
181
|
+
nums[num_id] = (aid, levels, starts)
|
|
182
|
+
return nums
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def format_number(n, fmt):
|
|
186
|
+
if fmt in {"bullet", "none"}:
|
|
187
|
+
return ""
|
|
188
|
+
if n < 1 or fmt not in {"lowerLetter", "upperLetter", "lowerRoman", "upperRoman", "decimalZero"}:
|
|
189
|
+
return str(n)
|
|
190
|
+
if fmt == "decimalZero":
|
|
191
|
+
return f"{n:02d}"
|
|
192
|
+
if fmt.endswith("Letter"):
|
|
193
|
+
# Word continues after z with aa, bb, ...
|
|
194
|
+
text = chr(ord("a") + (n - 1) % 26) * ((n - 1) // 26 + 1)
|
|
195
|
+
else:
|
|
196
|
+
text = ""
|
|
197
|
+
for value, numeral in ROMAN:
|
|
198
|
+
count, n = divmod(n, value)
|
|
199
|
+
text += numeral * count
|
|
200
|
+
return text.upper() if fmt.startswith("upper") else text
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
def level_label(level, levels, count):
|
|
204
|
+
"""Return a level's label, filling its lvlText's %N placeholders with the counts of the levels."""
|
|
205
|
+
if level["fmt"] == "bullet":
|
|
206
|
+
return "•"
|
|
207
|
+
|
|
208
|
+
def number(match):
|
|
209
|
+
ref = levels.get(int(match[1]) - 1, level)
|
|
210
|
+
return format_number(count.get(int(match[1]) - 1, ref["start"]), "decimal" if level["legal"] else ref["fmt"])
|
|
211
|
+
|
|
212
|
+
return re.sub(r"%([1-9])", number, level["text"])
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
def paragraphs(el):
|
|
216
|
+
"""Yield w:p elements in document order, skipping mc:Fallback (a duplicate of mc:Choice)."""
|
|
217
|
+
for child in el:
|
|
218
|
+
if child.tag == f"{{{MC}}}Fallback":
|
|
219
|
+
continue
|
|
220
|
+
if child.tag == wq("p"):
|
|
221
|
+
yield child
|
|
222
|
+
yield from paragraphs(child)
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
def label_lists(root, nums, styles, defaults):
|
|
226
|
+
"""Prefix each numbered paragraph with its label as Word displays it, and remove its numbering."""
|
|
227
|
+
counters = {} # {counter key: {ilvl: count}}, shared by the numIds of an abstractNum
|
|
228
|
+
seen = set()
|
|
229
|
+
for p in paragraphs(root):
|
|
230
|
+
ppr = p.find(wq("pPr"))
|
|
231
|
+
num_pr = None if ppr is None else ppr.find(wq("numPr"))
|
|
232
|
+
num_id = child_val(num_pr, "numId")
|
|
233
|
+
ilvl = child_val(num_pr, "ilvl")
|
|
234
|
+
sid = child_val(ppr, "pStyle") or defaults.get("paragraph")
|
|
235
|
+
from_style = next(((s, x) for s, x in style_chain(styles, sid) if x["num_id"]), None)
|
|
236
|
+
if num_id is None and from_style:
|
|
237
|
+
num_id = from_style[1]["num_id"]
|
|
238
|
+
ilvl = ilvl or from_style[1]["ilvl"]
|
|
239
|
+
if num_id not in nums:
|
|
240
|
+
continue
|
|
241
|
+
key, levels, starts = nums[num_id]
|
|
242
|
+
if ilvl is None:
|
|
243
|
+
ilvl = next((i for i, lvl in levels.items() if lvl["style"] and lvl["style"] == sid), 0)
|
|
244
|
+
ilvl = int(ilvl)
|
|
245
|
+
count = counters.setdefault(key, {})
|
|
246
|
+
if num_id not in seen:
|
|
247
|
+
seen.add(num_id)
|
|
248
|
+
for level in starts:
|
|
249
|
+
for deeper in [i for i in count if i >= level]:
|
|
250
|
+
del count[deeper]
|
|
251
|
+
level = levels.get(ilvl) or read_level(ET.Element("lvl"))
|
|
252
|
+
count[ilvl] = count[ilvl] + 1 if ilvl in count else level["start"]
|
|
253
|
+
for deeper in [i for i in count if i > ilvl]:
|
|
254
|
+
restart = levels.get(deeper, {}).get("restart")
|
|
255
|
+
if restart is None or (restart and ilvl < restart):
|
|
256
|
+
del count[deeper]
|
|
257
|
+
|
|
258
|
+
label = level_label(level, levels, count)
|
|
259
|
+
if num_pr is not None:
|
|
260
|
+
ppr.remove(num_pr)
|
|
261
|
+
if from_style:
|
|
262
|
+
# numId 0 turns off the numbering that the paragraph style sets.
|
|
263
|
+
num_pr = ET.SubElement(ppr, wq("numPr"))
|
|
264
|
+
ET.SubElement(num_pr, wq("numId")).set(wq("val"), "0")
|
|
265
|
+
if label.strip():
|
|
266
|
+
run_ = ET.Element(wq("r"))
|
|
267
|
+
text = ET.SubElement(run_, wq("t"))
|
|
268
|
+
text.text = label + ("" if level["suff"] == "nothing" else " ")
|
|
269
|
+
text.set(f"{{{XML}}}space", "preserve")
|
|
270
|
+
p.insert(0 if ppr is None else list(p).index(ppr) + 1, run_)
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
def mark_strikethrough(root, styles):
|
|
274
|
+
"""Wrap each sequence of struck-through runs in "[skreślono: …]"."""
|
|
275
|
+
neutral = {wq(tag) for tag in ("bookmarkStart", "bookmarkEnd", "proofErr", "commentRangeStart", "commentRangeEnd")}
|
|
276
|
+
|
|
277
|
+
def struck(run_):
|
|
278
|
+
rpr = run_.find(wq("rPr"))
|
|
279
|
+
if (strike := strike_of(rpr)) is not None:
|
|
280
|
+
return strike
|
|
281
|
+
sid = child_val(rpr, "rStyle")
|
|
282
|
+
return next((s["strike"] for _, s in style_chain(styles, sid) if s["strike"] is not None), False)
|
|
283
|
+
|
|
284
|
+
def close(group):
|
|
285
|
+
texts = [t for run_ in group for t in run_.iter(wq("t")) if t.text]
|
|
286
|
+
if "".join(t.text for t in texts).strip():
|
|
287
|
+
texts[0].text = f"[skreślono: {texts[0].text}"
|
|
288
|
+
texts[-1].text = f"{texts[-1].text}]"
|
|
289
|
+
# Turn off the strikethrough, which pandoc would otherwise also mark as ~~…~~.
|
|
290
|
+
for run_ in group:
|
|
291
|
+
rpr = run_.find(wq("rPr"))
|
|
292
|
+
if rpr is None:
|
|
293
|
+
rpr = ET.Element(wq("rPr"))
|
|
294
|
+
run_.insert(0, rpr)
|
|
295
|
+
for el in [el for el in rpr if el.tag in {wq("strike"), wq("dstrike")}]:
|
|
296
|
+
rpr.remove(el)
|
|
297
|
+
ET.SubElement(rpr, wq("strike")).set(wq("val"), "0")
|
|
298
|
+
|
|
299
|
+
for parent in list(root.iter()):
|
|
300
|
+
group = []
|
|
301
|
+
for child in parent:
|
|
302
|
+
if child.tag == wq("r") and struck(child):
|
|
303
|
+
group.append(child)
|
|
304
|
+
elif child.tag not in neutral:
|
|
305
|
+
close(group)
|
|
306
|
+
group = []
|
|
307
|
+
close(group)
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
def label_docx(path, out):
|
|
311
|
+
"""Write a copy of a docx with literal list labels and marked strikethrough, which pandoc otherwise loses."""
|
|
312
|
+
with zipfile.ZipFile(path) as z:
|
|
313
|
+
document = part_targets(z, "").get("officeDocument", "word/document.xml")
|
|
314
|
+
targets = part_targets(z, document)
|
|
315
|
+
names = set(z.namelist())
|
|
316
|
+
|
|
317
|
+
def load(kind):
|
|
318
|
+
name = targets.get(kind)
|
|
319
|
+
return parse_part(z.read(name)) if name in names else None
|
|
320
|
+
|
|
321
|
+
styles, defaults = read_styles(load("styles"))
|
|
322
|
+
nums = read_numbering(load("numbering"), styles)
|
|
323
|
+
changed = {document: parse_part(z.read(document))}
|
|
324
|
+
label_lists(changed[document], nums, styles, defaults)
|
|
325
|
+
for kind in ("footnotes", "endnotes"):
|
|
326
|
+
if (root := load(kind)) is not None:
|
|
327
|
+
changed[targets[kind]] = root
|
|
328
|
+
for root in changed.values():
|
|
329
|
+
mark_strikethrough(root, styles)
|
|
330
|
+
|
|
331
|
+
with zipfile.ZipFile(out, "w", zipfile.ZIP_DEFLATED) as dst:
|
|
332
|
+
for info in z.infolist():
|
|
333
|
+
if info.filename in changed:
|
|
334
|
+
dst.writestr(info.filename, ET.tostring(changed[info.filename], encoding="UTF-8"))
|
|
335
|
+
else:
|
|
336
|
+
dst.writestr(info.filename, z.read(info))
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
def convert_docx(path, tmp):
|
|
340
|
+
copy = tmp / "labelled.docx"
|
|
341
|
+
try:
|
|
342
|
+
label_docx(path, copy)
|
|
343
|
+
return convert_pandoc(copy, "docx")
|
|
344
|
+
except Exception: # noqa: BLE001 # a malformed docx still gets pandoc's own conversion
|
|
345
|
+
return convert_pandoc(path, "docx")
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
def convert_word(path, tmp, fallback=None, portable=None):
|
|
349
|
+
"""
|
|
350
|
+
Convert a .doc, .rtf or .odt file; one with struck-through text goes through docx, to mark it.
|
|
351
|
+
|
|
352
|
+
``fallback`` converts a file without struck-through text, instead of textutil. Without textutil (macOS), the file
|
|
353
|
+
goes through docx with LibreOffice, or else ``portable`` converts it.
|
|
354
|
+
"""
|
|
355
|
+
if not which("textutil"):
|
|
356
|
+
if portable and not which("soffice", "libreoffice"):
|
|
357
|
+
return portable()
|
|
358
|
+
return convert_docx(convert_libreoffice(path, tmp, "docx"), tmp)
|
|
359
|
+
html = run(["textutil", "-convert", "html", "-stdout", str(path)])
|
|
360
|
+
if b"line-through" in html.stdout:
|
|
361
|
+
docx = tmp / f"{path.stem}.docx"
|
|
362
|
+
result = run(["textutil", "-convert", "docx", "-output", str(docx), str(path)])
|
|
363
|
+
if not result.returncode and docx.exists():
|
|
364
|
+
return convert_docx(docx, tmp)
|
|
365
|
+
return fallback() if fallback else convert_textutil(path)
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: opencontracting-nutcracker
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Convert tender documents, including archives and scans, to text
|
|
5
|
+
Author-email: Open Contracting Partnership <data@open-contracting.org>
|
|
6
|
+
License-Expression: BSD-3-Clause
|
|
7
|
+
Project-URL: Homepage, https://github.com/open-contracting/nutcracker
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
14
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
15
|
+
Requires-Python: >=3.11
|
|
16
|
+
Description-Content-Type: text/x-rst
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Requires-Dist: click
|
|
19
|
+
Requires-Dist: openpyxl
|
|
20
|
+
Requires-Dist: xlrd
|
|
21
|
+
Provides-Extra: pdf
|
|
22
|
+
Requires-Dist: pymupdf; extra == "pdf"
|
|
23
|
+
Provides-Extra: test
|
|
24
|
+
Requires-Dist: coverage; extra == "test"
|
|
25
|
+
Requires-Dist: pytest; extra == "test"
|
|
26
|
+
Dynamic: license-file
|
|
27
|
+
|
|
28
|
+
|PyPI Version| |Build Status| |Coverage Status| |Python Version|
|
|
29
|
+
|
|
30
|
+
Nutcracker converts tender documents to text, page by page: PDFs (with OCR of scanned pages), Word, OpenDocument, RTF, spreadsheets, HTML, XML, text, images, and the members of ZIP, 7z and RAR archives, including split and nested archives.
|
|
31
|
+
|
|
32
|
+
(If you are viewing this on GitHub, open the `full documentation <https://ocp-nutcracker.readthedocs.io/>`__ for additional details.)
|
|
33
|
+
|
|
34
|
+
.. |PyPI Version| image:: https://img.shields.io/pypi/v/opencontracting-nutcracker.svg
|
|
35
|
+
:target: https://pypi.org/project/opencontracting-nutcracker/
|
|
36
|
+
.. |Build Status| image:: https://github.com/open-contracting/nutcracker/actions/workflows/ci.yml/badge.svg
|
|
37
|
+
:target: https://github.com/open-contracting/nutcracker/actions/workflows/ci.yml
|
|
38
|
+
.. |Coverage Status| image:: https://codecov.io/github/open-contracting/nutcracker/graph/badge.svg
|
|
39
|
+
:target: https://codecov.io/github/open-contracting/nutcracker
|
|
40
|
+
.. |Python Version| image:: https://img.shields.io/pypi/pyversions/opencontracting-nutcracker.svg
|
|
41
|
+
:target: https://pypi.org/project/opencontracting-nutcracker/
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
docs/Makefile,sha256=i2WHuFlgfyAPEW4ssEP8NY4cOibDJrVjvzSEU8_Ggwc,634
|
|
2
|
+
docs/changelog.rst,sha256=CVvSQIPIepGoH7jCI2B-5bX0DjXeQ9cxSR3RwxLTFRc,717
|
|
3
|
+
docs/conf.py,sha256=moQ67Eepal0y_SzY5Q2es6dZM0qJ_9DqQQ_dwBGYY9c,1477
|
|
4
|
+
docs/index.rst,sha256=op2ql9K-dx3Hg2J-MmpLLI67WVZJu7gXxtWhGDRW7qQ,4426
|
|
5
|
+
docs/requirements.txt,sha256=Jlpco83K7sYgScPxRKwl2-XB0fDFvmrslrBO2SGjTYo,5
|
|
6
|
+
docs/api/index.rst,sha256=uJlp5xyLGYzUqd0l_hQxrSLzN1AcZ2d7uyar1iSpRvA,251
|
|
7
|
+
docs/contributing/index.rst,sha256=p6BRHcuMFrriDDt5gnc80mWvi6kuZoFSRlVL43Me81I,765
|
|
8
|
+
nutcracker/__init__.py,sha256=AfdjTDeO0nszA0wnlNNhJAbw-3-jz5TZLqvnSD_KcGQ,16126
|
|
9
|
+
nutcracker/__main__.py,sha256=1ufNwLylviQPMOZjgD-rHtSs2prrgfTjYKb9JIhyzhA,1487
|
|
10
|
+
nutcracker/archive.py,sha256=dlZKh1fXvnk_L2mO76iLqnF8CfVNTfG48FyPPZsaAbY,7119
|
|
11
|
+
nutcracker/exceptions.py,sha256=64i89G7nvsiDevSwvb7W7R4_ZQh7Yj2Qk6osALw21L8,240
|
|
12
|
+
nutcracker/pdf.py,sha256=Xf2zEr8Rh_H5V6c8uTzvCPG-3Nn5hWdUeZ9s4W14Usk,9336
|
|
13
|
+
nutcracker/util.py,sha256=IQc0NPpk8fy1_u40O231FJTcEATW2hn-Df2m0p2hP1A,2005
|
|
14
|
+
nutcracker/word.py,sha256=nvuNqRuwk9cn6f7PGcJp-L22aqmZkC7fgQj_vR5Ob-E,14863
|
|
15
|
+
opencontracting_nutcracker-0.0.1.dist-info/licenses/LICENSE,sha256=BnL91T_06DgJ6cB0TPozJeskTDl3qYkqGxzgjcDnAxs,1528
|
|
16
|
+
opencontracting_nutcracker-0.0.1.dist-info/METADATA,sha256=l3XWcU24hR-SuIPk-7_1pRGS1RWWYZRom7ASqLEJ9Ko,2136
|
|
17
|
+
opencontracting_nutcracker-0.0.1.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
18
|
+
opencontracting_nutcracker-0.0.1.dist-info/entry_points.txt,sha256=2Lfow4egkVEJMSgr8RruMcKB1PZjtL36KkA8yfidwOQ,56
|
|
19
|
+
opencontracting_nutcracker-0.0.1.dist-info/top_level.txt,sha256=OZF7JgkVoHCXLDI0Ip5ABw8ihRvzvCEmWU-Pn7NoWUw,21
|
|
20
|
+
opencontracting_nutcracker-0.0.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026, Open Contracting Partnership
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
* Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
* Neither the name of the copyright holder nor the names of its
|
|
17
|
+
contributors may be used to endorse or promote products derived from
|
|
18
|
+
this software without specific prior written permission.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|