Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Python version

  • Loading branch information...
commit 9c8c5993fac91aff998214693e8660433e9a5d1b 1 parent 99fd3fa
Mathieu Lecarme authored
Showing with 38 additions and 0 deletions.
  1. +38 −0 python/ditaa.py
38 python/ditaa.py
View
@@ -0,0 +1,38 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+__author__ = "Mathieu Lecarme <mathieu@garambrogne.net>"
+__version__ = '0.1'
+
+import urllib
+
+class Ditaa:
+ antialias = True;
+ shadows = True;
+ scale = 1;
+ round_corners = False;
+ separations = True;
+ def __init__(self, url):
+ self.url = url
+ def buildImage(self, ditaa):
+ return urllib.urlopen(self.url, urllib.urlencode({
+ 'ditaa': ditaa,
+ 'no-antialias': not self.antialias,
+ 'no-shadows': not self.shadows,
+ 'scale': self.scale,
+ 'round-corners': self.round_corners,
+ 'no-separations': not self.separations
+ }))
+ def saveImage(self, ditaa, path):
+ f = open(path, 'w')
+ f.write(self.buildImage(ditaa).read())
+ f.close()
+if __name__ == '__main__':
+ ditaa = Ditaa('http://admin.garambrogne.net/ditaa_web/ditaa')
+ ditaa.round_corners = True
+ ditaa.scale = 1.5
+ ditaa.saveImage('''
+ +--------------+
+ | Python rulez |
+ +--------------+''', '/tmp/python_ditaa.png')
+
Please sign in to comment.
Something went wrong with that request. Please try again.