-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathtest.py
51 lines (36 loc) · 1.23 KB
/
test.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
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
@File : server.py
@Date : 2022/04/13
@Author : Yaronzz
@Version : 1.0
@Contact : [email protected]
@Desc :
"""
import socket
import re
# # AF_INET 表示使用IPv4, SOCK_DGRAM 则表明数据将是数据报(datagrams)
# udp_client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# client_msg = 'Hello world.'
# udp_client.sendto(client_msg.encode('utf8'), ('101.33.238.192', 8081))
# while True:
# rec_msg, addr = udp_client.recvfrom(1024)
# print('msg form server:', rec_msg.decode('utf8'))
varDict = {}
varDict['TMP'] = "#001122"
qssStr = "{ color: $TMP%200; }"
def combineColor(color: str, opacity: str):
if '#' not in color:
return color
opacity = int(int(opacity) / 100 * 255 + 0.5)
if opacity < 0:
opacity = 0
if opacity > 255:
opacity = 255
opacity = hex(opacity).replace('0x', '')
return '#' + opacity + color.replace('#', '')
qssStr = re.sub(r'[$](\w+)[%](\w+)([\s;]*)',
lambda m: '{}{}'.format(combineColor(varDict[m.group(1)], m.group(2)), m.group(3)), qssStr)
# qssStr = re.sub(r'[$](\w+)([\s;]*)', lambda m: '{}{}'.format(varDict[m.group(1)], m.group(2)), qssStr)
pass