-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcommon.py
144 lines (122 loc) · 4.2 KB
/
common.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# path is a list of int.
def command_init(node, time):
return { "name": "init", "node": node, "time": time }
def command_layout_init(node):
return { "name": "layout_init", "node": node }
def command_recalculate(time):
return { "name": "recalculate", "time": time }
def command_add(path, node):
return { "name": "add", "path": path, "node": node }
def command_remove(path, old_node):
return { "name": "remove", "path": path, "old_node": old_node }
def command_layout_add(path, node):
return { "name": "layout_add", "path": path, "node": node }
def command_layout_remove(path, old_node):
return { "name": "layout_remove", "path": path, "old_node": old_node }
def command_replace(path, old_node, node):
return { "name": "replace", "path": path, "old_node": old_node, "node": node }
def command_layout_replace(path, old_node, node):
return { "name": "layout_replace", "path": path, "old_node": old_node, "node": node }
def command_replace_value(path, on, type_, k, old_value, v):
return { "name": "replace_value", "path": path, "on": on, "type": type_, "key": k, "old_value": old_value, "value": v }
def command_insert_value(path, on, type_, k, v):
return { "name": "insert_value", "path": path, "on": on, "type": type_, "key": k, "value": v }
def command_delete_value(path, on, type_, k, old_value):
return { "name": "delete_value", "path": path, "on": on, "type": type_, "key": k, "old_value": old_value }
def command_layout_info_changed(path, old, new):
return { "name": "layout_info_changed", "path": path, "old": old, "new": new }
def size(j):
ret = 1
for c in j["children"]:
ret += size(c)
return ret
def regularize_dom(j):
if "id" not in j:
return None
elif j["name"] == "#comment":
return None
elif j["name"] == "#doctype":
return None
else:
if "children" not in j:
j["children"] = []
tmp = []
for c in j["children"]:
c = regularize_dom(c)
if c is not None:
tmp.append(c)
j["children"] = tmp
if "attributes" not in j:
j["attributes"] = {}
if "properties" not in j:
j["properties"] = {}
return j
def regularize_layout(j):
if "children" not in j:
j["children"] = []
tmp = []
for c in j["children"]:
c = regularize_layout(c)
tmp.append(c)
j["children"] = tmp
if "x" not in j:
j["x"] = 0
if "y" not in j:
j["y"] = 0
if "width" not in j:
j["width"] = 0
if "height" not in j:
j["height"] = 0
return j
trace_list = []
trace_list.append("aliyun")
trace_list.append("amazon")
trace_list.append("anydesk")
trace_list.append("apple")
trace_list.append("archive")
trace_list.append("arxiv")
trace_list.append("bananaspace")
trace_list.append("bilibili")
trace_list.append("booking")
trace_list.append("chess")
trace_list.append("coursera")
trace_list.append("cppreference")
trace_list.append("discord_nologin")
trace_list.append("espn")
trace_list.append("expedia")
trace_list.append("firefox")
trace_list.append("github_commits")
trace_list.append("github_nologin")
trace_list.append("github_repo")
trace_list.append("gmail_nologin")
trace_list.append("google_hover")
trace_list.append("google_play")
trace_list.append("google_scholar")
trace_list.append("google_searchbar")
trace_list.append("google_searchpage")
trace_list.append("googlesource_chromium")
trace_list.append("haskell")
trace_list.append("hn_type")
trace_list.append("hsr")
trace_list.append("hsreplay")
trace_list.append("janestreet_main")
trace_list.append("jetbrains")
trace_list.append("lichess_anal")
trace_list.append("mihoyo")
trace_list.append("ocaml")
trace_list.append("panda_express")
trace_list.append("reddit")
trace_list.append("spotify")
trace_list.append("stack_overflow_main")
trace_list.append("steam")
trace_list.append("twitter_login")
trace_list.append("twitter_main")
trace_list.append("vscode")
trace_list.append("walmart")
trace_list.append("w3school")
trace_list.append("wikipedia_hover")
trace_list.append("wikipedia_idle")
trace_list.append("windows")
trace_list.append("yahoo")
trace_list.append("youtube")
#trace_list=["wikipedia_hover", "twitter_main"]