Overview
Comment: | [build] code cleaning (pylint) |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk | build |
Files: | files | file ages | folders |
SHA3-256: |
f335e01188ba6bce7fa27ca09fa4643e |
User & Date: | olr on 2019-05-11 11:07:04 |
Other Links: | manifest | tags |
Context
2019-05-11
| ||
11:35 | [build] code cleaning (pylint) check-in: a7e04ce1e4 user: olr tags: trunk, build | |
11:07 | [build] code cleaning (pylint) check-in: f335e01188 user: olr tags: trunk, build | |
10:55 | [build] code cleaning (pylint) check-in: dad850cc6c user: olr tags: trunk, build | |
Changes
Modified gc_lang/fr/build.py from [1b0ecacee8] to [1571ea13d8].
︙ | ︙ | |||
20 21 22 23 24 25 26 | print("Building WebExtension") helpers.createCleanFolder("_build/webext/"+sLang) dir_util.copy_tree("gc_lang/"+sLang+"/webext/", "_build/webext/"+sLang) dir_util.copy_tree("grammalecte-js", "_build/webext/"+sLang+"/grammalecte") dVars['webextOptionsHTML'] = _createOptionsForWebExtension(dVars) helpers.copyAndFileTemplate("_build/webext/"+sLang+"/manifest.json", "_build/webext/"+sLang+"/manifest.json", dVars) helpers.copyAndFileTemplate("_build/webext/"+sLang+"/panel/main.html", "_build/webext/"+sLang+"/panel/main.html", dVars) | | | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | print("Building WebExtension") helpers.createCleanFolder("_build/webext/"+sLang) dir_util.copy_tree("gc_lang/"+sLang+"/webext/", "_build/webext/"+sLang) dir_util.copy_tree("grammalecte-js", "_build/webext/"+sLang+"/grammalecte") dVars['webextOptionsHTML'] = _createOptionsForWebExtension(dVars) helpers.copyAndFileTemplate("_build/webext/"+sLang+"/manifest.json", "_build/webext/"+sLang+"/manifest.json", dVars) helpers.copyAndFileTemplate("_build/webext/"+sLang+"/panel/main.html", "_build/webext/"+sLang+"/panel/main.html", dVars) with helpers.CD("_build/webext/"+sLang): os.system("web-ext build") def _createOptionsForWebExtension (dVars): sHTML = "" sLang = dVars['sDefaultUILang'] for sSection, lOpt in dVars['lStructOpt']: |
︙ | ︙ |
Modified helpers.py from [334a9e053b] to [4d4366fbed].
|
| > | > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | """ Tools for handling files """ import os import shutil import errno import zipfile from string import Template class CD: "Context manager for changing the current working directory" def __init__ (self, newPath): self.newPath = os.path.expanduser(newPath) self.savedPath = "" def __enter__ (self): self.savedPath = os.getcwd() |
︙ | ︙ | |||
57 58 59 60 61 62 63 64 65 66 67 68 69 70 | if not os.path.exists(sp): os.makedirs(sp, exist_ok=True) else: eraseFolder(sp) def copyFolderContent (spSrc, spDst): try: shutil.copytree(spSrc, spDst) except OSError as e: if e.errno == errno.ENOTDIR: shutil.copy(spSrc, spDst) else: raise | > | 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | if not os.path.exists(sp): os.makedirs(sp, exist_ok=True) else: eraseFolder(sp) def copyFolderContent (spSrc, spDst): "copy folder content from src to dst" try: shutil.copytree(spSrc, spDst) except OSError as e: if e.errno == errno.ENOTDIR: shutil.copy(spSrc, spDst) else: raise |
︙ | ︙ | |||
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | def copyAndFileTemplate (spfSrc, spfDst, dVars): "write file <spfSrc> as <spfDst> with variables filed with <dVars>" s = Template(open(spfSrc, "r", encoding="utf-8").read()).safe_substitute(dVars) open(spfDst, "w", encoding="utf-8", newline="\n").write(s) def addFolderToZipAndFileFile (hZip, spSrc, spDst, dVars, bRecursive): # recursive function spSrc = spSrc.strip("/ ") spDst = spDst.strip("/ ") for sf in os.listdir(spSrc): spfSrc = (spSrc + "/" + sf).strip("/ ") spfDst = (spDst + "/" + sf).strip("/ ") if os.path.isdir(spfSrc): if bRecursive: addFolderToZipAndFileFile(hZip, spfSrc, spfDst, dVars, bRecursive) else: if spfSrc.endswith((".py", ".js", ".css", ".xcu", ".xul", ".rdf", ".dtd", ".properties")): | > < < | 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | def copyAndFileTemplate (spfSrc, spfDst, dVars): "write file <spfSrc> as <spfDst> with variables filed with <dVars>" s = Template(open(spfSrc, "r", encoding="utf-8").read()).safe_substitute(dVars) open(spfDst, "w", encoding="utf-8", newline="\n").write(s) def addFolderToZipAndFileFile (hZip, spSrc, spDst, dVars, bRecursive): "add folder content to zip archive and file files with <dVars>" # recursive function spSrc = spSrc.strip("/ ") spDst = spDst.strip("/ ") for sf in os.listdir(spSrc): spfSrc = (spSrc + "/" + sf).strip("/ ") spfDst = (spDst + "/" + sf).strip("/ ") if os.path.isdir(spfSrc): if bRecursive: addFolderToZipAndFileFile(hZip, spfSrc, spfDst, dVars, bRecursive) else: if spfSrc.endswith((".py", ".js", ".css", ".xcu", ".xul", ".rdf", ".dtd", ".properties")): hZip.writestr(spfDst, fileFile(spfSrc, dVars)) else: hZip.write(spfSrc, spfDst) |
Modified make.py from [5247125cb0] to [59e4608258].
︙ | ︙ | |||
449 450 451 452 453 454 455 | unittest.TextTestRunner().run(xTestSuite) if xArgs.perf or xArgs.perf_memo: hDst = open("./gc_lang/"+sLang+"/perf_memo.txt", "a", encoding="utf-8", newline="\n") if xArgs.perf_memo else None tests.perf(sVersion, hDst) # Firefox (obsolete) #if False: | | | | 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 | unittest.TextTestRunner().run(xTestSuite) if xArgs.perf or xArgs.perf_memo: hDst = open("./gc_lang/"+sLang+"/perf_memo.txt", "a", encoding="utf-8", newline="\n") if xArgs.perf_memo else None tests.perf(sVersion, hDst) # Firefox (obsolete) #if False: # with helpers.CD("_build/xpi/"+sLang): # spfFirefox = dVars['win_fx_dev_path'] if platform.system() == "Windows" else dVars['linux_fx_dev_path'] # os.system('jpm run -b "' + spfFirefox + '"') if xArgs.web_ext or xArgs.firefox: with helpers.CD("_build/webext/"+sLang): if xArgs.lint_web_ext: os.system(r'web-ext lint -o text') if xArgs.firefox: # Firefox Developper edition spfFirefox = dVars['win_fx_dev_path'] if platform.system() == "Windows" else dVars['linux_fx_dev_path'] else: # Firefox Nightly edition |
︙ | ︙ |