-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathjoint.py
More file actions
37 lines (29 loc) · 735 Bytes
/
joint.py
File metadata and controls
37 lines (29 loc) · 735 Bytes
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
# -*- coding: utf-8 -*-
import lxml.html
def unescape(s):
s = s.replace("<", "<")
s = s.replace(">", ">")
# this has to be last:
s = s.replace("&", "&")
return s
def readContent(path):
f = open(path)
content = f.read()
f.close()
return content
base_path = "./offline-editor/"
insert = base_path + "category.xml"
base = base_path + "base.html"
output = base_path + "main.html"
terget_id = 'toolbox'
html = readContent(base)
html = html.decode('utf-8')
root = lxml.html.fromstring(html)
element = root.get_element_by_id(terget_id)
html = readContent(insert)
element.text = html
content = lxml.html.tostring(root,encoding="utf-8")
text = unescape(content)
f = open(output,"w")
f.write(text)
f.close()