Overview
Comment: | [build][core] colors for errors (draft) |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk | core | build |
Files: | files | file ages | folders |
SHA3-256: |
d614738660fb4ee6ca81738e8602ea89 |
User & Date: | olr on 2018-09-23 10:13:19 |
Other Links: | manifest | tags |
Context
2018-09-24
| ||
08:14 | [fr] nr: qu’en-dira-t-on, + faux positif: à l’arrache check-in: dffdca5554 user: olr tags: trunk, fr | |
2018-09-23
| ||
10:13 | [build][core] colors for errors (draft) check-in: d614738660 user: olr tags: trunk, core, build | |
2018-09-21
| ||
08:22 | [fr] règle: aussi +adj que >être check-in: 86b8eee060 user: olr tags: trunk, fr | |
Changes
Modified compile_rules.py from [dbd936143b] to [c923230bdf].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | """ Grammalecte: compile rules """ import re import traceback import json import compile_rules_js_convert as jsconv import compile_rules_graph as crg dDEF = {} lFUNCTIONS = [] aRULESET = set() # set of rule-ids to check if there is several rules with the same id nRULEWITHOUTNAME = 0 dJSREGEXES = {} sWORDLIMITLEFT = r"(?<![\w.,–-])" # r"(?<![-.,—])\b" seems slower sWORDLIMITRIGHT = r"(?![\w–-])" # r"\b(?!-—)" seems slower | > | > > > | | > | | > > > > > > | | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | """ Grammalecte: compile rules """ import re import traceback import json import colorsys import compile_rules_js_convert as jsconv import compile_rules_graph as crg dDEF = {} lFUNCTIONS = [] aRULESET = set() # set of rule-ids to check if there is several rules with the same id nRULEWITHOUTNAME = 0 dJSREGEXES = {} sWORDLIMITLEFT = r"(?<![\w.,–-])" # r"(?<![-.,—])\b" seems slower sWORDLIMITRIGHT = r"(?![\w–-])" # r"\b(?!-—)" seems slower def convertRGBToInteger (r, g, b): return (r & 255) << 16 | (g & 255) << 8 | (b & 255) def convertHSLToInteger (h, s, l): r, g, b = colorsys.hls_to_rgb(h/360, l/100, s/100) return convertRGBToInteger(round(r*255), round(g*255), round(b*255)) def createColors (lOptColor): dAppColor = {} for sApp, dOptColor in lOptColor: if sApp == "Writer": dAppColor["dOptColor"+sApp] = { sKey: convertHSLToInteger(*aColor) for sKey, aColor in dOptColor.items() } elif sApp in ("Firefox", "Thunderbird"): dAppColor["dOptColor"+sApp] = { sKey: "hsl({}, {}%, {}%)".format(*aColor) for sKey, aColor in dOptColor.items() } else: dAppColor["dOptColor"+sApp] = dOptColor #print(dAppColor) return dAppColor def prepareFunction (s): "convert simple rule syntax to a string of Python code" s = s.replace("__also__", "bCondMemo") s = s.replace("__else__", "not bCondMemo") s = re.sub(r"isStart *\(\)", 'before("^ *$|, *$")', s) |
︙ | ︙ | |||
415 416 417 418 419 420 421 | m = re.match("OPT/([a-z0-9]+):(.+)$", sLine) for i, sOpt in enumerate(m.group(2).split()): lOpt[i][1][m.group(1)] = eval(sOpt) elif sLine.startswith("OPTCOLORSOFTWARE:"): lOptColor = [ [s, {}] for s in sLine[17:].strip().split() ] # don’t use tuples (s, {}), because unknown to JS elif sLine.startswith("OPTCOLOR/"): m = re.match("OPTCOLOR/([a-z0-9]+):(.+)$", sLine) | | | < > | 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 | m = re.match("OPT/([a-z0-9]+):(.+)$", sLine) for i, sOpt in enumerate(m.group(2).split()): lOpt[i][1][m.group(1)] = eval(sOpt) elif sLine.startswith("OPTCOLORSOFTWARE:"): lOptColor = [ [s, {}] for s in sLine[17:].strip().split() ] # don’t use tuples (s, {}), because unknown to JS elif sLine.startswith("OPTCOLOR/"): m = re.match("OPTCOLOR/([a-z0-9]+):(.+)$", sLine) for i, sColor in enumerate(m.group(2).split()): lOptColor[i][1][m.group(1)] = [ int(s) for s in sColor.split(",") ] elif sLine.startswith("OPTPRIORITY/"): m = re.match("OPTPRIORITY/([a-z0-9]+): *([0-9])$", sLine) dOptPriority[m.group(1)] = int(m.group(2)) elif sLine.startswith("OPTLANG/"): m = re.match("OPTLANG/([a-z][a-z](?:_[A-Z][A-Z]|)):(.+)$", sLine) sLang = m.group(1)[:2] dOptLabel[sLang] = { "__optiontitle__": m.group(2).strip() } elif sLine.startswith("OPTDEFAULTUILANG:"): m = re.match("OPTDEFAULTUILANG: *([a-z][a-z](?:_[A-Z][A-Z]|))$", sLine) sDefaultUILang = m.group(1)[:2] elif sLine.startswith("OPTLABEL/"): m = re.match("OPTLABEL/([a-z0-9]+):(.+)$", sLine) dOptLabel[sLang][m.group(1)] = list(map(str.strip, m.group(2).split("|"))) if "|" in m.group(2) else [m.group(2).strip(), ""] else: print("# Error. Wrong option line in:\n ") print(sLine) print(" options defined for: " + ", ".join([ t[0] for t in lOpt ])) dOptions = { "lStructOpt": lStructOpt, "dOptLabel": dOptLabel, "sDefaultUILang": sDefaultUILang } dOptions.update({ "dOpt"+k: v for k, v in lOpt }) dOptions.update(createColors(lOptColor)) return dOptions, dOptPriority def printBookmark (nLevel, sComment, nLine): "print bookmark within the rules file" print(" {:>6}: {}".format(nLine, " " * nLevel + sComment)) |
︙ | ︙ |
Modified gc_core/js/lang_core/gc_options.js from [f47ea826e5] to [c30eb8d096].
︙ | ︙ | |||
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | var gc_options = { getOptions: function (sContext="JavaScript") { if (this.dOpt.hasOwnProperty(sContext)) { return this.dOpt[sContext]; } return this.dOpt["JavaScript"]; }, lStructOpt: ${lStructOpt}, dOpt: { "JavaScript": new Map (${dOptJavaScript}), "Firefox": new Map (${dOptFirefox}), "Thunderbird": new Map (${dOptThunderbird}), }, dOptLabel: ${dOptLabel} } if (typeof(exports) !== 'undefined') { exports.getOptions = gc_options.getOptions; exports.lStructOpt = gc_options.lStructOpt; exports.dOpt = gc_options.dOpt; exports.dOptLabel = gc_options.dOptLabel; } | > > > > > > > > > > > > > > > | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | var gc_options = { getOptions: function (sContext="JavaScript") { if (this.dOpt.hasOwnProperty(sContext)) { return this.dOpt[sContext]; } return this.dOpt["JavaScript"]; }, getOptionsColors: function (sContext="JavaScript") { if (this.dOptColor.hasOwnProperty(sContext)) { return this.dOptColor[sContext]; } return this.dOptColor["JavaScript"]; }, lStructOpt: ${lStructOpt}, dOpt: { "JavaScript": new Map (${dOptJavaScript}), "Firefox": new Map (${dOptFirefox}), "Thunderbird": new Map (${dOptThunderbird}), }, dOptColor: { "JavaScript": new Map (${dOptColorJavaScript}), "Firefox": new Map (${dOptColorFirefox}), "Thunderbird": new Map (${dOptColorThunderbird}), }, dOptLabel: ${dOptLabel} } if (typeof(exports) !== 'undefined') { exports.getOptions = gc_options.getOptions; exports.getOptionsColors = gc_options.getOptionsColors; exports.lStructOpt = gc_options.lStructOpt; exports.dOpt = gc_options.dOpt; exports.dOptColor = gc_options.dOptColor; exports.dOptLabel = gc_options.dOptLabel; } |
Modified gc_core/py/lang_core/gc_options.py from [c84731594a] to [f5b1b8c491].
︙ | ︙ | |||
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | def getOptions (sContext="Python"): "returns dictionary of options" if sContext in dOpt: return dOpt[sContext] return dOpt["Python"] lStructOpt = ${lStructOpt} dOpt = { "Python": ${dOptPython}, "Server": ${dOptServer}, "Writer": ${dOptWriter} } _dOptLabel = ${dOptLabel} | > > > > > > > > > > > > | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | def getOptions (sContext="Python"): "returns dictionary of options" if sContext in dOpt: return dOpt[sContext] return dOpt["Python"] def getOptionsColors (sContext="Python"): "returns dictionary of options" if sContext in dOptColor: return dOptColor[sContext] return dOptColor["Python"] lStructOpt = ${lStructOpt} dOpt = { "Python": ${dOptPython}, "Server": ${dOptServer}, "Writer": ${dOptWriter} } dOptColor = { "Python": ${dOptColorPython}, "Server": ${dOptColorServer}, "Writer": ${dOptColorWriter} } _dOptLabel = ${dOptLabel} |