def parse_association_end(el: uml.Property, s: str) -> None: """ Parse the text at one end of an association. The association end holds two strings. It is automatically figured out which string is fed to the parser. """ el.model.create # if no name, then clear as there could be some garbage # due to previous parsing (i.e. '[1' m = association_end_name_pat.match(s) if m and not m.group("name"): el.name = None # clear also multiplicity if no characters in ``s`` m = association_end_mult_pat.match(s) if m and not m.group("mult_u"): if el.upperValue: el.upperValue = None if m and m.group("mult_u") or m.group("tags"): g = m.group el.lowerValue = g("mult_l") el.upperValue = g("mult_u") else: m = association_end_name_pat.match(s) g = m.group if g("garbage"): el.name = s del el.visibility del el.isDerived else: _set_visibility(el, g("vis")) el.isDerived = g("derived") and True or False el.name = g("name") # Optionally, the multiplicity and tagged values may be defined: if g("mult_l"): el.lowerValue = g("mult_l") if g("mult_u"): if not g("mult_l"): el.lowerValue = None el.upperValue = g("mult_u")
def parse_attribute(el: uml.Property, s: str) -> None: """ Parse string s in the property. Tagged values, multiplicity and stuff like that is altered to reflect the data in the property string. """ m = attribute_pat.match(s) if not m or m.group("garbage"): el.name = s del el.visibility del el.isDerived if el.typeValue: el.typeValue = None if el.lowerValue: el.lowerValue = None if el.upperValue: el.upperValue = None if el.defaultValue: el.defaultValue = None else: g = m.group el.model.create _set_visibility(el, g("vis")) el.isDerived = g("derived") and True or False el.name = g("name") el.typeValue = g("type") el.lowerValue = g("mult_l") el.upperValue = g("mult_u") el.defaultValue = g("default")