+def package_available(package, args='', verbose=False):
+ """ check if a verion of a latex package accepting given args is available """
+ tempdir = mkdtemp('-wl2pdf-test')
+ fpath = os.path.join(tempdir, 'test.tex')
+ f = open(fpath, 'w')
+ f.write(r"""
+ \documentclass{book}
+ \usepackage[%s]{%s}
+ \begin{document}
+ \end{document}
+ """ % (args, package))
+ f.close()
+ if verbose:
+ p = call(['xelatex', '-output-directory', tempdir, fpath])
+ else:
+ p = call(['xelatex', '-interaction=batchmode', '-output-directory', tempdir, fpath], stdout=PIPE, stderr=PIPE)
+ shutil.rmtree(tempdir)
+ return p == 0
+
+
+def transform(provider, slug=None, file_path=None,
+ output_file=None, output_dir=None, make_dir=False, verbose=False, save_tex=None, morefloats=None):
+ """ produces a PDF file with XeLaTeX
+
+ provider: a DocProvider
+ slug: slug of file to process, available by provider
+ file_path can be provided instead of a slug
+ output_file: file-like object or path to output file
+ output_dir: path to directory to save output file to; either this or output_file must be present
+ make_dir: writes output to <output_dir>/<author>/<slug>.pdf istead of <output_dir>/<slug>.pdf
+ verbose: prints all output from LaTeX
+ save_tex: path to save the intermediary LaTeX file to
+ morefloats (old/new/none): force specific morefloats