Untitled

mail@pastecode.io avatar
unknown
python
2 years ago
1.3 kB
5
Indexable
Never
import re
from array import *
f = open('/home/volkan/Desktop/leases', 'r')

lines = f.readlines()
startsDate = []
endsDate=[]

newList = []
control = 0
control2 = 0
control3 = 0

for line in lines:
    words = line.split()
    for word in words:
        if re.match("^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$", word):
            #print(word)
            newList.append(word)

        elif word == "free;" or word=="active;":
            control += 1
            if control==1:
                newList.append(word)

        elif word=="set vendor-class-identifier" or word=="client-hostname":
            newstring = words[-1]
            newList.append(newstring)

        elif "starts" in words:
            control2 +=1
            if control2==1:
                startsDate.append(words[-5:])

        elif "ends" in words:
            control3 +=1
            if control3==1:
                endsDate.append(words[-5:])

        elif re.match("([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}", word):
            #print(word)
            newList.append(word)
            print(newList)
            print("Starts Date & Time  :",startsDate)
            print("Ends Date & Time  :",endsDate)
            newList.clear()
            startsDate.clear()
            endsDate.clear()
            control=0
            control2=0
            control3=0