Helpviewer/History/HistoryManager.py

branch
Py2 comp.
changeset 3058
0a02c433f52d
parent 3057
10516539f238
parent 3020
542e97d4ecb3
child 3060
5883ce99ee12
equal deleted inserted replaced
3057:10516539f238 3058:0a02c433f52d
382 """ 382 """
383 historyFile = QFile(self.getFileName()) 383 historyFile = QFile(self.getFileName())
384 if not historyFile.exists(): 384 if not historyFile.exists():
385 return 385 return
386 if not historyFile.open(QIODevice.ReadOnly): 386 if not historyFile.open(QIODevice.ReadOnly):
387 E5MessageBox.warning(None, 387 E5MessageBox.warning(
388 None,
388 self.trUtf8("Loading History"), 389 self.trUtf8("Loading History"),
389 self.trUtf8( 390 self.trUtf8(
390 """<p>Unable to open history file <b>{0}</b>.<br/>""" 391 """<p>Unable to open history file <b>{0}</b>.<br/>"""
391 """Reason: {1}</p>""")\ 392 """Reason: {1}</p>""")\
392 .format(historyFile.fileName, historyFile.errorString())) 393 .format(historyFile.fileName, historyFile.errorString()))
461 else: 462 else:
462 f = historyFile 463 f = historyFile
463 opened = f.open(QIODevice.Append) 464 opened = f.open(QIODevice.Append)
464 465
465 if not opened: 466 if not opened:
466 E5MessageBox.warning(None, 467 E5MessageBox.warning(
468 None,
467 self.trUtf8("Saving History"), 469 self.trUtf8("Saving History"),
468 self.trUtf8( 470 self.trUtf8(
469 """<p>Unable to open history file <b>{0}</b>.<br/>""" 471 """<p>Unable to open history file <b>{0}</b>.<br/>"""
470 """Reason: {1}</p>""")\ 472 """Reason: {1}</p>""")\
471 .format(f.fileName(), f.errorString())) 473 .format(f.fileName(), f.errorString()))
483 f.write(data) 485 f.write(data)
484 486
485 f.close() 487 f.close()
486 if saveAll: 488 if saveAll:
487 if historyFile.exists() and not historyFile.remove(): 489 if historyFile.exists() and not historyFile.remove():
488 E5MessageBox.warning(None, 490 E5MessageBox.warning(
491 None,
489 self.trUtf8("Saving History"), 492 self.trUtf8("Saving History"),
490 self.trUtf8( 493 self.trUtf8(
491 """<p>Error removing old history file <b>{0}</b>.""" 494 """<p>Error removing old history file <b>{0}</b>."""
492 """<br/>Reason: {1}</p>""")\ 495 """<br/>Reason: {1}</p>""")\
493 .format(historyFile.fileName(), 496 .format(historyFile.fileName(),
494 historyFile.errorString())) 497 historyFile.errorString()))
495 if not f.copy(historyFile.fileName()): 498 if not f.copy(historyFile.fileName()):
496 E5MessageBox.warning(None, 499 E5MessageBox.warning(
500 None,
497 self.trUtf8("Saving History"), 501 self.trUtf8("Saving History"),
498 self.trUtf8( 502 self.trUtf8(
499 """<p>Error moving new history file over old one """ 503 """<p>Error moving new history file over old one """
500 """(<b>{0}</b>).<br/>Reason: {1}</p>""")\ 504 """(<b>{0}</b>).<br/>Reason: {1}</p>""")\
501 .format(historyFile.fileName(), f.errorString())) 505 .format(historyFile.fileName(), f.errorString()))

eric ide

mercurial