[core] add Node.statusName property

This commit is contained in:
Yann Lanthony 2017-10-13 16:31:20 +02:00
parent 81fe366365
commit 653cec28c9

View file

@ -351,11 +351,12 @@ class Node(BaseObject):
""" """
statusFile = self.statusFile() statusFile = self.statusFile()
if not os.path.exists(statusFile): if not os.path.exists(statusFile):
self.status.status = Status.NONE self.upgradeStatusTo(Status.NONE)
return return
with open(statusFile, 'r') as jsonFile: with open(statusFile, 'r') as jsonFile:
statusData = json.load(jsonFile) statusData = json.load(jsonFile)
self.status.fromDict(statusData) self.status.fromDict(statusData)
self.statusChanged.emit()
def saveStatusFile(self): def saveStatusFile(self):
""" """
@ -397,6 +398,7 @@ class Node(BaseObject):
print('WARNING: downgrade status on node "{}" from {} to {}'.format(self._name, self.status.status.name, print('WARNING: downgrade status on node "{}" from {} to {}'.format(self._name, self.status.status.name,
newStatus)) newStatus))
self.status.status = newStatus self.status.status = newStatus
self.statusChanged.emit()
self.saveStatusFile() self.saveStatusFile()
def isAlreadySubmitted(self): def isAlreadySubmitted(self):
@ -457,12 +459,19 @@ class Node(BaseObject):
def getStatus(self): def getStatus(self):
return self.status return self.status
@property
def statusName(self):
return self.status.status.name
name = Property(str, getName, constant=True) name = Property(str, getName, constant=True)
attributes = Property(BaseObject, getAttributes, constant=True) attributes = Property(BaseObject, getAttributes, constant=True)
internalFolderChanged = Signal() internalFolderChanged = Signal()
internalFolder = Property(str, internalFolder.fget, notify=internalFolderChanged) internalFolder = Property(str, internalFolder.fget, notify=internalFolderChanged)
depthChanged = Signal() depthChanged = Signal()
depth = Property(int, depth.fget, notify=depthChanged) depth = Property(int, depth.fget, notify=depthChanged)
statusChanged = Signal()
statusName = Property(str, statusName.fget, notify=statusChanged)
WHITE = 0 WHITE = 0
GRAY = 1 GRAY = 1