mirror of
https://github.com/cp2k/cp2k.git
synced 2026-07-28 22:25:32 -04:00
Ready all python scripts for self-testing
svn-origin-rev: 16681
This commit is contained in:
parent
32a0e46281
commit
531921f2c8
11 changed files with 53 additions and 98 deletions
|
|
@ -83,7 +83,9 @@ def process_log(log_fn, mnk, winners):
|
|||
|
||||
|
||||
#===============================================================================
|
||||
|
||||
main()
|
||||
if(len(sys.argv)==2 and sys.argv[-1]=="--selftest"):
|
||||
pass #TODO implement selftest
|
||||
else:
|
||||
main()
|
||||
|
||||
#EOF
|
||||
|
|
|
|||
|
|
@ -300,8 +300,10 @@ def combinations(*sizes):
|
|||
return(list(product(sizes, sizes, sizes)))
|
||||
|
||||
#===============================================================================
|
||||
|
||||
main()
|
||||
if(len(sys.argv)==2 and sys.argv[-1]=="--selftest"):
|
||||
pass #TODO implement selftest
|
||||
else:
|
||||
main()
|
||||
|
||||
#EOF
|
||||
|
||||
|
|
|
|||
|
|
@ -77,4 +77,11 @@ def main():
|
|||
f.close()
|
||||
|
||||
print("Wrote parameters.new")
|
||||
main()
|
||||
|
||||
#===============================================================================
|
||||
if(len(sys.argv)==2 and sys.argv[-1]=="--selftest"):
|
||||
pass #TODO implement selftest
|
||||
else:
|
||||
main()
|
||||
|
||||
#EOF
|
||||
|
|
|
|||
|
|
@ -39,7 +39,9 @@ def main():
|
|||
print("Number of jobs submitted: %d"%n_submits)
|
||||
|
||||
#===============================================================================
|
||||
|
||||
main()
|
||||
if(len(sys.argv)==2 and sys.argv[-1]=="--selftest"):
|
||||
pass #TODO implement selftest
|
||||
else:
|
||||
main()
|
||||
|
||||
#EOF
|
||||
|
|
|
|||
|
|
@ -223,8 +223,10 @@ def combinations(*sizes):
|
|||
return(list(product(sizes, sizes, sizes)))
|
||||
|
||||
#===============================================================================
|
||||
|
||||
main()
|
||||
if(len(sys.argv)==2 and sys.argv[-1]=="--selftest"):
|
||||
pass #TODO implement selftest
|
||||
else:
|
||||
main()
|
||||
|
||||
#EOF
|
||||
|
||||
|
|
|
|||
11
tools/formatting/addSynopsis.py
Executable file → Normal file
11
tools/formatting/addSynopsis.py
Executable file → Normal file
|
|
@ -1,5 +1,3 @@
|
|||
#! /usr/bin/env python
|
||||
|
||||
import sys
|
||||
from sys import argv
|
||||
|
||||
|
|
@ -260,11 +258,4 @@ def addSynopsisInDir(interfaceDir, outDir,filePaths,logFile=sys.stdout):
|
|||
logFile.write("+++ error renaming"+outFilePath+"\n")
|
||||
return fileMapping
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv)<4:
|
||||
print "usage:", sys.argv[0]," interface_dir out_dir sourcefile1.F [sourcefile2.F ...]"
|
||||
else:
|
||||
interfaceDir=sys.argv[1]
|
||||
outDir=sys.argv[2]
|
||||
addSynopsisInDir(interfaceDir, outDir,sys.argv[3:],sys.stdout)
|
||||
|
||||
#EOF
|
||||
|
|
|
|||
28
tools/formatting/normalizeExtended.py
Executable file → Normal file
28
tools/formatting/normalizeExtended.py
Executable file → Normal file
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
Impose white space conventions and indentation based on scopes / subunits
|
||||
|
||||
|
|
@ -779,28 +777,4 @@ def format_extended_ffile(infile, outfile, logFile=sys.stdout, indent_size=2, or
|
|||
# rm subsequent blank lines
|
||||
skip_blank = is_empty and not comments
|
||||
|
||||
#=========================================================================
|
||||
|
||||
if __name__ == '__main__':
|
||||
import os.path
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
print "usage:", sys.argv[0], " out_dir file1 [file2 ...]"
|
||||
sys.exit(1)
|
||||
|
||||
outDir = sys.argv[1]
|
||||
if not os.path.isdir(outDir):
|
||||
print "out_dir must be a directory"
|
||||
print "usage:", sys.argv[0], " out_dir file1 [file2 ...]"
|
||||
sys.exit(1)
|
||||
|
||||
for fileName in sys.argv[2:]:
|
||||
try:
|
||||
print "normalizing body of", fileName
|
||||
|
||||
with open(fileName, 'r') as infile:
|
||||
with open(os.path.join(outDir, os.path.basename(fileName)), 'w') as outfile:
|
||||
format_extended_ffile(infile, outfile)
|
||||
except:
|
||||
print "error for file", fileName
|
||||
raise
|
||||
#EOF
|
||||
|
|
|
|||
28
tools/formatting/normalizeFortranFile.py
Executable file → Normal file
28
tools/formatting/normalizeFortranFile.py
Executable file → Normal file
|
|
@ -1,5 +1,3 @@
|
|||
#! /usr/bin/env python
|
||||
|
||||
import sys
|
||||
import re
|
||||
import string
|
||||
|
|
@ -996,28 +994,4 @@ def rewriteFortranFile(inFile,outFile,logFile=sys.stdout,orig_filename=None):
|
|||
logFile.write("Processing file '"+inFile.name+"'\n")
|
||||
raise
|
||||
|
||||
if __name__ == '__main__':
|
||||
import os.path
|
||||
if len(sys.argv)<2:
|
||||
print "usage:", sys.argv[0]," out_dir file1 [file2 ...]"
|
||||
else:
|
||||
outDir=sys.argv[1]
|
||||
if not os.path.isdir(outDir):
|
||||
print "out_dir must be a directory"
|
||||
print "usage:", sys.argv[0]," out_dir file1 [file2 ...]"
|
||||
else:
|
||||
for fileName in sys.argv[2:]:
|
||||
try:
|
||||
print "normalizing",fileName
|
||||
infile=open(fileName,'r')
|
||||
outfile=open(os.path.join(outDir,
|
||||
os.path.basename(fileName)),'w')
|
||||
rewriteFortranFile(infile,outfile)
|
||||
infile.close()
|
||||
outfile.close()
|
||||
except:
|
||||
print "error for file", fileName
|
||||
print "*** "*6
|
||||
print "removedUse=",rUse
|
||||
print "removedVar=",rVar
|
||||
# print "done"
|
||||
#EOF
|
||||
|
|
|
|||
22
tools/formatting/replacer.py
Executable file → Normal file
22
tools/formatting/replacer.py
Executable file → Normal file
|
|
@ -1,5 +1,3 @@
|
|||
#! /usr/bin/env python
|
||||
|
||||
import re
|
||||
import sys
|
||||
|
||||
|
|
@ -14,38 +12,28 @@ def replaceWords(infile,outfile,replacements=repl,
|
|||
specialReplacements=specialRepl,
|
||||
logFile=sys.stdout):
|
||||
"""Replaces the words in infile writing the output to outfile.
|
||||
|
||||
|
||||
replacements is a dictionary with the words to replace.
|
||||
specialReplacements is a dictionary with general regexp replacements.
|
||||
"""
|
||||
lineNr=0
|
||||
nonWordRe=re.compile(r"(\W+)")
|
||||
|
||||
|
||||
while 1:
|
||||
line= infile.readline()
|
||||
lineNr=lineNr+1
|
||||
if not line: break
|
||||
|
||||
|
||||
if specialReplacements:
|
||||
for subs in specialReplacements.keys():
|
||||
line=subs.sub(specialReplacements[subs],line)
|
||||
|
||||
|
||||
tokens=nonWordRe.split(line)
|
||||
for token in tokens:
|
||||
if replacements.has_key(token):
|
||||
outfile.write(replacements[token])
|
||||
else:
|
||||
outfile.write(token)
|
||||
|
||||
#EOF
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv)<2:
|
||||
print "usage:", sys.argv[0]," file_in file_out"
|
||||
elif(len(sys.argv)==2 and sys.argv[-1]=="--selftest"):
|
||||
pass #TODO implement selftest
|
||||
else:
|
||||
infile=open(sys.argv[1],'r')
|
||||
outfile=open(sys.argv[2],'w')
|
||||
replaceWords(infile,outfile,replacements=repl,
|
||||
specialReplacements=specialRepl)
|
||||
|
||||
|
|
|
|||
|
|
@ -791,9 +791,13 @@ def maple2f90(code,replacements={}):
|
|||
c1="\n".join(lc1)+"\n"
|
||||
return c1
|
||||
|
||||
#===============================================================================
|
||||
if __name__=="__main__":
|
||||
replacements={}
|
||||
for i in range(len(renamedVar)):
|
||||
replacements[renamedVar[i]]=origNames[i]
|
||||
print maple2f90(code,replacements)
|
||||
|
||||
if(len(sys.argv)==2 and sys.argv[-1]=="--selftest"):
|
||||
pass #TODO implement selftest
|
||||
else:
|
||||
replacements={}
|
||||
for i in range(len(renamedVar)):
|
||||
replacements[renamedVar[i]]=origNames[i]
|
||||
print maple2f90(code,replacements)
|
||||
#EOF
|
||||
|
|
|
|||
|
|
@ -176,8 +176,8 @@ def prettfyInplace(fileName,bkDir="preprettify",normalize_use=1,
|
|||
infile.close()
|
||||
outfile.close()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
def main():
|
||||
defaultsDict={'upcase':1,'normalize-use':1,'extended':0,'indent':2,'replace':1,
|
||||
'interface-dir':None,
|
||||
'backup-dir':'preprettify'}
|
||||
|
|
@ -192,7 +192,7 @@ if __name__ == '__main__':
|
|||
If requested the replacements performed by the replacer.py script
|
||||
are also preformed.
|
||||
"""+str(defaultsDict))
|
||||
|
||||
|
||||
replace=None
|
||||
if "--help" in sys.argv:
|
||||
print usageDesc
|
||||
|
|
@ -248,3 +248,12 @@ if __name__ == '__main__':
|
|||
sys.stdout.write('-'*60+"\n")
|
||||
sys.stdout.write("Processing file '"+fileName+"'\n")
|
||||
sys.exit(failure>0)
|
||||
|
||||
|
||||
#===============================================================================
|
||||
if(len(sys.argv)==2 and sys.argv[-1]=="--selftest"):
|
||||
pass #TODO implement selftest
|
||||
else:
|
||||
main()
|
||||
|
||||
#EOF
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue