mirror of
https://github.com/nwchemgit/nwchem.git
synced 2026-07-21 06:25:21 -04:00
fix bandit text warnings
This commit is contained in:
parent
f862f56f04
commit
a0824916fd
4 changed files with 48 additions and 48 deletions
|
|
@ -34,9 +34,9 @@ from pylab import *
|
||||||
def parse_nwchem_output(fname):
|
def parse_nwchem_output(fname):
|
||||||
import re
|
import re
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
singlet_pat = re.compile('\s+Root\s+\d+\s+singlet')
|
singlet_pat = re.compile(r'\s+Root\s+\d+\s+singlet')
|
||||||
triplet_pat = re.compile('\s+Root\s+\d+\s+triplet')
|
triplet_pat = re.compile(r'\s+Root\s+\d+\s+triplet')
|
||||||
unrestricted_pat = re.compile('\s+Root\s+\d')
|
unrestricted_pat = re.compile(r'\s+Root\s+\d')
|
||||||
singlets = []
|
singlets = []
|
||||||
triplets = []
|
triplets = []
|
||||||
unrestricted = []
|
unrestricted = []
|
||||||
|
|
@ -59,7 +59,7 @@ def parse_nwchem_output(fname):
|
||||||
|
|
||||||
def parse_element(line,f):
|
def parse_element(line,f):
|
||||||
import re
|
import re
|
||||||
oscillator_pat = re.compile('\s+Oscillator')
|
oscillator_pat = re.compile(r'\s+Oscillator')
|
||||||
words = line.split()
|
words = line.split()
|
||||||
try:
|
try:
|
||||||
energy = float(words[4])
|
energy = float(words[4])
|
||||||
|
|
|
||||||
|
|
@ -189,7 +189,7 @@ def find_code_skeleton_type(lines,subr_lines):
|
||||||
autoxc-Ds generated subroutine.
|
autoxc-Ds generated subroutine.
|
||||||
"""
|
"""
|
||||||
(lineno_start,lineno_end) = subr_lines
|
(lineno_start,lineno_end) = subr_lines
|
||||||
pattern = re.compile("if \(taua\.gt\.tol_rho\) then")
|
pattern = re.compile(r"if \(taua\.gt\.tol_rho\) then")
|
||||||
subr_type = type_autoxc
|
subr_type = type_autoxc
|
||||||
line = lineno_start
|
line = lineno_start
|
||||||
while line <= lineno_end:
|
while line <= lineno_end:
|
||||||
|
|
@ -210,14 +210,14 @@ def find_autoxc_code_skeleton(lines,subr_lines):
|
||||||
ifstart = -1
|
ifstart = -1
|
||||||
ifend = -1
|
ifend = -1
|
||||||
#
|
#
|
||||||
pattern = re.compile("if \(rhoa\.gt\.tol_rho\) then")
|
pattern = re.compile(r"if \(rhoa\.gt\.tol_rho\) then")
|
||||||
while line <= lineno_end:
|
while line <= lineno_end:
|
||||||
if pattern.search(lines[line]):
|
if pattern.search(lines[line]):
|
||||||
ifstart = line+1
|
ifstart = line+1
|
||||||
break
|
break
|
||||||
line += 1
|
line += 1
|
||||||
#
|
#
|
||||||
pattern = re.compile("endif ! rhoa\.gt\.tol_rho")
|
pattern = re.compile(r"endif ! rhoa\.gt\.tol_rho")
|
||||||
while line <= lineno_end:
|
while line <= lineno_end:
|
||||||
if pattern.search(lines[line]):
|
if pattern.search(lines[line]):
|
||||||
ifend = line-1
|
ifend = line-1
|
||||||
|
|
@ -232,14 +232,14 @@ def find_autoxc_code_skeleton(lines,subr_lines):
|
||||||
ifendb = -1
|
ifendb = -1
|
||||||
ifstartc = -1
|
ifstartc = -1
|
||||||
ifendc = -1
|
ifendc = -1
|
||||||
pattern = re.compile("if \(rhoa\.gt\.tol_rho\.and\.rhob\.gt\.tol_rho\) then")
|
pattern = re.compile(r"if \(rhoa\.gt\.tol_rho\.and\.rhob\.gt\.tol_rho\) then")
|
||||||
while line <= lineno_end:
|
while line <= lineno_end:
|
||||||
if pattern.search(lines[line]):
|
if pattern.search(lines[line]):
|
||||||
ifstarta = line+1
|
ifstarta = line+1
|
||||||
break
|
break
|
||||||
line += 1
|
line += 1
|
||||||
#
|
#
|
||||||
pattern = re.compile("elseif \(rhoa\.gt\.tol_rho\.and\.rhob\.le\.tol_rho\) then")
|
pattern = re.compile(r"elseif \(rhoa\.gt\.tol_rho\.and\.rhob\.le\.tol_rho\) then")
|
||||||
while line <= lineno_end:
|
while line <= lineno_end:
|
||||||
if pattern.search(lines[line]):
|
if pattern.search(lines[line]):
|
||||||
ifenda = line-1
|
ifenda = line-1
|
||||||
|
|
@ -247,7 +247,7 @@ def find_autoxc_code_skeleton(lines,subr_lines):
|
||||||
break
|
break
|
||||||
line += 1
|
line += 1
|
||||||
#
|
#
|
||||||
pattern = re.compile("elseif \(rhoa\.le\.tol_rho\.and\.rhob\.gt\.tol_rho\) then")
|
pattern = re.compile(r"elseif \(rhoa\.le\.tol_rho\.and\.rhob\.gt\.tol_rho\) then")
|
||||||
while line <= lineno_end:
|
while line <= lineno_end:
|
||||||
if pattern.search(lines[line]):
|
if pattern.search(lines[line]):
|
||||||
ifendb = line-1
|
ifendb = line-1
|
||||||
|
|
@ -255,7 +255,7 @@ def find_autoxc_code_skeleton(lines,subr_lines):
|
||||||
break
|
break
|
||||||
line += 1
|
line += 1
|
||||||
#
|
#
|
||||||
pattern = re.compile("endif ! rhoa\.gt\.tol_rho\.and\.rhob\.gt\.tol_rho")
|
pattern = re.compile(r"endif ! rhoa\.gt\.tol_rho\.and\.rhob\.gt\.tol_rho")
|
||||||
while line <= lineno_end:
|
while line <= lineno_end:
|
||||||
if pattern.search(lines[line]):
|
if pattern.search(lines[line]):
|
||||||
ifendc = line-1
|
ifendc = line-1
|
||||||
|
|
@ -281,14 +281,14 @@ def find_autoxcDs_code_skeleton(lines,subr_lines):
|
||||||
ifstartb = -1
|
ifstartb = -1
|
||||||
ifendb = -1
|
ifendb = -1
|
||||||
#
|
#
|
||||||
pattern = re.compile("if \(taua\.gt\.tol_rho\) then")
|
pattern = re.compile(r"if \(taua\.gt\.tol_rho\) then")
|
||||||
while line <= lineno_end:
|
while line <= lineno_end:
|
||||||
if pattern.search(lines[line]):
|
if pattern.search(lines[line]):
|
||||||
ifstarta = line+1
|
ifstarta = line+1
|
||||||
break
|
break
|
||||||
line += 1
|
line += 1
|
||||||
#
|
#
|
||||||
pattern = re.compile("else")
|
pattern = re.compile(r"else")
|
||||||
while line <= lineno_end:
|
while line <= lineno_end:
|
||||||
if pattern.search(lines[line]):
|
if pattern.search(lines[line]):
|
||||||
ifenda = line-1
|
ifenda = line-1
|
||||||
|
|
@ -296,7 +296,7 @@ def find_autoxcDs_code_skeleton(lines,subr_lines):
|
||||||
break
|
break
|
||||||
line += 1
|
line += 1
|
||||||
#
|
#
|
||||||
pattern = re.compile("endif")
|
pattern = re.compile(r"endif")
|
||||||
while line <= lineno_end:
|
while line <= lineno_end:
|
||||||
if pattern.search(lines[line]):
|
if pattern.search(lines[line]):
|
||||||
ifendb = line-1
|
ifendb = line-1
|
||||||
|
|
@ -315,14 +315,14 @@ def find_autoxcDs_code_skeleton(lines,subr_lines):
|
||||||
ifendc = -1
|
ifendc = -1
|
||||||
ifstartd = -1
|
ifstartd = -1
|
||||||
ifendd = -1
|
ifendd = -1
|
||||||
pattern = re.compile("if \(taua\.gt\.tol_rho\.and\.taub\.gt\.tol_rho\) then")
|
pattern = re.compile(r"if \(taua\.gt\.tol_rho\.and\.taub\.gt\.tol_rho\) then")
|
||||||
while line <= lineno_end:
|
while line <= lineno_end:
|
||||||
if pattern.search(lines[line]):
|
if pattern.search(lines[line]):
|
||||||
ifstarta = line+1
|
ifstarta = line+1
|
||||||
break
|
break
|
||||||
line += 1
|
line += 1
|
||||||
#
|
#
|
||||||
pattern = re.compile("elseif \(taua\.gt\.tol_rho\.and\.taub\.le\.tol_rho\) then")
|
pattern = re.compile(r"elseif \(taua\.gt\.tol_rho\.and\.taub\.le\.tol_rho\) then")
|
||||||
while line <= lineno_end:
|
while line <= lineno_end:
|
||||||
if pattern.search(lines[line]):
|
if pattern.search(lines[line]):
|
||||||
ifenda = line-1
|
ifenda = line-1
|
||||||
|
|
@ -330,7 +330,7 @@ def find_autoxcDs_code_skeleton(lines,subr_lines):
|
||||||
break
|
break
|
||||||
line += 1
|
line += 1
|
||||||
#
|
#
|
||||||
pattern = re.compile("elseif \(taua\.le\.tol_rho\.and\.taub\.gt\.tol_rho\) then")
|
pattern = re.compile(r"elseif \(taua\.le\.tol_rho\.and\.taub\.gt\.tol_rho\) then")
|
||||||
while line <= lineno_end:
|
while line <= lineno_end:
|
||||||
if pattern.search(lines[line]):
|
if pattern.search(lines[line]):
|
||||||
ifendb = line-1
|
ifendb = line-1
|
||||||
|
|
@ -340,7 +340,7 @@ def find_autoxcDs_code_skeleton(lines,subr_lines):
|
||||||
#
|
#
|
||||||
# needed because "else" is a substring of "elseif ..."
|
# needed because "else" is a substring of "elseif ..."
|
||||||
line = ifstartc
|
line = ifstartc
|
||||||
pattern = re.compile("else")
|
pattern = re.compile(r"else")
|
||||||
while line <= lineno_end:
|
while line <= lineno_end:
|
||||||
if pattern.search(lines[line]):
|
if pattern.search(lines[line]):
|
||||||
ifendc = line-1
|
ifendc = line-1
|
||||||
|
|
@ -348,7 +348,7 @@ def find_autoxcDs_code_skeleton(lines,subr_lines):
|
||||||
break
|
break
|
||||||
line += 1
|
line += 1
|
||||||
#
|
#
|
||||||
pattern = re.compile("endif")
|
pattern = re.compile(r"endif")
|
||||||
while line <= lineno_end:
|
while line <= lineno_end:
|
||||||
if pattern.search(lines[line]):
|
if pattern.search(lines[line]):
|
||||||
ifendd = line-1
|
ifendd = line-1
|
||||||
|
|
@ -368,7 +368,7 @@ def find_type_declaration_insertion_point(lines,subr_lines):
|
||||||
subroutine calls can be inserted.
|
subroutine calls can be inserted.
|
||||||
"""
|
"""
|
||||||
(lineno_start,lineno_end) = subr_lines
|
(lineno_start,lineno_end) = subr_lines
|
||||||
pattern = re.compile("#include \"nwxc_param.fh\"")
|
pattern = re.compile(r"#include \"nwxc_param.fh\"")
|
||||||
line_insert = -1
|
line_insert = -1
|
||||||
line = lineno_start
|
line = lineno_start
|
||||||
while line <= lineno_end:
|
while line <= lineno_end:
|
||||||
|
|
@ -412,7 +412,7 @@ def collect_subroutine_calls(lines,ifbranch_lines):
|
||||||
"""
|
"""
|
||||||
(lineno_start,lineno_end) = ifbranch_lines
|
(lineno_start,lineno_end) = ifbranch_lines
|
||||||
dict = {}
|
dict = {}
|
||||||
pattern = re.compile("nwxc")
|
pattern = re.compile(r"nwxc")
|
||||||
line = lineno_start
|
line = lineno_start
|
||||||
while line <= lineno_end:
|
while line <= lineno_end:
|
||||||
if pattern.search(lines[line]):
|
if pattern.search(lines[line]):
|
||||||
|
|
@ -640,8 +640,8 @@ def find_max_order_diff(lines,subr_lines):
|
||||||
(lineno_start,lineno_end) = subr_lines
|
(lineno_start,lineno_end) = subr_lines
|
||||||
aline = lines[lineno_start]
|
aline = lines[lineno_start]
|
||||||
orderdiff = 0
|
orderdiff = 0
|
||||||
pattern_d2 = re.compile("_d2\(")
|
pattern_d2 = re.compile(r"_d2\(")
|
||||||
pattern_d3 = re.compile("_d3\(")
|
pattern_d3 = re.compile(r"_d3\(")
|
||||||
if pattern_d2.search(aline):
|
if pattern_d2.search(aline):
|
||||||
orderdiff = 2
|
orderdiff = 2
|
||||||
elif pattern_d3.search(aline):
|
elif pattern_d3.search(aline):
|
||||||
|
|
@ -740,9 +740,9 @@ def find_varname(dict,diffstr):
|
||||||
#DEBUG
|
#DEBUG
|
||||||
lengthl = len(list)
|
lengthl = len(list)
|
||||||
if num == lengthl:
|
if num == lengthl:
|
||||||
sys.stdout.write("entity %s not found\n"%callref)
|
sys.stdout.write(r"entity %s not found\n"%callref)
|
||||||
for jj in range(0,length):
|
for jj in range(0,length):
|
||||||
sys.stdout.write("list %d: %s\n"%(jj,list[jj]))
|
sys.stdout.write(r"list %d: %s\n"%(jj,list[jj]))
|
||||||
sys.exit(10)
|
sys.exit(10)
|
||||||
# num is now the variable set number
|
# num is now the variable set number
|
||||||
lengthd = len(data)
|
lengthd = len(data)
|
||||||
|
|
@ -764,8 +764,8 @@ def find_varname(dict,diffstr):
|
||||||
#print "find_varname: orderdiff:",orderdiff
|
#print "find_varname: orderdiff:",orderdiff
|
||||||
#DEBUG
|
#DEBUG
|
||||||
# orderdiff is now the order of differentiation
|
# orderdiff is now the order of differentiation
|
||||||
patternc = re.compile("gamma")
|
patternc = re.compile(r"gamma")
|
||||||
patternt = re.compile("tau")
|
patternt = re.compile(r"tau")
|
||||||
var_func = func_lda
|
var_func = func_lda
|
||||||
if lengthd >= 3:
|
if lengthd >= 3:
|
||||||
if patternc.match(data[1]):
|
if patternc.match(data[1]):
|
||||||
|
|
@ -909,7 +909,7 @@ def find_indent(line):
|
||||||
Given a line of source code work the indentation out and return a string
|
Given a line of source code work the indentation out and return a string
|
||||||
containing as many spaces as the indentation.
|
containing as many spaces as the indentation.
|
||||||
"""
|
"""
|
||||||
pattern = re.compile("\s*")
|
pattern = re.compile(r"\s*")
|
||||||
obj = pattern.match(line)
|
obj = pattern.match(line)
|
||||||
indent = obj.group()
|
indent = obj.group()
|
||||||
return indent
|
return indent
|
||||||
|
|
@ -919,13 +919,13 @@ def find_var_in_line(line,var_name):
|
||||||
Find all locations where the variable given by "var_name" is used.
|
Find all locations where the variable given by "var_name" is used.
|
||||||
The locations are stored in a list which is returned.
|
The locations are stored in a list which is returned.
|
||||||
"""
|
"""
|
||||||
patterne = re.compile(" = ")
|
patterne = re.compile(r" = ")
|
||||||
# If var_name = t2 we need to make sure we do not replace
|
# If var_name = t2 we need to make sure we do not replace
|
||||||
# cmat2 as well. Patternw is needed to achieve that. So we look for
|
# cmat2 as well. Patternw is needed to achieve that. So we look for
|
||||||
# t2 as well at2, if the end-points are equal the string found does
|
# t2 as well at2, if the end-points are equal the string found does
|
||||||
# not match the variable t2.
|
# not match the variable t2.
|
||||||
patternv = re.compile(var_name+"[^0-9]")
|
patternv = re.compile(var_name+"[^0-9]")
|
||||||
patternw = re.compile("a"+var_name+"[^0-9]")
|
patternw = re.compile(r"a"+var_name+"[^0-9]")
|
||||||
aline = line+" "
|
aline = line+" "
|
||||||
found = patterne.search(aline)
|
found = patterne.search(aline)
|
||||||
list = []
|
list = []
|
||||||
|
|
@ -952,7 +952,7 @@ def expand_var_in_line(line,list):
|
||||||
Here we expand the tuples in the list to cover these strings in full.
|
Here we expand the tuples in the list to cover these strings in full.
|
||||||
The list with updated tuples is returned.
|
The list with updated tuples is returned.
|
||||||
"""
|
"""
|
||||||
pattern = re.compile("\)")
|
pattern = re.compile(r"\)")
|
||||||
item = 0
|
item = 0
|
||||||
length = len(list)
|
length = len(list)
|
||||||
while item < length:
|
while item < length:
|
||||||
|
|
@ -1006,7 +1006,7 @@ def rewrap_line(longline):
|
||||||
conform the Fortran77 standard. The chunks are written to standard output.
|
conform the Fortran77 standard. The chunks are written to standard output.
|
||||||
In addition we do not want to break the line in the middle of numbers.
|
In addition we do not want to break the line in the middle of numbers.
|
||||||
"""
|
"""
|
||||||
pattern = re.compile("\S")
|
pattern = re.compile(r"\S")
|
||||||
i = (pattern.search(longline)).start()
|
i = (pattern.search(longline)).start()
|
||||||
indent = longline[:i]
|
indent = longline[:i]
|
||||||
indent = indent[:5]+"+"+indent[7:]+" "
|
indent = indent[:5]+"+"+indent[7:]+" "
|
||||||
|
|
|
||||||
|
|
@ -39,18 +39,18 @@ def rewrap_line(longline):
|
||||||
while len(longline)-1 > 72:
|
while len(longline)-1 > 72:
|
||||||
i = -1
|
i = -1
|
||||||
# wrap before * / ( ) + or -
|
# wrap before * / ( ) + or -
|
||||||
i = max(i,rfind(longline,"+",0,71))
|
i = max(i,rfind(longline,r"+",0,71))
|
||||||
i = max(i,rfind(longline,"-",0,71))
|
i = max(i,rfind(longline,r"-",0,71))
|
||||||
i = max(i,rfind(longline,"/",0,71))
|
i = max(i,rfind(longline,r"/",0,71))
|
||||||
i = max(i,rfind(longline,"\,",0,70))
|
i = max(i,rfind(longline,r"\,",0,70))
|
||||||
i = max(i,rfind(longline,", ",0,70))
|
i = max(i,rfind(longline,r", ",0,70))
|
||||||
i = max(i,rfind(longline,"\it",0,69))
|
i = max(i,rfind(longline,r"\it",0,69))
|
||||||
i = max(i,rfind(longline,"\rho",0,68))
|
i = max(i,rfind(longline,r"\rho",0,68))
|
||||||
i = max(i,rfind(longline,"\sigma",0,66))
|
i = max(i,rfind(longline,r"\sigma",0,66))
|
||||||
i = max(i,rfind(longline,"\tau",0,68))
|
i = max(i,rfind(longline,r"\tau",0,68))
|
||||||
i = max(i,rfind(longline,"\left",0,67))
|
i = max(i,rfind(longline,r"\left",0,67))
|
||||||
i = max(i,rfind(longline,"\over",0,67))
|
i = max(i,rfind(longline,r"\over",0,67))
|
||||||
i = max(i,rfind(longline,"\right",0,66))
|
i = max(i,rfind(longline,r"\right",0,66))
|
||||||
if i == -1:
|
if i == -1:
|
||||||
sys.stderr.write("No sensible break point found in:\n")
|
sys.stderr.write("No sensible break point found in:\n")
|
||||||
sys.stderr.write(longline)
|
sys.stderr.write(longline)
|
||||||
|
|
|
||||||
|
|
@ -286,7 +286,7 @@ class Operator:
|
||||||
"""Returns a LaTex form of output"""
|
"""Returns a LaTex form of output"""
|
||||||
show = string.join([self.type[0],"_{",repr(self.index),"}"], "")
|
show = string.join([self.type[0],"_{",repr(self.index),"}"], "")
|
||||||
if (self.dagger == "creation"):
|
if (self.dagger == "creation"):
|
||||||
show = string.join([show, "^{\dagger}"], "")
|
show = string.join([show, r"^{\dagger}"], "")
|
||||||
return show
|
return show
|
||||||
|
|
||||||
def duplicate(self):
|
def duplicate(self):
|
||||||
|
|
@ -507,7 +507,7 @@ class Amplitude:
|
||||||
show = string.join([show, index.texwithoutdagger()])
|
show = string.join([show, index.texwithoutdagger()])
|
||||||
show = string.join([show,"}"])
|
show = string.join([show,"}"])
|
||||||
if (self.conjugate):
|
if (self.conjugate):
|
||||||
show = string.join(["\\left(",show,"\\right)^{\\dagger}"],"")
|
show = string.join([r"\\left(",show,"\\right)^{\\dagger}"],"")
|
||||||
return show
|
return show
|
||||||
|
|
||||||
def duplicate(self):
|
def duplicate(self):
|
||||||
|
|
@ -845,10 +845,10 @@ class OperatorSequence:
|
||||||
if (self.sequence):
|
if (self.sequence):
|
||||||
show = string.join([show, "\\langle 0 |"])
|
show = string.join([show, "\\langle 0 |"])
|
||||||
for sequence in self.sequence:
|
for sequence in self.sequence:
|
||||||
show = string.join([show, "\{"])
|
show = string.join([show, r"\{"])
|
||||||
for operator in sequence:
|
for operator in sequence:
|
||||||
show = string.join([show, operator.tex()])
|
show = string.join([show, operator.tex()])
|
||||||
show = string.join([show, "\}"])
|
show = string.join([show, r"\}"])
|
||||||
show = string.join([show, "|0\\rangle"])
|
show = string.join([show, "|0\\rangle"])
|
||||||
return show
|
return show
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue