-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdateInputs.py
More file actions
38 lines (32 loc) · 1.09 KB
/
Copy pathUpdateInputs.py
File metadata and controls
38 lines (32 loc) · 1.09 KB
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
import re
import os
pattern1=re.compile("^\[rest://(.*)\]$")
pattern2=re.compile("endpoint =.*")
index=None
endpoint=None
flag=False
with open("inputs.conf",'r') as f, open("new_file.txt",'w') as f1:
for line in f:
match1=re.search(pattern1,line)
if match1:
print("Found pattern1 on line: "+line)
index=match1.group(1)
with open("maplecroft_indices.txt") as maplecroft_indices:
for lines in maplecroft_indices:
if index in lines:
lists=lines.split("|")
endpoint=lists[1]
flag=True
break
else:
flag=False
match2=pattern2.search(line)
if match2 and flag==True:
print(index+" --- "+endpoint);
endpoint="endpoint = "+endpoint
line=endpoint
f1.write(line)
f.close()
f1.close()
os.remove('inputs.conf')
os.rename("new_file.txt", 'inputs.conf')