Grammalecte  Check-in [4dd659124b]

Overview
Comment:[lo] lexicon editor: fix import and normalize personal dictionary name
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | lo
Files: files | file ages | folders
SHA3-256: 4dd659124be74cbc9b9780f96eb385d0dada8611400107031d3e15264571ce04
User & Date: olr on 2020-09-03 09:30:47
Other Links: manifest | tags
Context
2020-09-03
09:31
[fr] ajustements check-in: 8e5062528d user: olr tags: fr, trunk
09:30
[lo] lexicon editor: fix import and normalize personal dictionary name check-in: 4dd659124b user: olr tags: lo, trunk
2020-09-02
09:40
[fx] don’t remove HTML entities check-in: 1097f9a5d9 user: olr tags: fx, trunk
Changes

Modified gc_lang/fr/oxt/DictOptions/LexiconEditor.py from [5dfd11a474] to [afc37335be].

4
5
6
7
8
9
10

11
12
13
14
15
16
17
...
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
...
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450

import unohelper
import uno
import json
import re
import os
import traceback


import helpers
import lxe_strings
import grammalecte.graphspell as sc
import grammalecte.graphspell.dawg as dawg
import grammalecte.graphspell.ibdawg as ibdawg
import grammalecte.fr.conj as conj
................................................................................
                lFile = xFilePicker.getFiles()
                #print(lFile)
                #MessageBox(self.xDocument, "File(s): " + str(lFile), "DEBUG", INFOBOX)
                spfImported = lFile[0][5:].lstrip("/") # remove file://
                if platform.system() != "Windows":
                    spfImported = "/" + spfImported
        except:
            spfImported = os.path.join(os.path.expanduser("~"), "fr.personal.json") # workaround
        if spfImported and os.path.isfile(spfImported):
            with open(spfImported, "r", encoding="utf-8") as hDst:
                sJSON = hDst.read()
                try:
                    sTest = json.loads(sJSON)
                except:
                    sMessage = self.dUI.get('wrong_json', "#err_msg: %s") % spfImported
................................................................................
    @_waitPointer
    def saveLexicon (self):
        xGridDataModel = self.xGridModelLex.GridDataModel
        lEntry = []
        for i in range(xGridDataModel.RowCount):
            lEntry.append(xGridDataModel.getRowData(i))
        if lEntry:
            oDAWG = dawg.DAWG(lEntry, "S", "fr", "Français", "fr.personal", "Dictionnaire personnel")
            self.oPersonalDicJSON = oDAWG.getBinaryAsJSON()
            self.xOptionNode.setPropertyValue("personal_dic", json.dumps(self.oPersonalDicJSON, ensure_ascii=False))
            self.xSettingNode.commitChanges()
            self.xNumDic.Label = str(self.oPersonalDicJSON["nEntry"])
            self.xDateDic.Label = self.oPersonalDicJSON["sDate"]
        else:
            self.xOptionNode.setPropertyValue("personal_dic", "")







>







 







|







 







|







4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
...
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
...
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451

import unohelper
import uno
import json
import re
import os
import traceback
import platform

import helpers
import lxe_strings
import grammalecte.graphspell as sc
import grammalecte.graphspell.dawg as dawg
import grammalecte.graphspell.ibdawg as ibdawg
import grammalecte.fr.conj as conj
................................................................................
                lFile = xFilePicker.getFiles()
                #print(lFile)
                #MessageBox(self.xDocument, "File(s): " + str(lFile), "DEBUG", INFOBOX)
                spfImported = lFile[0][5:].lstrip("/") # remove file://
                if platform.system() != "Windows":
                    spfImported = "/" + spfImported
        except:
            spfImported = os.path.join(os.path.expanduser("~"), "fr.__personal__.json") # workaround
        if spfImported and os.path.isfile(spfImported):
            with open(spfImported, "r", encoding="utf-8") as hDst:
                sJSON = hDst.read()
                try:
                    sTest = json.loads(sJSON)
                except:
                    sMessage = self.dUI.get('wrong_json', "#err_msg: %s") % spfImported
................................................................................
    @_waitPointer
    def saveLexicon (self):
        xGridDataModel = self.xGridModelLex.GridDataModel
        lEntry = []
        for i in range(xGridDataModel.RowCount):
            lEntry.append(xGridDataModel.getRowData(i))
        if lEntry:
            oDAWG = dawg.DAWG(lEntry, "S", "fr", "Français", "fr.__personal__", "Dictionnaire personnel")
            self.oPersonalDicJSON = oDAWG.getBinaryAsJSON()
            self.xOptionNode.setPropertyValue("personal_dic", json.dumps(self.oPersonalDicJSON, ensure_ascii=False))
            self.xSettingNode.commitChanges()
            self.xNumDic.Label = str(self.oPersonalDicJSON["nEntry"])
            self.xDateDic.Label = self.oPersonalDicJSON["sDate"]
        else:
            self.xOptionNode.setPropertyValue("personal_dic", "")