[py-svn] r21142 - in py/dist/py: bin misc rest rest/testing
cfbolz at codespeak.net
cfbolz at codespeak.net
Tue Dec 13 19:42:21 CET 2005
Author: cfbolz
Date: Tue Dec 13 19:42:18 2005
New Revision: 21142
Added:
py/dist/py/rest/directive.py
- copied, changed from r21130, py/dist/py/rest/restgraphviz.py
Removed:
py/dist/py/rest/restgraphviz.py
Modified:
py/dist/py/bin/rst2pdf.py
py/dist/py/misc/rest.py
py/dist/py/rest/testing/test_restgraphviz.py
Log:
rename restgraphviz to directive, since I want to use it for more than the
graphviz directive.
Modified: py/dist/py/bin/rst2pdf.py
==============================================================================
--- py/dist/py/bin/rst2pdf.py (original)
+++ py/dist/py/bin/rst2pdf.py Tue Dec 13 19:42:18 2005
@@ -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
@@ -27,7 +27,7 @@
help="print debug output and don't delete files")
if __name__ == '__main__':
- graphvizdirective = restgraphviz.GraphvizDirective("latex")
+ directive.BackendStore("latex")
(options, args) = parser.parse_args()
if options.configfile is not None:
configfile = py.path.local(options.configfile)
Modified: py/dist/py/misc/rest.py
==============================================================================
--- py/dist/py/misc/rest.py (original)
+++ py/dist/py/misc/rest.py Tue Dec 13 19:42:18 2005
@@ -9,14 +9,14 @@
pass
def convert_rest_html(source, source_path, stylesheet=None, encoding='latin1'):
- from py.__.rest import restgraphviz
+ 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
- graphvizdirective = restgraphviz.GraphvizDirective("html")
+ directive.BackendStore("html")
kwargs = {
'stylesheet' : stylesheet,
'stylesheet_path': None,
Copied: py/dist/py/rest/directive.py (from r21130, py/dist/py/rest/restgraphviz.py)
==============================================================================
--- py/dist/py/rest/restgraphviz.py (original)
+++ py/dist/py/rest/directive.py Tue Dec 13 19:42:18 2005
@@ -10,7 +10,7 @@
backend_to_image_format = {"html": "png", "latex": "pdf"}
-class GraphvizDirective(object):
+class BackendStore(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
@@ -18,7 +18,7 @@
def __init__(self, backend):
self.backend = backend
self.convert_to_format = backend_to_image_format[backend]
- directives.register_directive("graphviz", self.directive_function)
+ directives.register_directive("graphviz", self.graphviz_directive)
def convert(self, fn, path):
path = py.path.local(path).dirpath()
@@ -26,18 +26,20 @@
result = convert_dot(dot, self.convert_to_format)
return result.relto(path)
- def directive_function(self, name, arguments, options, content, lineno,
- content_offset, block_text, state, state_machine):
+ def graphviz_directive(self, name, arguments, options, content,
+ lineno, content_offset, block_text, state,
+ state_machine):
newname = self.convert(arguments[0], state.document.settings._source)
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,
+ graphviz_directive.arguments = (1, 0, 1)
+ graphviz_directive.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}
+
Deleted: /py/dist/py/rest/restgraphviz.py
==============================================================================
--- /py/dist/py/rest/restgraphviz.py Tue Dec 13 19:42:18 2005
+++ (empty file)
@@ -1,43 +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
-
-backend_to_image_format = {"html": "png", "latex": "pdf"}
-
-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, backend):
- self.backend = backend
- self.convert_to_format = backend_to_image_format[backend]
- directives.register_directive("graphviz", self.directive_function)
-
- def convert(self, fn, path):
- path = py.path.local(path).dirpath()
- dot = path.join(fn)
- result = convert_dot(dot, self.convert_to_format)
- return result.relto(path)
-
- def directive_function(self, name, arguments, options, content, lineno,
- content_offset, block_text, state, state_machine):
- newname = self.convert(arguments[0], state.document.settings._source)
- 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/dist/py/rest/testing/test_restgraphviz.py
==============================================================================
--- py/dist/py/rest/testing/test_restgraphviz.py (original)
+++ py/dist/py/rest/testing/test_restgraphviz.py Tue Dec 13 19:42:18 2005
@@ -1,12 +1,12 @@
import py
-from py.__.rest import restgraphviz
+from py.__.rest import directive
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("html")
+ directive.BackendStore("html")
#for reasons that elude me rest.process expects svnwcs???
txt = py.path.svnwc(datadir.join("graphviz.txt"))
html = txt.new(ext="html")
@@ -20,7 +20,7 @@
png.remove()
def test_graphviz_pdf():
- graphvizdirective = restgraphviz.GraphvizDirective("latex")
+ directive.BackendStore("latex")
txt = py.path.local(datadir.join("graphviz.txt"))
pdf = txt.new(ext="pdf")
dotpdf = datadir.join("example1.pdf")
More information about the pytest-commit
mailing list