generate.py
Go to the documentation of this file.
1 import os
2 import requests
3 import re
4 import urllib
5 
6 WSD_URL = 'http://www.websequencediagrams.com/'
7 
8 def getSequenceDiagram(text, out_fn, style='modern-blue'):
9  request = {}
10  request["message"] = text
11  request["style"] = style
12  request["apiVersion"] = "1"
13 
14  r = requests.post(WSD_URL, data=request)
15  response = r.json()
16  if 'img' not in response:
17  print("Invalid response from server.")
18  return
19 
20  with open(out_fn, 'w') as f:
21  print out_fn
22  r = requests.get(WSD_URL + response['img'])
23  f.write(r.content)
24 
25 
26 if __name__ == '__main__':
27  current_directory = os.path.abspath(os.path.dirname(__file__))
28  for fn in os.listdir(current_directory):
29  base, ext = os.path.splitext(fn)
30  if ext != '.flow':
31  continue
32  text = open(os.path.join(current_directory, fn)).read()
33  out_fn = os.path.join(current_directory, base + '.png')
34  getSequenceDiagram(text, out_fn)
def getSequenceDiagram(text, out_fn, style='modern-blue')
Definition: generate.py:8


locomotor
Author(s):
autogenerated on Sun Jan 10 2021 04:08:39