當前位置: 首頁>>代碼示例>>Python>>正文


Python gaphor.UML類代碼示例

本文整理匯總了Python中gaphor.UML的典型用法代碼示例。如果您正苦於以下問題:Python UML類的具體用法?Python UML怎麽用?Python UML使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了UML類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_parse_operation

 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)
開發者ID:amolenaar,項目名稱:gaphor,代碼行數:8,代碼來源:test_umllex.py

示例2: test_parse_operation_return

 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)
開發者ID:amolenaar,項目名稱:gaphor,代碼行數:9,代碼來源:test_umllex.py

示例3: test_parse_property_simple

 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)
開發者ID:amolenaar,項目名稱:gaphor,代碼行數:11,代碼來源:test_umllex.py

示例4: test_parse_multiplicity

 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)
開發者ID:dieterv,項目名稱:gaphor,代碼行數:12,代碼來源:test_umllex.py

示例5: test_parse_operation_1_param

 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)
開發者ID:amolenaar,項目名稱:gaphor,代碼行數:12,代碼來源:test_umllex.py

示例6: test_parse_multiplicity2

 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)
開發者ID:amolenaar,項目名稱:gaphor,代碼行數:12,代碼來源:test_umllex.py

示例7: _set_object_value

 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
開發者ID:dieterv,項目名稱:gaphor,代碼行數:12,代碼來源:propertypages.py

示例8: test_parse_property_invalid

    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)
開發者ID:amolenaar,項目名稱:gaphor,代碼行數:12,代碼來源:test_umllex.py

示例9: test_operation_parameter_deletion

    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())
開發者ID:Nyox,項目名稱:gaphor,代碼行數:13,代碼來源:test_uml2.py

示例10: test_parse_property_complex

    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)
開發者ID:amolenaar,項目名稱:gaphor,代碼行數:13,代碼來源:test_umllex.py

示例11: test_parse_association_end

    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)
開發者ID:amolenaar,項目名稱:gaphor,代碼行數:13,代碼來源:test_umllex.py

示例12: test_parse_derived_end

 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)
開發者ID:amolenaar,項目名稱:gaphor,代碼行數:14,代碼來源:test_umllex.py

示例13: test_parse_operation_2_params

 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)
開發者ID:amolenaar,項目名稱:gaphor,代碼行數:15,代碼來源:test_umllex.py

示例14: test_parse_operation_2_params

 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)
開發者ID:Nyox,項目名稱:gaphor,代碼行數:15,代碼來源:test_umllex.py

示例15: render

 def render(self):
     """Render the OperationItem."""
     
     return UML.format(self.subject,\
                       visibility=True,\
                       type=True,\
                       multiplicity=True,\
                       default=True) or ''
開發者ID:dieterv,項目名稱:gaphor,代碼行數:8,代碼來源:klass.py


注:本文中的gaphor.UML類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。