Overview
Comment: | [build] rewrite keys of DARGt to reduce file size |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | build | rg |
Files: | files | file ages | folders |
SHA3-256: |
32ead98e9def5f64c3f331325cce35bf |
User & Date: | olr on 2018-06-25 21:12:08 |
Other Links: | branch diff | manifest | tags |
Context
2018-06-26
| ||
04:42 | [fr] erreurs de frappe check-in: 9ecb48dd7f user: olr tags: fr, rg | |
2018-06-25
| ||
21:12 | [build] rewrite keys of DARGt to reduce file size check-in: 32ead98e9d user: olr tags: build, rg | |
20:16 | [fr] conversion: regex rules -> graph rules check-in: e933d6a0a8 user: olr tags: fr, rg | |
Changes
Modified compile_rules_graph.py from [ad40703abe] to [9d41dade40].
︙ | ︙ | |||
258 259 260 261 262 263 264 265 266 267 268 269 270 271 | dFUNCTIONS["_g_d_"+sActionId] = sAction sAction = "_g_d_"+sActionId return [sOption, sCondition, cAction, sAction] else: print("# Unknown action at line " + sActionId) return None def make (lRule, dDef, sLang, bJavaScript): "compile rules, returns a dictionary of values" # for clarity purpose, don’t create any file here # removing comments, zeroing empty lines, creating definitions, storing tests, merging rule lines print(" parsing rules...") | > > > > > > > > > > > > > > > > > > > > > > > | 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | dFUNCTIONS["_g_d_"+sActionId] = sAction sAction = "_g_d_"+sActionId return [sOption, sCondition, cAction, sAction] else: print("# Unknown action at line " + sActionId) return None def rewriteKeysOfDARGs (dAllGraph): "keys of DARGs are long numbers (hash): this function replace these hashes with smaller numbers (to reduce storing)" dAllNewGraph = {} for sGraphName, dGraph in dAllGraph.items(): # create translation dictionary dKeyTrans = {} for i, nKey in enumerate(dGraph): dKeyTrans[nKey] = i # replace keys dNewGraph = {} for nKey, dVal in dGraph.items(): dNewGraph[dKeyTrans[nKey]] = dVal for nKey, dVal in dGraph.items(): for sArc, val in dVal.items(): if type(val) is int: dVal[sArc] = dKeyTrans[val] else: for sArc, nKey in val.items(): val[sArc] = dKeyTrans[nKey] dAllNewGraph[sGraphName] = dNewGraph return dAllNewGraph def make (lRule, dDef, sLang, bJavaScript): "compile rules, returns a dictionary of values" # for clarity purpose, don’t create any file here # removing comments, zeroing empty lines, creating definitions, storing tests, merging rule lines print(" parsing rules...") |
︙ | ︙ | |||
379 380 381 382 383 384 385 | print(sActionName, aAction) print("\nFunctions:") print(sPyCallables) # Result return { "graph_callables": sPyCallables, | | | 402 403 404 405 406 407 408 409 410 411 | print(sActionName, aAction) print("\nFunctions:") print(sPyCallables) # Result return { "graph_callables": sPyCallables, "rules_graphs": rewriteKeysOfDARGs(dAllGraph), "rules_actions": dACTIONS } |