Index: gc_lang/fr/build.py ================================================================== --- gc_lang/fr/build.py +++ gc_lang/fr/build.py @@ -22,11 +22,11 @@ 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): + with helpers.CD("_build/webext/"+sLang): os.system("web-ext build") def _createOptionsForWebExtension (dVars): sHTML = "" Index: helpers.py ================================================================== --- helpers.py +++ helpers.py @@ -1,16 +1,18 @@ -# Useful tools +""" +Tools for handling files +""" import os import shutil import errno import zipfile from string import Template -class cd: +class CD: "Context manager for changing the current working directory" def __init__ (self, newPath): self.newPath = os.path.expanduser(newPath) self.savedPath = "" @@ -59,10 +61,11 @@ 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) @@ -80,10 +83,11 @@ 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 " # recursive function spSrc = spSrc.strip("/ ") spDst = spDst.strip("/ ") for sf in os.listdir(spSrc): spfSrc = (spSrc + "/" + sf).strip("/ ") @@ -91,10 +95,8 @@ 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")): - #print(spfSrc + " > " + spfDst) hZip.writestr(spfDst, fileFile(spfSrc, dVars)) else: - #print(spfSrc + " > " + spfDst) hZip.write(spfSrc, spfDst) Index: make.py ================================================================== --- make.py +++ make.py @@ -451,16 +451,16 @@ 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): + # 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): + 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']