Differences From Artifact [4468e2a847]:
- File helpers.py — part of check-in [3834076ae7] at 2017-08-31 06:06:31 on branch webext2 — [build] helpers: use shutil and os module only (user: olr, size: 2713) [annotate] [blame] [check-ins using] [more...]
To Artifact [b55cd82bf9]:
- File helpers.py — part of check-in [ab436f24fc] at 2017-12-24 17:50:05 on branch graphspell — [build] graphspell as separate package (user: olr, size: 2945) [annotate] [blame] [check-ins using] [more...]
1 2 3 4 5 6 7 8 9 10 11 | 1 2 3 4 5 6 7 8 9 10 11 12 | + | # Useful tools import os import shutil import errno import zipfile from string import Template class cd: "Context manager for changing the current working directory" |
︙ | |||
53 54 55 56 57 58 59 60 61 62 63 64 65 66 | 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | + + + + + + + + + + | 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: 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 def fileFile (spf, dVars): "return file <spf> as a text filed with variables from <dVars>" return Template(open(spf, "r", encoding="utf-8").read()).safe_substitute(dVars) def copyAndFileTemplate (spfSrc, spfDst, dVars): |
︙ |