10
0
mirror of https://gitlab.com/scemama/irpf90.git synced 2024-11-19 12:32:22 +01:00
irpf90/src/util.py

25 lines
533 B
Python
Raw Normal View History

2009-09-02 20:45:53 +02:00
#!/usr/bin/python
def same_file(filename,txt):
assert isinstance(filename,str)
assert isinstance(txt,list)
try:
file = open(filename,"r")
except IOError:
return False
lines = file.readlines()
file.close()
if len(lines) != len(txt):
return False
for a,b in zip(lines,txt):
if a != b:
return False
return True
if __name__ == '__main__':
txt = open('/etc/passwd','r').readlines()
print same_file('/etc/passwd',txt)
print same_file('/etc/group',txt)
print same_file('/etc/passwd-',txt)