handle some file open()s better
This commit is contained in:
parent
357e369559
commit
b66ee7e619
23
gameview.py
23
gameview.py
@ -1197,7 +1197,8 @@ class gui(QtGui.QWidget):
|
|||||||
self.height = 730
|
self.height = 730
|
||||||
theme = get_option("General", "theme", "default")
|
theme = get_option("General", "theme", "default")
|
||||||
try:
|
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:
|
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))
|
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)
|
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, "description", evi[1].replace('\n', '\\n').encode('utf-8'))
|
||||||
inifile.set(id, "image", evi[2].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):
|
def onImportEvidence(self, is_autoload=False):
|
||||||
if not is_autoload:
|
if not is_autoload:
|
||||||
@ -2545,14 +2547,15 @@ class gui(QtGui.QWidget):
|
|||||||
self.anim_state = 3
|
self.anim_state = 3
|
||||||
|
|
||||||
if exists(AO2XPpath+"callwords.ini"):
|
if exists(AO2XPpath+"callwords.ini"):
|
||||||
callwords = [line.rstrip() for line in open(AO2XPpath+"callwords.ini")]
|
with open(AO2XPpath+"callwords.ini") as f:
|
||||||
for callword in callwords:
|
callwords = [line.rstrip() for line in f]
|
||||||
if callword.decode('utf-8').lower() in self.m_chatmessage[CHATMSG].lower().split(" "):
|
for callword in callwords:
|
||||||
self.ooclog.append("<b>%s called you.</b>" % f_char)
|
if callword.decode('utf-8').lower() in self.m_chatmessage[CHATMSG].lower().split(" "):
|
||||||
snd = audio.loadhandle(False, "word_call.wav", 0, 0, BASS_STREAM_AUTOFREE)
|
self.ooclog.append("<b>%s called you.</b>" % f_char)
|
||||||
if snd:
|
snd = audio.loadhandle(False, "word_call.wav", 0, 0, BASS_STREAM_AUTOFREE)
|
||||||
audio.playhandle(snd, True)
|
if snd:
|
||||||
break
|
audio.playhandle(snd, True)
|
||||||
|
break
|
||||||
|
|
||||||
def do_effect(self, fx_name, fx_sound, p_char, p_folder):
|
def do_effect(self, fx_name, fx_sound, p_char, p_folder):
|
||||||
effect = ini.get_effect(fx_name, p_char, p_folder)
|
effect = ini.get_effect(fx_name, p_char, p_folder)
|
||||||
|
@ -296,7 +296,8 @@ class Settings(QtGui.QDialog):
|
|||||||
self.inifile.set("Audio", "Sound volume", self.soundslider.value())
|
self.inifile.set("Audio", "Sound volume", self.soundslider.value())
|
||||||
self.inifile.set("Audio", "Blip volume", self.blipslider.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:
|
with open(AO2XPpath+"callwords.ini", "w") as f:
|
||||||
f.write(self.callwords_edit.toPlainText().toUtf8())
|
f.write(self.callwords_edit.toPlainText().toUtf8())
|
||||||
|
Loading…
Reference in New Issue
Block a user