Improved the alert to user interface, and added an enum class for severity flags.

This commit is contained in:
Veronica K. B. Olsen
2019-05-12 20:34:52 +02:00
parent 9d180bf101
commit e2895ce4f7
7 changed files with 48 additions and 22 deletions
+6 -2
View File
@@ -16,6 +16,7 @@ import nw
from os import path, mkdir, rename, unlink
from nw.tools.analyse import TextAnalysis
from nw.enum import nwAlert
logger = logging.getLogger(__name__)
@@ -31,6 +32,9 @@ class NWDoc():
self.theItem = None
self.docHandle = None
# Internal Mapping
self.makeAlert = self.theParent.makeAlert
return
def openDocument(self, tHandle):
@@ -49,7 +53,7 @@ class NWDoc():
with open(docPath,mode="r") as inFile:
theDoc = inFile.read()
except Exception as e:
self.theParent.makeAlert(["Failed to open document file.",str(e)],2)
self.makeAlert(["Failed to open document file.",str(e)], nwAlert.ERROR)
return ""
else:
logger.debug("The requested document does not exist.")
@@ -83,7 +87,7 @@ class NWDoc():
with open(docPath,mode="w") as outFile:
outFile.write(docText)
except Exception as e:
self.theParent.makeAlert(["Could not save document.",str(e)],2)
self.makeAlert(["Could not save document.",str(e)], nwAlert.ERROR)
return False
if path.isfile(docTemp): unlink(docTemp)