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

46 lines
846 B
Python
Raw Normal View History

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-04 18:37:10 +02:00
def find_subname(line):
buffer = line.text.split('(')
if len(buffer) > 1:
buffer = " ".join(buffer[:-1])
else:
buffer = buffer[0]
buffer = buffer.lower().split()
if len(buffer) < 2:
error.fail(line,"Syntax Error")
return buffer[-1]
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'])