-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathext.py
66 lines (43 loc) · 1.13 KB
/
ext.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
# -*- coding: utf-8 -*-
"""
ext
----------------
extension functions of regular.express
:author: Prev([email protected])
"""
def get_shares(design_name, key, envinfo) :
global model
return process_shares(
model.macro('#view-range', design_name, 'shares', key).rows,
envinfo = envinfo,
)
def process_shares(shares, envinfo) :
output = []
for index, data in enumerate(shares) :
if index % 2 == 1 : continue
try :
o = data['doc']
o['author'] = shares[index+1]['doc']
o['env_group'] = envinfo.getdict(o['env'][0], loose_mode=True)
o['env_child'] = envinfo.getdict(o['env'][0], o['env'][1], loose_mode=True)
except Exception as e:
print(e)
pass
else :
output.append(o)
return output
def env_icon(icon_info) :
if icon_info['type'] == 'devicon' :
return '<i class="devicon-%s-plain"></i>' % icon_info['value']
elif icon_info['type'] == 'img':
return '<img src="%s">' % icon_info['value']
elif icon_info['type'] == 'raw':
return icon_info['value']
else:
return None
def json2(o) :
import json, html, ast
o = ast.literal_eval( repr( o ) )
s = json.dumps( o )
s = html.escape(s)
return s