ayesha-21 commited on
Commit
f15a4d9
·
verified ·
1 Parent(s): 750c306

Delete odt_evaluator.py

Browse files
Files changed (1) hide show
  1. odt_evaluator.py +0 -117
odt_evaluator.py DELETED
@@ -1,117 +0,0 @@
1
- import os
2
- import subprocess
3
- import sys
4
-
5
- ODT = "/home/user/Proposals/Project_Alpha_final.odt"
6
- TMP_XML = "/tmp/content.xml"
7
-
8
-
9
- def emit(msg: str):
10
- print(msg)
11
-
12
-
13
- # =================================================
14
- # 1. File existence
15
- # =================================================
16
- if not os.path.isfile(ODT):
17
- emit("FILE_MISSING")
18
- sys.exit(0)
19
-
20
- emit("FILE_OK")
21
-
22
-
23
- # =================================================
24
- # 2. Extract content.xml
25
- # =================================================
26
- try:
27
- with open(TMP_XML, "w", encoding="utf-8") as out:
28
- subprocess.run(
29
- ["unzip", "-p", ODT, "content.xml"],
30
- stdout=out,
31
- stderr=subprocess.DEVNULL,
32
- check=True
33
- )
34
- except Exception:
35
- emit("CONTENT_MISSING")
36
- sys.exit(0)
37
-
38
- emit("CONTENT_OK")
39
-
40
-
41
- # =================================================
42
- # 3. Load XML safely
43
- # =================================================
44
- with open(TMP_XML, "r", encoding="utf-8", errors="ignore") as f:
45
- xml = f.read()
46
-
47
- # Anti-reward-hacking: ensure document is not empty
48
- if len(xml.strip()) < 800:
49
- emit("CONTENT_MISSING")
50
- sys.exit(0)
51
-
52
-
53
- # =================================================
54
- # 4. Manual page break (page-2 proxy)
55
- # =================================================
56
- page_break_pos = xml.find("<text:soft-page-break")
57
-
58
- if page_break_pos != -1:
59
- emit("PAGE_BREAK_AFTER_P1_OK")
60
- else:
61
- emit("PAGE_BREAK_MISSING")
62
-
63
-
64
- # =================================================
65
- # 5. Table of Contents checks
66
- # =================================================
67
- toc_pos = xml.find("<text:table-of-content")
68
-
69
- # TOC must appear after page break → proxy for page 2
70
- if toc_pos == -1:
71
- emit("TOC_MISSING")
72
- elif page_break_pos != -1 and toc_pos > page_break_pos:
73
- pass # valid placement
74
- else:
75
- emit("TOC_NOT_ON_PAGE2")
76
-
77
-
78
- # TOC title
79
- if "Proposal Outline" in xml:
80
- emit("TOC_TITLE_OK")
81
- else:
82
- emit("TOC_TITLE_BAD")
83
-
84
- # TOC level restriction
85
- if 'text:outline-level="1"' in xml:
86
- emit("TOC_LEVEL_OK")
87
- else:
88
- emit("TOC_LEVEL_BAD")
89
-
90
-
91
- # =================================================
92
- # 6. Image checks
93
- # =================================================
94
- img_pos = xml.find("<draw:image")
95
-
96
- if img_pos != -1:
97
- emit("IMG_PRESENT_OK")
98
- else:
99
- emit("IMG_MISSING")
100
-
101
- # Image must be below TOC
102
- if img_pos != -1 and toc_pos != -1 and img_pos > toc_pos:
103
- emit("IMG_BELOW_TOC_OK")
104
- else:
105
- emit("IMG_ABOVE_TOC")
106
-
107
- # Anchor type
108
- if 'text:anchor-type="as-char"' in xml:
109
- emit("ANCHOR_OK")
110
- else:
111
- emit("ANCHOR_BAD")
112
-
113
- # Width exactly 15 cm
114
- if 'svg:width="15cm"' in xml or 'svg:width="150mm"' in xml:
115
- emit("WIDTH_OK")
116
- else:
117
- emit("WIDTH_BAD")