From 6e3c50892f6d299baf253f675e14816c15b359e2 Mon Sep 17 00:00:00 2001 From: kennyballou Date: Tue, 12 Mar 2013 18:41:54 -0600 Subject: Add clean method to tex module --- docs/source/buildreference.rst | 7 +++++++ xnt/build/tex.py | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/docs/source/buildreference.rst b/docs/source/buildreference.rst index eae9601..2cabe1f 100644 --- a/docs/source/buildreference.rst +++ b/docs/source/buildreference.rst @@ -127,3 +127,10 @@ pdflatex Where *document* is the master tex file of the document and *path* is the full or relative path to exectue `pdflatex` in. + +.. _xnt.build.tex.clean: +.. function:: clean(path="./", remove_pdf=False) + + Clean up generated output files of `pdflatex` and similar. Currently, the + function removes `out`, `log`, `aux`, `toc`, `tol`, `tof`, `tot`, `bbl`, + and `blg`. Conditionally, it will remove the generated `pdf` as well. diff --git a/xnt/build/tex.py b/xnt/build/tex.py index 1cd20e3..6249edf 100644 --- a/xnt/build/tex.py +++ b/xnt/build/tex.py @@ -56,3 +56,20 @@ def pdflatex(document, error_codes.append(pdf(draftmode=False)) os.chdir(cwd) return sum(error_codes) + +def clean(path="./", remove_pdf=False): + """Clean up generated files of PDF compiliation""" + cwd = os.getcwd() + os.chdir(path) + xnt.tasks.rm("*.out", + "*.log", + "*.aux", + "*.toc", + "*.tol", + "*.tof", + "*.tot", + "*.bbl", + "*.blg") + if remove_pdf: + xnt.tasks.rm("*.pdf") + os.chdir(cwd) -- cgit v1.2.1