def dict2svg(d): base_name = str(uuid.uuid4()) uml_path = base_name + ".uml" with open(uml_path, 'w') as fp: fp.write(dict2plantuml(d)) try: output = plantuml_exec(uml_path) svg_name = output[0] return SVG(filename=svg_name) finally: if os.path.exists(uml_path): os.unlink(uml_path) svg_path = base_name + ".svg" if os.path.exists(svg_path): os.unlink(svg_path)
def main(): """ This function calls get_info() in order to get a dictionary with everything it needs. After printing that dictionary, using the PlantUML library, it creates a new UML diagram. For every image in the running directory, the function adds the paths to to_concat array and then calls concat_images with all those paths. :return: it creates uml_no images with a single UML diagram per image, then it calls concat_images >> main() """ unique = str(time.time()) info = get_info() print(info) to_concat = [] uml = plantuml.PlantUML() uml_no = 0 for d in info: retry = 0 uml_no += 1 file_name = (str(uml_no) + '-' + unique + '.png') while True: if retry == 3: print "Can't get image after 3 tries. Will try with the next image..." break with open(file_name, 'wb') as out: try: out.write(uml.processes(dict2uml.dict2plantuml(d))) break except: retry += 1 if os.path.isfile(file_name): to_concat += [file_name] if len(to_concat) is 0: print "No images found." print "Folder may be empty." exit() concat_images(to_concat, unique)
def test_answer(): assert dict2plantuml({}) == \ '@startuml\nclass "root" as root {\n\t.. Properties ..\n}\n\n@enduml'
import dict2uml d = {"beers": ["Heineken", "Budweiser", "Guinness"]} print(dict2uml.dict2plantuml(d))
1:line.find(")")].replace( ',', '')) implementation = ( line[line.find("class") + len("class") + 1:line.find("(")].replace(',', '')) implementations.append(implementation) for name in implementations: if name in found_list: pass else: impl_dict = {inherits: temp_dict} found_list.append(name) relations.append(impl_dict) else: relations.append(temp_dict) found_list.append(class_line) return relations if __name__ == "__main__": info = get_info() print(info) uml = plantuml.PlantUML() uml_no = 0 for d in info: uml_no += 1 file_name = (str(uml_no) + '.png') with open(file_name, 'wb') as out: out.write(uml.processes(dict2uml.dict2plantuml(d)))