Index: darg.py ================================================================== --- darg.py +++ darg.py @@ -113,10 +113,11 @@ dGraph[sHashId] = oNode.getNodeAsDict() else: print("Error. Double nodeā€¦ same id: ", sHashId) print(str(oNode.getNodeAsDict())) dGraph = self._rewriteKeysOfDARG(dGraph) + self._sortActions(dGraph) self._checkRegexes(dGraph) return dGraph def _rewriteKeysOfDARG (self, dGraph): "keys of DARG are long numbers (hashes): this function replace these hashes with smaller numbers (to reduce storing size)" @@ -135,10 +136,19 @@ else: for sArc, nKey in val.items(): val[sArc] = dKeyTrans[nKey] return dNewGraph + def _sortActions (self, dGraph): + "when a pattern is found, several actions may be launched, and it must be performed in a certain order" + for nKey, dVal in dGraph.items(): + if "" in dVal: + for sLineId, nKey in dVal[""].items(): + # we change the dictionary of actions in a list of actions (values of dictionary all points to the final node) + if isinstance(dGraph[nKey], dict): + dGraph[nKey] = sorted(dGraph[nKey].keys()) + def _checkRegexes (self, dGraph): "check validity of regexes" aRegex = set() for nKey, dVal in dGraph.items(): if "" in dVal: