seawolf2357 commited on
Commit
cae0b38
·
verified ·
1 Parent(s): 88e4488

Upload verify_conversion.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. verify_conversion.py +33 -0
verify_conversion.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pyhwp.html_converter import HwpToHtmlConverter
2
+ import os
3
+ import sys
4
+
5
+ def main():
6
+ hwp_file = 'verify_test.hwp'
7
+ html_file = 'verify_test.xhtml'
8
+
9
+ if not os.path.exists(hwp_file):
10
+ print(f"Error: {hwp_file} not found.")
11
+ return 1
12
+
13
+ print(f"Converting {hwp_file} to {html_file}...")
14
+ try:
15
+ converter = HwpToHtmlConverter(hwp_file)
16
+ converter.convert(html_file)
17
+ if os.path.exists(html_file):
18
+ size = os.path.getsize(html_file)
19
+ print(f"Success! Generated {html_file} ({size} bytes).")
20
+ # Optional: Print first few lines of output
21
+ with open(html_file, 'r', encoding='utf-8') as f:
22
+ print("--- Output Content Preview ---")
23
+ print(f.read()[:500])
24
+ print("... (truncated)")
25
+ else:
26
+ print("Error: Output file was not created.")
27
+ return 1
28
+ except Exception as e:
29
+ print(f"Conversion failed with error: {e}")
30
+ return 1
31
+
32
+ if __name__ == "__main__":
33
+ sys.exit(main())