Skip to content
Snippets Groups Projects
Commit 3c94b18d authored by Daniel Brown's avatar Daniel Brown
Browse files

fixing too many file open errors

parent 7d635b06
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,7 @@ from __future__ import division ...@@ -3,7 +3,7 @@ from __future__ import division
from __future__ import print_function from __future__ import print_function
from __future__ import unicode_literals from __future__ import unicode_literals
__version__ = "1.0.11" __version__ = "1.0.13"
# This flag is used to switch on the gui features in pkat at import time # This flag is used to switch on the gui features in pkat at import time
USE_GUI = False USE_GUI = False
......
...@@ -924,7 +924,9 @@ class kat(object): ...@@ -924,7 +924,9 @@ class kat(object):
`^-....____: +. {1}\n""".format(pykat.__version__, pykat_web)) `^-....____: +. {1}\n""".format(pykat.__version__, pykat_web))
def loadKatFile(self, katfile, blocks=None): def loadKatFile(self, katfile, blocks=None):
commands=open(katfile).read() with open(katfile) as f:
commands= f.read()
self.parseCommands(commands, blocks=blocks) self.parseCommands(commands, blocks=blocks)
def parseKatCode(self, code, blocks=None): def parseKatCode(self, code, blocks=None):
...@@ -1444,11 +1446,10 @@ class kat(object): ...@@ -1444,11 +1446,10 @@ class kat(object):
Saves the current kat object to a Finesse input file Saves the current kat object to a Finesse input file
""" """
try: try:
with open(filename,'w') as katfile:
katScript = "".join(self.generateKatScript()) katScript = "".join(self.generateKatScript())
katfile = open(filename,'w')
katfile.writelines(katScript) katfile.writelines(katScript)
katfile.flush() katfile.flush()
katfile.close()
except pkex.BasePyKatException as ex: except pkex.BasePyKatException as ex:
print (ex) print (ex)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment