1919from datetime import datetime
2020from time import time
2121
22- from nw .enum import nwItemType , nwItemClass , nwItemLayout
22+ from nw .enum import nwItemType , nwItemClass , nwItemLayout , nwAlert
2323from nw .common import checkString , checkBool
2424from nw .project .item import NWItem
2525
@@ -59,6 +59,9 @@ def __init__(self, theParent):
5959 # Set Defaults
6060 self .clearProject ()
6161
62+ # Internal Mapping
63+ self .makeAlert = self .theParent .makeAlert
64+
6265 return
6366
6467 ##
@@ -67,7 +70,7 @@ def __init__(self, theParent):
6770
6871 def newRoot (self , rootName , rootClass ):
6972 if not self .checkRootUnique (rootClass ):
70- self .theParent . makeAlert ("Duplicate root item detected!" ,2 )
73+ self .makeAlert ("Duplicate root item detected!" , nwAlert . ERROR )
7174 return None
7275 newItem = NWItem ()
7376 newItem .setName (rootName )
@@ -152,7 +155,7 @@ def openProject(self, fileName):
152155 if not path .isfile (fileName ):
153156 fileName = path .join (fileName , "nwProject.nwx" )
154157 if not path .isfile (fileName ):
155- self .theParent . makeAlert ("File not found: %s" % fileName ,2 )
158+ self .makeAlert ("File not found: %s" % fileName , nwAlert . ERROR )
156159 return False
157160
158161 self .clearProject ()
@@ -176,7 +179,7 @@ def openProject(self, fileName):
176179 logger .verbose ("File version is %s" % fileVersion )
177180
178181 if not nwxRoot == "novelWriterXML" or not fileVersion == "1.0" :
179- self .theParent . makeAlert ("Project file does not appear to be a novelWriterXML file version 1.0" ,2 )
182+ self .makeAlert ("Project file does not appear to be a novelWriterXML file version 1.0" , nwAlert . ERROR )
180183 return False
181184
182185 for xChild in xRoot :
@@ -228,7 +231,7 @@ def openProject(self, fileName):
228231 def saveProject (self ):
229232
230233 if self .projPath is None :
231- self .theParent . makeAlert ("Project path not set, cannot save." ,2 )
234+ self .makeAlert ("Project path not set, cannot save." , nwAlert . ERROR )
232235 return False
233236
234237 self .projMeta = path .join (self .projPath ,"meta" )
@@ -275,7 +278,7 @@ def saveProject(self):
275278 xml_declaration = True
276279 ))
277280 except Exception as e :
278- self .theParent . makeAlert (["Failed to save project." ,str (e )],2 )
281+ self .makeAlert (["Failed to save project." ,str (e )], nwAlert . ERROR )
279282 return False
280283
281284 self .mainConf .setRecent (self .projPath )
@@ -367,7 +370,7 @@ def _checkFolder(self, thePath):
367370 mkdir (thePath )
368371 logger .info ("Created folder %s" % thePath )
369372 except Exception as e :
370- self .theParent . makeAlert (["Could not create folder." ,str (e )],2 )
373+ self .makeAlert (["Could not create folder." ,str (e )], nwAlert . ERROR )
371374 return False
372375 return True
373376
@@ -414,7 +417,7 @@ def _scanProjectFolder(self):
414417
415418 # Report status
416419 if len (orphanFiles ) > 0 :
417- self .theParent . makeAlert ("Found %d orphaned file(s) in project folder!" % len (orphanFiles ),1 )
420+ self .makeAlert ("Found %d orphaned file(s) in project folder!" % len (orphanFiles ), nwAlert . WARN )
418421 else :
419422 logger .debug ("File check OK" )
420423 return
0 commit comments