Grammalecte  Diff

Differences From Artifact [7b07e55412]:

To Artifact [ddf3c68ae3]:


313
314
315
316
317
318
319

320



321
322
323
324
325
326

327
328
329
330
331
332
333
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338







+

+
+
+






+









def makeLocutions (sp, bJS=False):
    "compile list of locutions in JSON"
    print("> Locutions ", end="")
    print("(Python et JavaScript)"  if bJS  else "(Python seulement)")
    dLocutions = {}
    sVal = ":H"
    for sLine in readFile(sp+"/data/locutions.txt"):
        if sLine.startswith("[") and sLine.endswith("]"):
            sLabel, sVal = sLine[1:-1].split("|", 1)
            continue
        lElem = sLine.split()
        dCur = dLocutions
        for sWord in lElem:
            if sWord not in dCur:
                dCur[sWord] = {}
            dCur = dCur[sWord]
        dCur[":"] = sVal

    sCode = "# generated data (do not edit)\n\n" + \
            "dLocutions = " + str(dLocutions) + "\n"
    open(sp+"/modules/locutions_data.py", "w", encoding="utf-8", newline="\n").write(sCode)
    if bJS:
        open(sp+"/modules-js/locutions_data.json", "w", encoding="utf-8", newline="\n").write(json.dumps(dLocutions, ensure_ascii=False))