Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update of Survey Simulator in preparation for v9 release of OSSOS. 20…
…17-03-08T07:44 UT
- Loading branch information
jmpetit
authored and
jmpetit
committed
Mar 8, 2017
1 parent
bbc9088
commit 42b1fbb
Showing
23 changed files
with
1,710 additions
and
1,636 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#! /usr/bin/env python | ||
""" | ||
Inline the "include 'param.inc'" statements in SurveySubs.f. | ||
""" | ||
|
||
def read_file_raw(fichier): | ||
""" | ||
Reads in file 'fichier' and returns a list of lines. | ||
No processing is done on any line. | ||
""" | ||
iter = 0 | ||
while True: | ||
try: | ||
f = file(fichier,'r') | ||
except IOError: | ||
try: | ||
fg = gzip.open(fichier+'.gz','r') | ||
except IOError: | ||
print 'Cannot open', fichier, ' nor ', fichier+'.gz' | ||
iter += 1 | ||
if iter > 5: | ||
print 'Something is wrong, quitting!' | ||
lines = None | ||
break | ||
fichier = raw_input('Please re-enter the file name: ') | ||
else: | ||
lines = fg.readlines() | ||
fg.close() | ||
break | ||
else: | ||
lines = f.readlines() | ||
f.close() | ||
break | ||
return lines | ||
|
||
if __name__ == "__main__": | ||
fin = 'zzzz1' | ||
fout = 'zzzz0' | ||
lines = read_file_raw(fin) | ||
pas = read_file_raw('param.inc') | ||
if lines: | ||
fo = open(fout, 'w') | ||
for line in lines: | ||
cp = True | ||
ws = line.split() | ||
if (len(ws) == 2): | ||
if (((ws[0] == "include") or (ws[0] == "INCLUDE")) and (ws[1] == "'param.inc'")): | ||
cp = False | ||
for pa in pas: | ||
fo.write(pa) | ||
if cp: | ||
fo.write(line) | ||
fo.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.