Пример #1
0
            report(a, "Attribute has no type: %s" % a.name)
        elif a.typeValue.value.lower() not in (
                "string",
                "boolean",
                "integer",
                "unlimitednatural",
        ):
            report(a, "Invalid attribute type: %s" % a.typeValue.value)


# TODO: Check the sanity of the generated data model.
def check_UML_module():
    all_classes = list(map(getattr, [UML] * len(dir(UML)), dir(UML)))
    for c in all_classes:
        if not isinstance(c, UML.Element):
            continue
        # TODO: check derived unions.


if __name__ == "__main__":
    from gaphor.UML import ElementFactory
    from gaphor import storage

    element_factory = ElementFactory()
    storage.load(path.join("gaphor", "UML", "uml2.gaphor"),
                 factory=element_factory)
    check_associations(element_factory)
    check_attributes(element_factory)

# vim:sw=4:et
Пример #2
0
def check_attributes(element_factory):
    for a in element_factory.select(
            lambda e: e.isKindOf(uml2.Property) and not e.association):
        if not a.typeValue or not a.typeValue.value:
            report(a, 'Attribute has no type: %s' % a.name)
        elif a.typeValue.value.lower() not in ('string', 'boolean', 'integer',
                                               'unlimitednatural'):
            report(a, 'Invalid attribute type: %s' % a.typeValue.value)


# TODO: Check the sanity of the generated data model.
def check_UML_module():
    all_classes = list(map(getattr, [UML] * len(dir(UML)), dir(UML)))
    for c in all_classes:
        if not isinstance(c, uml2.Element):
            continue
        # TODO: check derived unions.


if __name__ == '__main__':
    from gaphor.UML import ElementFactory
    from gaphor import storage

    element_factory = ElementFactory()
    storage.load(path.join('gaphor', 'UML', 'uml2.gaphor'),
                 factory=element_factory)
    check_associations(element_factory)
    check_attributes(element_factory)

# vim:sw=4:et
Пример #3
0
        tail = a.memberEnd[1]
        check_association_end(element_factory, head)
        check_association_end(element_factory, tail)

def check_attributes(element_factory):
    for a in element_factory.select(lambda e: e.isKindOf(UML.Property) and not e.association):
        if not a.typeValue or not a.typeValue.value:
            report(a,'Attribute has no type: %s' % a.name)
        elif a.typeValue.value.lower() not in ('string', 'boolean', 'integer', 'unlimitednatural'):
            report(a, 'Invalid attribute type: %s' % a.typeValue.value)

# TODO: Check the sanity of the generated data model.
def check_UML_module():
    all_classes = map(getattr, [UML] * len(dir(UML)), dir(UML))
    for c in all_classes:
        if not isinstance(c, UML.Element):
            continue
        # TODO: check derived unions.

if __name__ == '__main__':
    from gaphor.UML import ElementFactory
    from gaphor import storage

    element_factory = ElementFactory()
    storage.load(path.join('gaphor', 'UML', 'uml2.gaphor'), factory=element_factory)
    check_associations(element_factory)
    check_attributes(element_factory)


# vim:sw=4:et