(WIP) implementing CBD language... Meta-meta-model: Association inherits from Class. Matcher accepts pivot. Add generic graphviz renderer.
This commit is contained in:
parent
a26ceef10f
commit
1eb8a84553
25 changed files with 542 additions and 170 deletions
21
concrete_syntax/plantuml/make_url.py
Normal file
21
concrete_syntax/plantuml/make_url.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
from zlib import compress
|
||||
import base64
|
||||
import string
|
||||
|
||||
maketrans = bytes.maketrans
|
||||
|
||||
# Includes code fragments from: https://github.com/dougn/python-plantuml/blob/bb5407e87aabbac9e8baef5a6726b03f72afca16/plantuml.py
|
||||
# Copyright (c) 2013, Doug Napoleone and then Copyright (c) 2015, Samuel Marks
|
||||
|
||||
plantuml_alphabet = string.digits + string.ascii_uppercase + string.ascii_lowercase + '-_'
|
||||
base64_alphabet = string.ascii_uppercase + string.ascii_lowercase + string.digits + '+/'
|
||||
b64_to_plantuml = maketrans(base64_alphabet.encode('utf-8'), plantuml_alphabet.encode('utf-8'))
|
||||
|
||||
def encode(plantuml_text: str) -> str:
|
||||
zlibbed_str = compress(plantuml_text.encode('utf-8'))
|
||||
compressed_string = zlibbed_str[2:-4]
|
||||
return base64.b64encode(compressed_string).translate(b64_to_plantuml).decode('utf-8')
|
||||
|
||||
def make_url(plantuml_text: str) -> str:
|
||||
encoded = encode(plantuml_text)
|
||||
return f"https://deemz.org/plantuml/pdf/{encoded}"
|
||||
|
|
@ -3,9 +3,10 @@
|
|||
from services import scd, od
|
||||
from services.bottom.V0 import Bottom
|
||||
from transformation import ramify
|
||||
from concrete_syntax.common import display_value
|
||||
from concrete_syntax.common import display_value, display_name
|
||||
from uuid import UUID
|
||||
|
||||
|
||||
def render_class_diagram(state, model, prefix_ids=""):
|
||||
bottom = Bottom(state)
|
||||
model_scd = scd.SCD(model, state)
|
||||
|
|
@ -102,7 +103,7 @@ def render_object_diagram(state, m, mm, render_attributes=True, prefix_ids=""):
|
|||
attributes = od.get_attributes(bottom, class_node)
|
||||
|
||||
for obj_name, obj_node in m_od.get_objects(class_node).items():
|
||||
output += f"\nmap \"{obj_name} : {class_name}\" as {make_id(obj_node)} {{"
|
||||
output += f"\nmap \"{display_name(obj_name)} : {class_name}\" as {make_id(obj_node)} {{"
|
||||
|
||||
if render_attributes:
|
||||
for attr_name, attr_edge in attributes:
|
||||
|
|
@ -122,7 +123,7 @@ def render_object_diagram(state, m, mm, render_attributes=True, prefix_ids=""):
|
|||
src_name = m_od.get_object_name(src_obj)
|
||||
tgt_name = m_od.get_object_name(tgt_obj)
|
||||
|
||||
output += f"\n{make_id(src_obj)} -> {make_id(tgt_obj)} : :{assoc_name}"
|
||||
output += f"\n{make_id(src_obj)} -> {make_id(tgt_obj)} : {display_name(link_name)}:{assoc_name}"
|
||||
|
||||
return output
|
||||
|
||||
|
|
@ -229,4 +230,3 @@ def render_trace_match(state, name_mapping: dict, pattern_m: UUID, host_m: UUID,
|
|||
host_attr_name = od.get_attr_name(bottom, host_el_type)
|
||||
output += f"\n{make_pattern_id(pattern_obj)}::{pattern_attr_name} ..> {make_host_id(host_obj)}::{host_attr_name} {render_suffix}"
|
||||
return output
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue