From ceeb38a6676aa102eafc9676f00b223d95f8bdb2 Mon Sep 17 00:00:00 2001 From: gabe Date: Sat, 4 Sep 2021 12:58:10 -0500 Subject: [PATCH] added conversion function. Need to do speedtest to see whether this method is faster or slower than calling unix find. --- adocStaticSiteGen.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/adocStaticSiteGen.py b/adocStaticSiteGen.py index 863400b..ec550ce 100755 --- a/adocStaticSiteGen.py +++ b/adocStaticSiteGen.py @@ -80,9 +80,21 @@ def find_paths_to_convert(inputDir, pathList): pathList.append(Path(path.path)) return pathList +#simple wrapper around the asciidoctor cli. +def convert_file(inDir, outDir, inFile): + logging.debug(f'converting {inFile} from directory {inDir} to directory {outDir}') + try: + subprocess.run(['asciidoctor', f'--base-dir={inDir}', f'--source-dir={inDir}', f'--destination-dir={outDir}', inFile], check=True) + except Exception as e: + logging.error(f'could not convert {inFile}!') + logging.error(f'stdErr was {e.stderr}') + logging.error(f'stdOut was {e.stdout}') + inFile, outFile, compress = parse_arguments() os.chdir(inFile) tmpDir=TmpDir('./') +pathsToConvert=find_paths_to_convert('./', []) +for i in pathsToConvert: + convert_file('./', tmpDir.path, i) breakpoint() tmpDir.cleanup() -print(find_paths_to_convert('./', []))