generate.py
Go to the documentation of this file.
00001 import os
00002 import requests
00003 import re
00004 import urllib
00005 
00006 WSD_URL = 'http://www.websequencediagrams.com/'
00007 
00008 def getSequenceDiagram(text, out_fn, style='modern-blue'):
00009     request = {}
00010     request["message"] = text
00011     request["style"] = style
00012     request["apiVersion"] = "1"
00013 
00014     r = requests.post(WSD_URL, data=request)
00015     response = r.json()
00016     if 'img' not in response:
00017         print("Invalid response from server.")
00018         return
00019 
00020     with open(out_fn, 'w') as f:
00021         print out_fn
00022         r = requests.get(WSD_URL + response['img'])
00023         f.write(r.content)
00024 
00025 
00026 if __name__ == '__main__':
00027     current_directory = os.path.abspath(os.path.dirname(__file__))
00028     for fn in os.listdir(current_directory):
00029         base, ext = os.path.splitext(fn)
00030         if ext != '.flow':
00031             continue
00032         text = open(os.path.join(current_directory, fn)).read()
00033         out_fn = os.path.join(current_directory, base + '.png')
00034         getSequenceDiagram(text, out_fn)


locomotor
Author(s):
autogenerated on Wed Jun 26 2019 20:09:43