changeset 3:1a267297f779

graphviz now works, giving real version
author k0s <k0scist@gmail.com>
date Thu, 14 Jan 2010 00:16:34 -0500
parents 1e2c475015d8
children 5258325a496a
files contenttransformer/transformers.py example.ini example/process.gv.txt setup.py
diffstat 4 files changed, 20 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/contenttransformer/transformers.py	Thu Jan 14 00:09:06 2010 -0500
+++ b/contenttransformer/transformers.py	Thu Jan 14 00:16:34 2010 -0500
@@ -5,11 +5,14 @@
 class Graphviz(object):
     def __init__(self, content):
         """create a Graphviz object"""
-        raise NotImplementedError # TODO
+        process = subprocess.Popen(['dot', '-Tpng'],
+                                   stdin=subprocess.PIPE,
+                                   stdout=subprocess.PIPE)
+        self.image, _ = process.communicate(content)
 
     def __call__(self, environ, start_response):
         """return a WSGI response"""
-   
+        return Response(content_type='image/png', body=self.image)(environ, start_response)   
 
 class RestructuredText(object):
     settings = { 'report_level': 5 }
--- a/example.ini	Thu Jan 14 00:09:06 2010 -0500
+++ b/example.ini	Thu Jan 14 00:16:34 2010 -0500
@@ -20,4 +20,4 @@
 [app:contenttransformer]
 paste.app_factory = contenttransformer.factory:factory
 transformer.directory = %(here)s/example
-transformer.transforms = *.txt=ReST
\ No newline at end of file
+transformer.transforms = *.gv.txt=Graphviz,*.txt=ReST
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/process.gv.txt	Thu Jan 14 00:16:34 2010 -0500
@@ -0,0 +1,13 @@
+digraph g {
+start -> types;
+start [label="new project"];
+types [label="pastescript template"];
+types -> templates [dir=none];
+templates [
+          label="webob_view|genshi_view|console_script"
+          shape="record"];
+types -> development;
+development -> types;
+development -> integration;
+integration [label="integration with website + middleware"];
+};
--- a/setup.py	Thu Jan 14 00:09:06 2010 -0500
+++ b/setup.py	Thu Jan 14 00:16:34 2010 -0500
@@ -1,7 +1,7 @@
 from setuptools import setup, find_packages
 import sys, os
 
-version = "0.0"
+version = "0.1"
 
 setup(name='contentransformer',
       version=version,