From jan at codespeak.net Sun Jan 1 14:38:32 2006 From: jan at codespeak.net (jan at codespeak.net) Date: Sun, 1 Jan 2006 14:38:32 +0100 (CET) Subject: [py-svn] r21618 - in py/branch/setup/py: bin documentation magic misc path/local rest rest/testing rest/testing/data test test/terminal Message-ID: <20060101133832.24CC427DB5@code1.codespeak.net> Author: jan Date: Sun Jan 1 14:38:16 2006 New Revision: 21618 Added: py/branch/setup/py/rest/directive.py - copied unchanged from r21617, py/dist/py/rest/directive.py py/branch/setup/py/rest/rst.py - copied unchanged from r21617, py/dist/py/rest/rst.py py/branch/setup/py/rest/testing/data/formula.txt - copied unchanged from r21617, py/dist/py/rest/testing/data/formula.txt py/branch/setup/py/rest/testing/data/formula1.txt - copied unchanged from r21617, py/dist/py/rest/testing/data/formula1.txt py/branch/setup/py/rest/testing/data/tocdepth.rst2pdfconfig - copied unchanged from r21617, py/dist/py/rest/testing/data/tocdepth.rst2pdfconfig py/branch/setup/py/rest/testing/test_directive.py - copied unchanged from r21617, py/dist/py/rest/testing/test_directive.py py/branch/setup/py/rest/testing/test_htmlrest.py - copied unchanged from r21617, py/dist/py/rest/testing/test_htmlrest.py py/branch/setup/py/rest/testing/test_rst.py - copied unchanged from r21617, py/dist/py/rest/testing/test_rst.py Removed: py/branch/setup/py/rest/restgraphviz.py py/branch/setup/py/rest/testing/test_restgraphviz.py Modified: py/branch/setup/py/bin/py.rest py/branch/setup/py/bin/rst2pdf.py py/branch/setup/py/documentation/conftest.py py/branch/setup/py/documentation/test_conftest.py py/branch/setup/py/magic/assertion.py py/branch/setup/py/misc/rest.py py/branch/setup/py/path/local/local.py py/branch/setup/py/rest/convert.py py/branch/setup/py/rest/latex.py py/branch/setup/py/rest/rest.sty.template py/branch/setup/py/rest/testing/data/example.rst2pdfconfig py/branch/setup/py/rest/testing/data/part1.txt py/branch/setup/py/rest/testing/data/part2.txt py/branch/setup/py/rest/testing/test_convert.py py/branch/setup/py/rest/testing/test_rst2pdf.py py/branch/setup/py/test/defaultconftest.py py/branch/setup/py/test/terminal/terminal.py Log: Merged dist changes r20355:21617 into the setup branch. Modified: py/branch/setup/py/bin/py.rest ============================================================================== --- py/branch/setup/py/bin/py.rest (original) +++ py/branch/setup/py/bin/py.rest Sun Jan 1 14:38:16 2006 @@ -14,10 +14,17 @@ from _findpy import py from py.__.misc import rest + +if hasattr(sys.stdout, 'fileno') and os.isatty(sys.stdout.fileno()): + def log(msg): + print msg +else: + def log(msg): + pass + + if __name__=='__main__': - from py.__.rest import restgraphviz basedir = os.path.dirname(os.path.dirname(os.path.abspath(sys.argv[0]))) - graphvizdirective = restgraphviz.GraphvizDirective("png") sys.path.insert(0, basedir) if len(sys.argv) == 1: @@ -34,9 +41,7 @@ def rec(p): return p.check(dotfile=0) if p.check(dir=1): - graphvizdirective.path = p for x in p.visit(fil, rec): rest.process(x) elif p.check(file=1): - graphvizdirective.path = p.dirpath() rest.process(p) Modified: py/branch/setup/py/bin/rst2pdf.py ============================================================================== --- py/branch/setup/py/bin/rst2pdf.py (original) +++ py/branch/setup/py/bin/rst2pdf.py Sun Jan 1 14:38:16 2006 @@ -12,7 +12,7 @@ from _findpy import py -from py.__.rest import restgraphviz +from py.__.rest import directive from py.__.rest.latex import process_rest_file, process_configfile optparse = py.compat.optparse @@ -20,23 +20,22 @@ parser = optparse.OptionParser(usage=docstring) parser.add_option("-c", "--config", dest="configfile", help="use config file") -parser.add_option("--stylesheet", dest="stylesheet", default="rest.sty", +parser.add_option("--stylesheet", dest="stylesheet", default=None, help="use style sheet") parser.add_option("--debug", action="store_true", dest="debug", default=False, help="print debug output and don't delete files") if __name__ == '__main__': - graphvizdirective = restgraphviz.GraphvizDirective("pdf") + directive.BackendStore("latex") (options, args) = parser.parse_args() if options.configfile is not None: configfile = py.path.local(options.configfile) - graphvizdirective.path = configfile.dirpath() process_configfile(options.configfile, options.debug) elif len(args) != 1: parser.error("please supply a file name") else: f = py.path.local(args[0]) - graphvizdirective.path = f.dirpath() - process_rest_file(args[0], options.debug) + process_rest_file(args[0], options.stylesheet, options.debug) + Modified: py/branch/setup/py/documentation/conftest.py ============================================================================== --- py/branch/setup/py/documentation/conftest.py (original) +++ py/branch/setup/py/documentation/conftest.py Sun Jan 1 14:38:16 2006 @@ -127,6 +127,8 @@ if tryfn.startswith('http:') or tryfn.startswith('https'): if option.checkremote: yield urlcheck, tryfn, path, lineno + elif tryfn.startswith('webcal:'): + continue else: i = tryfn.find('#') if i != -1: Modified: py/branch/setup/py/documentation/test_conftest.py ============================================================================== --- py/branch/setup/py/documentation/test_conftest.py (original) +++ py/branch/setup/py/documentation/test_conftest.py Sun Jan 1 14:38:16 2006 @@ -34,4 +34,5 @@ l = session.getitemoutcomepairs(py.test.Item.Failed) assert len(l) == 0 l = session.getitemoutcomepairs(py.test.Item.Passed) - assert len(l) == 2 + l2 = session.getitemoutcomepairs(py.test.Item.Skipped) + assert len(l+l2) == 2 Modified: py/branch/setup/py/magic/assertion.py ============================================================================== --- py/branch/setup/py/magic/assertion.py (original) +++ py/branch/setup/py/magic/assertion.py Sun Jan 1 14:38:16 2006 @@ -13,7 +13,7 @@ f = sys._getframe(1) try: source = py.code.Frame(f).statement - source = str(source).strip() + source = str(source.deindent()).strip() except py.error.ENOENT: source = None # this can also occur during reinterpretation, when the Modified: py/branch/setup/py/misc/rest.py ============================================================================== --- py/branch/setup/py/misc/rest.py (original) +++ py/branch/setup/py/misc/rest.py Sun Jan 1 14:38:16 2006 @@ -1,4 +1,4 @@ - +import py import sys, os, traceback import re @@ -10,12 +10,14 @@ pass 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.BackendStore("html") kwargs = { 'stylesheet' : stylesheet, 'stylesheet_path': None, @@ -38,7 +40,9 @@ """ process a textfile """ log("processing %s" % txtpath) assert txtpath.check(ext='.txt') - htmlpath = txtpath.localpath.new(ext='.html') + if isinstance(txtpath, py.path.svnwc): + txtpath = txtpath.localpath + htmlpath = txtpath.new(ext='.html') #svninfopath = txtpath.localpath.new(ext='.svninfo') style = txtpath.dirpath('style.css') Modified: py/branch/setup/py/path/local/local.py ============================================================================== --- py/branch/setup/py/path/local/local.py (original) +++ py/branch/setup/py/path/local/local.py Sun Jan 1 14:38:16 2006 @@ -372,7 +372,8 @@ if ensuresyspath: self._prependsyspath(pkgpath.dirpath()) pkg = __import__(pkgpath.basename, None, None, []) - assert py.path.local(pkg.__file__).relto(pkgpath) + assert py.path.local(pkg.__file__).realpath().relto( + pkgpath.realpath()) if hasattr(pkg, '__package__'): modname = pkg.__package__.getimportname(self) assert modname is not None, "package %s doesn't know %s" % ( Modified: py/branch/setup/py/rest/convert.py ============================================================================== --- py/branch/setup/py/rest/convert.py (original) +++ py/branch/setup/py/rest/convert.py Sun Jan 1 14:38:16 2006 @@ -1,5 +1,6 @@ import py +from py.__.process.cmdexec import ExecutionFailed # utility functions to convert between various formats format_to_dotargument = {"png": "png", @@ -13,10 +14,10 @@ try: eps = ps.new(ext=".eps") py.process.cmdexec("ps2epsi %s %s" % (ps, eps)) - except py.process.ExecutionFailed: + except ExecutionFailed: try: py.process.cmdexec("ps2eps -l -f %s" % ps) - except py.process.ExecutionFailed: + except ExecutionFailed: raise OSError("neither ps2eps nor ps2epsi found") def ps2pdf(ps, compat_level="1.2"): @@ -33,6 +34,12 @@ # XXX write a pure python version py.process.cmdexec("epstopdf %s" % eps) +def dvi2eps(dvi, dest=None): + if dest is None: + dest = eps.new(ext=".eps") + command = 'dvips -q -E -n 1 -D 600 -p 1 -o %s %s' % (dest, dvi) + py.process.cmdexec(command) + def convert_dot(fn, new_extension): result = fn.new(ext=new_extension) print result @@ -54,3 +61,93 @@ eps.remove() return result + +class latexformula2png(object): + def __init__(self, formula, dest, temp=None): + self.formula = formula + try: + import Image + self.Image = Image + self.scale = 2 # create a larger image + self.upscale = 5 # create the image upscale times larger, then scale it down + except ImportError: + self.scale = 2 + self.upscale = 1 + self.Image = None + self.output_format = ('pngmono', 'pnggray', 'pngalpha')[2] + if temp is None: + temp = py.test.ensuretemp("latexformula") + self.temp = temp + self.latex = self.temp.join('formula.tex') + self.dvi = self.temp.join('formula.dvi') + self.eps = self.temp.join('formula.eps') + self.png = self.temp.join('formula.png') + self.saveas(dest) + + def saveas(self, dest): + self.gen_latex() + self.gen_dvi() + dvi2eps(self.dvi, self.eps) + self.gen_png() + self.scale_image() + self.png.copy(dest) + + def gen_latex(self): + self.latex.write (""" + \\documentclass{article} + \\pagestyle{empty} + \\begin{document} + + %s + \\pagebreak + + \\end{document} + """ % (self.formula)) + + def gen_dvi(self): + origdir = py.path.local() + self.temp.chdir() + py.process.cmdexec('latex %s' % (self.latex)) + origdir.chdir() + + def gen_png(self): + tempdir = py.path.local.mkdtemp() + + re_bbox = py.std.re.compile('%%BoundingBox:\s*(\d+) (\d+) (\d+) (\d+)') + eps = self.eps.read() + x1, y1, x2, y2 = [int(i) for i in re_bbox.search(eps).groups()] + X = x2 - x1 + 2 + Y = y2 - y1 + 2 + mx = -x1 + my = -y1 + ps = self.temp.join('temp.ps') + source = self.eps + ps.write(""" + 1 1 1 setrgbcolor + newpath + -1 -1 moveto + %(X)d -1 lineto + %(X)d %(Y)d lineto + -1 %(Y)d lineto + closepath + fill + %(mx)d %(my)d translate + 0 0 0 setrgbcolor + (%(source)s) run + + """ % locals()) + + sx = int((x2 - x1) * self.scale * self.upscale) + sy = int((y2 - y1) * self.scale * self.upscale) + res = 72 * self.scale * self.upscale + command = 'gs -q -g%dx%d -r%dx%d -sDEVICE=%s -sOutputFile=%s -dNOPAUSE -dBATCH %s' % (sx, sy, res, res, self.output_format, self.png, ps) + py.process.cmdexec(command) + + def scale_image(self): + if self.Image is None: + return + image = self.Image.open(str(self.png)) + image.resize((image.size[0] / self.upscale, + image.size[1] / self.upscale), + self.Image.ANTIALIAS).save(str(self.png)) + Modified: py/branch/setup/py/rest/latex.py ============================================================================== --- py/branch/setup/py/rest/latex.py (original) +++ py/branch/setup/py/rest/latex.py Sun Jan 1 14:38:16 2006 @@ -12,7 +12,6 @@ def merge_files(pathlist, pagebreak=False): - pathlist = [py.path.local(path) for path in pathlist] if len(pathlist) == 1: return pathlist[0].read() sectnum = False @@ -63,6 +62,12 @@ fill_in["specified_font"] = "%" fill_in["sans_serif"] = "%" fill_in["font_package"] = "" + if 'toc_depth' in options: + fill_in["have_tocdepth"] = "" + fill_in["toc_depth"] = options["toc_depth"] + else: + fill_in["have_tocdepth"] = "%" + fill_in["toc_depth"] = "" fill_in["heading"] = options.get("heading", "") template_file = path.join("rest.sty.template") if not template_file.check(): @@ -78,20 +83,29 @@ py.std.sys.path.insert(0, path) execfile(str(configfile), configfile_dic) pagebreak = configfile_dic.get("pagebreak", False) - content = merge_files(configfile_dic['rest_sources'], pagebreak) + rest_sources = [py.path.local(p) + for p in configfile_dic['rest_sources']] rest = configfile.new(ext='txt') - rest.write(content) + if len(rest_sources) > 1: + assert rest not in rest_sources + content = merge_files(rest_sources, pagebreak) + if len(rest_sources) > 1: + rest.write(content) sty = configfile.new(ext='sty') content = create_stylesheet(configfile_dic, path) sty.write(content) - process_rest_file(rest, sty.basename, debug) + rest_options = None + if 'rest_options' in configfile_dic: + rest_options = configfile_dic['rest_options'] + process_rest_file(rest, sty.basename, debug, rest_options) #cleanup: if not debug: sty.remove() - rest.remove() + if rest not in rest_sources: + rest.remove() old.chdir() -def process_rest_file(restfile, stylesheet=None, debug=False): +def process_rest_file(restfile, stylesheet=None, debug=False, rest_options=None): old = py.path.local() f = py.path.local(restfile) path = f.dirpath() @@ -100,20 +114,25 @@ if pdf.check(): pdf.remove() tex = f.new(ext="tex").basename - options = [f, "--graphicx-option=auto", "--traceback"] + options = [f, "--input-encoding=latin-1", "--graphicx-option=auto", "--traceback"] if stylesheet is not None: sty = path.join(stylesheet) if sty.check(): options.append("--stylesheet=%s" % (sty, )) options.append(f.new(basename=tex)) options = map(str, options) + if rest_options is not None: + options.extend(rest_options) publish_cmdline(writer_name='latex', argv=options) - for i in range(2): - #XXX sometimes pdflatex has to be run several time - #find a cleaner way to do it + i = 0 + while i < 10: # there should never be as many as five reruns, but to be sure latexoutput = py.process.cmdexec("pdflatex %s" % (tex, )) if debug: print latexoutput + if py.std.re.search("LaTeX Warning:.*Rerun", latexoutput) is None: + break + i += 1 + old.chdir() #cleanup: if not debug: Modified: py/branch/setup/py/rest/rest.sty.template ============================================================================== --- py/branch/setup/py/rest/rest.sty.template (original) +++ py/branch/setup/py/rest/rest.sty.template Sun Jan 1 14:38:16 2006 @@ -2,7 +2,8 @@ \usepackage{lastpage} \pagestyle{fancy} \usepackage[pdftex]{graphicx} -\usepackage{epstopdf} + +%(have_tocdepth)s\setcounter{tocdepth}{%(toc_depth)s} %(sans_serif)s\renewcommand{\familydefault}{\sfdefault} %(specified_font)s\usepackage{%(font_package)s} Deleted: /py/branch/setup/py/rest/restgraphviz.py ============================================================================== --- /py/branch/setup/py/rest/restgraphviz.py Sun Jan 1 14:38:16 2006 +++ (empty file) @@ -1,40 +0,0 @@ -import py - -from py.__.rest.convert import convert_dot - -import sys -from docutils import nodes, utils -from docutils.parsers.rst import directives, states -from docutils.parsers.rst.directives import images -from docutils.nodes import whitespace_normalize_name - -class GraphvizDirective(object): - #XXX this whole class should not be there: - #XXX it is only used to work around the inflexibility of docutils: - # a directive does not know the path of the file it looks at, nor the - # format - def __init__(self, convert_to_format, path=py.path.local()): - self.convert_to_format = convert_to_format - self.path = path - directives.register_directive("graphviz", self.directive_function) - - def convert(self, fn): - dot = self.path.join(fn) - result = convert_dot(dot, self.convert_to_format) - return result.relto(self.path) - - def directive_function(self, name, arguments, options, content, lineno, - content_offset, block_text, state, state_machine): - newname = self.convert(arguments[0]) - text = block_text.replace("graphviz", "image", 1) - text = text.replace(arguments[0], newname, 1) - return images.image(u'image', [newname], options, content, lineno, - content_offset, text, state, state_machine) - directive_function.arguments = (1, 0, 1) - directive_function.options = {'alt': directives.unchanged, - 'height': directives.nonnegative_int, - 'width': directives.nonnegative_int, - 'scale': directives.nonnegative_int, - 'align': images.align, - 'target': directives.unchanged_required, - 'class': directives.class_option} Modified: py/branch/setup/py/rest/testing/data/example.rst2pdfconfig ============================================================================== --- py/branch/setup/py/rest/testing/data/example.rst2pdfconfig (original) +++ py/branch/setup/py/rest/testing/data/example.rst2pdfconfig Sun Jan 1 14:38:16 2006 @@ -1,2 +1,3 @@ rest_sources = ['part1.txt', 'part2.txt'] +rest_options = ["--use-latex-toc", "--generator"] # generator is easy to test Modified: py/branch/setup/py/rest/testing/data/part1.txt ============================================================================== --- py/branch/setup/py/rest/testing/data/part1.txt (original) +++ py/branch/setup/py/rest/testing/data/part1.txt Sun Jan 1 14:38:16 2006 @@ -1,7 +1,19 @@ +.. contents:: + This is the first part of the example rest file =============================================== -.. sectnum:: -some content. some more. the end. +some content. + +fancy subsection heading +------------------------- + +some more content. + +really stupid document +------------------------ + +we are all thankful that it ends now. + Modified: py/branch/setup/py/rest/testing/data/part2.txt ============================================================================== --- py/branch/setup/py/rest/testing/data/part2.txt (original) +++ py/branch/setup/py/rest/testing/data/part2.txt Sun Jan 1 14:38:16 2006 @@ -1,7 +1,7 @@ This is the second part of the test file ========================================= -.. sectnum:: +.. contents:: the text in it is not much more interesting. Modified: py/branch/setup/py/rest/testing/test_convert.py ============================================================================== --- py/branch/setup/py/rest/testing/test_convert.py (original) +++ py/branch/setup/py/rest/testing/test_convert.py Sun Jan 1 14:38:16 2006 @@ -1,5 +1,5 @@ import py -from py.__.rest.convert import convert_dot +from py.__.rest.convert import convert_dot, latexformula2png def is_on_path(name): try: @@ -12,8 +12,8 @@ datadir = py.magic.autopath().dirpath().join("data") def setup_module(mod): - if not is_on_path("gs") or not is_on_path("dot"): - py.test.skip("ghostscript and graphviz needed") + if not is_on_path("gs") or not is_on_path("dot") or not is_on_path("latex"): + py.test.skip("ghostscript, graphviz and latex needed") def test_convert_dot(): # XXX not really clear that the result is valid pdf/eps @@ -27,3 +27,10 @@ assert eps.check() eps.remove() +def test_latexformula(): + png = datadir.join("test.png") + formula = r'$$Entropy(T) = - \sum^{m}_{j=1} \frac{|T_j|}{|T|} \log \frac{|T_j|}{|T|}$$' + #does not crash + latexformula2png(formula, png) + assert png.check() + png.remove() Deleted: /py/branch/setup/py/rest/testing/test_restgraphviz.py ============================================================================== --- /py/branch/setup/py/rest/testing/test_restgraphviz.py Sun Jan 1 14:38:16 2006 +++ (empty file) @@ -1,32 +0,0 @@ -import py -from py.__.rest import restgraphviz -from py.__.misc import rest -from py.__.rest.latex import process_rest_file - -datadir = py.magic.autopath().dirpath().join("data") - -def test_graphviz_html(): - graphvizdirective = restgraphviz.GraphvizDirective("png", datadir) - #for reasons that elude me rest.process expects svnwcs??? - txt = py.path.svnwc(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() - -def test_graphviz_pdf(): - graphvizdirective = restgraphviz.GraphvizDirective("pdf", datadir) - 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() - Modified: py/branch/setup/py/rest/testing/test_rst2pdf.py ============================================================================== --- py/branch/setup/py/rest/testing/test_rst2pdf.py (original) +++ py/branch/setup/py/rest/testing/test_rst2pdf.py Sun Jan 1 14:38:16 2006 @@ -13,6 +13,23 @@ def test_process_configfile(): config = data.join("example.rst2pdfconfig") pdf = config.new(ext="pdf") - process_configfile(config) + tex = data.join('example.tex') + process_configfile(config, debug=True) assert pdf.check() + assert tex.check() + texcontent = tex.read() + assert "Generated by" in texcontent + assert "Docutils" in texcontent + process_configfile(config, debug=False) + assert pdf.check() + assert not tex.check() pdf.remove() + +def test_process_all(): + # fallback test: only checks that no exception is raised + def rec(p): + return p.check(dotfile=0) + for x in data.visit("*.txt", rec=rec): + yield process_rest_file, x + for x in data.visit("*.rst2pdfconfig", rec=rec): + yield process_configfile, x Modified: py/branch/setup/py/test/defaultconftest.py ============================================================================== --- py/branch/setup/py/test/defaultconftest.py (original) +++ py/branch/setup/py/test/defaultconftest.py Sun Jan 1 14:38:16 2006 @@ -30,6 +30,10 @@ Option('', '--pdb', action="store_true", dest="usepdb", default=False, help="start pdb (the Python debugger) on errors."), + Option('', '--tb', + action="store", dest="tbstyle", default='long', + type="choice", choices=['long', 'short', 'no'], + help="traceback verboseness (long/short/no)"), Option('', '--fulltrace', action="store_true", dest="fulltrace", default=False, help="don't cut any tracebacks (default is to cut)"), Modified: py/branch/setup/py/test/terminal/terminal.py ============================================================================== --- py/branch/setup/py/test/terminal/terminal.py (original) +++ py/branch/setup/py/test/terminal/terminal.py Sun Jan 1 14:38:16 2006 @@ -243,6 +243,8 @@ self.out.line() def failures(self): + if self.config.option.tbstyle == 'no': + return # skip the detailed failure reports altogether l = self.getitemoutcomepairs(Item.Failed) if l: self.out.sep('_') @@ -264,12 +266,16 @@ if not traceback: self.out.line("empty traceback from item %r" % (item,)) return - last = traceback[-1] - first = traceback[0] + handler = getattr(self, 'repr_failure_tb%s' % self.config.option.tbstyle) + handler(item, excinfo, traceback) + + def repr_failure_tblong(self, item, excinfo, traceback): if not self.config.option.nomagic and excinfo.errisinstance(RuntimeError): recursionindex = traceback.recursionindex() else: recursionindex = None + last = traceback[-1] + first = traceback[0] for index, entry in py.builtin.enumerate(traceback): if entry == first: if item: @@ -300,6 +306,45 @@ self.out.sep("!") break + def repr_failure_tbshort(self, item, excinfo, traceback): + # print a Python-style short traceback + if not self.config.option.nomagic and excinfo.errisinstance(RuntimeError): + recursionindex = traceback.recursionindex() + else: + recursionindex = None + last = traceback[-1] + first = traceback[0] + self.out.line() + for index, entry in py.builtin.enumerate(traceback): + code = entry.frame.code + self.out.line(' File "%s", line %d, in %s' % ( + code.raw.co_filename, entry.lineno+1, code.raw.co_name)) + fullsource = entry.frame.code.fullsource + try: + source = [fullsource[entry.lineno].lstrip()] + except IndexError: + source = [] + if entry == last: + if source: + self.repr_source(source, 'E') + self.repr_failure_explanation(excinfo, source) + else: + if source: + self.repr_source(source, ' ') + self.repr_locals(entry) + + # trailing info + if entry == last: + #if item: + # self.repr_failure_info(item, entry) + self.repr_out_err(item) + self.out.sep("_") + else: + if index == recursionindex: + self.out.line("Recursion detected (same locals & position)") + self.out.sep("!") + break + def repr_failure_info(self, item, entry): root = item.fspath modpath = item.getmodpath() From jan at codespeak.net Mon Jan 9 13:10:20 2006 From: jan at codespeak.net (jan at codespeak.net) Date: Mon, 9 Jan 2006 13:10:20 +0100 (CET) Subject: [py-svn] r21831 - py/dist/py/rest Message-ID: <20060109121020.E1FAA27B68@code1.codespeak.net> Author: jan Date: Mon Jan 9 13:10:19 2006 New Revision: 21831 Modified: py/dist/py/rest/rst.py Log: added hypertarget and hyperref Modified: py/dist/py/rest/rst.py ============================================================================== --- py/dist/py/rest/rst.py (original) +++ py/dist/py/rest/rst.py Mon Jan 9 13:10:19 2006 @@ -187,6 +187,11 @@ __tagclass__ = RestTag __stickname__ = True + class hyperref(RestTag): + start_string = '`' + end_string = '`_' + write_literal = True + class emph(RestTag): start_string = '*' end_string = start_string @@ -219,6 +224,12 @@ def write_children(self, out, child_outs): out.extend(child_outs, join = ' ' * len(self.start_string)) + class hypertarget(RestTag): + sep = '\n\n' + start_string = '.. _' + end_string = ':' + write_literal = True + class title(RestTag): sep = '\n' start_string = '#' From jan at codespeak.net Mon Jan 9 13:58:49 2006 From: jan at codespeak.net (jan at codespeak.net) Date: Mon, 9 Jan 2006 13:58:49 +0100 (CET) Subject: [py-svn] r21833 - py/branch/setup Message-ID: <20060109125849.7BC2F27B55@code1.codespeak.net> Author: jan Date: Mon Jan 9 13:58:48 2006 New Revision: 21833 Modified: py/branch/setup/setup.py Log: experimental: py-lib requires docutils >=0.3.8 Modified: py/branch/setup/setup.py ============================================================================== --- py/branch/setup/setup.py (original) +++ py/branch/setup/setup.py Mon Jan 9 13:58:48 2006 @@ -14,6 +14,7 @@ author_email="hpk at merlinux.de", license="MIT license", download_url="http://codespeak.net/download/py/py-0.8.0-alpha2.tar.gz", + install_requires= ["docutils >= 0.3.8"], packages=find_packages(), package_data=find_package_data(), scripts=['py/bin/_findpy.py', From hpk at codespeak.net Tue Jan 10 16:00:10 2006 From: hpk at codespeak.net (hpk at codespeak.net) Date: Tue, 10 Jan 2006 16:00:10 +0100 (CET) Subject: [py-svn] r21886 - py/dist/py/misc Message-ID: <20060110150010.EF2CA27B58@code1.codespeak.net> Author: hpk Date: Tue Jan 10 16:00:09 2006 New Revision: 21886 Modified: py/dist/py/misc/rest.py Log: new docutils defaults to embedding stylesheets into the generated html - without even checking if it is a filename or URL ... Modified: py/dist/py/misc/rest.py ============================================================================== --- py/dist/py/misc/rest.py (original) +++ py/dist/py/misc/rest.py Tue Jan 10 16:00:09 2006 @@ -22,6 +22,7 @@ 'stylesheet' : stylesheet, 'stylesheet_path': None, 'traceback' : 1, + 'embed_stylesheet': 0, 'output_encoding' : encoding, #'halt' : 0, # 'info', 'halt_level' : 2, From jan at codespeak.net Mon Jan 16 16:27:02 2006 From: jan at codespeak.net (jan at codespeak.net) Date: Mon, 16 Jan 2006 16:27:02 +0100 (CET) Subject: [py-svn] r22225 - py/branch/setup Message-ID: <20060116152702.8710327B5E@code1.codespeak.net> Author: jan Date: Mon Jan 16 16:27:01 2006 New Revision: 22225 Modified: py/branch/setup/setup.py Log: remove dependency on docutils in setup.py Modified: py/branch/setup/setup.py ============================================================================== --- py/branch/setup/setup.py (original) +++ py/branch/setup/setup.py Mon Jan 16 16:27:01 2006 @@ -14,7 +14,7 @@ author_email="hpk at merlinux.de", license="MIT license", download_url="http://codespeak.net/download/py/py-0.8.0-alpha2.tar.gz", - install_requires= ["docutils >= 0.3.8"], + #install_requires= ["docutils >= 0.3.8"], packages=find_packages(), package_data=find_package_data(), scripts=['py/bin/_findpy.py', From arigo at codespeak.net Tue Jan 24 13:34:21 2006 From: arigo at codespeak.net (arigo at codespeak.net) Date: Tue, 24 Jan 2006 13:34:21 +0100 (CET) Subject: [py-svn] r22586 - in py/dist/py/path: local svn Message-ID: <20060124123421.D8A8527DB5@code1.codespeak.net> Author: arigo Date: Tue Jan 24 13:34:19 2006 New Revision: 22586 Modified: py/dist/py/path/local/local.py py/dist/py/path/svn/wccommand.py Log: Added a "mode='wb'" argument to the write() methods of paths. Modified: py/dist/py/path/local/local.py ============================================================================== --- py/dist/py/path/local/local.py (original) +++ py/dist/py/path/local/local.py Tue Jan 24 13:34:19 2006 @@ -253,10 +253,10 @@ self._callex(os.mkdir, str(p)) return p - def write(self, content): + def write(self, content, mode='wb'): """ write string content into path. """ s = str(content) - f = self.open('wb') + f = self.open(mode) try: f.write(s) finally: Modified: py/dist/py/path/svn/wccommand.py ============================================================================== --- py/dist/py/path/svn/wccommand.py (original) +++ py/dist/py/path/svn/wccommand.py Tue Jan 24 13:34:19 2006 @@ -102,9 +102,9 @@ """ update working copy item to given revision. (None -> HEAD). """ self._svn('up -r %s' % rev) - def write(self, content): + def write(self, content, mode='wb'): """ write content into local filesystem wc. """ - self.localpath.write(content) + self.localpath.write(content, mode) def dirpath(self, *args): """ return the directory Path of the current Path. """ From jan at codespeak.net Wed Jan 25 08:10:38 2006 From: jan at codespeak.net (jan at codespeak.net) Date: Wed, 25 Jan 2006 08:10:38 +0100 (CET) Subject: [py-svn] r22623 - py/dist/py/rest Message-ID: <20060125071038.37BB127B5C@code1.codespeak.net> Author: jan Date: Wed Jan 25 08:10:36 2006 New Revision: 22623 Modified: py/dist/py/rest/directive.py Log: ensure import statement is compatible with docutils-0.3.5 Modified: py/dist/py/rest/directive.py ============================================================================== --- py/dist/py/rest/directive.py (original) +++ py/dist/py/rest/directive.py Wed Jan 25 08:10:36 2006 @@ -3,10 +3,15 @@ from py.__.rest.convert import convert_dot, latexformula2png import sys -from docutils import nodes, utils +from docutils import nodes from docutils.parsers.rst import directives, states, roles from docutils.parsers.rst.directives import images +try: + from docutils.utils import unescape # docutils version > 0.3.5 +except ImportError: + from docutils.parsers.rst.states import unescape # docutils 0.3.5 + backend_to_image_format = {"html": "png", "latex": "pdf"} class BackendStore(object): @@ -61,7 +66,7 @@ imagename = "%s_%s.png" % ( hash(text), "".join([c for c in text if c.isalnum()])) image = imagedir.join(imagename) - latexformula2png(utils.unescape(text, True), image) + latexformula2png(unescape(text, True), image) imagenode = nodes.image(image.relto(sourcedir), uri=image.relto(sourcedir)) return [imagenode], [] latexformula_role.content = True From jan at codespeak.net Mon Jan 30 10:39:46 2006 From: jan at codespeak.net (jan at codespeak.net) Date: Mon, 30 Jan 2006 10:39:46 +0100 (CET) Subject: [py-svn] r22868 - in py/dist/py/rest: . testing Message-ID: <20060130093946.0ACC627DB5@code1.codespeak.net> Author: jan Date: Mon Jan 30 10:39:45 2006 New Revision: 22868 Modified: py/dist/py/rest/rst.py py/dist/py/rest/testing/test_rst.py Log: all unknown tag in class rest are now directives Modified: py/dist/py/rest/rst.py ============================================================================== --- py/dist/py/rest/rst.py (original) +++ py/dist/py/rest/rst.py Mon Jan 30 10:39:45 2006 @@ -183,7 +183,7 @@ -class rest(Namespace): +class rest(UniversalDirective): __tagclass__ = RestTag __stickname__ = True Modified: py/dist/py/rest/testing/test_rst.py ============================================================================== --- py/dist/py/rest/testing/test_rst.py (original) +++ py/dist/py/rest/testing/test_rst.py Mon Jan 30 10:39:45 2006 @@ -209,14 +209,6 @@ + '\n' + title.sep assert title.text() == expected check_rest(title.text()) - -## def test_subtitle(): -## phrase = 'If your computer speaks English it was probably made in Japan' -## subtitle = rest.subtitle(phrase) -## expected = phrase + '\n' + subtitle.underline * len(phrase) + '\n' -## assert unicode(subtitle) == expected -## assert check_rest(subtitle) - def test_list_item(self): @@ -302,6 +294,7 @@ def test_directive_replace_underscore_in_directive_name(self): + # should we replace underscore in keyword arguments? expected = '''\ .. csv-table:: Frozen Delights! :header: "Treat", "Quantity", "Description" From cfbolz at codespeak.net Tue Jan 31 22:07:25 2006 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Tue, 31 Jan 2006 22:07:25 +0100 (CET) Subject: [py-svn] r22912 - py/dist/py/documentation Message-ID: <20060131210725.CE5D31007F@code0.codespeak.net> Author: cfbolz Date: Tue Jan 31 22:07:24 2006 New Revision: 22912 Added: py/dist/py/documentation/planning.txt Log: (hpk, jab, cfbolz): some very rough planning for the release 0.8 Added: py/dist/py/documentation/planning.txt ============================================================================== --- (empty file) +++ py/dist/py/documentation/planning.txt Tue Jan 31 22:07:24 2006 @@ -0,0 +1,73 @@ +Release +======= + +currently working configurations +-------------------------------- + +2.3 - 2.4.2 work + +2.5 has obscure problems + +with setuptools: 2.3 - 2.4.2 as 'develop' + +regular installation: works mostly, strange test-failures + +to be tested: 2.2, windows + +absolutely necessary steps: +---------------------------- + + * documentation + + * improving getting started, describe install methods + * describe the rest stuff? + * py.log + * py.path is mostly undocumented, API documentation + + * basic windows testing, maybe disabling execnet?, what about the scripts in windows? + + * are all c extensions compiled when installing globally? + + * refactoring py.log + + * write/read methods on py.path should be renamed/deprecated: setcontent, getcontent instead? + + * what about _subprocess.c? + + * warning for docutils + + * don't expose _extpy + + * py/bin should be nicefied, get optparse interface + + * _findpy.py + * py.cleanup: + * py.lookup: add -i option + * pytest.cmd + * rst2pdf.py: merge with py.rest, add warnings when missing tex + * _makepyrelease.py: move somewhere + * py.countloc + * py.test + * py.rest + * win32 + + * skip tests if dependencies are not installed + +nice to have +------------ + + * sets.py, subprocess.py in compat + * fix -k option to py.test + * add --report=(text|terminal|session|rest|tkinter|rest) to py.test + +PyCon sprint +============= + +HP +== + +Vision +====== + + * define necessary minimal abstractions to make a working path documentation +