Purpose: Compare the contents between ow ticket and swf log.
It can generate the different contents into different.txt.
perthon version: 3.6.3
Use: python compare.py
import sys
f_ow, f_swf = None, None
p_ow = "F080-OVnvpro-041.txt"
p_swf = 'swf-log.txt'
p_diff = "different.txt"
# reead lines from F080-OVnvpro-041.txt
try:
f_ow = open(p_ow, "r")
ow = f_ow.readlines()
for i in range(len(ow)):
ow[i] = ow[i].lstrip()
except IOError:
print(p_ow + " does not exist!")
sys.exit(2)
finally:
if f_ow:
f_ow.close()
# reead lines from swf-log.txt
try:
with open(p_swf,'+r') as f:
t1 = f.read()
#Move the Read offset to the beginning
f.seek(0, 0)
t2 = t1.replace('/nvpro/branches/released/F080/src/nv/etc', 'install')
f.write(t2)
f_swf = open(p_swf, "r")
swf = f_swf.readlines()
except IOError:
print(p_swf + " does not exist!" )
sys.exit(2)
finally:
if f_swf:
f_swf.close()
#filter
for a in ow:
for b in swf:
if a == b:
swf.remove(b)
for i in range(len(swf)):
swf[i] = swf[i].strip()
#print swf
#print " ".join(swf)
for diff in swf:
with open(p_diff,"a") as fdif:
fdif.write(diff+"\n")