本文整理汇总了Python中gaphor.UML.parse方法的典型用法代码示例。如果您正苦于以下问题:Python UML.parse方法的具体用法?Python UML.parse怎么用?Python UML.parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gaphor.UML
的用法示例。
在下文中一共展示了UML.parse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_parse_operation
# 需要导入模块: from gaphor import UML [as 别名]
# 或者: from gaphor.UML import parse [as 别名]
def test_parse_operation(self):
"""Test parsing simple operation
"""
o = factory.create(UML.Operation)
UML.parse(o, "myfunc()")
self.assertEqual("myfunc", o.name)
self.assertTrue(not o.returnResult[0].typeValue)
self.assertFalse(o.formalParameter)
示例2: test_parse_operation_return
# 需要导入模块: from gaphor import UML [as 别名]
# 或者: from gaphor.UML import parse [as 别名]
def test_parse_operation_return(self):
"""Test parsing operation with return value
"""
o = factory.create(UML.Operation)
UML.parse(o, "+ myfunc(): int")
self.assertEqual("myfunc", o.name)
self.assertEqual("int", o.returnResult[0].typeValue)
self.assertEqual("public", o.visibility)
self.assertTrue(not o.formalParameter)
示例3: test_parse_property_simple
# 需要导入模块: from gaphor import UML [as 别名]
# 或者: from gaphor.UML import parse [as 别名]
def test_parse_property_simple(self):
"""Test simple property parsing
"""
a = factory.create(UML.Property)
UML.parse(a, "myattr")
self.assertFalse(a.isDerived)
self.assertEqual("myattr", a.name)
self.assertTrue(a.typeValue is None, a.typeValue)
self.assertTrue(a.lowerValue is None, a.lowerValue)
self.assertTrue(a.upperValue is None, a.upperValue)
self.assertTrue(a.defaultValue is None, a.defaultValue)
示例4: test_parse_multiplicity2
# 需要导入模块: from gaphor import UML [as 别名]
# 或者: from gaphor.UML import parse [as 别名]
def test_parse_multiplicity2(self):
"""Test parsing of multiplicity with multiline constraints
"""
a = factory.create(UML.Association)
p = factory.create(UML.Property)
p.association = a
UML.parse(p, "0..2 { tag1, \ntag2}")
self.assertTrue(p.name is None)
self.assertTrue(not p.typeValue)
self.assertEqual("0", p.lowerValue)
self.assertEqual("2", p.upperValue)
self.assertTrue(not p.defaultValue)
示例5: test_parse_property_invalid
# 需要导入模块: from gaphor import UML [as 别名]
# 或者: from gaphor.UML import parse [as 别名]
def test_parse_property_invalid(self):
"""Test parsing property with invalid syntax
"""
a = factory.create(UML.Property)
UML.parse(a, '+ name = str[*] = "aap" { static }')
self.assertEqual('+ name = str[*] = "aap" { static }', a.name)
self.assertFalse(a.isDerived)
self.assertTrue(not a.typeValue)
self.assertTrue(not a.lowerValue)
self.assertTrue(not a.upperValue)
self.assertTrue(not a.defaultValue)
示例6: _set_object_value
# 需要导入模块: from gaphor import UML [as 别名]
# 或者: from gaphor.UML import parse [as 别名]
def _set_object_value(self, row, col, value):
attr = row[-1]
if col == 0:
UML.parse(attr, value)
row[0] = UML.format(attr)
elif col == 1:
attr.isStatic = not attr.isStatic
row[1] = attr.isStatic
elif col == 2:
# Value in attribute object changed:
row[0] = UML.format(attr)
row[1] = attr.isStatic
示例7: test_parse_operation_1_param
# 需要导入模块: from gaphor import UML [as 别名]
# 或者: from gaphor.UML import parse [as 别名]
def test_parse_operation_1_param(self):
"""Test parsing of operation with one parameter
"""
o = factory.create(UML.Operation)
UML.parse(o, "- myfunc2 (a: node): double")
self.assertEqual("myfunc2", o.name)
self.assertEqual("double", o.returnResult[0].typeValue)
self.assertEqual("private", o.visibility)
self.assertEqual(1, len(o.formalParameter))
self.assertEqual("a", o.formalParameter[0].name)
self.assertEqual("node", o.formalParameter[0].typeValue)
self.assertTrue(o.formalParameter[0].defaultValue is None)
示例8: test_parse_multiplicity
# 需要导入模块: from gaphor import UML [as 别名]
# 或者: from gaphor.UML import parse [as 别名]
def test_parse_multiplicity(self):
"""Test parsing of multiplicity
"""
a = factory.create(UML.Association)
p = factory.create(UML.Property)
p.association = a
UML.parse(p, "0..2 { tag }")
self.assertTrue(p.name is None)
self.assertTrue(not p.typeValue)
self.assertEquals("0", p.lowerValue.value)
self.assertEquals("2", p.upperValue.value)
self.assertTrue(not p.defaultValue)
示例9: test_parse_property_complex
# 需要导入模块: from gaphor import UML [as 别名]
# 或者: from gaphor.UML import parse [as 别名]
def test_parse_property_complex(self):
"""Test complex property parsing
"""
a = factory.create(UML.Property)
UML.parse(a, '+ / name : str[0..*] = "aap" { static }')
self.assertEqual("public", a.visibility)
self.assertTrue(a.isDerived)
self.assertEqual("name", a.name)
self.assertEqual("str", a.typeValue)
self.assertEqual("0", a.lowerValue)
self.assertEqual("*", a.upperValue)
self.assertEqual('"aap"', a.defaultValue)
示例10: test_parse_association_end
# 需要导入模块: from gaphor import UML [as 别名]
# 或者: from gaphor.UML import parse [as 别名]
def test_parse_association_end(self):
"""Test parsing of association end
"""
a = factory.create(UML.Association)
p = factory.create(UML.Property)
p.association = a
UML.parse(p, "end")
self.assertEqual("end", p.name)
self.assertTrue(not p.typeValue)
self.assertTrue(not p.lowerValue)
self.assertTrue(not p.upperValue)
self.assertTrue(not p.defaultValue)
示例11: test_operation_parameter_deletion
# 需要导入模块: from gaphor import UML [as 别名]
# 或者: from gaphor.UML import parse [as 别名]
def test_operation_parameter_deletion(self):
factory = UML.ElementFactory()
self.assertEquals(0, len(factory.lselect()))
c = factory.create(UML.Class)
c.name = 'Class'
o = factory.create(UML.Operation)
c.ownedOperation = o
UML.parse(o, 'a(x: int, y: int)')
c.unlink()
self.assertEquals(0, len(factory.lselect()), factory.lselect())
示例12: test_parse_derived_end
# 需要导入模块: from gaphor import UML [as 别名]
# 或者: from gaphor.UML import parse [as 别名]
def test_parse_derived_end(self):
"""Test parsing derived association end
"""
a = factory.create(UML.Association)
p = factory.create(UML.Property)
p.association = a
UML.parse(p, "-/end[*] { mytag}")
self.assertEqual("private", p.visibility)
self.assertTrue(p.isDerived)
self.assertEqual("end", p.name)
self.assertTrue(not p.typeValue)
self.assertTrue(not p.lowerValue)
self.assertEqual("*", p.upperValue)
self.assertTrue(not p.defaultValue)
示例13: test_parse_operation_2_params
# 需要导入模块: from gaphor import UML [as 别名]
# 或者: from gaphor.UML import parse [as 别名]
def test_parse_operation_2_params(self):
"""Test parsing of operation with two parameters
"""
o = factory.create(UML.Operation)
UML.parse(o, "# myfunc2 (a: str, b: int = 3 { static}): float")
self.assertEqual("myfunc2", o.name)
self.assertEqual("float", o.returnResult[0].typeValue)
self.assertEqual("protected", o.visibility)
self.assertEqual(2, len(o.formalParameter))
self.assertEqual("a", o.formalParameter[0].name)
self.assertEqual("str", o.formalParameter[0].typeValue)
self.assertTrue(o.formalParameter[0].defaultValue is None)
self.assertEqual("b", o.formalParameter[1].name)
self.assertEqual("int", o.formalParameter[1].typeValue)
self.assertEqual("3", o.formalParameter[1].defaultValue)
示例14: test_parse_operation_2_params
# 需要导入模块: from gaphor import UML [as 别名]
# 或者: from gaphor.UML import parse [as 别名]
def test_parse_operation_2_params(self):
"""Test parsing of operation with two parameters
"""
o = factory.create(UML.Operation)
UML.parse(o, '# myfunc2 (a: str, b: int = 3 { static}): float')
self.assertEquals('myfunc2', o.name)
self.assertEquals('float', o.returnResult[0].typeValue)
self.assertEquals('protected', o.visibility)
self.assertEquals(2, len(o.formalParameter))
self.assertEquals('a', o.formalParameter[0].name)
self.assertEquals('str', o.formalParameter[0].typeValue)
self.assertTrue(o.formalParameter[0].defaultValue is None)
self.assertEquals('b', o.formalParameter[1].name)
self.assertEquals('int', o.formalParameter[1].typeValue)
self.assertEquals('3', o.formalParameter[1].defaultValue)
示例15: testAttribute
# 需要导入模块: from gaphor import UML [as 别名]
# 或者: from gaphor.UML import parse [as 别名]
def testAttribute(self):
"""
Test how attribute is updated
"""
attr = self.element_factory.create(UML.Property)
UML.parse(attr, '-name:myType')
clazzitem = self.create(ClassItem, UML.Class)
clazzitem.subject.ownedAttribute = attr
self.assertEquals(1, len(clazzitem._compartments[0]))
item = clazzitem._compartments[0][0]
self.assertTrue(isinstance(item, FeatureItem))
size = item.get_size()
self.assertNotEquals((0, 0), size)
attr.defaultValue = 'myDefault'
self.diagram.canvas.update()
self.assertTrue(size < item.get_size())