def importx10totexdir(texdir, backupdir, x10root, verbose=True): """ import the x10 code fragments requested by the .tex files in the directory tree whose root's absolute path is texdir. If the import is successful, the source file is updated and the original source is saved in the directory whose absolute path is backupdir. The saved original has a timestamp added to its file name for uniqueness. """ _warnings.clear() for srcdir, dirs, files in os.walk(texdir): if verbose: print("source directory: " + srcdir+" backup "+backupdir) if osutils.isdotfirst(srcdir): # skip "hidden" directories continue; for file in files: if file.endswith(".tex"): texin = join(srcdir, file) if verbose: print("\tProcessing " + texin) texout = texin+".cow" importx10totex(texin, texout, x10root, verbose) timestamp = osutils.timestamp()[2:-2] backup = os.path.join(backupdir, file[:-3] + timestamp + ".tex") rc = subprocess.call(["cp", texin, backup]) if rc == 0: rc = subprocess.call(["rm", texin]) if rc == 0: rc = subprocess.call(["mv", texout, texin]) if rc != 0: raise Exception("mv " + texout + " " + texin + " failed: rc = "+str(rc)) else: raise Exception("rm " + texit + " failed: rc =" + str(rc)) else: raise Exception("cp " + texin + " " + backup + " failed: rc=" + str(rc))
def doSeriousBackup(latexdir, latexbak): timestamp = osutils.timestamp() backupstamp = "backup." + timestamp backupdir = latexbak + "/" + backupstamp shutil.copytree(latexdir, backupdir)