Overview
Comment: | [build] code cleaning (pylint) |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk | build |
Files: | files | file ages | folders |
SHA3-256: |
b508963a37b5b59eb46bda8d026acda1 |
User & Date: | olr on 2019-05-11 12:06:46 |
Other Links: | manifest | tags |
Context
2019-05-11
| ||
12:47 | [build] code cleaning (pylint) check-in: 1d0bea98d6 user: olr tags: trunk, build | |
12:06 | [build] code cleaning (pylint) check-in: b508963a37 user: olr tags: trunk, build | |
11:35 | [build] code cleaning (pylint) check-in: a7e04ce1e4 user: olr tags: trunk, build | |
Changes
Modified compile_rules.py from [380dd94ff7] to [f961bd8f78].
︙ | |||
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | 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 | + + + | dJSREGEXES = {} sWORDLIMITLEFT = r"(?<![\w.,–-])" # r"(?<![-.,—])\b" seems slower sWORDLIMITRIGHT = r"(?![\w–-])" # r"\b(?!-—)" seems slower def convertRGBToInteger (r, g, b): "rbg (int, int, int) -> int" return (r & 255) << 16 | (g & 255) << 8 | (b & 255) def convertHSLToRBG (h, s, l): "hsl (int, int, int) -> [int, int, int]" r, g, b = colorsys.hls_to_rgb(h/360, l/100, s/100) return [round(r*255), round(g*255), round(b*255)] def createColors (dColor): "dictionary of colors {color_name: [h, s, l]} -> returns dictionary of colors as dictionaries of color types" dColorType = { "sCSS": {}, # dictionary of colors as strings for HTML/CSS (example: hsl(0, 50%, 50%)) "aRGB": {}, # dictionary of colors as RGB tuple "nInt": {} # dictionary of colors as integer values (for Writer) } for sKey, aHSL in dColor.items(): dColorType["sCSS"][sKey] = "hsl({}, {}%, {}%)".format(*aHSL) |
︙ | |||
76 77 78 79 80 81 82 | 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | - + - + - - + - + - + - - - - + + + + - + | s = re.sub(r"after0\(\s*", 'look(sSentence0[m.end():], ', s) # after0(sSentence) s = re.sub(r"textarea0\(\s*", 'look(sSentence0, ', s) # textarea0(sSentence) s = re.sub(r"\bspell *[(]", '_oSpellChecker.isValid(', s) s = re.sub(r"[\\](\d+)", 'm.group(\\1)', s) return s |
︙ | |||
231 232 233 234 235 236 237 | 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | - + - - + | sRegex = uppercase(sRegex, sLang) else: print("# Unknown case mode [" + cCaseMode + "] at line " + sLineId) ## check regex try: re.compile(sRegex) |
︙ | |||
344 345 346 347 348 349 350 | 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 | - + - + - - - + + | lFUNCTIONS.append(("_s_"+sIdAction, sAction[1:])) sAction = "=_s_"+sIdAction elif sAction.startswith('"') and sAction.endswith('"'): sAction = sAction[1:-1] if not sMsg: print("# Error in action at line " + sIdAction + ": the message is empty.") return [sCondition, cAction, sAction, iGroup, sMsg, sURL] |
︙ | |||
393 394 395 396 397 398 399 | 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 | - + | def mergeRulesByOption (lRules): "returns a list of tuples [option, list of rules] keeping the rules order" lFinal = [] lTemp = [] sOption = None for aRule in lRules: if aRule[0] != sOption: |
︙ | |||
423 424 425 426 427 428 429 | 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 | - + | m = re.match("OPTGROUP/([a-z0-9]+):(.+)$", sLine) lStructOpt.append( [m.group(1), list(map(str.split, m.group(2).split(",")))] ) elif sLine.startswith("OPTSOFTWARE:"): lOpt = [ [s, {}] for s in sLine[12:].strip().split() ] # don’t use tuples (s, {}), because unknown to JS elif sLine.startswith("OPT/"): m = re.match("OPT/([a-z0-9]+):(.+)$", sLine) for i, sOpt in enumerate(m.group(2).split()): |
︙ | |||
479 480 481 482 483 484 485 | 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 | - + | return dCacheVars fBuildTime = time.time() print("> read rules file...") try: lRules = open(spLang + "/rules.grx", 'r', encoding="utf-8").readlines() |
︙ | |||
556 557 558 559 560 561 562 | 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 | - - + - - - | lRuleLine[-1][1] += " " + sLine.strip() else: # new rule lRuleLine.append([i, sLine.strip()]) # generating options files print(" parsing options...") |
︙ |