1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
+
|
# Lexicon Editor
# by Olivier R.
# License: MPL 2
import unohelper
import uno
import json
import urllib.parse
import re
import os
import traceback
import platform
import helpers
import lxe_strings as ui
|
417
418
419
420
421
422
423
424
425
426
427
428
429
430
|
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
|
+
|
# lFile = xFilePicker.getSelectedFiles()
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
spfImported = urllib.parse.unquote(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)
|
470
471
472
473
474
475
476
477
478
479
480
481
482
483
|
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
|
+
|
nResult = xFilePicker.execute()
if nResult == 1:
# lFile = xFilePicker.getSelectedFiles()
lFile = xFilePicker.getFiles()
spfExported = lFile[0][5:].lstrip("/") # remove file://
if platform.system() != "Windows":
spfExported = "/" + spfExported
spfExported = urllib.parse.unquote(spfExported)
#spfExported = os.path.join(os.path.expanduser("~"), "fr.personal.json")
sJSON = self.xOptionNode.getPropertyValue("personal_dic")
if sJSON:
with open(spfExported, "w", encoding="utf-8") as hDst:
hDst.write(sJSON)
sMessage = ui.get('export_message') % spfExported
else:
|