sysmlpy 0.1.0__tar.gz

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 (142) hide show
  1. sysmlpy-0.1.0/LICENSE +21 -0
  2. sysmlpy-0.1.0/PKG-INFO +230 -0
  3. sysmlpy-0.1.0/README.md +187 -0
  4. sysmlpy-0.1.0/pyproject.toml +136 -0
  5. sysmlpy-0.1.0/src/sysmlpy/__init__.py +226 -0
  6. sysmlpy-0.1.0/src/sysmlpy/__main__.py +75 -0
  7. sysmlpy-0.1.0/src/sysmlpy/antlr/README.md +146 -0
  8. sysmlpy-0.1.0/src/sysmlpy/antlr/SysMLv2Lexer.interp +695 -0
  9. sysmlpy-0.1.0/src/sysmlpy/antlr/SysMLv2Lexer.py +1123 -0
  10. sysmlpy-0.1.0/src/sysmlpy/antlr/SysMLv2Lexer.tokens +444 -0
  11. sysmlpy-0.1.0/src/sysmlpy/antlr/SysMLv2Parser.interp +960 -0
  12. sysmlpy-0.1.0/src/sysmlpy/antlr/SysMLv2Parser.py +40750 -0
  13. sysmlpy-0.1.0/src/sysmlpy/antlr/SysMLv2Parser.tokens +444 -0
  14. sysmlpy-0.1.0/src/sysmlpy/antlr/SysMLv2ParserListener.py +4485 -0
  15. sysmlpy-0.1.0/src/sysmlpy/antlr/SysMLv2ParserVisitor.py +2498 -0
  16. sysmlpy-0.1.0/src/sysmlpy/antlr/src/sysmlpy/grammar/antlr4/SysMLv2Lexer.interp +695 -0
  17. sysmlpy-0.1.0/src/sysmlpy/antlr/src/sysmlpy/grammar/antlr4/SysMLv2Lexer.py +1123 -0
  18. sysmlpy-0.1.0/src/sysmlpy/antlr/src/sysmlpy/grammar/antlr4/SysMLv2Lexer.tokens +444 -0
  19. sysmlpy-0.1.0/src/sysmlpy/antlr_parser.py +185 -0
  20. sysmlpy-0.1.0/src/sysmlpy/antlr_visitor.py +10864 -0
  21. sysmlpy-0.1.0/src/sysmlpy/definition.py +1115 -0
  22. sysmlpy-0.1.0/src/sysmlpy/examples/attribute_values.py +161 -0
  23. sysmlpy-0.1.0/src/sysmlpy/examples/part_attributes.py +139 -0
  24. sysmlpy-0.1.0/src/sysmlpy/examples/tuples_sequences.py +231 -0
  25. sysmlpy-0.1.0/src/sysmlpy/formatting.py +47 -0
  26. sysmlpy-0.1.0/src/sysmlpy/grammar/antlr4/README.md +30 -0
  27. sysmlpy-0.1.0/src/sysmlpy/grammar/antlr4/SysMLv2Lexer.g4 +931 -0
  28. sysmlpy-0.1.0/src/sysmlpy/grammar/antlr4/SysMLv2Lexer.interp +695 -0
  29. sysmlpy-0.1.0/src/sysmlpy/grammar/antlr4/SysMLv2Lexer.py +1123 -0
  30. sysmlpy-0.1.0/src/sysmlpy/grammar/antlr4/SysMLv2Lexer.tokens +444 -0
  31. sysmlpy-0.1.0/src/sysmlpy/grammar/antlr4/SysMLv2Parser.g4 +2432 -0
  32. sysmlpy-0.1.0/src/sysmlpy/grammar/antlr4/SysMLv2Parser.interp +960 -0
  33. sysmlpy-0.1.0/src/sysmlpy/grammar/antlr4/SysMLv2Parser.py +40750 -0
  34. sysmlpy-0.1.0/src/sysmlpy/grammar/antlr4/SysMLv2Parser.tokens +444 -0
  35. sysmlpy-0.1.0/src/sysmlpy/grammar/antlr4/SysMLv2ParserListener.py +4485 -0
  36. sysmlpy-0.1.0/src/sysmlpy/grammar/antlr4/SysMLv2ParserVisitor.py +2498 -0
  37. sysmlpy-0.1.0/src/sysmlpy/grammar/antlr4/desc.xml +7 -0
  38. sysmlpy-0.1.0/src/sysmlpy/grammar/antlr4/examples/camera.sysml +14 -0
  39. sysmlpy-0.1.0/src/sysmlpy/grammar/antlr4/examples/toaster-system.sysml +193 -0
  40. sysmlpy-0.1.0/src/sysmlpy/grammar/antlr4/examples/vehicle-model.sysml +118 -0
  41. sysmlpy-0.1.0/src/sysmlpy/grammar/antlr4/pom.xml +59 -0
  42. sysmlpy-0.1.0/src/sysmlpy/grammar/classes.py +8610 -0
  43. sysmlpy-0.1.0/src/sysmlpy/library/LICENSE +165 -0
  44. sysmlpy-0.1.0/src/sysmlpy/library/README.md +52 -0
  45. sysmlpy-0.1.0/src/sysmlpy/library/__init__.py +0 -0
  46. sysmlpy-0.1.0/src/sysmlpy/library/domain/Analysis/AnalysisTooling.sysml +34 -0
  47. sysmlpy-0.1.0/src/sysmlpy/library/domain/Analysis/SampledFunctions.sysml +119 -0
  48. sysmlpy-0.1.0/src/sysmlpy/library/domain/Analysis/StateSpaceRepresentation.sysml +143 -0
  49. sysmlpy-0.1.0/src/sysmlpy/library/domain/Analysis/TradeStudies.sysml +171 -0
  50. sysmlpy-0.1.0/src/sysmlpy/library/domain/Cause and Effect/CausationConnections.sysml +83 -0
  51. sysmlpy-0.1.0/src/sysmlpy/library/domain/Cause and Effect/CauseAndEffect.sysml +81 -0
  52. sysmlpy-0.1.0/src/sysmlpy/library/domain/Geometry/ShapeItems.sysml +899 -0
  53. sysmlpy-0.1.0/src/sysmlpy/library/domain/Geometry/SpatialItems.sysml +168 -0
  54. sysmlpy-0.1.0/src/sysmlpy/library/domain/Metadata/ImageMetadata.sysml +78 -0
  55. sysmlpy-0.1.0/src/sysmlpy/library/domain/Metadata/ModelingMetadata.sysml +143 -0
  56. sysmlpy-0.1.0/src/sysmlpy/library/domain/Metadata/ParametersOfInterestMetadata.sysml +39 -0
  57. sysmlpy-0.1.0/src/sysmlpy/library/domain/Metadata/RiskMetadata.sysml +100 -0
  58. sysmlpy-0.1.0/src/sysmlpy/library/domain/Quantities and Units/ISQ.sysml +42 -0
  59. sysmlpy-0.1.0/src/sysmlpy/library/domain/Quantities and Units/ISQAcoustics.sysml +439 -0
  60. sysmlpy-0.1.0/src/sysmlpy/library/domain/Quantities and Units/ISQAtomicNuclear.sysml +2726 -0
  61. sysmlpy-0.1.0/src/sysmlpy/library/domain/Quantities and Units/ISQBase.sysml +206 -0
  62. sysmlpy-0.1.0/src/sysmlpy/library/domain/Quantities and Units/ISQCharacteristicNumbers.sysml +1991 -0
  63. sysmlpy-0.1.0/src/sysmlpy/library/domain/Quantities and Units/ISQChemistryMolecular.sysml +1353 -0
  64. sysmlpy-0.1.0/src/sysmlpy/library/domain/Quantities and Units/ISQCondensedMatter.sysml +1223 -0
  65. sysmlpy-0.1.0/src/sysmlpy/library/domain/Quantities and Units/ISQElectromagnetism.sysml +2333 -0
  66. sysmlpy-0.1.0/src/sysmlpy/library/domain/Quantities and Units/ISQInformation.sysml +958 -0
  67. sysmlpy-0.1.0/src/sysmlpy/library/domain/Quantities and Units/ISQLight.sysml +1537 -0
  68. sysmlpy-0.1.0/src/sysmlpy/library/domain/Quantities and Units/ISQMechanics.sysml +1564 -0
  69. sysmlpy-0.1.0/src/sysmlpy/library/domain/Quantities and Units/ISQSpaceTime.sysml +1169 -0
  70. sysmlpy-0.1.0/src/sysmlpy/library/domain/Quantities and Units/ISQThermodynamics.sysml +1256 -0
  71. sysmlpy-0.1.0/src/sysmlpy/library/domain/Quantities and Units/MeasurementRefCalculations.sysml +30 -0
  72. sysmlpy-0.1.0/src/sysmlpy/library/domain/Quantities and Units/MeasurementReferences.sysml +526 -0
  73. sysmlpy-0.1.0/src/sysmlpy/library/domain/Quantities and Units/Quantities.sysml +107 -0
  74. sysmlpy-0.1.0/src/sysmlpy/library/domain/Quantities and Units/QuantityCalculations.sysml +70 -0
  75. sysmlpy-0.1.0/src/sysmlpy/library/domain/Quantities and Units/SI.sysml +378 -0
  76. sysmlpy-0.1.0/src/sysmlpy/library/domain/Quantities and Units/SIPrefixes.sysml +48 -0
  77. sysmlpy-0.1.0/src/sysmlpy/library/domain/Quantities and Units/TensorCalculations.sysml +50 -0
  78. sysmlpy-0.1.0/src/sysmlpy/library/domain/Quantities and Units/Time.sysml +274 -0
  79. sysmlpy-0.1.0/src/sysmlpy/library/domain/Quantities and Units/USCustomaryUnits.sysml +260 -0
  80. sysmlpy-0.1.0/src/sysmlpy/library/domain/Quantities and Units/VectorCalculations.sysml +62 -0
  81. sysmlpy-0.1.0/src/sysmlpy/library/domain/Requirement Derivation/DerivationConnections.sysml +63 -0
  82. sysmlpy-0.1.0/src/sysmlpy/library/domain/Requirement Derivation/RequirementDerivation.sysml +39 -0
  83. sysmlpy-0.1.0/src/sysmlpy/library/kernel/Base.kerml +95 -0
  84. sysmlpy-0.1.0/src/sysmlpy/library/kernel/BaseFunctions.kerml +80 -0
  85. sysmlpy-0.1.0/src/sysmlpy/library/kernel/BooleanFunctions.kerml +22 -0
  86. sysmlpy-0.1.0/src/sysmlpy/library/kernel/Clocks.kerml +156 -0
  87. sysmlpy-0.1.0/src/sysmlpy/library/kernel/CollectionFunctions.kerml +68 -0
  88. sysmlpy-0.1.0/src/sysmlpy/library/kernel/Collections.kerml +147 -0
  89. sysmlpy-0.1.0/src/sysmlpy/library/kernel/ComplexFunctions.kerml +47 -0
  90. sysmlpy-0.1.0/src/sysmlpy/library/kernel/ControlFunctions.kerml +117 -0
  91. sysmlpy-0.1.0/src/sysmlpy/library/kernel/ControlPerformances.kerml +135 -0
  92. sysmlpy-0.1.0/src/sysmlpy/library/kernel/DataFunctions.kerml +43 -0
  93. sysmlpy-0.1.0/src/sysmlpy/library/kernel/FeatureReferencingPerformances.kerml +190 -0
  94. sysmlpy-0.1.0/src/sysmlpy/library/kernel/IntegerFunctions.kerml +43 -0
  95. sysmlpy-0.1.0/src/sysmlpy/library/kernel/KerML.kerml +483 -0
  96. sysmlpy-0.1.0/src/sysmlpy/library/kernel/Links.kerml +67 -0
  97. sysmlpy-0.1.0/src/sysmlpy/library/kernel/Metaobjects.kerml +58 -0
  98. sysmlpy-0.1.0/src/sysmlpy/library/kernel/NaturalFunctions.kerml +27 -0
  99. sysmlpy-0.1.0/src/sysmlpy/library/kernel/NumericalFunctions.kerml +43 -0
  100. sysmlpy-0.1.0/src/sysmlpy/library/kernel/Objects.kerml +212 -0
  101. sysmlpy-0.1.0/src/sysmlpy/library/kernel/Observation.kerml +161 -0
  102. sysmlpy-0.1.0/src/sysmlpy/library/kernel/OccurrenceFunctions.kerml +154 -0
  103. sysmlpy-0.1.0/src/sysmlpy/library/kernel/Occurrences.kerml +992 -0
  104. sysmlpy-0.1.0/src/sysmlpy/library/kernel/Performances.kerml +293 -0
  105. sysmlpy-0.1.0/src/sysmlpy/library/kernel/RationalFunctions.kerml +49 -0
  106. sysmlpy-0.1.0/src/sysmlpy/library/kernel/RealFunctions.kerml +56 -0
  107. sysmlpy-0.1.0/src/sysmlpy/library/kernel/ScalarFunctions.kerml +33 -0
  108. sysmlpy-0.1.0/src/sysmlpy/library/kernel/ScalarValues.kerml +23 -0
  109. sysmlpy-0.1.0/src/sysmlpy/library/kernel/SequenceFunctions.kerml +111 -0
  110. sysmlpy-0.1.0/src/sysmlpy/library/kernel/SpatialFrames.kerml +197 -0
  111. sysmlpy-0.1.0/src/sysmlpy/library/kernel/StatePerformances.kerml +145 -0
  112. sysmlpy-0.1.0/src/sysmlpy/library/kernel/StringFunctions.kerml +25 -0
  113. sysmlpy-0.1.0/src/sysmlpy/library/kernel/Transfers.kerml +281 -0
  114. sysmlpy-0.1.0/src/sysmlpy/library/kernel/TransitionPerformances.kerml +66 -0
  115. sysmlpy-0.1.0/src/sysmlpy/library/kernel/TrigFunctions.kerml +35 -0
  116. sysmlpy-0.1.0/src/sysmlpy/library/kernel/Triggers.kerml +188 -0
  117. sysmlpy-0.1.0/src/sysmlpy/library/kernel/VectorFunctions.kerml +273 -0
  118. sysmlpy-0.1.0/src/sysmlpy/library/kernel/VectorValues.kerml +64 -0
  119. sysmlpy-0.1.0/src/sysmlpy/library/systems/Actions.sysml +552 -0
  120. sysmlpy-0.1.0/src/sysmlpy/library/systems/Allocations.sysml +29 -0
  121. sysmlpy-0.1.0/src/sysmlpy/library/systems/AnalysisCases.sysml +38 -0
  122. sysmlpy-0.1.0/src/sysmlpy/library/systems/Attributes.sysml +25 -0
  123. sysmlpy-0.1.0/src/sysmlpy/library/systems/Calculations.sysml +37 -0
  124. sysmlpy-0.1.0/src/sysmlpy/library/systems/Cases.sysml +71 -0
  125. sysmlpy-0.1.0/src/sysmlpy/library/systems/Connections.sysml +60 -0
  126. sysmlpy-0.1.0/src/sysmlpy/library/systems/Constraints.sysml +44 -0
  127. sysmlpy-0.1.0/src/sysmlpy/library/systems/Flows.sysml +126 -0
  128. sysmlpy-0.1.0/src/sysmlpy/library/systems/Interfaces.sysml +89 -0
  129. sysmlpy-0.1.0/src/sysmlpy/library/systems/Items.sysml +153 -0
  130. sysmlpy-0.1.0/src/sysmlpy/library/systems/Metadata.sysml +32 -0
  131. sysmlpy-0.1.0/src/sysmlpy/library/systems/Parts.sysml +81 -0
  132. sysmlpy-0.1.0/src/sysmlpy/library/systems/Ports.sysml +54 -0
  133. sysmlpy-0.1.0/src/sysmlpy/library/systems/Requirements.sysml +194 -0
  134. sysmlpy-0.1.0/src/sysmlpy/library/systems/StandardViewDefinitions.sysml +123 -0
  135. sysmlpy-0.1.0/src/sysmlpy/library/systems/States.sysml +103 -0
  136. sysmlpy-0.1.0/src/sysmlpy/library/systems/SysML.sysml +539 -0
  137. sysmlpy-0.1.0/src/sysmlpy/library/systems/UseCases.sysml +57 -0
  138. sysmlpy-0.1.0/src/sysmlpy/library/systems/VerificationCases.sysml +103 -0
  139. sysmlpy-0.1.0/src/sysmlpy/library/systems/Views.sysml +164 -0
  140. sysmlpy-0.1.0/src/sysmlpy/navigate.py +272 -0
  141. sysmlpy-0.1.0/src/sysmlpy/store.py +547 -0
  142. sysmlpy-0.1.0/src/sysmlpy/usage.py +2978 -0
sysmlpy-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Westfall-io
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
sysmlpy-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,230 @@
1
+ Metadata-Version: 2.4
2
+ Name: sysmlpy
3
+ Version: 0.1.0
4
+ Summary: SysML v2.0 Parser
5
+ License: MIT License
6
+
7
+ Copyright (c) 2023 Westfall-io
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the "Software"), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in all
17
+ copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ SOFTWARE.
26
+ License-File: LICENSE
27
+ Author: Jon R. Fox (mycr0ft)
28
+ Author-email: jon.fox@drfox.com
29
+ Requires-Python: >=3.7
30
+ Classifier: Development Status :: 3 - Alpha
31
+ Classifier: Programming Language :: Python :: 3
32
+ Classifier: License :: OSI Approved :: MIT License
33
+ Classifier: Operating System :: OS Independent
34
+ Provides-Extra: graph
35
+ Requires-Dist: antlr4-python3-runtime (>=4.13)
36
+ Requires-Dist: networkx (>=3.0) ; extra == "graph"
37
+ Requires-Dist: pint (>=0.24)
38
+ Requires-Dist: pyyaml (>=6.0)
39
+ Project-URL: Bug Tracker, https://github.com/Westfall-io/sysmlpy/issues
40
+ Project-URL: Homepage, https://github.com/Westfall-io/sysmlpy
41
+ Description-Content-Type: text/markdown
42
+
43
+ # sysmlpy
44
+ [![PyPI version](https://badge.fury.io/py/sysmlpy.svg)](https://badge.fury.io/py/sysmlpy)[![PyPI status](https://img.shields.io/pypi/status/sysmlpy.svg)](https://pypi.python.org/pypi/sysmlpy/)[![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://lbesson.mit-license.org/)
45
+
46
+ ## Description
47
+ sysmlpy is an open source pure Python library for constructing python-based
48
+ classes consistent with the [SysML v2.0 standard](https://github.com/Systems-Modeling/SysML-v2-Release).
49
+
50
+ This project began as a fork of the sysml2py project by [Christopher
51
+ Cox](https://github.com/chriscox-westfall). Since April 2026 [Jon Fox](mailto:jon.fox@drfox.com)
52
+ decided to complete coverage of all SysMLv2 features over two months of weekends,
53
+ and dropped the textX parser in favor of [an ANTLR4 parser grammar](https://github.com/daltskin/sysml-v2-grammar) and
54
+ changed our unit library to pint.
55
+ The project had diverged so much from sysml2py that a new name, sysmlpy, was selected.
56
+
57
+ ![Lines of Code Over Time](loc_history.svg)
58
+
59
+ **v0.12.0:** 100% conformance test pass rate (123/123). Storage abstraction layer with in-memory and NetworkX graph backends. Convenience functions: find_all, count, traverse, to_dict, to_graph, path_between.
60
+
61
+ ## Requirements
62
+ sysmlpy requires the following Python packages:
63
+ - [pyyaml](https://github.com/yaml/pyyaml)
64
+ - [pint](https://github.com/hgrecco/pint)
65
+ - [antlr4-python3-runtime](https://github.com/antlr/antlr4)
66
+
67
+ ### Optional Dependencies
68
+ - [networkx](https://networkx.org/) — graph analysis backend (install with `pip install sysmlpy[graph]`)
69
+
70
+ ## Installation
71
+
72
+ Multiple installation methods are supported by sysmlpy, including:
73
+
74
+ | **Logo** | **Platform** | **Command** |
75
+ |:-----------------------------------------------------------------:|:------------:|:---------------------------------------------------------------------------------:|
76
+ | ![PyPI logo](https://simpleicons.org/icons/pypi.svg) | PyPI | ``python -m pip install sysmlpy`` |
77
+ | ![PyPI logo](https://simpleicons.org/icons/pypi.svg) | PyPI | ``python -m pip install sysmlpy[graph]`` (with graph analysis) |
78
+ | ![GitHub logo](https://simpleicons.org/icons/github.svg) | GitHub | ``python -m pip install https://github.com/mycr0ft/sysmlpy/archive/refs/heads/main.zip`` |
79
+
80
+ ## Documentation
81
+
82
+ Documentation can be found [here.](https://mycr0ft.github.io/sysmlpy/)
83
+
84
+ ### Basic Usage
85
+
86
+ The code below will create a part called Stage 1, with a shortname of <'3.1'>
87
+ referencing a specific requirement or document. It has a mass attribute of 100
88
+ kg. It has a thrust attribute of 1000 N. These attributes are created and placed
89
+ as a child of the part. Next, we recall the part value for thrust and add 199 N.
90
+ Finally, we can dump the output from this class.
91
+ ```
92
+ from sysmlpy import Attribute, Part, ureg
93
+
94
+ a = Attribute(name='mass')
95
+ a.set_value(100 * ureg.kilogram)
96
+ b = Attribute(name='thrust')
97
+ b.set_value(1000 * ureg.newton)
98
+ c = Part(name="Stage_1", shortname="'3.1'")
99
+ c._set_child(a)
100
+ c._set_child(b)
101
+ v = "Stage_1.thrust"
102
+ c._get_child(v).set_value(c._get_child(v).get_value() + 199 * ureg.newton)
103
+ print(c.dump())
104
+ ```
105
+
106
+ It will output the following:
107
+ ```
108
+ part <'3.1'> Stage_1 {
109
+ attribute mass= 100 [kilogram];
110
+ attribute thrust= 1199.0 [newton];
111
+ }
112
+ ```
113
+
114
+ The package is able to handle Items, Parts, and Attributes.
115
+
116
+ ```
117
+ a = Part(name='camera')
118
+ b = Item(name='lens')
119
+ d = Attribute(name='mass')
120
+ c = Part(name='sensor')
121
+ c._set_child(a)
122
+ c._set_child(b)
123
+ a._set_child(d)
124
+ print(c.dump())
125
+ ```
126
+
127
+ will return:
128
+ ```
129
+ part sensor {
130
+ part camera {
131
+ attribute mass;
132
+ }
133
+ item lens;
134
+ }
135
+ ```
136
+
137
+ Actions
138
+ -------
139
+
140
+ Actions (activities) can be defined with input and output parameters::
141
+
142
+ ```
143
+ from sysmlpy import Action
144
+
145
+ # Action definition with typed inputs/outputs
146
+ a = Action(definition=True, name='Focus')
147
+ a.add_input('scene', 'Scene')
148
+ a.add_output('image', 'Image')
149
+ print(a.dump())
150
+ # → action def Focus { in scene : Scene; out image : Image; }
151
+
152
+ # Action usage with references
153
+ b = Action(name='TakePicture')
154
+ b.add_input('scene')
155
+ b.add_output('picture')
156
+ print(b.dump())
157
+ # → action TakePicture { in scene; out picture; }
158
+ ```
159
+
160
+ References
161
+ ----------
162
+
163
+ References can reference other elements::
164
+
165
+ ```
166
+ from sysmlpy import Reference, Item
167
+
168
+ # Simple reference
169
+ r = Reference(name='driver')
170
+ print(r.dump())
171
+ # → ref driver;
172
+
173
+ # Reference with type
174
+ person = Item(name='Person')
175
+ r2 = Reference(name='driver')
176
+ r2.set_type(person)
177
+ print(r2.dump())
178
+ # → ref driver : Person;
179
+
180
+ # Reference redefinition
181
+ r3 = Reference(name='payload', redefines=True)
182
+ r3.set_type(person)
183
+ print(r3.dump())
184
+ # → ref :>> payload : Person;
185
+ ```
186
+
187
+ ## Grammar Round-Trip
188
+
189
+ `loads()` parses SysML v2 text and `classtree()` converts the result back to text. This round-trip is the basis for the grammar test suite.
190
+
191
+ ```python
192
+ from sysmlpy import loads
193
+ from sysmlpy.formatting import classtree
194
+
195
+ text = """package 'Action Example' {
196
+ action def Focus { in scene : Scene; out image : Image; }
197
+ action def Shoot { in image: Image; out picture : Picture; }
198
+
199
+ action def TakePicture {
200
+ in item scene : Scene;
201
+ out item picture : Picture;
202
+
203
+ bind focus.scene = scene;
204
+
205
+ action focus : Focus { in scene; out image; }
206
+
207
+ flow focus.image to shoot.image;
208
+
209
+ first focus then shoot;
210
+
211
+ action shoot : Shoot { in image; out picture; }
212
+
213
+ bind shoot.picture = picture;
214
+ }
215
+ }"""
216
+
217
+ model = loads(text)
218
+ tree = classtree(model)
219
+ print(tree.dump())
220
+ ```
221
+
222
+ **61% of the 56 grammar round-trip tests currently pass** (34/56), covering packages, parts, items, ports, interfaces, binding connectors, flow connections, all action forms (definition, shorthand, succession, decomposition), expressions, calculations, and constraints.
223
+
224
+ ## Conformance
225
+
226
+ **100% of 123 OMG XPect conformance tests pass** (123/123).
227
+
228
+ ## License
229
+ sysmlpy is released under the MIT license, hence allowing commercial use of the library.
230
+
@@ -0,0 +1,187 @@
1
+ # sysmlpy
2
+ [![PyPI version](https://badge.fury.io/py/sysmlpy.svg)](https://badge.fury.io/py/sysmlpy)[![PyPI status](https://img.shields.io/pypi/status/sysmlpy.svg)](https://pypi.python.org/pypi/sysmlpy/)[![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://lbesson.mit-license.org/)
3
+
4
+ ## Description
5
+ sysmlpy is an open source pure Python library for constructing python-based
6
+ classes consistent with the [SysML v2.0 standard](https://github.com/Systems-Modeling/SysML-v2-Release).
7
+
8
+ This project began as a fork of the sysml2py project by [Christopher
9
+ Cox](https://github.com/chriscox-westfall). Since April 2026 [Jon Fox](mailto:jon.fox@drfox.com)
10
+ decided to complete coverage of all SysMLv2 features over two months of weekends,
11
+ and dropped the textX parser in favor of [an ANTLR4 parser grammar](https://github.com/daltskin/sysml-v2-grammar) and
12
+ changed our unit library to pint.
13
+ The project had diverged so much from sysml2py that a new name, sysmlpy, was selected.
14
+
15
+ ![Lines of Code Over Time](loc_history.svg)
16
+
17
+ **v0.12.0:** 100% conformance test pass rate (123/123). Storage abstraction layer with in-memory and NetworkX graph backends. Convenience functions: find_all, count, traverse, to_dict, to_graph, path_between.
18
+
19
+ ## Requirements
20
+ sysmlpy requires the following Python packages:
21
+ - [pyyaml](https://github.com/yaml/pyyaml)
22
+ - [pint](https://github.com/hgrecco/pint)
23
+ - [antlr4-python3-runtime](https://github.com/antlr/antlr4)
24
+
25
+ ### Optional Dependencies
26
+ - [networkx](https://networkx.org/) — graph analysis backend (install with `pip install sysmlpy[graph]`)
27
+
28
+ ## Installation
29
+
30
+ Multiple installation methods are supported by sysmlpy, including:
31
+
32
+ | **Logo** | **Platform** | **Command** |
33
+ |:-----------------------------------------------------------------:|:------------:|:---------------------------------------------------------------------------------:|
34
+ | ![PyPI logo](https://simpleicons.org/icons/pypi.svg) | PyPI | ``python -m pip install sysmlpy`` |
35
+ | ![PyPI logo](https://simpleicons.org/icons/pypi.svg) | PyPI | ``python -m pip install sysmlpy[graph]`` (with graph analysis) |
36
+ | ![GitHub logo](https://simpleicons.org/icons/github.svg) | GitHub | ``python -m pip install https://github.com/mycr0ft/sysmlpy/archive/refs/heads/main.zip`` |
37
+
38
+ ## Documentation
39
+
40
+ Documentation can be found [here.](https://mycr0ft.github.io/sysmlpy/)
41
+
42
+ ### Basic Usage
43
+
44
+ The code below will create a part called Stage 1, with a shortname of <'3.1'>
45
+ referencing a specific requirement or document. It has a mass attribute of 100
46
+ kg. It has a thrust attribute of 1000 N. These attributes are created and placed
47
+ as a child of the part. Next, we recall the part value for thrust and add 199 N.
48
+ Finally, we can dump the output from this class.
49
+ ```
50
+ from sysmlpy import Attribute, Part, ureg
51
+
52
+ a = Attribute(name='mass')
53
+ a.set_value(100 * ureg.kilogram)
54
+ b = Attribute(name='thrust')
55
+ b.set_value(1000 * ureg.newton)
56
+ c = Part(name="Stage_1", shortname="'3.1'")
57
+ c._set_child(a)
58
+ c._set_child(b)
59
+ v = "Stage_1.thrust"
60
+ c._get_child(v).set_value(c._get_child(v).get_value() + 199 * ureg.newton)
61
+ print(c.dump())
62
+ ```
63
+
64
+ It will output the following:
65
+ ```
66
+ part <'3.1'> Stage_1 {
67
+ attribute mass= 100 [kilogram];
68
+ attribute thrust= 1199.0 [newton];
69
+ }
70
+ ```
71
+
72
+ The package is able to handle Items, Parts, and Attributes.
73
+
74
+ ```
75
+ a = Part(name='camera')
76
+ b = Item(name='lens')
77
+ d = Attribute(name='mass')
78
+ c = Part(name='sensor')
79
+ c._set_child(a)
80
+ c._set_child(b)
81
+ a._set_child(d)
82
+ print(c.dump())
83
+ ```
84
+
85
+ will return:
86
+ ```
87
+ part sensor {
88
+ part camera {
89
+ attribute mass;
90
+ }
91
+ item lens;
92
+ }
93
+ ```
94
+
95
+ Actions
96
+ -------
97
+
98
+ Actions (activities) can be defined with input and output parameters::
99
+
100
+ ```
101
+ from sysmlpy import Action
102
+
103
+ # Action definition with typed inputs/outputs
104
+ a = Action(definition=True, name='Focus')
105
+ a.add_input('scene', 'Scene')
106
+ a.add_output('image', 'Image')
107
+ print(a.dump())
108
+ # → action def Focus { in scene : Scene; out image : Image; }
109
+
110
+ # Action usage with references
111
+ b = Action(name='TakePicture')
112
+ b.add_input('scene')
113
+ b.add_output('picture')
114
+ print(b.dump())
115
+ # → action TakePicture { in scene; out picture; }
116
+ ```
117
+
118
+ References
119
+ ----------
120
+
121
+ References can reference other elements::
122
+
123
+ ```
124
+ from sysmlpy import Reference, Item
125
+
126
+ # Simple reference
127
+ r = Reference(name='driver')
128
+ print(r.dump())
129
+ # → ref driver;
130
+
131
+ # Reference with type
132
+ person = Item(name='Person')
133
+ r2 = Reference(name='driver')
134
+ r2.set_type(person)
135
+ print(r2.dump())
136
+ # → ref driver : Person;
137
+
138
+ # Reference redefinition
139
+ r3 = Reference(name='payload', redefines=True)
140
+ r3.set_type(person)
141
+ print(r3.dump())
142
+ # → ref :>> payload : Person;
143
+ ```
144
+
145
+ ## Grammar Round-Trip
146
+
147
+ `loads()` parses SysML v2 text and `classtree()` converts the result back to text. This round-trip is the basis for the grammar test suite.
148
+
149
+ ```python
150
+ from sysmlpy import loads
151
+ from sysmlpy.formatting import classtree
152
+
153
+ text = """package 'Action Example' {
154
+ action def Focus { in scene : Scene; out image : Image; }
155
+ action def Shoot { in image: Image; out picture : Picture; }
156
+
157
+ action def TakePicture {
158
+ in item scene : Scene;
159
+ out item picture : Picture;
160
+
161
+ bind focus.scene = scene;
162
+
163
+ action focus : Focus { in scene; out image; }
164
+
165
+ flow focus.image to shoot.image;
166
+
167
+ first focus then shoot;
168
+
169
+ action shoot : Shoot { in image; out picture; }
170
+
171
+ bind shoot.picture = picture;
172
+ }
173
+ }"""
174
+
175
+ model = loads(text)
176
+ tree = classtree(model)
177
+ print(tree.dump())
178
+ ```
179
+
180
+ **61% of the 56 grammar round-trip tests currently pass** (34/56), covering packages, parts, items, ports, interfaces, binding connectors, flow connections, all action forms (definition, shorthand, succession, decomposition), expressions, calculations, and constraints.
181
+
182
+ ## Conformance
183
+
184
+ **100% of 123 OMG XPect conformance tests pass** (123/123).
185
+
186
+ ## License
187
+ sysmlpy is released under the MIT license, hence allowing commercial use of the library.
@@ -0,0 +1,136 @@
1
+ [build-system]
2
+ #requires = ["setuptools>=61.0"]
3
+ #build-backend = "setuptools.build_meta"
4
+ requires = ["poetry-core"]
5
+ build-backend = "poetry.core.masonry.api"
6
+
7
+ [project]
8
+ name = "sysmlpy"
9
+ version = "0.1.0"
10
+ description = "SysML v2.0 Parser"
11
+ authors = [
12
+ { name="Jon R. Fox (mycr0ft)", email="jon.fox@drfox.com" },
13
+ ]
14
+ readme = "README.md"
15
+ license = {file = "LICENSE"}
16
+ requires-python = ">=3.7"
17
+ classifiers = [
18
+ "Development Status :: 3 - Alpha",
19
+ "Programming Language :: Python :: 3",
20
+ "License :: OSI Approved :: MIT License",
21
+ "Operating System :: OS Independent",
22
+ ]
23
+
24
+ [project.urls]
25
+ "Homepage" = "https://github.com/Westfall-io/sysmlpy"
26
+ "Bug Tracker" = "https://github.com/Westfall-io/sysmlpy/issues"
27
+
28
+
29
+
30
+ [tool.setuptools]
31
+ include-package-data = true
32
+
33
+ [tool.setuptools.packages.find]
34
+ where = ["src/sysmlpy", "src"]
35
+
36
+ [tool.setuptools.package-data]
37
+ grammar = ["*.tx"]
38
+ "sysmlpy" = [
39
+ "library/**/*.sysml",
40
+ "library/**/*.kerml",
41
+ "library/LICENSE",
42
+ ]
43
+
44
+
45
+ [tool.pytest.ini_options]
46
+ pythonpath = [
47
+ "src"
48
+ ]
49
+ markers = [
50
+ "conformance: SysML v2 Pilot Implementation 2026-03 parse conformance tests (deselect with '-m not conformance')",
51
+ ]
52
+
53
+
54
+ [tool.semantic_release]
55
+ version_variable = [
56
+ "src/sysmlpy/__init__.py:version",
57
+ ]
58
+ version_toml=[
59
+ "pyproject.toml:tool.poetry.version",
60
+ "pyproject.toml:project.version",
61
+ ]
62
+ commit_parser = "emoji"
63
+ build_command = "pip install poetry && poetry build"
64
+ commit_message = ":bookmark:{version}\n\nAutomatically generated by python-semantic-release"
65
+
66
+ [tool.semantic_release.changelog]
67
+ exclude_commit_patterns = [":robot:",":twisted_rightwards_arrows:",
68
+ ":poop:", "^[^:].*"]
69
+
70
+ [tool.semantic_release.commit_parser_options]
71
+ major_tags = [":boom:"]
72
+ minor_tags = [
73
+ ":sparkles:",
74
+ ":children_crossing:",
75
+ ":lipstick:",
76
+ ":iphone:",
77
+ ":egg:",
78
+ ":chart_with_upwards_trend:",
79
+ ]
80
+ patch_tags = [
81
+ ":ambulance:",
82
+ ":lock:",
83
+ ":bug:",
84
+ ":zap:",
85
+ ":goal_net:",
86
+ ":alien:",
87
+ ":wheelchair:",
88
+ ":speech_balloon:",
89
+ ":mag:",
90
+ ":apple:",
91
+ ":penguin:",
92
+ ":checkered_flag:",
93
+ ":robot:",
94
+ ":green_apple:",
95
+ ":memo:",
96
+ ":heavy_plus_sign:",
97
+ ":construction:",
98
+ ":white_check_mark:",
99
+ ]
100
+
101
+ [tool.semantic_release.branches.main]
102
+ match = "(main|master)"
103
+ prerelease = false
104
+ build_command = "pip install poetry && poetry build"
105
+
106
+ [tool.semantic_release.branches."dev0.5.x"]
107
+ match = "dev0.5.x"
108
+ prerelease = true
109
+ prerelease_token = "rc"
110
+ build_command = "pip install poetry && poetry build"
111
+
112
+
113
+ [tool.poetry]
114
+ name = "sysmlpy"
115
+ version = "0.1.0"
116
+ description = ""
117
+ authors = ["Jon R. Fox (mycr0ft) <jon.fox@drfox.com>"]
118
+ readme = "README.md"
119
+ packages = [{ include = "sysmlpy", from = "src" }]
120
+
121
+ [tool.poetry.dependencies]
122
+ python = "^3.9"
123
+ pint = ">=0.24"
124
+ pyyaml = ">=6.0"
125
+ antlr4-python3-runtime = ">=4.13"
126
+ networkx = { version = ">=3.0", optional = true }
127
+
128
+ [tool.poetry.extras]
129
+ graph = ["networkx"]
130
+
131
+ [tool.poetry.scripts]
132
+ sysmlpy = "sysmlpy.__main__:main"
133
+
134
+ [tool.poetry.group.dev.dependencies]
135
+ pytest = ">=8.0,<9.0"
136
+