2009-09-02 20:45:53 +02:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
2009-09-04 15:11:42 +02:00
|
|
|
def strip(x):
|
|
|
|
return x.strip()
|
|
|
|
|
2009-09-02 20:45:53 +02:00
|
|
|
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
|
|
|
|
|
2009-09-04 15:11:42 +02:00
|
|
|
def build_dim(dim):
|
|
|
|
if len(dim) == 0:
|
|
|
|
return ""
|
|
|
|
else:
|
|
|
|
return "(%s)"%( ",".join(dim) )
|
|
|
|
|
2009-09-02 20:45:53 +02:00
|
|
|
if __name__ == '__main__':
|
2009-09-04 15:11:42 +02:00
|
|
|
print build_dim([])
|
|
|
|
print build_dim(['a'])
|
|
|
|
print build_dim(['a','b'])
|