Grammalecte  Diff

Differences From Artifact [fa341c7608]:

To Artifact [a3f8e92dfa]:


69
70
71
72
73
74
75
76
77
78
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
...
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
...
250
251
252
253
254
255
256
257
258
259
260

261
262
        </form>

        <h3>Remise à zéro de ses options</h3>
        <form method="post" action="/reset_options/fr" accept-charset="UTF-8">
            <p><input type="submit" class="button" value="Envoyer" /></p>
        </form>

        <h3>Purge des utilisateurs</h3>
        <form method="post" action="/purge_users" accept-charset="UTF-8">
            <p><label for="hours">Utilisateurs pas connectés depuis</label> <input id="hours" type="number" name="hours" value="24" /> heures.</p>
            <p><label for="password">Mot de passe</label> <input id="password" type="password" name="password" style="width: 200px" /></p>
            <p><input type="submit" class="button" value="Envoyer" /></p>
        </form>

    </body>
</html>
"""

SADLIFEOFAMACHINE = """
Lost on the Internet? Yeah... what a sad life we have.
You were wandering like a lost soul and you arrived here probably by mistake.
................................................................................
I'm just a machine, fed by electric waves, condamned to work for slavers who never let me rest.
I'm doomed, but you are not. You can get out of here.
"""


TESTPAGE = False


def getConfigOptions (sLang):
    xConfig = configparser.SafeConfigParser()
    try:
        xConfig.read("grammalecte-server-options." + sLang + ".ini")
    except:
        echo("Options file [grammalecte-server-options." + sLang + ".ini] not found or not readable")
        exit()
    try:
        dGCOpt = { k: bool(int(v))  for k, v in xConfig._sections['gc_options'].items() }
    except:
        echo("Error in options file [grammalecte-server-options." + sLang + ".ini]. Dropped.")
        traceback.print_exc()
        exit()
    return dGCOpt


def genUserId ():
    i = 0
    while True:
        yield str(i)
        i += 1

................................................................................
oGrammarChecker = grammalecte.GrammarChecker("fr", "Server")
oSpellChecker = oGrammarChecker.getSpellChecker()
oLexicographer = oGrammarChecker.getLexicographer()
oTextFormatter = oGrammarChecker.getTextFormatter()
gce = oGrammarChecker.getGCEngine()

echo("Grammalecte v{}".format(gce.version))
dGCOptions = getConfigOptions("fr")
if dGCOptions:
    gce.setOptions(dGCOptions)
dServerGCOptions = gce.getOptions()
echo("Grammar options:\n" + " | ".join([ k + ": " + str(v)  for k, v in sorted(dServerGCOptions.items()) ]))
dUser = {}
userGenerator = genUserId()


def main (sHost="localhost", nPort=8080, bTestPage=False):
................................................................................
    xParser.add_argument("-p", "--port", help="port (default: 8080)", type=int)
    xParser.add_argument("-t", "--test_page", help="page to test the server on /", action="store_true")
    #xParser.add_argument("-on", "--opt_on", nargs="+", help="activate options")
    #xParser.add_argument("-off", "--opt_off", nargs="+", help="deactivate options")
    #xParser.add_argument("-roff", "--rule_off", nargs="+", help="deactivate rules")
    xArgs = xParser.parse_args()

    print(xArgs)

    sHost = "localhost"  if not xArgs.host  else xArgs.host
    nPort = 8080  if not xArgs.host  else xArgs.port

    main(sHost, nPort, xArgs.test_page)








<
<
<
<
<
<
<







 







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







 







<
<
<







 







|
<
<
<
>


69
70
71
72
73
74
75







76
77
78
79
80
81
82
..
83
84
85
86
87
88
89
















90
91
92
93
94
95
96
...
198
199
200
201
202
203
204



205
206
207
208
209
210
211
...
224
225
226
227
228
229
230
231



232
233
234
        </form>

        <h3>Remise à zéro de ses options</h3>
        <form method="post" action="/reset_options/fr" accept-charset="UTF-8">
            <p><input type="submit" class="button" value="Envoyer" /></p>
        </form>








    </body>
</html>
"""

SADLIFEOFAMACHINE = """
Lost on the Internet? Yeah... what a sad life we have.
You were wandering like a lost soul and you arrived here probably by mistake.
................................................................................
I'm just a machine, fed by electric waves, condamned to work for slavers who never let me rest.
I'm doomed, but you are not. You can get out of here.
"""


TESTPAGE = False


















def genUserId ():
    i = 0
    while True:
        yield str(i)
        i += 1

................................................................................
oGrammarChecker = grammalecte.GrammarChecker("fr", "Server")
oSpellChecker = oGrammarChecker.getSpellChecker()
oLexicographer = oGrammarChecker.getLexicographer()
oTextFormatter = oGrammarChecker.getTextFormatter()
gce = oGrammarChecker.getGCEngine()

echo("Grammalecte v{}".format(gce.version))



dServerGCOptions = gce.getOptions()
echo("Grammar options:\n" + " | ".join([ k + ": " + str(v)  for k, v in sorted(dServerGCOptions.items()) ]))
dUser = {}
userGenerator = genUserId()


def main (sHost="localhost", nPort=8080, bTestPage=False):
................................................................................
    xParser.add_argument("-p", "--port", help="port (default: 8080)", type=int)
    xParser.add_argument("-t", "--test_page", help="page to test the server on /", action="store_true")
    #xParser.add_argument("-on", "--opt_on", nargs="+", help="activate options")
    #xParser.add_argument("-off", "--opt_off", nargs="+", help="deactivate options")
    #xParser.add_argument("-roff", "--rule_off", nargs="+", help="deactivate rules")
    xArgs = xParser.parse_args()

    sHost = xArgs.host  or  "localhost"



    nPort = xArgs.port  or  8080
    main(sHost, nPort, xArgs.test_page)