-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCriteriaCSS.py
51 lines (44 loc) · 2.22 KB
/
CriteriaCSS.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
#This script is for produsing groups of selectors for statstiscs
import re
#prefix = '<tr><td>open</td><td>'
#suffix = '</td><td></td></tr><tr><td>waitForPageToLoad</td><td></td><td>3000</td></tr>'
with open('CSSDB.txt','r') as f:
newlines = []
for line in f.readlines():
line=re.sub(r'^\s*', '', line)
line=line.replace(':link', '')
line=line.replace(':visited', '')
line=line.replace(':active', '')
line=line.replace(':hover', '')
line=line.replace(':focus', '')
line=line.replace(':-o-prefocus', '')
line=line.replace(':first-letter', '')
line=line.replace(':first-line', '')
line=line.replace(':before', '')
line=line.replace(':after', '')
if not line.startswith('@'):
temp=re.findall (r':nth-[a-z\-]+\([^)]+\)', line)
line=re.sub(r'(:nth-[a-z\-]+)\([^)]+\)',r'\1()', line)
line=re.sub(r'^[0-9].*', '', line)
line=re.sub(r'^to$', '', line)
line=re.sub(r'::[^\n,]+', '', line)
line=re.sub(r'#[^\.\s,>:+\*~#\)]+', '#id', line)#create ids
line=re.sub(r'\.[^\.\s,>:+\*~#\)]+', '.class', line)#create classes
line=re.sub(r'([\s,>+\(])[^\.\s,>:+\*~#\[\)]+', r'\1tag', line)#create tags
line=re.sub(r'([*~])[^=\.\s,>:+\*~#\[\)]+', r'\1tag', line)
line=re.sub(r'^[^\.\s,>:+\*~#\[]+', 'tag', line)#for the beginning tags
line=re.sub(r':lang\(.*\)', '', line)
line=re.sub(r'\[[^\^\$\*\|\!~=\]]+', '[name', line)#create attributes names
line=re.sub(r'\[name([\^\$\*\|\!~]?=)\"?([^\"\]]+)"?\]', r'[name\1value]', line)#create attributes values
line=re.sub(r'gt\(\s*tag\s*\)', 'gt(value)',line)
line=re.sub(r'lt\(\s*tag\s*\)', 'lt(value)',line)
line=re.sub(r'eg\(\s*tag\s*\)', 'eg(value)',line)
line=re.sub(r'contains\(\s*tag\s*\)', 'contains(value)',line)
if not line=='\n':
newlines.append(line)
if temp:
newlines.append(str(temp))
with open('CSSDBCriteria.txt', 'w') as f:
for line in newlines:
line=line.rstrip(' \t\n\r')
f.write('%s\n' % line)