Skip to content

Commit

Permalink
Merge pull request #98 from leeping/py3compat
Browse files Browse the repository at this point in the history
Py3compat
  • Loading branch information
leeping committed Jan 22, 2018
2 parents e3f1041 + d26cdff commit 6c63991
Show file tree
Hide file tree
Showing 156 changed files with 3,185 additions and 20,258 deletions.
3 changes: 2 additions & 1 deletion Products/AMBER-FB15/PrelimStudy/mue.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python

from __future__ import print_function
import numpy as np

QM_MM = np.loadtxt('EnergyCompare.txt')
Expand All @@ -10,4 +11,4 @@
D -= np.mean(D)
D /= 4.184
D = np.abs(D)
print np.dot(D,QM_Wt)
print(np.dot(D,QM_Wt))
4 changes: 3 additions & 1 deletion bin/ForceBalance.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
""" @package ForceBalance
Executable script for starting ForceBalance. """
from __future__ import print_function

from builtins import range
import os, sys, re
import argparse
from forcebalance.parser import parse_inputs
Expand Down Expand Up @@ -141,7 +143,7 @@ def main():
newline += whites[i]
except: pass
i += 1
print newline
print(newline)

parser = argparse.ArgumentParser(description="Force Field Optimization System")
parser.add_argument("-c", "--continue", action="store_true", help="Continue from a previous run")
Expand Down
3 changes: 2 additions & 1 deletion bin/MakeInputFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
future we may want to autogenerate the input file. This would make everyone's lives much
easier, don't you think? :)
"""
from __future__ import print_function

import sys
import re
Expand Down Expand Up @@ -34,7 +35,7 @@ def main():
out.append("\n")
out += parser.printsection("$target",tgt_opt,parser.tgt_opts_types)
for line in out:
print line
print(line)

if __name__ == "__main__":
main()
32 changes: 18 additions & 14 deletions doc/callgraph/CallGraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@
@author Jiahao Chen
@date 2010
"""
from __future__ import print_function

import glob, StringIO, sys, tokenize
from future import standard_library
standard_library.install_aliases()
from builtins import object
import glob, io, sys, tokenize

class node:
class node(object):
"""
Data structure for holding information about python objects
"""
Expand Down Expand Up @@ -130,7 +134,7 @@ def main():

if not indeclar and t[0] not in knowntypeslist:
try:
g = tokenize.generate_tokens(StringIO.StringIO(line).readline)
g = tokenize.generate_tokens(io.StringIO(line).readline)

for _, token, _, _, _ in g:
matches = []
Expand All @@ -140,8 +144,8 @@ def main():
matches.append(someobj)

if len(matches)>1:
print >> sys.stderr, "Multiple matches detected for", token
print >> sys.stderr, "!!! Graph may contain errors !!!"
print("Multiple matches detected for", token, file=sys.stderr)
print("!!! Graph may contain errors !!!", file=sys.stderr)
for obj in matches:
if obj.parent == thisobj.oid:
match = obj
Expand All @@ -162,16 +166,16 @@ def main():



print "digraph G {"
print("digraph G {")

#Print modules
print 'subgraph {'
print('subgraph {')
#print ' rank = same'
for module in modulelist:
thisid = [obj.oid for obj in globalobjectlist[module] if \
obj.name == module and obj.dtype == 'file'][0]
print ' ', thisid, '[ label="'+module+'", color = grey, style="rounded,filled", fillcolor = yellow]'
print '}'
print(' ', thisid, '[ label="'+module+'", color = grey, style="rounded,filled", fillcolor = yellow]')
print('}')

#Print objects
inherits = []
Expand All @@ -183,18 +187,18 @@ def main():
elif obj.dtype == 'class':
shape = 'house'
if shape != None:
print obj.oid, '[label = "'+obj.name+'", shape =', shape, ']'
print(obj.oid, '[label = "'+obj.name+'", shape =', shape, ']')
if (obj.oid, obj.parent) not in inherits:
inherits.append((obj.oid, obj.parent))

for a, b in inherits:
print a, '->', b, '[style = dashed, arrowhead = none]'
print(a, '->', b, '[style = dashed, arrowhead = none]')

print "#Call graph"
print("#Call graph")

for a, b in references:
print a.oid, '->', b.oid
print "}"
print(a.oid, '->', b.oid)
print("}")

#List orphans
#import sys
Expand Down
26 changes: 14 additions & 12 deletions doc/doxypy.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env python2

from __future__ import print_function
from builtins import object
__applicationName__ = "doxypy"
__blurb__ = """
doxypy is an input filter for Doxygen. It preprocesses python
Expand Down Expand Up @@ -86,7 +88,7 @@ def makeTransition(self, input):
self.current_input = input
self.current_transition = transition
if options.debug:
print >>sys.stderr, "# FSM: executing (%s -> %s) for line '%s'" % (from_state, to_state, input)
print("# FSM: executing (%s -> %s) for line '%s'" % (from_state, to_state, input), file=sys.stderr)
callback(match)
return

Expand Down Expand Up @@ -208,8 +210,8 @@ def __flushBuffer(self):
if self.output:
try:
if options.debug:
print >>sys.stderr, "# OUTPUT: ", self.output
print >>self.outstream, "\n".join(self.output)
print("# OUTPUT: ", self.output, file=sys.stderr)
print("\n".join(self.output), file=self.outstream)
self.outstream.flush()
except IOError:
# Fix for FS#33. Catches "broken pipe" when doxygen closes
Expand All @@ -228,7 +230,7 @@ def resetCommentSearch(self, match):
Closes the current commentblock and starts a new comment search.
"""
if options.debug:
print >>sys.stderr, "# CALLBACK: resetCommentSearch"
print("# CALLBACK: resetCommentSearch", file=sys.stderr)
self.__closeComment()
self.startCommentSearch(match)

Expand All @@ -239,7 +241,7 @@ def startCommentSearch(self, match):
the current indentation.
"""
if options.debug:
print >>sys.stderr, "# CALLBACK: startCommentSearch"
print("# CALLBACK: startCommentSearch", file=sys.stderr)
self.defclass = [self.fsm.current_input]
self.comment = []
self.indent = match.group(1)
Expand All @@ -251,7 +253,7 @@ def stopCommentSearch(self, match):
appends the current line to the output.
"""
if options.debug:
print >>sys.stderr, "# CALLBACK: stopCommentSearch"
print("# CALLBACK: stopCommentSearch", file=sys.stderr)
self.__closeComment()

self.defclass = []
Expand All @@ -263,7 +265,7 @@ def appendFileheadLine(self, match):
Closes the open comment block, resets it and appends the current line.
"""
if options.debug:
print >>sys.stderr, "# CALLBACK: appendFileheadLine"
print("# CALLBACK: appendFileheadLine", file=sys.stderr)
self.__closeComment()
self.comment = []
self.output.append(self.fsm.current_input)
Expand All @@ -275,7 +277,7 @@ def appendCommentLine(self, match):
well as singleline comments.
"""
if options.debug:
print >>sys.stderr, "# CALLBACK: appendCommentLine"
print("# CALLBACK: appendCommentLine", file=sys.stderr)
(from_state, to_state, condition, callback) = self.fsm.current_transition

# single line comment
Expand Down Expand Up @@ -312,13 +314,13 @@ def appendCommentLine(self, match):
def appendNormalLine(self, match):
"""Appends a line to the output."""
if options.debug:
print >>sys.stderr, "# CALLBACK: appendNormalLine"
print("# CALLBACK: appendNormalLine", file=sys.stderr)
self.output.append(self.fsm.current_input)

def appendDefclassLine(self, match):
"""Appends a line to the triggering block."""
if options.debug:
print >>sys.stderr, "# CALLBACK: appendDefclassLine"
print("# CALLBACK: appendDefclassLine", file=sys.stderr)
self.defclass.append(self.fsm.current_input)

def makeCommentBlock(self):
Expand All @@ -330,7 +332,7 @@ def makeCommentBlock(self):
doxyStart = "##"
commentLines = self.comment

commentLines = map(lambda x: "%s# %s" % (self.indent, x), commentLines)
commentLines = ["%s# %s" % (self.indent, x) for x in commentLines]
l = [self.indent + doxyStart]
l.extend(commentLines)

Expand Down Expand Up @@ -397,7 +399,7 @@ def optParse():
(options, filename) = parser.parse_args()

if not filename:
print >>sys.stderr, "No filename given."
print("No filename given.", file=sys.stderr)
sys.exit(-1)

return filename[0]
Expand Down
3 changes: 2 additions & 1 deletion doc/make-option-index.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python

from __future__ import print_function
from forcebalance import parser, optimizer
from forcebalance.objective import Implemented_Targets
import re
Expand Down Expand Up @@ -433,7 +434,7 @@ def main():
#Answer.append("%s (%s):%s" % (str(j), vartype, parser.gen_opts_types[i][j][1]))
#Answer.append("%s %s" % (str(j),str(val)))
#Answer.append("$end")
print '\n'.join(Answer)
print('\n'.join(Answer))



Expand Down
Loading

0 comments on commit 6c63991

Please sign in to comment.