Grammalecte  Check-in [e17a78cf83]

Overview
Comment:[build] make data more readable
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | build
Files: files | file ages | folders
SHA3-256: e17a78cf83f930cd5bc2ecb56ef068fa353598ac2f63fdb08aa0bd9bbee3b4a3
User & Date: olr on 2020-04-22 14:59:43
Other Links: manifest | tags
Context
2020-04-22
16:56
[build] code simplification check-in: 9094ac6082 user: olr tags: trunk, build
14:59
[build] make data more readable check-in: e17a78cf83 user: olr tags: trunk, build
14:29
[build] code clarification (Python f-strings) check-in: d1aa895785 user: olr tags: trunk, build
Changes

Modified compile_rules.py from [f64fcce154] to [c6e75ae902].

403
404
405
406
407
408
409













410
411
412
413
414
415
416
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429







+
+
+
+
+
+
+
+
+
+
+
+
+







            # new tuple
            sOption = aRule[0]
            lTemp = []
        lTemp.append(aRule[1:])
    lFinal.append([sOption, lTemp])
    return lFinal


def createRulesAsString (lRules):
    "create rules as a string of arrays (to be bundled in a JSON string)"
    sArray = "[\n"
    for sOption, aRuleGroup in lRules:
        sOption = "False"  if not sOption  else  f'"{sOption}"'
        sArray += f'  [{sOption}, [\n'
        for aRule in aRuleGroup:
            sArray += f'    {aRule},\n'
        sArray += "  ]],\n"
    sArray += "]"
    return sArray


def prepareOptions (lOptionLines):
    "returns a dictionary with data about options"
    sLang = ""
    sDefaultUILang = ""
    lStructOpt = []
    lOpt = []
645
646
647
648
649
650
651
652
653


654
655
656
657
658
659
660
661
662
663
664
665
658
659
660
661
662
663
664


665
666
667
668
669
670
671
672
673
674
675
676
677
678







-
-
+
+












    dVars = {
        "fBuildTime": fBuildTime,
        "sFileHash": sFileHash,
        "callables": sPyCallables,
        "callablesJS": sJSCallables,
        "gctests": sGCTests,
        "gctestsJS": sGCTestsJS,
        "paragraph_rules": mergeRulesByOption(lParagraphRules),
        "sentence_rules": mergeRulesByOption(lSentenceRules),
        "paragraph_rules": createRulesAsString(mergeRulesByOption(lParagraphRules)),
        "sentence_rules": createRulesAsString(mergeRulesByOption(lSentenceRules)),
        "paragraph_rules_JS": jsconv.writeRulesToJSArray(mergeRulesByOption(lParagraphRulesJS)),
        "sentence_rules_JS": jsconv.writeRulesToJSArray(mergeRulesByOption(lSentenceRulesJS))
    }
    dVars.update(dOptions)

    # compile graph rules
    dVars2 = crg.make(lGraphRule, sLang, dDEFINITIONS, dDECLENSIONS, dOptPriority)
    dVars.update(dVars2)

    with open("_build/data_cache.json", "w", encoding="utf-8") as hDst:
        hDst.write(json.dumps(dVars, ensure_ascii=False))
    return dVars