-
Notifications
You must be signed in to change notification settings - Fork 64
/
flagck.py
49 lines (39 loc) · 1.09 KB
/
flagck.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
#!/bin/env python3
# 检查T/F标记
import re
file_name = 'POSCAR'
with open(file_name) as input_file:
content = input_file.readlines()
pattern = re.compile('\s+')
pre_flag = []
flag = []
if re.search(r'^[Ss]', content[7]) is None:
print('')
print("Selective flag not found!")
print('')
exit(1)
print('')
print("Atom_id Content")
print("------------------------------------------")
for i in range(9, len(content)):
temp = pattern.split(content[i].strip())
if len(temp) == 1:
exit(1)
if len(temp) != 6:
print("-----------")
print("%4d: %s" % (i - 8, content[i].rstrip()))
print("-----------")
continue
if len(pre_flag) == 0:
pre_flag = [temp[3], temp[4], temp[5]]
flag = [temp[3], temp[4], temp[5]]
else:
flag = [temp[3], temp[4], temp[5]]
if flag == pre_flag:
continue
else:
pre_flag = flag
print("%4d: %s" % (i - 9, content[i - 1].rstrip()))
print("%4d: %s" % (i - 8, content[i].rstrip()))
print("-----------")
print('')