handle some file open()s better
This commit is contained in:
parent
357e369559
commit
b66ee7e619
@ -1197,7 +1197,8 @@ class gui(QtGui.QWidget):
|
||||
self.height = 730
|
||||
theme = get_option("General", "theme", "default")
|
||||
try:
|
||||
exec open(AO2XPpath+"ao2xp_themes/"+theme+"/theme.py")
|
||||
with open(AO2XPpath+"ao2xp_themes/"+theme+"/theme.py") as t:
|
||||
exec t
|
||||
except Exception as e:
|
||||
QtGui.QMessageBox.critical(None, "Unable to load theme", "There was a problem loading the current theme \"%s\":\n\n%s." % (theme, e))
|
||||
os._exit(-2)
|
||||
@ -1602,7 +1603,8 @@ class gui(QtGui.QWidget):
|
||||
inifile.set(id, "description", evi[1].replace('\n', '\\n').encode('utf-8'))
|
||||
inifile.set(id, "image", evi[2].encode('utf-8'))
|
||||
|
||||
inifile.write(open(path, "wb"))
|
||||
with open(path, "wb") as f:
|
||||
inifile.write(f)
|
||||
|
||||
def onImportEvidence(self, is_autoload=False):
|
||||
if not is_autoload:
|
||||
@ -2545,7 +2547,8 @@ class gui(QtGui.QWidget):
|
||||
self.anim_state = 3
|
||||
|
||||
if exists(AO2XPpath+"callwords.ini"):
|
||||
callwords = [line.rstrip() for line in open(AO2XPpath+"callwords.ini")]
|
||||
with open(AO2XPpath+"callwords.ini") as f:
|
||||
callwords = [line.rstrip() for line in f]
|
||||
for callword in callwords:
|
||||
if callword.decode('utf-8').lower() in self.m_chatmessage[CHATMSG].lower().split(" "):
|
||||
self.ooclog.append("<b>%s called you.</b>" % f_char)
|
||||
|
@ -296,7 +296,8 @@ class Settings(QtGui.QDialog):
|
||||
self.inifile.set("Audio", "Sound volume", self.soundslider.value())
|
||||
self.inifile.set("Audio", "Blip volume", self.blipslider.value())
|
||||
|
||||
self.inifile.write(open("AO2XP.ini", "wb"))
|
||||
with open("AO2XP.ini", "wb") as f:
|
||||
self.inifile.write(f)
|
||||
|
||||
with open(AO2XPpath+"callwords.ini", "w") as f:
|
||||
f.write(self.callwords_edit.toPlainText().toUtf8())
|
||||
|
Loading…
Reference in New Issue
Block a user