Grammalecte  Check-in [f086eb66a0]

Overview
Comment:[core] gc engine: create errors, code clarification
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | core | rg
Files: files | file ages | folders
SHA3-256: f086eb66a0d7830084ab3f9515d914d760230fe175678e3588d363b56516cd01
User & Date: olr on 2018-06-27 20:53:35
Other Links: branch diff | manifest | tags
Context
2018-06-27
20:58
[core][bug] gc engine: missing parameter check-in: 6e8a6ca2ac user: olr tags: core, rg
20:53
[core] gc engine: create errors, code clarification check-in: f086eb66a0 user: olr tags: core, rg
20:18
[core] gc engine: merge error creation functions (code clarification) check-in: 6f2fcade8d user: olr tags: core, rg
Changes

Modified gc_core/py/lang_core/gc_engine.py from [6d8fead8fe] to [e1ed0e462e].

212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229

230
231
232
233
234
235
236
237
238
239
240


def _createError (s, sx, sRepl, nOffset, m, iGroup, sLineId, sRuleId, bUppercase, sMsg, sURL, bShowRuleId, sOption, bContext):
    nStart = nOffset + m.start(iGroup)
    nEnd = nOffset + m.end(iGroup)
    # suggestions
    if sRepl[0:1] == "=":
        sugg = globals()[sRepl[1:]](s, m)
        if sugg:
            if bUppercase and m.group(iGroup)[0:1].isupper():
                lSugg = list(map(str.capitalize, sugg.split("|")))
            else:
                lSugg = sugg.split("|")
        else:
            lSugg = []
    elif sRepl == "_":
        lSugg = []
    else:

        if bUppercase and m.group(iGroup)[0:1].isupper():
            lSugg = list(map(str.capitalize, m.expand(sRepl).split("|")))
        else:
            lSugg = m.expand(sRepl).split("|")
    # Message
    sMessage = globals()[sMsg[1:]](s, m)  if sMsg[0:1] == "="  else  m.expand(sMsg)
    if bShowRuleId:
        sMessage += "  # " + sLineId + " # " + sRuleId
    #
    if _bWriterError:
        xErr = SingleProofreadingError()    # uno.createUnoStruct( "com.sun.star.linguistic2.SingleProofreadingError" )







|
<
<
<
<
<
<
|



>
|
|
<
<







212
213
214
215
216
217
218
219






220
221
222
223
224
225
226


227
228
229
230
231
232
233


def _createError (s, sx, sRepl, nOffset, m, iGroup, sLineId, sRuleId, bUppercase, sMsg, sURL, bShowRuleId, sOption, bContext):
    nStart = nOffset + m.start(iGroup)
    nEnd = nOffset + m.end(iGroup)
    # suggestions
    if sRepl[0:1] == "=":
        sSugg = globals()[sRepl[1:]](s, m)






        lSugg = sSugg.split("|")  if sSugg  else []
    elif sRepl == "_":
        lSugg = []
    else:
        lSugg = m.expand(sRepl).split("|")
    if bUppercase and lSugg and m.group(iGroup)[0:1].isupper():
        lSugg = list(map(str.capitalize, lSugg))


    # Message
    sMessage = globals()[sMsg[1:]](s, m)  if sMsg[0:1] == "="  else  m.expand(sMsg)
    if bShowRuleId:
        sMessage += "  # " + sLineId + " # " + sRuleId
    #
    if _bWriterError:
        xErr = SingleProofreadingError()    # uno.createUnoStruct( "com.sun.star.linguistic2.SingleProofreadingError" )
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796

797
798
799
800
801
802
803
804
805
806
807
                    raise Exception(str(e), sLineId, sRuleId, self.sSentence)
        return bChange, dError

    def _createError (self, sSugg, nTokenOffset, iFirstToken, nStart, nEnd, sLineId, sRuleId, bUppercase, sMsg, sURL, bShowRuleId, sOption, bContext):
        # suggestions
        if sSugg[0:1] == "=":
            sSugg = globals()[sSugg[1:]](self.lToken, nTokenOffset)
            if sSugg:
                if bUppercase and self.lToken[iFirstToken]["sValue"][0:1].isupper():
                    lSugg = list(map(str.capitalize, sSugg.split("|")))
                else:
                    lSugg = sSugg.split("|")
            else:
                lSugg = []
        elif sSugg == "_":
            lSugg = []
        else:

            if bUppercase and self.lToken[iFirstToken]["sValue"][0:1].isupper():
                lSugg = list(map(str.capitalize, self._expand(sSugg, nTokenOffset).split("|")))
            else:
                lSugg = self._expand(sSugg, nTokenOffset).split("|")
        # Message
        sMessage = globals()[sMsg[1:]](self.lToken)  if sMsg[0:1] == "="  else self._expand(sMsg, nTokenOffset)
        if bShowRuleId:
            sMessage += "  " + sLineId + " # " + sRuleId
        #
        if _bWriterError:
            xErr = SingleProofreadingError()    # uno.createUnoStruct( "com.sun.star.linguistic2.SingleProofreadingError" )







<
<
<
<
|
<
<



>
|
|
<
<







773
774
775
776
777
778
779




780


781
782
783
784
785
786


787
788
789
790
791
792
793
                    raise Exception(str(e), sLineId, sRuleId, self.sSentence)
        return bChange, dError

    def _createError (self, sSugg, nTokenOffset, iFirstToken, nStart, nEnd, sLineId, sRuleId, bUppercase, sMsg, sURL, bShowRuleId, sOption, bContext):
        # suggestions
        if sSugg[0:1] == "=":
            sSugg = globals()[sSugg[1:]](self.lToken, nTokenOffset)




            lSugg = sSugg.split("|")  if sSugg  else []


        elif sSugg == "_":
            lSugg = []
        else:
            lSugg = self._expand(sSugg, nTokenOffset).split("|")
        if bUppercase and lSugg and self.lToken[iFirstToken]["sValue"][0:1].isupper():
            lSugg = list(map(str.capitalize, lSugg))


        # Message
        sMessage = globals()[sMsg[1:]](self.lToken)  if sMsg[0:1] == "="  else self._expand(sMsg, nTokenOffset)
        if bShowRuleId:
            sMessage += "  " + sLineId + " # " + sRuleId
        #
        if _bWriterError:
            xErr = SingleProofreadingError()    # uno.createUnoStruct( "com.sun.star.linguistic2.SingleProofreadingError" )