repl.it
@rpat/

scriptTest

Python

No description

fork
loading
Files
  • main.py
main.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
import re
data = open("text",'r').read()
out = open("text1",'w')


splitByIP = re.compile("(=* [0-9]+\.[0-9]+\.[0-9]+\.[0-9]+ =*)")
dataSplitted = []
for i in splitByIP.split(data):
    dataSplitted.append(list(map(lambda y: list(map(lambda k : k.strip().replace("=",""),y)), list(map(lambda x : x.split(":"), i.split("\n"))))))

resultDict = {}
ipPattern = re.compile('( [0-9]+\.[0-9]+\.[0-9]+\.[0-9]+ )')
currentNode = []
appendFlag = False
for content in dataSplitted:
    if ipPattern.match(content[0][0]):
        resultDict[content[0][0].strip()] = {}
        currentNode = content[0][0].strip()
        appendFlag = True
    elif appendFlag == True:
            for k in range(1,5):
                resultDict[currentNode][content[k][0]] = content[k][1]
            appendFlag = False

print(resultDict)
for key,value in resultDict.items():
    print("\n-----**************************-----\n")
    print("Node IP: " + key)
    print("\tBridge Name:" + value['Bridge'])
    print("\tBond: " + value['Bond'])
    print("\tBond Mode: " + value['bond_mode'])
    print("\tInterfaces: " + value['interfaces'])
    print("\n-----**************************-----\n")
Fetching token
?