Grammalecte  Check-in [099f103bb1]

Overview
Comment:[build] fix setup.py, shebang and rename cli.py and server.py
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | build
Files: files | file ages | folders
SHA3-256: 099f103bb1f75b48f60fea2a1d879f32987d25764ec4119f2648a16cac88445f
User & Date: olr on 2017-11-13 17:05:39
Other Links: manifest | tags
Context
2017-11-13
20:18
[fx] action when extension is installed check-in: 126234b371 user: olr tags: fx, trunk
17:05
[build] fix setup.py, shebang and rename cli.py and server.py check-in: 099f103bb1 user: olr tags: build, trunk
14:07
[core] char_player update check-in: 0b029f2147 user: olr tags: core, trunk
Changes

Modified gc_lang/fr/setup.py from [378a2ab4e1] to [651ab7645b].

22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
..
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
..
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
    # https://packaging.python.org/en/latest/single_source_version.html
    version='${version}',

    description='French grammar checker',
    #long_description=long_description,

    # The project's main homepage.
    url='https://grammalecte.net',

    # Author details
    author='Olivier R.',
    #author_email='fuckoff.noreply@nowhere.nw',

    # Choose your license
    license='GPL3',
................................................................................
        'Programming Language :: Python :: 3.6',
    ],

    # What does your project relate to?
    keywords='French grammar checker correcteur grammatical français',

    # Scripts
    script=['cli.py', 'server.py', 'bootle.py'],

    # You can just specify the packages manually here if your project is
    # simple. Or you can use find_packages().
    # packages=find_packages(exclude=['contrib', 'docs', 'tests']),
    packages=['grammalecte', 'grammalecte.fr'],

    # Alternatively, if you want to distribute just a my_module.py, uncomment
................................................................................
    },

    # Although 'package_data' is the preferred approach, in some case you may
    # need to place data files outside of your packages. See:
    # http://docs.python.org/3.4/distutils/setupscript.html#installing-additional-files # noqa
    # In this case, 'data_file' will be installed into '<sys.prefix>/my_data'
    # data_files=[('my_data', ['data/data_file'])],
    data_files=[('', ['cli.py', 'server.py', 'bottle.py', 'README.txt', 'LICENSE.txt', \
                      'server_options.fr.ini', 'server_options._global.ini'])],

    # To provide executable scripts, use entry points in preference to the
    # "scripts" keyword. Entry points provide cross-platform support and allow
    # pip to create the appropriate form of executable for the target platform.
    # entry_points={
    #     'console_scripts': [
    #         'sample=sample:main',
    #     ],
    # },
)







|







 







|







 







|











22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
..
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
..
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
    # https://packaging.python.org/en/latest/single_source_version.html
    version='${version}',

    description='French grammar checker',
    #long_description=long_description,

    # The project's main homepage.
    url='http://grammalecte.net',

    # Author details
    author='Olivier R.',
    #author_email='fuckoff.noreply@nowhere.nw',

    # Choose your license
    license='GPL3',
................................................................................
        'Programming Language :: Python :: 3.6',
    ],

    # What does your project relate to?
    keywords='French grammar checker correcteur grammatical français',

    # Scripts
    scripts=['grammalecte-cli.py', 'grammalecte-server.py', 'bottle.py'],

    # You can just specify the packages manually here if your project is
    # simple. Or you can use find_packages().
    # packages=find_packages(exclude=['contrib', 'docs', 'tests']),
    packages=['grammalecte', 'grammalecte.fr'],

    # Alternatively, if you want to distribute just a my_module.py, uncomment
................................................................................
    },

    # Although 'package_data' is the preferred approach, in some case you may
    # need to place data files outside of your packages. See:
    # http://docs.python.org/3.4/distutils/setupscript.html#installing-additional-files # noqa
    # In this case, 'data_file' will be installed into '<sys.prefix>/my_data'
    # data_files=[('my_data', ['data/data_file'])],
    data_files=[('', ['grammalecte-cli.py', 'grammalecte-server.py', 'bottle.py', 'README.txt', 'LICENSE.txt', \
                      'server_options.fr.ini', 'server_options._global.ini'])],

    # To provide executable scripts, use entry points in preference to the
    # "scripts" keyword. Entry points provide cross-platform support and allow
    # pip to create the appropriate form of executable for the target platform.
    # entry_points={
    #     'console_scripts': [
    #         'sample=sample:main',
    #     ],
    # },
)

Name change from cli.py to grammalecte-cli.py.

Name change from server_options._global.ini to grammalecte-server-options._global.ini.

Name change from server_options.fr.ini to grammalecte-server-options.fr.ini.

Modified grammalecte-server.py from [f6702400a5] to [a304d7cf85].

1
2
3
4
5
6
7
8
..
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
#!python3

import sys
import os.path
import argparse
import json
import traceback
import configparser
................................................................................
I'm doomed, but you are not. You can get out of here.
"""


def getServerOptions ():
    xConfig = configparser.SafeConfigParser()
    try:
        xConfig.read("server_options._global.ini")
        dOpt = xConfig._sections['options']
    except:
        echo("Options file [server_options._global.ini] not found or not readable")
        exit()
    return dOpt


def getConfigOptions (sLang):
    xConfig = configparser.SafeConfigParser()
    try:
        xConfig.read("server_options." + sLang + ".ini")
    except:
        echo("Options file [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 [server_options." + sLang + ".ini]. Dropped.")
        traceback.print_exc()
        exit()
    return dGCOpt


def genUserId ():
    i = 0
|







 







|


|







|

|




|







1
2
3
4
5
6
7
8
..
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
 #!/usr/bin/env python3

import sys
import os.path
import argparse
import json
import traceback
import configparser
................................................................................
I'm doomed, but you are not. You can get out of here.
"""


def getServerOptions ():
    xConfig = configparser.SafeConfigParser()
    try:
        xConfig.read("grammalecte-server-options._global.ini")
        dOpt = xConfig._sections['options']
    except:
        echo("Options file [grammalecte-server-options._global.ini] not found or not readable")
        exit()
    return dOpt


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

Modified make.py from [63b5b07d38] to [37cd0bb45e].

1
2
3
4
5
6
7
8
..
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
...
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159

160
161
162
163
164
165
166
...
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
#!python3
# coding: UTF-8

import sys
import os
import subprocess
import re
import zipfile
................................................................................
    "create extension for Writer"
    print("Building extension for Writer")
    spfZip = "_build/" + dVars['name'] + "-"+ dVars['lang'] +"-v" + dVars['version'] + '.oxt'
    hZip = zipfile.ZipFile(spfZip, mode='w', compression=zipfile.ZIP_DEFLATED)

    # Package and parser
    copyGrammalectePyPackageInZipFile(hZip, spLangPack, dVars['dic_name']+".bdic", "pythonpath/")
    hZip.write("cli.py", "pythonpath/cli.py")

    # Extension files
    hZip.writestr("META-INF/manifest.xml", helpers.fileFile("gc_core/py/oxt/manifest.xml", dVars))
    hZip.writestr("description.xml", helpers.fileFile("gc_core/py/oxt/description.xml", dVars))
    hZip.writestr("Linguistic.xcu", helpers.fileFile("gc_core/py/oxt/Linguistic.xcu", dVars))
    hZip.writestr("Grammalecte.py", helpers.fileFile("gc_core/py/oxt/Grammalecte.py", dVars))

................................................................................
            #subprocess.run(cmd)
            os.system(cmd)
        else:
            print("# Error: path and filename of unopkg not set in config.ini")


def createServerOptions (sLang, dOptData):
    with open("server_options."+sLang+".ini", "w", encoding="utf-8", newline="\n") as hDst:
        hDst.write("# Server options. Lang: " + sLang + "\n\n[gc_options]\n")
        for sSection, lOpt in dOptData["lStructOpt"]:
            hDst.write("\n########## " + dOptData["dOptLabel"][sLang].get(sSection, sSection + "[no label found]")[0] + " ##########\n")
            for lLineOpt in lOpt:
                for sOpt in lLineOpt:
                    hDst.write("# " + dOptData["dOptLabel"][sLang].get(sOpt, "[no label found]")[0] + "\n")
                    hDst.write(sOpt + " = " + ("1" if dOptData["dOptServer"].get(sOpt, None) else "0") + "\n")
        hDst.write("html = 1\n")


def createServerZip (sLang, dVars, spLangPack):
    "create server zip"
    spfZip = "_build/" + dVars['name'] + "-"+ dVars['lang'] +"-v" + dVars['version'] + '.zip'
    hZip = zipfile.ZipFile(spfZip, mode='w', compression=zipfile.ZIP_DEFLATED)
    copyGrammalectePyPackageInZipFile(hZip, spLangPack, dVars['dic_name']+".bdic")
    for spf in ["cli.py", "server.py", "bottle.py", "server_options._global.ini", "server_options."+sLang+".ini", \

                "README.txt", "LICENSE.txt", "LICENSE.fr.txt"]:
        hZip.write(spf)
    hZip.writestr("setup.py", helpers.fileFile("gc_lang/fr/setup.py", dVars))


def copyGrammalectePyPackageInZipFile (hZip, spLangPack, sDicName, sAddPath=""):
    for sf in os.listdir("grammalecte"):
................................................................................
    with open("grammalecte/"+sLang+"/gc_test.txt", "w", encoding="utf-8", newline="\n") as hDstPy:
        hDstPy.write("# TESTS FOR LANG [" + sLang + "]\n\n")
        hDstPy.write(dVars['gctests'])

    createOXT(spLang, dVars, xConfig._sections['oxt'], spLangPack, bInstallOXT)

    createServerOptions(sLang, dVars)
    createServerZip(sLang, dVars, spLangPack)

    #### JAVASCRIPT
    if bJavaScript:
        print("JAVASCRIPT:")
        print("+ Plugins: ", end="")
        sCodePlugins = ""
        for sf in os.listdir(spLang+"/modules-js"):
|







 







|







 







|










|




|
>







 







|







1
2
3
4
5
6
7
8
..
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
...
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
...
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
 #!/usr/bin/env python3
# coding: UTF-8

import sys
import os
import subprocess
import re
import zipfile
................................................................................
    "create extension for Writer"
    print("Building extension for Writer")
    spfZip = "_build/" + dVars['name'] + "-"+ dVars['lang'] +"-v" + dVars['version'] + '.oxt'
    hZip = zipfile.ZipFile(spfZip, mode='w', compression=zipfile.ZIP_DEFLATED)

    # Package and parser
    copyGrammalectePyPackageInZipFile(hZip, spLangPack, dVars['dic_name']+".bdic", "pythonpath/")
    hZip.write("grammalecte-cli.py", "pythonpath/grammalecte-cli.py")

    # Extension files
    hZip.writestr("META-INF/manifest.xml", helpers.fileFile("gc_core/py/oxt/manifest.xml", dVars))
    hZip.writestr("description.xml", helpers.fileFile("gc_core/py/oxt/description.xml", dVars))
    hZip.writestr("Linguistic.xcu", helpers.fileFile("gc_core/py/oxt/Linguistic.xcu", dVars))
    hZip.writestr("Grammalecte.py", helpers.fileFile("gc_core/py/oxt/Grammalecte.py", dVars))

................................................................................
            #subprocess.run(cmd)
            os.system(cmd)
        else:
            print("# Error: path and filename of unopkg not set in config.ini")


def createServerOptions (sLang, dOptData):
    with open("grammalecte-server-options."+sLang+".ini", "w", encoding="utf-8", newline="\n") as hDst:
        hDst.write("# Server options. Lang: " + sLang + "\n\n[gc_options]\n")
        for sSection, lOpt in dOptData["lStructOpt"]:
            hDst.write("\n########## " + dOptData["dOptLabel"][sLang].get(sSection, sSection + "[no label found]")[0] + " ##########\n")
            for lLineOpt in lOpt:
                for sOpt in lLineOpt:
                    hDst.write("# " + dOptData["dOptLabel"][sLang].get(sOpt, "[no label found]")[0] + "\n")
                    hDst.write(sOpt + " = " + ("1" if dOptData["dOptServer"].get(sOpt, None) else "0") + "\n")
        hDst.write("html = 1\n")


def createPackageZip (sLang, dVars, spLangPack):
    "create server zip"
    spfZip = "_build/" + dVars['name'] + "-"+ dVars['lang'] +"-v" + dVars['version'] + '.zip'
    hZip = zipfile.ZipFile(spfZip, mode='w', compression=zipfile.ZIP_DEFLATED)
    copyGrammalectePyPackageInZipFile(hZip, spLangPack, dVars['dic_name']+".bdic")
    for spf in ["grammalecte-cli.py", "grammalecte-server.py", "bottle.py", \
                "grammalecte-server-options._global.ini", "grammalecte-server-options."+sLang+".ini", \
                "README.txt", "LICENSE.txt", "LICENSE.fr.txt"]:
        hZip.write(spf)
    hZip.writestr("setup.py", helpers.fileFile("gc_lang/fr/setup.py", dVars))


def copyGrammalectePyPackageInZipFile (hZip, spLangPack, sDicName, sAddPath=""):
    for sf in os.listdir("grammalecte"):
................................................................................
    with open("grammalecte/"+sLang+"/gc_test.txt", "w", encoding="utf-8", newline="\n") as hDstPy:
        hDstPy.write("# TESTS FOR LANG [" + sLang + "]\n\n")
        hDstPy.write(dVars['gctests'])

    createOXT(spLang, dVars, xConfig._sections['oxt'], spLangPack, bInstallOXT)

    createServerOptions(sLang, dVars)
    createPackageZip(sLang, dVars, spLangPack)

    #### JAVASCRIPT
    if bJavaScript:
        print("JAVASCRIPT:")
        print("+ Plugins: ", end="")
        sCodePlugins = ""
        for sf in os.listdir(spLang+"/modules-js"):