sysmlpy 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. sysmlpy/__init__.py +226 -0
  2. sysmlpy/__main__.py +75 -0
  3. sysmlpy/antlr/README.md +146 -0
  4. sysmlpy/antlr/SysMLv2Lexer.interp +695 -0
  5. sysmlpy/antlr/SysMLv2Lexer.py +1123 -0
  6. sysmlpy/antlr/SysMLv2Lexer.tokens +444 -0
  7. sysmlpy/antlr/SysMLv2Parser.interp +960 -0
  8. sysmlpy/antlr/SysMLv2Parser.py +40750 -0
  9. sysmlpy/antlr/SysMLv2Parser.tokens +444 -0
  10. sysmlpy/antlr/SysMLv2ParserListener.py +4485 -0
  11. sysmlpy/antlr/SysMLv2ParserVisitor.py +2498 -0
  12. sysmlpy/antlr/src/sysmlpy/grammar/antlr4/SysMLv2Lexer.interp +695 -0
  13. sysmlpy/antlr/src/sysmlpy/grammar/antlr4/SysMLv2Lexer.py +1123 -0
  14. sysmlpy/antlr/src/sysmlpy/grammar/antlr4/SysMLv2Lexer.tokens +444 -0
  15. sysmlpy/antlr_parser.py +185 -0
  16. sysmlpy/antlr_visitor.py +10864 -0
  17. sysmlpy/definition.py +1115 -0
  18. sysmlpy/examples/attribute_values.py +161 -0
  19. sysmlpy/examples/part_attributes.py +139 -0
  20. sysmlpy/examples/tuples_sequences.py +231 -0
  21. sysmlpy/formatting.py +47 -0
  22. sysmlpy/grammar/antlr4/README.md +30 -0
  23. sysmlpy/grammar/antlr4/SysMLv2Lexer.g4 +931 -0
  24. sysmlpy/grammar/antlr4/SysMLv2Lexer.interp +695 -0
  25. sysmlpy/grammar/antlr4/SysMLv2Lexer.py +1123 -0
  26. sysmlpy/grammar/antlr4/SysMLv2Lexer.tokens +444 -0
  27. sysmlpy/grammar/antlr4/SysMLv2Parser.g4 +2432 -0
  28. sysmlpy/grammar/antlr4/SysMLv2Parser.interp +960 -0
  29. sysmlpy/grammar/antlr4/SysMLv2Parser.py +40750 -0
  30. sysmlpy/grammar/antlr4/SysMLv2Parser.tokens +444 -0
  31. sysmlpy/grammar/antlr4/SysMLv2ParserListener.py +4485 -0
  32. sysmlpy/grammar/antlr4/SysMLv2ParserVisitor.py +2498 -0
  33. sysmlpy/grammar/antlr4/desc.xml +7 -0
  34. sysmlpy/grammar/antlr4/examples/camera.sysml +14 -0
  35. sysmlpy/grammar/antlr4/examples/toaster-system.sysml +193 -0
  36. sysmlpy/grammar/antlr4/examples/vehicle-model.sysml +118 -0
  37. sysmlpy/grammar/antlr4/pom.xml +59 -0
  38. sysmlpy/grammar/classes.py +8610 -0
  39. sysmlpy/library/LICENSE +165 -0
  40. sysmlpy/library/README.md +52 -0
  41. sysmlpy/library/__init__.py +0 -0
  42. sysmlpy/library/domain/Analysis/AnalysisTooling.sysml +34 -0
  43. sysmlpy/library/domain/Analysis/SampledFunctions.sysml +119 -0
  44. sysmlpy/library/domain/Analysis/StateSpaceRepresentation.sysml +143 -0
  45. sysmlpy/library/domain/Analysis/TradeStudies.sysml +171 -0
  46. sysmlpy/library/domain/Cause and Effect/CausationConnections.sysml +83 -0
  47. sysmlpy/library/domain/Cause and Effect/CauseAndEffect.sysml +81 -0
  48. sysmlpy/library/domain/Geometry/ShapeItems.sysml +899 -0
  49. sysmlpy/library/domain/Geometry/SpatialItems.sysml +168 -0
  50. sysmlpy/library/domain/Metadata/ImageMetadata.sysml +78 -0
  51. sysmlpy/library/domain/Metadata/ModelingMetadata.sysml +143 -0
  52. sysmlpy/library/domain/Metadata/ParametersOfInterestMetadata.sysml +39 -0
  53. sysmlpy/library/domain/Metadata/RiskMetadata.sysml +100 -0
  54. sysmlpy/library/domain/Quantities and Units/ISQ.sysml +42 -0
  55. sysmlpy/library/domain/Quantities and Units/ISQAcoustics.sysml +439 -0
  56. sysmlpy/library/domain/Quantities and Units/ISQAtomicNuclear.sysml +2726 -0
  57. sysmlpy/library/domain/Quantities and Units/ISQBase.sysml +206 -0
  58. sysmlpy/library/domain/Quantities and Units/ISQCharacteristicNumbers.sysml +1991 -0
  59. sysmlpy/library/domain/Quantities and Units/ISQChemistryMolecular.sysml +1353 -0
  60. sysmlpy/library/domain/Quantities and Units/ISQCondensedMatter.sysml +1223 -0
  61. sysmlpy/library/domain/Quantities and Units/ISQElectromagnetism.sysml +2333 -0
  62. sysmlpy/library/domain/Quantities and Units/ISQInformation.sysml +958 -0
  63. sysmlpy/library/domain/Quantities and Units/ISQLight.sysml +1537 -0
  64. sysmlpy/library/domain/Quantities and Units/ISQMechanics.sysml +1564 -0
  65. sysmlpy/library/domain/Quantities and Units/ISQSpaceTime.sysml +1169 -0
  66. sysmlpy/library/domain/Quantities and Units/ISQThermodynamics.sysml +1256 -0
  67. sysmlpy/library/domain/Quantities and Units/MeasurementRefCalculations.sysml +30 -0
  68. sysmlpy/library/domain/Quantities and Units/MeasurementReferences.sysml +526 -0
  69. sysmlpy/library/domain/Quantities and Units/Quantities.sysml +107 -0
  70. sysmlpy/library/domain/Quantities and Units/QuantityCalculations.sysml +70 -0
  71. sysmlpy/library/domain/Quantities and Units/SI.sysml +378 -0
  72. sysmlpy/library/domain/Quantities and Units/SIPrefixes.sysml +48 -0
  73. sysmlpy/library/domain/Quantities and Units/TensorCalculations.sysml +50 -0
  74. sysmlpy/library/domain/Quantities and Units/Time.sysml +274 -0
  75. sysmlpy/library/domain/Quantities and Units/USCustomaryUnits.sysml +260 -0
  76. sysmlpy/library/domain/Quantities and Units/VectorCalculations.sysml +62 -0
  77. sysmlpy/library/domain/Requirement Derivation/DerivationConnections.sysml +63 -0
  78. sysmlpy/library/domain/Requirement Derivation/RequirementDerivation.sysml +39 -0
  79. sysmlpy/library/kernel/Base.kerml +95 -0
  80. sysmlpy/library/kernel/BaseFunctions.kerml +80 -0
  81. sysmlpy/library/kernel/BooleanFunctions.kerml +22 -0
  82. sysmlpy/library/kernel/Clocks.kerml +156 -0
  83. sysmlpy/library/kernel/CollectionFunctions.kerml +68 -0
  84. sysmlpy/library/kernel/Collections.kerml +147 -0
  85. sysmlpy/library/kernel/ComplexFunctions.kerml +47 -0
  86. sysmlpy/library/kernel/ControlFunctions.kerml +117 -0
  87. sysmlpy/library/kernel/ControlPerformances.kerml +135 -0
  88. sysmlpy/library/kernel/DataFunctions.kerml +43 -0
  89. sysmlpy/library/kernel/FeatureReferencingPerformances.kerml +190 -0
  90. sysmlpy/library/kernel/IntegerFunctions.kerml +43 -0
  91. sysmlpy/library/kernel/KerML.kerml +483 -0
  92. sysmlpy/library/kernel/Links.kerml +67 -0
  93. sysmlpy/library/kernel/Metaobjects.kerml +58 -0
  94. sysmlpy/library/kernel/NaturalFunctions.kerml +27 -0
  95. sysmlpy/library/kernel/NumericalFunctions.kerml +43 -0
  96. sysmlpy/library/kernel/Objects.kerml +212 -0
  97. sysmlpy/library/kernel/Observation.kerml +161 -0
  98. sysmlpy/library/kernel/OccurrenceFunctions.kerml +154 -0
  99. sysmlpy/library/kernel/Occurrences.kerml +992 -0
  100. sysmlpy/library/kernel/Performances.kerml +293 -0
  101. sysmlpy/library/kernel/RationalFunctions.kerml +49 -0
  102. sysmlpy/library/kernel/RealFunctions.kerml +56 -0
  103. sysmlpy/library/kernel/ScalarFunctions.kerml +33 -0
  104. sysmlpy/library/kernel/ScalarValues.kerml +23 -0
  105. sysmlpy/library/kernel/SequenceFunctions.kerml +111 -0
  106. sysmlpy/library/kernel/SpatialFrames.kerml +197 -0
  107. sysmlpy/library/kernel/StatePerformances.kerml +145 -0
  108. sysmlpy/library/kernel/StringFunctions.kerml +25 -0
  109. sysmlpy/library/kernel/Transfers.kerml +281 -0
  110. sysmlpy/library/kernel/TransitionPerformances.kerml +66 -0
  111. sysmlpy/library/kernel/TrigFunctions.kerml +35 -0
  112. sysmlpy/library/kernel/Triggers.kerml +188 -0
  113. sysmlpy/library/kernel/VectorFunctions.kerml +273 -0
  114. sysmlpy/library/kernel/VectorValues.kerml +64 -0
  115. sysmlpy/library/systems/Actions.sysml +552 -0
  116. sysmlpy/library/systems/Allocations.sysml +29 -0
  117. sysmlpy/library/systems/AnalysisCases.sysml +38 -0
  118. sysmlpy/library/systems/Attributes.sysml +25 -0
  119. sysmlpy/library/systems/Calculations.sysml +37 -0
  120. sysmlpy/library/systems/Cases.sysml +71 -0
  121. sysmlpy/library/systems/Connections.sysml +60 -0
  122. sysmlpy/library/systems/Constraints.sysml +44 -0
  123. sysmlpy/library/systems/Flows.sysml +126 -0
  124. sysmlpy/library/systems/Interfaces.sysml +89 -0
  125. sysmlpy/library/systems/Items.sysml +153 -0
  126. sysmlpy/library/systems/Metadata.sysml +32 -0
  127. sysmlpy/library/systems/Parts.sysml +81 -0
  128. sysmlpy/library/systems/Ports.sysml +54 -0
  129. sysmlpy/library/systems/Requirements.sysml +194 -0
  130. sysmlpy/library/systems/StandardViewDefinitions.sysml +123 -0
  131. sysmlpy/library/systems/States.sysml +103 -0
  132. sysmlpy/library/systems/SysML.sysml +539 -0
  133. sysmlpy/library/systems/UseCases.sysml +57 -0
  134. sysmlpy/library/systems/VerificationCases.sysml +103 -0
  135. sysmlpy/library/systems/Views.sysml +164 -0
  136. sysmlpy/navigate.py +272 -0
  137. sysmlpy/store.py +547 -0
  138. sysmlpy/usage.py +2978 -0
  139. sysmlpy-0.1.0.dist-info/METADATA +230 -0
  140. sysmlpy-0.1.0.dist-info/RECORD +143 -0
  141. sysmlpy-0.1.0.dist-info/WHEEL +4 -0
  142. sysmlpy-0.1.0.dist-info/entry_points.txt +3 -0
  143. sysmlpy-0.1.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,103 @@
1
+ standard library package VerificationCases {
2
+ doc
3
+ /*
4
+ * This package defines the base types for verification cases and related behavioral elements
5
+ * in the SysML language.
6
+ */
7
+
8
+ private import Cases::Case;
9
+ private import Cases::cases;
10
+ private import Requirements::RequirementCheck;
11
+ private import ScalarValues::Boolean;
12
+
13
+ abstract verification def VerificationCase :> Case {
14
+ doc
15
+ /*
16
+ * VerificationCase is the most general class of performances of VerificationCaseDefinitions.
17
+ * VericationCase is the base class of all VerificationCaseDefinitions.
18
+ */
19
+
20
+ ref verification self : VerificationCase :>> Case::self;
21
+ subject subj :>> Case::subj;
22
+ return verdict : VerdictKind :>> result;
23
+
24
+ objective obj :>> Case::obj {
25
+ subject subj = VerificationCase::subj;
26
+
27
+ requirement requirementVerifications : RequirementCheck[0..*] :> subrequirements {
28
+ doc
29
+ /*
30
+ * A record of the evaluations of the RequirementChecks of requirements being verified.
31
+ */
32
+ }
33
+ }
34
+
35
+ ref requirement requirementVerifications : RequirementCheck[0..*] = obj.requirementVerifications {
36
+ doc
37
+ /*
38
+ * Checks on whether the verifiedRequirements of the VerificationCase have been satisfied.
39
+ */
40
+ }
41
+
42
+ abstract verification subVerificationCases : VerificationCase[0..*] :> verificationCases, subcases {
43
+ doc
44
+ /*
45
+ * The subcases of this VerificationCase that are VerificationCaseUsages.
46
+ */
47
+ }
48
+
49
+ }
50
+
51
+ abstract verification verificationCases : VerificationCase[0..*] nonunique :> cases {
52
+ doc
53
+ /*
54
+ * verificationCases is the base feature of all VerificationCaseUsages.
55
+ */
56
+ }
57
+
58
+ enum def VerdictKind {
59
+ doc
60
+ /*
61
+ * VerdictKind is an enumeration of the possible results of a VerificationCase.
62
+ */
63
+
64
+ pass;
65
+ fail;
66
+ inconclusive;
67
+ error;
68
+ }
69
+
70
+ calc def PassIf {
71
+ doc
72
+ /*
73
+ * PassIf returns a pass or fail VerdictKind depending on whether its argument is
74
+ * true or false.
75
+ */
76
+
77
+ in attribute isPassing : Boolean;
78
+ return attribute verdict : VerdictKind = if isPassing? VerdictKind::pass else VerdictKind::fail;
79
+ }
80
+
81
+ metadata def VerificationMethod {
82
+ doc
83
+ /*
84
+ * VerificationMethod can be used as metadata annotating a verification case or action.
85
+ */
86
+
87
+ attribute kind : VerificationMethodKind[1..*];
88
+ }
89
+
90
+ enum def VerificationMethodKind {
91
+ doc
92
+ /*
93
+ * VerificationMethodKind is an enumeration of the standard methods by which verification
94
+ * can be carried out.
95
+ */
96
+
97
+ inspect;
98
+ analyze;
99
+ demo;
100
+ test;
101
+ }
102
+
103
+ }
@@ -0,0 +1,164 @@
1
+ standard library package Views {
2
+ doc
3
+ /*
4
+ * This package defines the base types for views, viewpoints, renderings and related elements
5
+ * in the SysML language.
6
+ */
7
+
8
+ private import Parts::Part;
9
+ private import Parts::parts;
10
+ private import Requirements::RequirementCheck;
11
+ private import Requirements::requirementChecks;
12
+
13
+ abstract view def View :> Part {
14
+ ref view :>> self : View;
15
+
16
+ abstract ref view subviews : View[0..*] :> views {
17
+ doc
18
+ /*
19
+ * Other Views that are used in the rendering of this View.
20
+ */
21
+ }
22
+
23
+ abstract ref rendering viewRendering : Rendering[0..1] {
24
+ doc
25
+ /*
26
+ * The rendering of this View.
27
+ */
28
+ }
29
+
30
+ viewpoint viewpointSatisfactions : ViewpointCheck[0..*] :> viewpointChecks, checkedConstraints {
31
+ doc
32
+ /*
33
+ * Checks that the View satisfies all required ViewpointUsages.
34
+ */
35
+ }
36
+
37
+ satisfy requirement viewpointConformance by that {
38
+ doc
39
+ /*
40
+ * An assertion that all viewpointSatisfactions are true.
41
+ */
42
+
43
+ require viewpointSatisfactions {
44
+ doc
45
+ /*
46
+ * The required ViewpointChecks.
47
+ */
48
+ ref :>> ownedPerformances::this, subperformances::this default that.that;
49
+ }
50
+ }
51
+ }
52
+
53
+ abstract viewpoint def ViewpointCheck :> RequirementCheck {
54
+ doc
55
+ /*
56
+ * ViewpointCheck is a RequirementCheck for checking if a View meets the concerns of viewpoint stakeholders.
57
+ * It is the base type of all ViewpointDefinitions.
58
+ */
59
+
60
+ ref viewpoint :>> self : ViewpointCheck;
61
+ subject subj : View[1] :>> RequirementCheck::subj;
62
+ }
63
+
64
+ abstract rendering def Rendering :> Part {
65
+ doc
66
+ /*
67
+ * Rendering is the base type of all RenderingDefinitions.
68
+ */
69
+
70
+ ref rendering :>> self : Rendering;
71
+
72
+ abstract ref rendering subrenderings : Rendering[0..*] :> renderings {
73
+ doc
74
+ /*
75
+ * Other Renderings used to carry out this Rendering.
76
+ */
77
+ }
78
+ }
79
+
80
+ rendering def TextualRendering :> Rendering {
81
+ doc
82
+ /*
83
+ * A TextualRendering is a Rendering of a View into a textual format.
84
+ */
85
+ }
86
+
87
+ rendering def GraphicalRendering :> Rendering {
88
+ doc
89
+ /*
90
+ * A GraphicalRendering is a Rendering of a View into a Graphical format.
91
+ */
92
+ }
93
+
94
+ rendering def TabularRendering :> Rendering {
95
+ doc
96
+ /*
97
+ * A TabularRendering is a Rendering of a View into a tabular format.
98
+ */
99
+ }
100
+
101
+ abstract view views : View[0..*] nonunique :> parts {
102
+ doc
103
+ /*
104
+ * views is the base feature of all ViewUsages.
105
+ */
106
+ }
107
+
108
+ abstract viewpoint viewpointChecks : ViewpointCheck[0..*] nonunique :> requirementChecks {
109
+ doc
110
+ /*
111
+ * viewpointChecks is the base feature of all ViewpointUsages.
112
+ */
113
+ }
114
+
115
+ abstract rendering renderings : Rendering[0..*] nonunique :> parts {
116
+ doc
117
+ /*
118
+ * renderings is the base feature of all RenderingUsages.
119
+ */
120
+ }
121
+
122
+ rendering asTextualNotation : TextualRendering[1] :> renderings {
123
+ doc
124
+ /*
125
+ * asTextualNotation renders a View into textual notation as defined in the
126
+ * KerML and SysML specifications.
127
+ */
128
+ }
129
+
130
+ rendering asTreeDiagram : GraphicalRendering[1] :> renderings {
131
+ doc
132
+ /*
133
+ * asTreeDiagram renders a View as a tree diagram, using the
134
+ * graphical notation defined in the SysML specification.
135
+ */
136
+ }
137
+
138
+ rendering asInterconnectionDiagram : GraphicalRendering[1] :> renderings {
139
+ doc
140
+ /*
141
+ * asInterconnectionDiagram renders a View as an interconnection
142
+ * diagram, using the graphical notation defined in the SysML specification.
143
+ */
144
+ }
145
+
146
+ rendering asElementTable : TabularRendering[1] :> renderings {
147
+ doc
148
+ /*
149
+ * asElementTable renders a View as a table, with one row for each exposed
150
+ * Element and columns rendered by applying the columnViews in order to the
151
+ * Element in each row.
152
+ */
153
+
154
+ view columnView[0..*] ordered {
155
+ doc
156
+ /*
157
+ * The Views to be rendered in the column cells, in order, of each rows of the table.
158
+ */
159
+
160
+ abstract ref rendering :>> viewRendering[0..1];
161
+ }
162
+ rendering :>> subrenderings[0..*] = columnView.viewRendering;
163
+ }
164
+ }
sysmlpy/navigate.py ADDED
@@ -0,0 +1,272 @@
1
+ """
2
+ sysmlpy.navigate
3
+ ~~~~~~~~~~~~~~~~~
4
+
5
+ Provides the :class:`Searchable` mixin that adds typed property accessors
6
+ and ``find()`` / ``all()`` search methods to :class:`~sysmlpy.definition.Model`,
7
+ :class:`~sysmlpy.definition.Package`, and every
8
+ :class:`~sysmlpy.usage.Usage` subclass.
9
+
10
+ Usage
11
+ -----
12
+ After parsing, every node in the public-API tree supports::
13
+
14
+ model.packages # direct Package children
15
+ model.parts # direct Part children (defs + usages)
16
+ model.actions # direct Action children
17
+
18
+ model.find('Focus') # by name, any depth
19
+ model.find(type='action') # by type keyword, any depth
20
+ model.find('Focus', type='action') # name + type
21
+ model.find(type=Action) # by class
22
+ model.find('Focus', recursive=False) # direct children only
23
+
24
+ model.all('part') # shorthand for find(type='part')
25
+
26
+ Type strings
27
+ ------------
28
+ Each public-API class carries a ``sysml_type`` class attribute:
29
+
30
+ ====================== =============
31
+ Class sysml_type
32
+ ====================== =============
33
+ Package ``'package'``
34
+ Part ``'part'``
35
+ Item ``'item'``
36
+ Attribute ``'attribute'``
37
+ Port ``'port'``
38
+ Action ``'action'``
39
+ State ``'state'``
40
+ Constraint ``'constraint'``
41
+ Calculation ``'calculation'``
42
+ Requirement ``'requirement'``
43
+ Connection ``'connection'``
44
+ Flow ``'flow'``
45
+ Enumeration ``'enumeration'``
46
+ Interface ``'interface'``
47
+ UseCase ``'use_case'``
48
+ Reference ``'reference'``
49
+ Message ``'message'``
50
+ Allocation ``'allocation'``
51
+ Metadata ``'metadata'``
52
+ Rendering ``'rendering'``
53
+ Individual ``'individual'``
54
+ View ``'view'``
55
+ Viewpoint ``'viewpoint'``
56
+ Concern ``'concern'``
57
+ Case ``'case'``
58
+ AnalysisCase ``'analysis'``
59
+ VerificationCase ``'verification'``
60
+ ====================== =============
61
+ """
62
+
63
+
64
+ class Searchable:
65
+ """Mixin that adds typed property accessors and search helpers.
66
+
67
+ Classes that mix this in must expose a ``children`` list whose elements
68
+ may themselves carry a ``sysml_type`` string attribute (and optionally
69
+ their own ``find`` method for recursive search).
70
+ """
71
+
72
+ # ------------------------------------------------------------------
73
+ # Internal helper
74
+ # ------------------------------------------------------------------
75
+
76
+ def _children_of_type(self, *sysml_types):
77
+ """Return direct children whose ``sysml_type`` is in *sysml_types*."""
78
+ return [
79
+ c for c in getattr(self, "children", [])
80
+ if getattr(c, "sysml_type", None) in sysml_types
81
+ ]
82
+
83
+ # ------------------------------------------------------------------
84
+ # Typed property accessors (direct children only)
85
+ # ------------------------------------------------------------------
86
+
87
+ @property
88
+ def packages(self):
89
+ """Direct :class:`~sysmlpy.definition.Package` children."""
90
+ return self._children_of_type("package")
91
+
92
+ @property
93
+ def parts(self):
94
+ """Direct :class:`~sysmlpy.usage.Part` children (definitions and usages)."""
95
+ return self._children_of_type("part")
96
+
97
+ @property
98
+ def items(self):
99
+ """Direct :class:`~sysmlpy.usage.Item` children (definitions and usages)."""
100
+ return self._children_of_type("item")
101
+
102
+ @property
103
+ def attributes(self):
104
+ """Direct :class:`~sysmlpy.usage.Attribute` children (definitions and usages)."""
105
+ return self._children_of_type("attribute")
106
+
107
+ @property
108
+ def ports(self):
109
+ """Direct :class:`~sysmlpy.usage.Port` children (definitions and usages)."""
110
+ return self._children_of_type("port")
111
+
112
+ @property
113
+ def actions(self):
114
+ """Direct :class:`~sysmlpy.usage.Action` children (definitions and usages)."""
115
+ return self._children_of_type("action")
116
+
117
+ @property
118
+ def states(self):
119
+ """Direct :class:`~sysmlpy.usage.State` children (definitions and usages)."""
120
+ return self._children_of_type("state")
121
+
122
+ @property
123
+ def constraints(self):
124
+ """Direct :class:`~sysmlpy.usage.Constraint` children (definitions and usages)."""
125
+ return self._children_of_type("constraint")
126
+
127
+ @property
128
+ def calculations(self):
129
+ """Direct :class:`~sysmlpy.usage.Calculation` children (definitions and usages)."""
130
+ return self._children_of_type("calculation")
131
+
132
+ @property
133
+ def requirements(self):
134
+ """Direct :class:`~sysmlpy.usage.Requirement` children (definitions and usages)."""
135
+ return self._children_of_type("requirement")
136
+
137
+ @property
138
+ def connections(self):
139
+ """Direct :class:`~sysmlpy.usage.Connection` children (definitions and usages)."""
140
+ return self._children_of_type("connection")
141
+
142
+ @property
143
+ def flows(self):
144
+ """Direct :class:`~sysmlpy.usage.Flow` children (definitions and usages)."""
145
+ return self._children_of_type("flow")
146
+
147
+ @property
148
+ def enumerations(self):
149
+ """Direct :class:`~sysmlpy.usage.Enumeration` children."""
150
+ return self._children_of_type("enumeration")
151
+
152
+ @property
153
+ def interfaces(self):
154
+ """Direct :class:`~sysmlpy.usage.Interface` children (definitions and usages)."""
155
+ return self._children_of_type("interface")
156
+
157
+ @property
158
+ def use_cases(self):
159
+ """Direct :class:`~sysmlpy.usage.UseCase` children (definitions and usages)."""
160
+ return self._children_of_type("use_case")
161
+
162
+ @property
163
+ def references(self):
164
+ """Direct :class:`~sysmlpy.usage.Reference` children."""
165
+ return self._children_of_type("reference")
166
+
167
+ @property
168
+ def messages(self):
169
+ """Direct :class:`~sysmlpy.usage.Message` children."""
170
+ return self._children_of_type("message")
171
+
172
+ @property
173
+ def allocations(self):
174
+ """Direct :class:`~sysmlpy.usage.Allocation` children (definitions and usages)."""
175
+ return self._children_of_type("allocation")
176
+
177
+ @property
178
+ def views(self):
179
+ """Direct :class:`~sysmlpy.usage.View` children (definitions and usages)."""
180
+ return self._children_of_type("view")
181
+
182
+ @property
183
+ def viewpoints(self):
184
+ """Direct :class:`~sysmlpy.usage.Viewpoint` children (definitions and usages)."""
185
+ return self._children_of_type("viewpoint")
186
+
187
+ # ------------------------------------------------------------------
188
+ # Search methods
189
+ # ------------------------------------------------------------------
190
+
191
+ def find(self, name=None, *, type=None, recursive=True):
192
+ """Find model elements by name and/or SysML type.
193
+
194
+ Parameters
195
+ ----------
196
+ name : str, optional
197
+ Declared element name to match exactly. ``None`` matches any name.
198
+ type : str or class, optional
199
+ SysML type to filter by. Pass a string keyword (``'part'``,
200
+ ``'action'``, …) or the corresponding class (``Part``,
201
+ ``Action``, …). ``None`` matches any type.
202
+ recursive : bool
203
+ When ``True`` (default) the search descends recursively into
204
+ every child that itself exposes a ``find`` method.
205
+
206
+ Returns
207
+ -------
208
+ list
209
+ Matching elements. Returns an empty list when nothing is found.
210
+
211
+ Examples
212
+ --------
213
+ Find all elements named ``'Focus'`` anywhere in the tree::
214
+
215
+ model.find('Focus')
216
+
217
+ Find every action, top-level only::
218
+
219
+ model.find(type='action', recursive=False)
220
+
221
+ Find by class instead of string::
222
+
223
+ from sysmlpy import Part
224
+ model.find(type=Part)
225
+
226
+ Combine name and type::
227
+
228
+ model.find('engine', type='part')
229
+ """
230
+ results = []
231
+ for child in getattr(self, "children", []):
232
+ # --- name gate ---
233
+ if name is not None and getattr(child, "name", None) != name:
234
+ name_ok = False
235
+ else:
236
+ name_ok = True
237
+
238
+ # --- type gate ---
239
+ if type is None:
240
+ type_ok = True
241
+ elif isinstance(type, str):
242
+ type_ok = getattr(child, "sysml_type", None) == type
243
+ else:
244
+ type_ok = isinstance(child, type)
245
+
246
+ if name_ok and type_ok:
247
+ results.append(child)
248
+
249
+ # --- recurse ---
250
+ if recursive and hasattr(child, "find"):
251
+ results.extend(child.find(name=name, type=type, recursive=True))
252
+
253
+ return results
254
+
255
+ def all(self, type, recursive=True):
256
+ """Return all elements of *type*, searching recursively by default.
257
+
258
+ This is a convenience alias for ``find(type=type, recursive=recursive)``.
259
+
260
+ Parameters
261
+ ----------
262
+ type : str or class
263
+ SysML type string (``'part'``, ``'action'``, …) or the
264
+ corresponding class.
265
+ recursive : bool
266
+ When ``True`` (default) the search descends into every child.
267
+
268
+ Returns
269
+ -------
270
+ list
271
+ """
272
+ return self.find(type=type, recursive=recursive)