2009-09-02 20:45:53 +02:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
import util
|
|
|
|
import makefile
|
|
|
|
import irpf90_t
|
|
|
|
|
|
|
|
initialized = False
|
|
|
|
|
|
|
|
|
|
|
|
def init():
|
|
|
|
|
|
|
|
global initialized
|
|
|
|
if initialized:
|
|
|
|
return
|
|
|
|
|
|
|
|
# Create directories
|
|
|
|
for dir in [ irpf90_t.irpdir, irpf90_t.mandir ]:
|
|
|
|
try:
|
|
|
|
wd = os.getcwd()
|
|
|
|
os.chdir(dir)
|
|
|
|
os.chdir(wd)
|
|
|
|
except OSError:
|
|
|
|
os.mkdir(dir)
|
|
|
|
|
|
|
|
# Create makefile
|
|
|
|
makefile.create()
|
|
|
|
|
|
|
|
# Copy current files in the irpdir
|
|
|
|
for filename in os.listdir(os.getcwd()):
|
|
|
|
if not filename[0].startswith(".") and not os.path.isdir(filename):
|
2009-09-17 10:54:09 +02:00
|
|
|
try:
|
2009-09-02 20:45:53 +02:00
|
|
|
file = open(filename,"r")
|
2009-09-17 10:54:09 +02:00
|
|
|
except IOError:
|
|
|
|
print "Warning : Unable to read file %s."%(filename)
|
|
|
|
else:
|
|
|
|
buffer = file.readlines()
|
2009-09-02 20:45:53 +02:00
|
|
|
file.close()
|
2009-09-17 10:54:09 +02:00
|
|
|
if not util.same_file(irpf90_t.irpdir+filename,buffer):
|
|
|
|
file = open(filename,"r")
|
|
|
|
buffer = file.read()
|
|
|
|
file.close()
|
|
|
|
file = open(irpf90_t.irpdir+filename,"w")
|
|
|
|
file.write(buffer)
|
|
|
|
file.close()
|
2009-09-02 20:45:53 +02:00
|
|
|
|
|
|
|
initialized = True
|
|
|
|
|