Grammalecte  Check-in [e18bf06f0c]

Overview
Comment:[build][bug] DARG: fix Heisenbug, sort actions identifiers by name (necessary for Python 3.5)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | build | warning | rg
Files: files | file ages | folders
SHA3-256: e18bf06f0cc02af838a4970e7919ec544f9c065cc9f5f62da7de6507d62015d6
User & Date: olr on 2018-09-06 07:04:05
Other Links: branch diff | manifest | tags
Context
2018-09-07
10:09
[core] gc engine: code cleaning check-in: cc997fd621 user: olr tags: core, rg
2018-09-06
07:04
[build][bug] DARG: fix Heisenbug, sort actions identifiers by name (necessary for Python 3.5) check-in: e18bf06f0c user: olr tags: build, warning, rg
2018-09-05
19:27
[core] gc engine: code clarity + change echo parameters check-in: 8fddaca364 user: olr tags: core, rg
Changes

Modified darg.py from [29c743b753] to [0a2000eec8].

111
112
113
114
115
116
117

118
119
120
121
122
123
124
            sHashId = oNode.__hash__()
            if sHashId not in dGraph:
                dGraph[sHashId] = oNode.getNodeAsDict()
            else:
                print("Error. Double node… same id: ", sHashId)
                print(str(oNode.getNodeAsDict()))
        dGraph = self._rewriteKeysOfDARG(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)"
        # create translation dictionary
        dKeyTrans = {}







>







111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
            sHashId = oNode.__hash__()
            if sHashId not in dGraph:
                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)"
        # create translation dictionary
        dKeyTrans = {}
133
134
135
136
137
138
139









140
141
142
143
144
145
146
                if type(val) is int:
                    dVal[sArc] = dKeyTrans[val]
                else:
                    for sArc, nKey in val.items():
                        val[sArc] = dKeyTrans[nKey]
        return dNewGraph










    def _checkRegexes (self, dGraph):
        "check validity of regexes"
        aRegex = set()
        for nKey, dVal in dGraph.items():
            if "<re_value>" in dVal:
                for sRegex in dVal["<re_value>"]:
                    if sRegex not in aRegex:







>
>
>
>
>
>
>
>
>







134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
                if type(val) is int:
                    dVal[sArc] = dKeyTrans[val]
                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 "<rules>" in dVal:
                for sLineId, nKey in dVal["<rules>"].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 "<re_value>" in dVal:
                for sRegex in dVal["<re_value>"]:
                    if sRegex not in aRegex: