Overview
Comment: | [core][fr] code cleaning (pylint) |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk | fr | core |
Files: | files | file ages | folders |
SHA3-256: |
2c639e2d925f312eca88f05c0c7ddcee |
User & Date: | olr on 2019-05-11 15:54:20 |
Other Links: | manifest | tags |
Context
2019-05-11
| ||
17:34 | [fr] conjugaisons: sujets nous/vous, ajustements check-in: 2b2c772a7d user: olr tags: trunk, fr | |
15:54 | [core][fr] code cleaning (pylint) check-in: 2c639e2d92 user: olr tags: trunk, fr, core | |
15:17 | [fr] erreur de paramètre check-in: 249d9c7d08 user: olr tags: trunk, fr | |
Changes
Modified gc_core/py/lang_core/gc_engine.py from [cf7715eca3] to [0d99523db5].
︙ | |||
100 101 102 103 104 105 106 | 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | - + | _rules_graph = gc_rules_graph # compile rules regex for sOption, lRuleGroup in chain(_rules.lParagraphRules, _rules.lSentenceRules): if sOption != "@@@@": for aRule in lRuleGroup: try: aRule[0] = re.compile(aRule[0]) |
︙ | |||
125 126 127 128 129 130 131 | 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | - + | def listRules (sFilter=None): "generator: returns typle (sOption, sLineId, sRuleId)" if sFilter: try: zFilter = re.compile(sFilter) |
︙ | |||
276 277 278 279 280 281 282 283 284 285 286 287 288 289 | 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 | + | self.dTokenPos = { dToken["nStart"]: dToken for dToken in self.lToken if dToken["sType"] != "INFO" } self.parseText(self.sSentence, self.sSentence0, False, iStart, sCountry, dOpt, bShowRuleId, bDebug, bContext) except: raise return self.dError.values() # this is a view (iterable) def parseText (self, sText, sText0, bParagraph, nOffset, sCountry, dOptions, bShowRuleId, bDebug, bContext): "parse the text with rules" bChange = False for sOption, lRuleGroup in _getRules(bParagraph): if sOption == "@@@@": # graph rules if not bParagraph and bChange: self.update(sText, bDebug) bChange = False |
︙ | |||
613 614 615 616 617 618 619 | 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 | - - + - - + | # Message sMessage = globals()[sMsg[1:]](sText, m) if sMsg[0:1] == "=" else m.expand(sMsg) if bShowRuleId: sMessage += " # " + sLineId + " # " + sRuleId # if _bWriterError: return self._createErrorForWriter(nStart, nEnd - nStart, sRuleId, sOption, sMessage, lSugg, sURL) |
︙ | |||
750 751 752 753 754 755 756 | 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 | - + | def rewriteFromTags (self, bDebug=False): "rewrite the sentence, modify tokens, purge the token list" if bDebug: echo("REWRITE") lNewToken = [] nMergeUntil = 0 |
︙ | |||
787 788 789 790 791 792 793 | 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 | - + - | nDiffLen = len(dToken["sRealValue"]) - len(dToken["sNewValue"]) sNewRepl = (dToken["sNewValue"] + " " * nDiffLen) if nDiffLen >= 0 else dToken["sNewValue"][:len(dToken["sRealValue"])] self.sSentence = self.sSentence[:dToken["nStart"]] + sNewRepl + self.sSentence[dToken["nEnd"]:] del dToken["sNewValue"] else: try: del self.dTokenPos[dToken["nStart"]] |
︙ | |||
860 861 862 863 864 865 866 | 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 | - + | "returns True if s has pattern sPattern and m.group(1) has pattern sPatternGroup1" m = re.search(sPattern, s) if not m: return False try: sWord = m.group(1) nPos = m.start(1) + nOffset |
︙ | |||
897 898 899 900 901 902 903 | 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 | - - - - + + + - - - - + + + | return False # check negative condition if sNegPattern: if sNegPattern == "*": # all morph must match sPattern zPattern = re.compile(sPattern) return all(zPattern.search(sMorph) for sMorph in lMorph) |
︙ | |||
966 967 968 969 970 971 972 | 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 | - - - - + + + | return False # check negative condition if sNegPattern: if sNegPattern == "*": # all morph must match sPattern zPattern = re.compile(sPattern) return all(zPattern.search(sMorph) for sMorph in lMorph) |
︙ | |||
991 992 993 994 995 996 997 | 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 | - - - - + + + - - - - + + + | return False # check negative condition if sNegPattern: if sNegPattern == "*": # all morph must match sPattern zPattern = re.compile(sPattern) return all(zPattern.search(sMorph) for sMorph in lMorph) |
︙ |
Modified gc_core/py/lang_core/gc_options.py from [d511603a82] to [b668596de4].
︙ | |||
22 23 24 25 26 27 28 | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | - + | def getOptionsColors (sTheme="Default", sColorType="aRGB"): "returns dictionary of options colors" dOptColor = _dOptColor[sTheme] if sTheme in _dOptColor else _dOptColor["Default"] dColorType = _dColorType[sColorType] if sColorType in _dColorType else _dColorType["aRGB"] try: return { sOpt: dColorType[sColor] for sOpt, sColor in dOptColor.items() } |
︙ |
Modified gc_lang/fr/modules/gce_analyseur.py from [252fe3713f] to [bae6058302].
1 2 3 4 5 6 7 8 9 10 11 12 13 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | + | #### GRAMMAR CHECKING ENGINE PLUGIN: Parsing functions for French language from . import cregex as cr def g_morphVC (dToken, sPattern, sNegPattern=""): "lance la fonction g_morph() sur la première partie d’un verbe composé (ex: vient-il)" nEnd = dToken["sValue"].rfind("-") if "-t-" in dToken["sValue"]: nEnd = nEnd - 2 return g_morph(dToken, sPattern, sNegPattern, 0, nEnd, False) def rewriteSubject (s1, s2): |
︙ |
Modified gc_lang/fr/modules/gce_date_verif.py from [0f6e9ac587] to [489e3ffdfc].
︙ | |||
29 30 31 32 33 34 35 | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | - + | "return True if the date is valid" if not sMonth.isdigit(): sMonth = _dMonth.get(sMonth.lower(), "13") try: return datetime.date(int(sYear), int(sMonth), int(sDay)) except ValueError: return False |
︙ | |||
64 65 66 67 68 69 70 | 64 65 66 67 68 69 70 71 72 73 74 75 | - + - - - + + | sGregorianDay = _lDay[xDate.weekday()] return _dGregorianToJulian.get(sGregorianDay, "Erreur: jour inconnu") # 1582 if xDate.month < 12 or xDate.day <= 9: # Calendrier julien sGregorianDay = _lDay[xDate.weekday()] return _dGregorianToJulian.get(sGregorianDay, "Erreur: jour inconnu") |
Modified gc_lang/fr/modules/gce_suggestions.py from [6333a4318e] to [14bc22abf3].
︙ | |||
177 178 179 180 181 182 183 | 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | - + | if sWordToAgree: lMorph = _oSpellChecker.getMorph(sFlex) if not lMorph: return "" sGender = cr.getGender(lMorph) if sGender == ":m": return suggMasPlur(sFlex) |
︙ | |||
415 416 417 418 419 420 421 | 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 | - + | return "" def suggCeOrCet (sWord): "suggest “ce” or “cet” or both according to the first letter of <sWord>" if re.match("(?i)[aeéèêiouyâîï]", sWord): return "cet" |
︙ | |||
471 472 473 474 475 476 477 | 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 | - + - + - + - + - + - + - + | def formatNF (s): "typography: format NF reference (norme française)" try: m = re.match("NF[ -]?(C|E|P|Q|S|X|Z|EN(?:[ -]ISO|))[ -]?([0-9]+(?:[/‑-][0-9]+|))", s) if not m: return "" return "NF " + m.group(1).upper().replace(" ", " ").replace("-", " ") + " " + m.group(2).replace("/", "‑").replace("-", "‑") |
︙ |