def convert_rest_html(source, source_path, stylesheet=None, encoding='latin1'): from py.__.rest import directive """ return html latin1-encoded document for the given input. source a ReST-string sourcepath where to look for includes (basically) stylesheet path (to be used if any) """ from docutils.core import publish_string directive.set_backend_and_register_directives("html") kwargs = { 'stylesheet': stylesheet, 'stylesheet_path': None, 'traceback': 1, 'embed_stylesheet': 0, 'output_encoding': encoding, #'halt' : 0, # 'info', 'halt_level': 2, } # docutils uses os.getcwd() :-( source_path = os.path.abspath(str(source_path)) prevdir = os.getcwd() try: #os.chdir(os.path.dirname(source_path)) return publish_string(source, source_path, writer_name='html', settings_overrides=kwargs) finally: os.chdir(prevdir)
def convert_rest_html(source, source_path, stylesheet=None, encoding='latin1'): from py.__.rest import directive """ return html latin1-encoded document for the given input. source a ReST-string sourcepath where to look for includes (basically) stylesheet path (to be used if any) """ from docutils.core import publish_string directive.set_backend_and_register_directives("html") kwargs = { 'stylesheet' : stylesheet, 'stylesheet_path': None, 'traceback' : 1, 'embed_stylesheet': 0, 'output_encoding' : encoding, #'halt' : 0, # 'info', 'halt_level' : 2, } # docutils uses os.getcwd() :-( source_path = os.path.abspath(str(source_path)) prevdir = os.getcwd() try: #os.chdir(os.path.dirname(source_path)) return publish_string(source, source_path, writer_name='html', settings_overrides=kwargs) finally: os.chdir(prevdir)
def _graphviz_pdf(self): if not py.path.local.sysfind("dot") or not py.path.local.sysfind("latex"): py.test.skip("graphviz and latex needed") directive.set_backend_and_register_directives("latex") txt = py.path.local(datadir.join("graphviz.txt")) pdf = txt.new(ext="pdf") dotpdf = datadir.join("example1.pdf") process_rest_file(txt) assert pdf.check() assert dotpdf.check() pdf.remove() dotpdf.remove()
def _graphviz_pdf(self): for exe in 'dot latex epstopdf'.split(): if not py.path.local.sysfind(exe): py.test.skip("%r needed" %(exe,)) directive.set_backend_and_register_directives("latex") txt = py.path.local(datadir.join("graphviz.txt")) pdf = txt.new(ext="pdf") dotpdf = datadir.join("example1.pdf") process_rest_file(txt) assert pdf.check() assert dotpdf.check() pdf.remove() dotpdf.remove()
def _graphviz_pdf(self): for exe in 'dot latex epstopdf ps2eps'.split(): if not py.path.local.sysfind(exe): py.test.skip("%r needed" % (exe, )) directive.set_backend_and_register_directives("latex") txt = py.path.local(datadir.join("graphviz.txt")) pdf = txt.new(ext="pdf") dotpdf = datadir.join("example1.pdf") process_rest_file(txt) assert pdf.check() assert dotpdf.check() pdf.remove() dotpdf.remove()
def _graphviz_html(self): if not py.path.local.sysfind("dot"): py.test.skip("graphviz needed") directive.set_backend_and_register_directives("html") if not py.path.local.sysfind("svn"): py.test.skip("svn needed") txt = datadir.join("graphviz.txt") html = txt.new(ext="html") png = datadir.join("example1.png") rest.process(txt) assert html.check() assert png.check() html_content = html.read() assert png.basename in html_content html.remove() png.remove()
from py.__.misc import rest from py.__.rest import directive from py.__.rest.latex import process_rest_file, process_configfile except ImportError, e: print str(e) sys.exit(1) (options, args) = parser.parse_args() if len(args) == 0: filenames = [py.path.svnwc()] else: filenames = [py.path.svnwc(x) for x in args] if options.topdf: directive.set_backend_and_register_directives("latex") for p in filenames: if not p.check(): log("path %s not found, ignoring" % p) continue def fil(p): return p.check(fnmatch='*.txt', versioned=True) def rec(p): return p.check(dotfile=0) if p.check(dir=1): for x in p.visit(fil, rec): rest.process(x) elif p.check(file=1): if p.ext == ".rst2pdfconfig": directive.set_backend_and_register_directives("latex")
from py.__.misc import rest from py.__.rest import directive from py.__.rest.latex import process_rest_file, process_configfile except ImportError, e: print str(e) sys.exit(1) (options, args) = parser.parse_args() if len(args) == 0: filenames = [py.path.svnwc()] else: filenames = [py.path.svnwc(x) for x in args] if options.topdf: directive.set_backend_and_register_directives("latex") for p in filenames: if not p.check(): log("path %s not found, ignoring" % p) continue def fil(p): return p.check(fnmatch='*.txt', versioned=True) def rec(p): return p.check(dotfile=0) if p.check(dir=1): for x in p.visit(fil, rec): rest.process(x)