-
Notifications
You must be signed in to change notification settings - Fork 8
/
make-viewer.py
executable file
·41 lines (34 loc) · 1.41 KB
/
make-viewer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python
# encoding: utf-8
"""Packaging script for the gatenlp library."""
import sys
import os
import subprocess
from setuptools import setup, find_packages
import re
from shutil import copyfile
HTML_ANN_VIEWER_HTML_FILE = os.path.join("html-ann-viewer", "gatenlp-ann-viewer.html")
HTML_ANN_VIEWER_MERGEDJS_FILE = os.path.join(
"html-ann-viewer", "gatenlp-ann-viewer-merged.js"
)
HTML_ANN_VIEWER_GATEJS_FILE = os.path.join("html-ann-viewer", "gatenlp-ann-viewer.js")
HTML_ANN_VIEWER_LIBJS_FILE = os.path.join("html-ann-viewer", "jquery-3.5.1.min.js")
HTML_ANN_VIEWER_DIST_DIR = os.path.join("gatenlp", "serialization", "_htmlviewer")
here = os.path.abspath(os.path.dirname(__file__))
def make_html_ann_viewer():
# concatenate the JS files to create the merged file
with open(HTML_ANN_VIEWER_MERGEDJS_FILE, "wt", encoding="UTF-8") as outfp:
for fname in [HTML_ANN_VIEWER_LIBJS_FILE, HTML_ANN_VIEWER_GATEJS_FILE]:
with open(fname, "rt", encoding="UTF-8") as infp:
for line in infp:
outfp.write(line)
print("Copying HTML and merged JS files", file=sys.stderr)
copyfile(
HTML_ANN_VIEWER_HTML_FILE,
os.path.join(HTML_ANN_VIEWER_DIST_DIR, "gatenlp-ann-viewer.html"),
)
copyfile(
HTML_ANN_VIEWER_MERGEDJS_FILE,
os.path.join(HTML_ANN_VIEWER_DIST_DIR, "gatenlp-ann-viewer-merged.js"),
)
make_html_ann_viewer()