rdf-construct 0.3.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 (110) hide show
  1. rdf_construct/__init__.py +12 -0
  2. rdf_construct/__main__.py +0 -0
  3. rdf_construct/cli.py +3429 -0
  4. rdf_construct/core/__init__.py +33 -0
  5. rdf_construct/core/config.py +116 -0
  6. rdf_construct/core/ordering.py +219 -0
  7. rdf_construct/core/predicate_order.py +212 -0
  8. rdf_construct/core/profile.py +157 -0
  9. rdf_construct/core/selector.py +64 -0
  10. rdf_construct/core/serialiser.py +232 -0
  11. rdf_construct/core/utils.py +89 -0
  12. rdf_construct/cq/__init__.py +77 -0
  13. rdf_construct/cq/expectations.py +365 -0
  14. rdf_construct/cq/formatters/__init__.py +45 -0
  15. rdf_construct/cq/formatters/json.py +104 -0
  16. rdf_construct/cq/formatters/junit.py +104 -0
  17. rdf_construct/cq/formatters/text.py +146 -0
  18. rdf_construct/cq/loader.py +300 -0
  19. rdf_construct/cq/runner.py +321 -0
  20. rdf_construct/diff/__init__.py +59 -0
  21. rdf_construct/diff/change_types.py +214 -0
  22. rdf_construct/diff/comparator.py +338 -0
  23. rdf_construct/diff/filters.py +133 -0
  24. rdf_construct/diff/formatters/__init__.py +71 -0
  25. rdf_construct/diff/formatters/json.py +192 -0
  26. rdf_construct/diff/formatters/markdown.py +210 -0
  27. rdf_construct/diff/formatters/text.py +195 -0
  28. rdf_construct/docs/__init__.py +60 -0
  29. rdf_construct/docs/config.py +238 -0
  30. rdf_construct/docs/extractors.py +603 -0
  31. rdf_construct/docs/generator.py +360 -0
  32. rdf_construct/docs/renderers/__init__.py +7 -0
  33. rdf_construct/docs/renderers/html.py +803 -0
  34. rdf_construct/docs/renderers/json.py +390 -0
  35. rdf_construct/docs/renderers/markdown.py +628 -0
  36. rdf_construct/docs/search.py +278 -0
  37. rdf_construct/docs/templates/html/base.html.jinja +44 -0
  38. rdf_construct/docs/templates/html/class.html.jinja +152 -0
  39. rdf_construct/docs/templates/html/hierarchy.html.jinja +28 -0
  40. rdf_construct/docs/templates/html/index.html.jinja +110 -0
  41. rdf_construct/docs/templates/html/instance.html.jinja +90 -0
  42. rdf_construct/docs/templates/html/namespaces.html.jinja +37 -0
  43. rdf_construct/docs/templates/html/property.html.jinja +124 -0
  44. rdf_construct/docs/templates/html/single_page.html.jinja +169 -0
  45. rdf_construct/lint/__init__.py +75 -0
  46. rdf_construct/lint/config.py +214 -0
  47. rdf_construct/lint/engine.py +396 -0
  48. rdf_construct/lint/formatters.py +327 -0
  49. rdf_construct/lint/rules.py +692 -0
  50. rdf_construct/localise/__init__.py +114 -0
  51. rdf_construct/localise/config.py +508 -0
  52. rdf_construct/localise/extractor.py +427 -0
  53. rdf_construct/localise/formatters/__init__.py +36 -0
  54. rdf_construct/localise/formatters/markdown.py +229 -0
  55. rdf_construct/localise/formatters/text.py +224 -0
  56. rdf_construct/localise/merger.py +346 -0
  57. rdf_construct/localise/reporter.py +356 -0
  58. rdf_construct/main.py +6 -0
  59. rdf_construct/merge/__init__.py +165 -0
  60. rdf_construct/merge/config.py +354 -0
  61. rdf_construct/merge/conflicts.py +281 -0
  62. rdf_construct/merge/formatters.py +426 -0
  63. rdf_construct/merge/merger.py +425 -0
  64. rdf_construct/merge/migrator.py +339 -0
  65. rdf_construct/merge/rules.py +377 -0
  66. rdf_construct/merge/splitter.py +1102 -0
  67. rdf_construct/puml2rdf/__init__.py +103 -0
  68. rdf_construct/puml2rdf/config.py +230 -0
  69. rdf_construct/puml2rdf/converter.py +420 -0
  70. rdf_construct/puml2rdf/merger.py +200 -0
  71. rdf_construct/puml2rdf/model.py +202 -0
  72. rdf_construct/puml2rdf/parser.py +565 -0
  73. rdf_construct/puml2rdf/validators.py +451 -0
  74. rdf_construct/refactor/__init__.py +72 -0
  75. rdf_construct/refactor/config.py +362 -0
  76. rdf_construct/refactor/deprecator.py +328 -0
  77. rdf_construct/refactor/formatters/__init__.py +8 -0
  78. rdf_construct/refactor/formatters/text.py +311 -0
  79. rdf_construct/refactor/renamer.py +294 -0
  80. rdf_construct/shacl/__init__.py +56 -0
  81. rdf_construct/shacl/config.py +166 -0
  82. rdf_construct/shacl/converters.py +520 -0
  83. rdf_construct/shacl/generator.py +364 -0
  84. rdf_construct/shacl/namespaces.py +93 -0
  85. rdf_construct/stats/__init__.py +29 -0
  86. rdf_construct/stats/collector.py +178 -0
  87. rdf_construct/stats/comparator.py +298 -0
  88. rdf_construct/stats/formatters/__init__.py +83 -0
  89. rdf_construct/stats/formatters/json.py +38 -0
  90. rdf_construct/stats/formatters/markdown.py +153 -0
  91. rdf_construct/stats/formatters/text.py +186 -0
  92. rdf_construct/stats/metrics/__init__.py +26 -0
  93. rdf_construct/stats/metrics/basic.py +147 -0
  94. rdf_construct/stats/metrics/complexity.py +137 -0
  95. rdf_construct/stats/metrics/connectivity.py +130 -0
  96. rdf_construct/stats/metrics/documentation.py +128 -0
  97. rdf_construct/stats/metrics/hierarchy.py +207 -0
  98. rdf_construct/stats/metrics/properties.py +88 -0
  99. rdf_construct/uml/__init__.py +22 -0
  100. rdf_construct/uml/context.py +194 -0
  101. rdf_construct/uml/mapper.py +371 -0
  102. rdf_construct/uml/odm_renderer.py +789 -0
  103. rdf_construct/uml/renderer.py +684 -0
  104. rdf_construct/uml/uml_layout.py +393 -0
  105. rdf_construct/uml/uml_style.py +613 -0
  106. rdf_construct-0.3.0.dist-info/METADATA +496 -0
  107. rdf_construct-0.3.0.dist-info/RECORD +110 -0
  108. rdf_construct-0.3.0.dist-info/WHEEL +4 -0
  109. rdf_construct-0.3.0.dist-info/entry_points.txt +3 -0
  110. rdf_construct-0.3.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,202 @@
1
+ """Intermediate representation for parsed PlantUML diagrams.
2
+
3
+ This module defines dataclasses that represent PlantUML elements in a
4
+ structured form, acting as an intermediate representation between the
5
+ raw PlantUML text and the generated RDF graph.
6
+ """
7
+
8
+ from dataclasses import dataclass, field
9
+ from enum import Enum
10
+ from typing import Optional
11
+
12
+
13
+ class RelationshipType(Enum):
14
+ """Types of relationships that can be represented in PlantUML."""
15
+
16
+ INHERITANCE = "inheritance" # --|> or <|--
17
+ ASSOCIATION = "association" # --> or --
18
+ AGGREGATION = "aggregation" # o-- or --o
19
+ COMPOSITION = "composition" # *-- or --*
20
+
21
+
22
+ class PropertyKind(Enum):
23
+ """Kind of property to generate in RDF."""
24
+
25
+ DATATYPE = "datatype" # owl:DatatypeProperty
26
+ OBJECT = "object" # owl:ObjectProperty
27
+ ANNOTATION = "annotation" # owl:AnnotationProperty
28
+
29
+
30
+ @dataclass
31
+ class PumlAttribute:
32
+ """An attribute within a PlantUML class.
33
+
34
+ Attributes represent datatype properties in the generated ontology.
35
+
36
+ Attributes:
37
+ name: Attribute name (e.g., 'floorArea')
38
+ datatype: XSD datatype string (e.g., 'decimal', 'string')
39
+ visibility: UML visibility marker (+, -, #, ~)
40
+ is_static: Whether marked as static (underlined)
41
+ """
42
+
43
+ name: str
44
+ datatype: Optional[str] = None
45
+ visibility: str = "+"
46
+ is_static: bool = False
47
+
48
+
49
+ @dataclass
50
+ class PumlClass:
51
+ """A class definition from PlantUML."""
52
+
53
+ name: str # Local name only (e.g., "Building")
54
+ package: Optional[str] = None # Namespace prefix (e.g., "building")
55
+ stereotype: Optional[str] = None
56
+ attributes: list[PumlAttribute] = field(default_factory=list)
57
+ note: Optional[str] = None
58
+ is_abstract: bool = False
59
+ display_name: Optional[str] = None # NEW: From "Display Name" as alias syntax
60
+
61
+ @property
62
+ def qualified_name(self) -> str:
63
+ """Return the fully qualified name including package."""
64
+ if self.package:
65
+ return f"{self.package}.{self.name}"
66
+ return self.name
67
+
68
+
69
+ @dataclass
70
+ class PumlRelationship:
71
+ """A relationship between two classes in PlantUML.
72
+
73
+ Depending on the type, this generates different RDF constructs:
74
+ - INHERITANCE -> rdfs:subClassOf
75
+ - ASSOCIATION -> owl:ObjectProperty
76
+ - AGGREGATION/COMPOSITION -> owl:ObjectProperty with semantics note
77
+
78
+ Attributes:
79
+ source: Source class name
80
+ target: Target class name
81
+ rel_type: Type of relationship
82
+ label: Relationship label (becomes property name)
83
+ source_cardinality: Cardinality at source end (e.g., '1', '*', '0..1')
84
+ target_cardinality: Cardinality at target end
85
+ note: Attached note for the relationship
86
+ """
87
+
88
+ source: str
89
+ target: str
90
+ rel_type: RelationshipType
91
+ label: Optional[str] = None
92
+ source_cardinality: Optional[str] = None
93
+ target_cardinality: Optional[str] = None
94
+ note: Optional[str] = None
95
+
96
+
97
+ @dataclass
98
+ class PumlPackage:
99
+ """A package definition from PlantUML.
100
+
101
+ Packages map to RDF namespaces in the generated ontology.
102
+
103
+ Attributes:
104
+ name: Display name of the package
105
+ namespace_uri: The URI to use as the namespace (from 'as' clause)
106
+ stereotype: Package stereotype (if any)
107
+ """
108
+
109
+ name: str
110
+ namespace_uri: Optional[str] = None
111
+ stereotype: Optional[str] = None
112
+
113
+
114
+ @dataclass
115
+ class PumlNote:
116
+ """A standalone note in PlantUML.
117
+
118
+ Notes attached to classes become rdfs:comment.
119
+ Standalone notes may be used for ontology metadata.
120
+
121
+ Attributes:
122
+ content: The note text
123
+ attached_to: Name of class this note is attached to (if any)
124
+ position: Position relative to attached element
125
+ """
126
+
127
+ content: str
128
+ attached_to: Optional[str] = None
129
+ position: Optional[str] = None
130
+
131
+
132
+ @dataclass
133
+ class PumlModel:
134
+ """Complete parsed PlantUML model.
135
+
136
+ This is the top-level container for all parsed elements,
137
+ ready for conversion to RDF.
138
+
139
+ Attributes:
140
+ classes: All parsed classes
141
+ relationships: All parsed relationships
142
+ packages: All parsed packages
143
+ notes: All standalone notes
144
+ title: Diagram title (becomes ontology label)
145
+ skin_params: PlantUML skinparam settings (preserved for round-trip)
146
+ """
147
+
148
+ classes: list[PumlClass] = field(default_factory=list)
149
+ relationships: list[PumlRelationship] = field(default_factory=list)
150
+ packages: list[PumlPackage] = field(default_factory=list)
151
+ notes: list[PumlNote] = field(default_factory=list)
152
+ title: Optional[str] = None
153
+ skin_params: dict[str, str] = field(default_factory=dict)
154
+
155
+ def get_class(self, name: str) -> Optional[PumlClass]:
156
+ """Find a class by name (local or qualified).
157
+
158
+ Args:
159
+ name: Class name - can be "Building" or "building.Building"
160
+
161
+ Returns:
162
+ The PumlClass if found, None otherwise
163
+ """
164
+ for cls in self.classes:
165
+ # Match by local name
166
+ if cls.name == name:
167
+ return cls
168
+ # Match by qualified name
169
+ if cls.qualified_name == name:
170
+ return cls
171
+ return None
172
+
173
+ def get_package(self, name: str) -> Optional[PumlPackage]:
174
+ """Find a package by name or URI.
175
+
176
+ Args:
177
+ name: Package name or namespace URI
178
+
179
+ Returns:
180
+ The PumlPackage if found, None otherwise
181
+ """
182
+ for pkg in self.packages:
183
+ if pkg.name == name or pkg.namespace_uri == name:
184
+ return pkg
185
+ return None
186
+
187
+ def inheritance_relationships(self) -> list[PumlRelationship]:
188
+ """Return only inheritance relationships (rdfs:subClassOf)."""
189
+ return [r for r in self.relationships if r.rel_type == RelationshipType.INHERITANCE]
190
+
191
+ def property_relationships(self) -> list[PumlRelationship]:
192
+ """Return relationships that become object properties."""
193
+ return [
194
+ r
195
+ for r in self.relationships
196
+ if r.rel_type
197
+ in (
198
+ RelationshipType.ASSOCIATION,
199
+ RelationshipType.AGGREGATION,
200
+ RelationshipType.COMPOSITION,
201
+ )
202
+ ]