Overview
| Comment: | [build][fr] useless to use os.makedirs via a function |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | trunk | fr | build |
| Files: | files | file ages | folders |
| SHA3-256: |
3ecdf872a25e67b49e19bb9968be23e0 |
| User & Date: | olr on 2025-11-24 17:52:47 |
| Other Links: | manifest | tags |
Context
|
2025-11-24
| ||
| 17:52 | [build][fr] useless to use os.makedirs via a function Leaf check-in: 3ecdf872a2 user: olr tags: trunk, fr, build | |
| 17:40 | [build][fr] create folders recursively check-in: fc398bebae user: olr tags: trunk, fr, build | |
Changes
Modified gc_lang/fr/dictionnaire/genfrdic.py from [48e0746ca6] to [fce132f18a].
| ︙ | ︙ | |||
191 192 193 194 195 196 197 |
if os.path.isfile(spf):
with open(spf, "r", encoding="utf-8") as hSrc:
for sLine in hSrc:
yield sLine
else:
print("# Error: file not found.")
| < < < < < < | 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
if os.path.isfile(spf):
with open(spf, "r", encoding="utf-8") as hSrc:
for sLine in hSrc:
yield sLine
else:
print("# Error: file not found.")
class Dictionnaire:
def __init__ (self, version, name):
# Dictionary
self.sName = name
self.lEntry = []
self.nEntry = 0
|
| ︙ | ︙ | |||
526 527 528 529 530 531 532 |
hDst.write(Flexion.simpleHeader())
for oFlex in self.lFlexions:
hDst.write(oFlex.getGrammarCheckerRepr())
def createFiles (self, spDst, lDictVars, nMode, bSimplified):
sDicName = PREFIX_DICT_PATH + self.sVersion
spDic = spDst + '/' + sDicName
| | | | | | | 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 |
hDst.write(Flexion.simpleHeader())
for oFlex in self.lFlexions:
hDst.write(oFlex.getGrammarCheckerRepr())
def createFiles (self, spDst, lDictVars, nMode, bSimplified):
sDicName = PREFIX_DICT_PATH + self.sVersion
spDic = spDst + '/' + sDicName
os.makedirs(spDic, exist_ok=True)
for dVars in lDictVars:
# template vars
dVars['version'] = self.sVersion
# Dictionaries files (.dic) (.aff)
self.writeAffixes(spDic, dVars, nMode, bSimplified)
self.writeDictionary(spDic, dVars, nMode, bSimplified)
copyTemplate('orthographe', spDic, 'README_dict_fr.txt', dVars)
createZipFiles(spDic, spDst, sDicName + '.zip')
def createLibreOfficeExtension (self, spBuild, dTplVars, lDictVars, sThesVer, spDestGL=""):
# LibreOffice extension
echo(" * Dictionnaire >> extension pour LibreOffice")
dTplVars['version'] = self.sVersion
sExtensionName = EXT_PREFIX_OOO + self.sVersion
spExt = spBuild + '/' + sExtensionName
os.makedirs(spExt+'/META-INF', exist_ok=True)
os.makedirs(spExt+'/ui', exist_ok=True)
os.makedirs(spExt+'/dictionaries', exist_ok=True)
os.makedirs(spExt+'/pythonpath', exist_ok=True)
shutil.copy2('_templates/ooo/manifest.xml', spExt+'/META-INF')
shutil.copy2('_templates/ooo/DictionarySwitcher.py', spExt)
shutil.copy2('_templates/ooo/ds_strings.py', spExt+'/pythonpath')
shutil.copy2('_templates/ooo/addons.xcu', spExt+'/ui')
shutil.copy2('_templates/ooo/french_flag.png', spExt)
shutil.copy2('_templates/ooo/french_flag_16.bmp', spExt+'/ui')
copyTemplate('_templates/ooo', spExt, 'description.xml', dTplVars)
|
| ︙ | ︙ | |||
585 586 587 588 589 590 591 |
def createMozillaExtensions (self, spBuild, dTplVars, lDictVars, spDestGL=""):
# Mozilla extension 1
echo(" * Dictionnaire >> extension pour Mozilla")
dTplVars['version'] = self.sVersion
sExtensionName = EXT_PREFIX_MOZ + self.sVersion
spExt = spBuild + '/' + sExtensionName
| | | 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 |
def createMozillaExtensions (self, spBuild, dTplVars, lDictVars, spDestGL=""):
# Mozilla extension 1
echo(" * Dictionnaire >> extension pour Mozilla")
dTplVars['version'] = self.sVersion
sExtensionName = EXT_PREFIX_MOZ + self.sVersion
spExt = spBuild + '/' + sExtensionName
os.makedirs(spExt+'/dictionaries', exist_ok=True)
copyTemplate('_templates/moz', spExt, 'manifest.json', dTplVars)
spDict = spBuild + '/' + PREFIX_DICT_PATH + self.sVersion
shutil.copy2(spDict+'/fr-classique.dic', spExt+'/dictionaries/fr-classic.dic')
shutil.copy2(spDict+'/fr-classique.aff', spExt+'/dictionaries/fr-classic.aff')
copyTemplate('orthographe', spExt, 'README_dict_fr.txt', dTplVars)
createZipFiles(spExt, spBuild, sExtensionName + '.xpi')
# Grammalecte
|
| ︙ | ︙ | |||
611 612 613 614 615 616 617 |
if oEntry.fq != oEntry.oldFq:
hDiff.write("{0.iD}\t{0.fq}\n".format(oEntry))
hNotes.write("{0.lemma}/{0.flags}\t{0.oldFq} > {0.fq}\n".format(oEntry))
def createLexiconPackages (self, spBuild, version, oStatsLex, spDestGL=""):
sLexName = LEX_PREFIX + version
spLex = spBuild + '/' + sLexName
| | | 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 |
if oEntry.fq != oEntry.oldFq:
hDiff.write("{0.iD}\t{0.fq}\n".format(oEntry))
hNotes.write("{0.lemma}/{0.flags}\t{0.oldFq} > {0.fq}\n".format(oEntry))
def createLexiconPackages (self, spBuild, version, oStatsLex, spDestGL=""):
sLexName = LEX_PREFIX + version
spLex = spBuild + '/' + sLexName
os.makedirs(spLex, exist_ok=True)
# write lexicon
self.sortLexiconByFreq()
self.writeLexicon(spLex + '/' + sLexName + '.txt', version, oStatsLex)
self.writeGrammarCheckerLexicon(spBuild + '/' + sLexName + '.lex', version)
copyTemplate('lexique', spLex, 'README_lexique.txt', {'version': version})
# zip
createZipFiles(spLex, spBuild, sLexName + '.zip')
|
| ︙ | ︙ | |||
1412 1413 1414 1415 1416 1417 1418 |
for e in self.dFlexions.items():
hDst.write("{} - {}\n".format(e[0], e[1]))
def createThesaurusPackage (spBuild, sVersion, spCopy="", spDataDestGL=""):
print(" * Création du thésaurus")
spThesaurus = spBuild+"/thesaurus-v"+sVersion
| | | 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 |
for e in self.dFlexions.items():
hDst.write("{} - {}\n".format(e[0], e[1]))
def createThesaurusPackage (spBuild, sVersion, spCopy="", spDataDestGL=""):
print(" * Création du thésaurus")
spThesaurus = spBuild+"/thesaurus-v"+sVersion
os.makedirs(spThesaurus, exist_ok=True)
thes_build.build("thesaurus/thes_fr.dat", "thesaurus/synsets_fr.dat", spThesaurus)
shutil.copy2('thesaurus/README_thes_fr.txt', spThesaurus)
if spCopy:
# copy in libreoffice extension package
print(" Copie du thésaurus dans:", spCopy)
shutil.copy2(spThesaurus+'/thes_fr.dat', spCopy)
shutil.copy2(spThesaurus+'/thes_fr.idx', spCopy)
|
| ︙ | ︙ | |||
1447 1448 1449 1450 1451 1452 1453 |
echo("Version: " + xArgs.verdic)
echo("Simplify: " + str(xArgs.simplify))
echo("Mode: " + str(xArgs.mode))
echo("Compression: " + str(not(xArgs.uncompress)))
### création du répertoire
spBuild = BUILD_PATH + '/' + xArgs.verdic
| | | 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 |
echo("Version: " + xArgs.verdic)
echo("Simplify: " + str(xArgs.simplify))
echo("Mode: " + str(xArgs.mode))
echo("Compression: " + str(not(xArgs.uncompress)))
### création du répertoire
spBuild = BUILD_PATH + '/' + xArgs.verdic
os.makedirs(spBuild, exist_ok=True)
### Lecture des fichiers et création du dictionnaire
oFrenchDict = Dictionnaire(xArgs.verdic, "French dictionary")
for sFile in ['orthographe/FRANCAIS.dic']:
oFrenchDict.readDictionary(sFile)
oFrenchDict.readAffixes('orthographe/FRANCAIS_7.aff')
|
| ︙ | ︙ |
Modified helpers.py from [82e1f566c6] to [3b783d8a38].
| ︙ | ︙ | |||
72 73 74 75 76 77 78 |
def createCleanFolder (sp):
"make an empty folder or erase its content if not empty"
if not os.path.exists(sp):
os.makedirs(sp, exist_ok=True)
else:
eraseFolderContent(sp)
| < < < < < < | 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
def createCleanFolder (sp):
"make an empty folder or erase its content if not empty"
if not os.path.exists(sp):
os.makedirs(sp, exist_ok=True)
else:
eraseFolderContent(sp)
def copyFolder (spSrc, spDst):
"copy folder content from src to dst"
try:
shutil.copytree(spSrc, spDst)
except OSError as e:
if e.errno == errno.ENOTDIR:
|
| ︙ | ︙ |
Modified lex_build.py from [f032803b08] to [a97d060e85].
1 2 3 4 5 6 7 | #!python3 """ Lexicon builder """ import argparse | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
#!python3
"""
Lexicon builder
"""
import argparse
import os
import graphspell.dawg as fsa
def build (spfSrc, sLangCode, sLangName, sfDict, bJavaScript=False, sDicName="", sDescription="", sFilter="", cStemmingMethod="S", nCompressMethod=1):
"transform a text lexicon as a binary indexable dictionary"
oDAWG = fsa.DAWG(spfSrc, cStemmingMethod, sLangCode, sLangName, sDicName, sDescription, sFilter)
os.makedirs("graphspell/_dictionaries", exist_ok=True)
oDAWG.writeAsJSObject("graphspell/_dictionaries/" + sfDict + ".json")
if bJavaScript:
os.makedirs("graphspell-js/_dictionaries", exist_ok=True)
oDAWG.writeAsJSObject("graphspell-js/_dictionaries/" + sfDict + ".json")
def main ():
"parse args from CLI"
xParser = argparse.ArgumentParser()
xParser.add_argument("src_lexicon", type=str, help="path and file name of the source lexicon")
|
| ︙ | ︙ |
Modified make.py from [a2a625b112] to [78c9ddad51].
| ︙ | ︙ | |||
281 282 283 284 285 286 287 |
return dVars['version']
def copyGraphspellCore (bJavaScript=False):
"copy Graphspell package in Grammalecte package"
print("> Copy Graphspell package in Grammalecte package")
helpers.createCleanFolder("grammalecte/graphspell")
| | | | 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 |
return dVars['version']
def copyGraphspellCore (bJavaScript=False):
"copy Graphspell package in Grammalecte package"
print("> Copy Graphspell package in Grammalecte package")
helpers.createCleanFolder("grammalecte/graphspell")
os.makedirs("grammalecte/graphspell/_dictionaries", exist_ok=True)
for sf in os.listdir("graphspell"):
if not os.path.isdir("graphspell/"+sf):
shutil.copy2("graphspell/"+sf, "grammalecte/graphspell")
if bJavaScript:
helpers.createCleanFolder("grammalecte-js/graphspell")
os.makedirs("grammalecte-js/graphspell/_dictionaries", exist_ok=True)
dVars = {}
for sf in os.listdir("js_extension"):
dVars[sf[:-3]] = open("js_extension/"+sf, "r", encoding="utf-8").read()
for sf in os.listdir("graphspell-js"):
if not os.path.isdir("graphspell-js/"+sf):
shutil.copy2("graphspell-js/"+sf, "grammalecte-js/graphspell")
helpers.copyAndFileTemplate("graphspell-js/"+sf, "grammalecte-js/graphspell/"+sf, dVars)
|
| ︙ | ︙ | |||
417 418 419 420 421 422 423 |
oNow = datetime.datetime.now()
print("============== MAKE GRAMMALECTE at {0.hour:>2} h {0.minute:>2} min {0.second:>2} s ==============".format(oNow))
if xArgs.build_data:
xArgs.build_data_before = True
xArgs.build_data_after = True
| | | | | 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 |
oNow = datetime.datetime.now()
print("============== MAKE GRAMMALECTE at {0.hour:>2} h {0.minute:>2} min {0.second:>2} s ==============".format(oNow))
if xArgs.build_data:
xArgs.build_data_before = True
xArgs.build_data_after = True
os.makedirs("_build", exist_ok=True)
os.makedirs("grammalecte", exist_ok=True)
if xArgs.javascript:
os.makedirs("grammalecte-js", exist_ok=True)
copyGraphspellCore(xArgs.javascript)
for sLang in xArgs.lang:
if os.path.exists("gc_lang/"+sLang) and os.path.isdir("gc_lang/"+sLang):
xConfig = getConfig(sLang)
dVars = xConfig._sections['args']
|
| ︙ | ︙ |