pyMetaModel API Documentation
metamodel
Created on 2022-11-23
@author: wf
Context
Bases: MetaModelElement
A Context groups some topics like a Namespace/Package. This class provides helper functions and constants to render a Context to corresponding wiki pages
Source code in meta/metamodel.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 |
|
__init__()
constructor
Source code in meta/metamodel.py
59 60 61 62 63 64 65 66 |
|
addLink(tl)
link source and target of the given topicLink
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tl |
TopicLink
|
the topicLink |
required |
Source code in meta/metamodel.py
147 148 149 150 151 152 153 154 155 156 157 |
|
addProperty(prop)
add the given property to this context
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prop |
Property
|
the property to add |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the property adding was successful |
Source code in meta/metamodel.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
|
createProperty4TopicLink(tl)
create a property for the given topic link
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tl |
TopicLink
|
the topiclink to create a property for |
required |
Source code in meta/metamodel.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
|
fromDictOfDicts(did)
classmethod
fill me from the given dict of dicts
Parameters:
Name | Type | Description | Default |
---|---|---|---|
did |
dict
|
the dict of dicts |
required |
Returns:
Name | Type | Description |
---|---|---|
Context |
Context
|
the context read |
Source code in meta/metamodel.py
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 |
|
fromSiDIF(sidif, title, depth=None, debug=False)
classmethod
initialize me from the given SiDIF markup
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sidif |
str
|
the SiDIF markup to parse |
required |
title |
str
|
the title for the SiDIF |
required |
depth |
int
|
the explain depth to show for the errorMessage |
None
|
debug |
bool
|
if True handle debugging |
False
|
Returns:
Type | Description |
---|---|
Tuple[Context, object, str]
|
Tuple[Context,str,str]: context, error and errorMessage |
Source code in meta/metamodel.py
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 |
|
fromSiDIF_input(sidif_input, debug=False)
classmethod
initialize me from the given SiDIF input which might be a file path or url
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sidif_input |
str
|
path to local file or URL |
required |
debug |
bool
|
if True swith debugging on |
False
|
Returns:
Type | Description |
---|---|
Tuple[Context, str, str]
|
Tuple[Context,str,str]: context, error and errorMessage |
Source code in meta/metamodel.py
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 |
|
fromWikiContext(mw_context, depth=None, debug=False)
classmethod
initialize me from the given MediaWiki Context
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mw_context |
MediaWikiContext
|
the Mediawiki context |
required |
depth |
int
|
the explain depth to show for the errorMessage |
None
|
debug |
bool
|
if True handle debugging |
False
|
Return
tuple(Context,Exception,str): the metamodel and potential parsing errors as Exception and error Message
Source code in meta/metamodel.py
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 |
|
link_source_with_target(tl, source, target)
link the source with the target via the given topicLink
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tl |
TopicLink
|
the topicLink |
required |
source |
Topic
|
the source Topic |
required |
target |
Topic
|
the target Topic |
required |
Source code in meta/metamodel.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
|
lookupTopic(topic_name, purpose)
lookup the given topic_name in my topics for the given purpose
Parameters:
Name | Type | Description | Default |
---|---|---|---|
topic_name |
str
|
the name of the topic to lookup |
required |
purpose |
str
|
the purpose to do the lookup for |
required |
Returns:
Name | Type | Description |
---|---|---|
Topic |
Topic
|
the topic if found else None and an error is added to my errors |
Source code in meta/metamodel.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
|
propertyAlreadyDeclared(prop_name, topic, purpose)
check whether the given property or role name is already Declared
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prop_name |
str
|
the property to check for duplicates |
required |
topic |
Topic
|
the topic to check |
required |
purpose |
str
|
the purpose to be displayed in error messages |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if this prop_name has already been use |
Source code in meta/metamodel.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
|
MetaModelElement
Bases: JSONAble
a generic MetaModelElement
to handle the technicalities of being a MetaModelElement so that derived MetaModelElements can focus on the MetaModel domain specific aspects
Source code in meta/metamodel.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
|
__init__()
construct me
Source code in meta/metamodel.py
27 28 29 30 31 32 33 34 35 36 37 |
|
__str__()
get a string representation of me
Source code in meta/metamodel.py
39 40 41 42 43 44 45 46 47 48 49 50 |
|
Property
Bases: MetaModelElement
Provides helper functions and constants for properties
Source code in meta/metamodel.py
548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 |
|
__init__()
constructor
Source code in meta/metamodel.py
553 554 555 556 557 |
|
Topic
Bases: MetaModelElement
A Topic is a Concept/Class/Thing/Entity
Source code in meta/metamodel.py
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 |
|
pluralName: str
property
writable
Getter for pluralName.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The plural name of the topic. |
__init__()
constructor
Source code in meta/metamodel.py
363 364 365 366 367 368 369 370 371 372 |
|
askQuery(mainlabel=None, filterShowInGrid=True, listLimit=None)
get the askQuery for the me topic
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mainlabel |
str
|
the mainlabel to use - topic.name as default |
None
|
filterShowInGrid |
bool
|
if True include only properties with showInGrid not being false |
True
|
listLimit |
int
|
the list limit to use |
None
|
Returns: str: the markup for the query
Source code in meta/metamodel.py
513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 |
|
askSort()
generate the sort clause for my SMW ask query
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
the generated wiki markup |
Source code in meta/metamodel.py
489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 |
|
getListLimit()
get the list limit for this topic
Source code in meta/metamodel.py
449 450 451 452 453 454 |
|
getPluralName()
get the plural name for this topic
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
the pluralname e.g. "Topics" for "Topic" or "Status" for "Status" or |
str
|
"Entities" for "Entity" |
Source code in meta/metamodel.py
439 440 441 442 443 444 445 446 447 |
|
propertiesByIndex()
return the properties by index
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
the list of properties sorted by index |
Source code in meta/metamodel.py
472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 |
|
sanitize()
make sure my properties exist
Source code in meta/metamodel.py
374 375 376 377 378 379 380 381 382 |
|
setConceptProperty()
set my concept property to any primary key or mandatory property
Source code in meta/metamodel.py
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 |
|
sortProperties()
get the properties that we should sort by
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
a list of properties in sort order |
Source code in meta/metamodel.py
456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 |
|
TopicLink
Bases: MetaModelElement
A TopicLink links two Concepts/Topics
Source code in meta/metamodel.py
599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 |
|
metamodel_cmd
Created on 2023-02-19
@author: wf
MetaModelCmd
command line interface for metamodel handling
Source code in meta/metamodel_cmd.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
|
__init__(debug=False)
constructor
Parameters:
Name | Type | Description | Default |
---|---|---|---|
debug |
bool
|
if True switch debugging on |
False
|
Source code in meta/metamodel_cmd.py
25 26 27 28 29 30 31 32 33 34 35 |
|
genLinkML(args)
generate linkML yaml for the given command line arguments
Parameters:
Name | Type | Description | Default |
---|---|---|---|
args |
Namespace
|
the command line arguments |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
the uml markup |
Source code in meta/metamodel_cmd.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
|
genUml(args)
generate uml for the given context with the given name from the given wiki
Parameters:
Name | Type | Description | Default |
---|---|---|---|
args |
Namespace
|
the command line arguments |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
the PlantUml |
Source code in meta/metamodel_cmd.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
|
getArgParser()
classmethod
get my argument parser
Source code in meta/metamodel_cmd.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
|
readContext(args)
read the context from the given args
Parameters:
Name | Type | Description | Default |
---|---|---|---|
args |
Args
|
command line arguments |
required |
Source code in meta/metamodel_cmd.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
|
main(argv=None)
main program.
Source code in meta/metamodel_cmd.py
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
|
mw
Created on 23.11.2022
@author: wf
MediaWikiContext
dataclass
Class for keeping track of MediaWiki Context
Source code in meta/mw.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
|
read_sidif()
Read the SiDIF for this Mediawiki context
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
the SiDIF |
Source code in meta/mw.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
|
sidif_url()
return the sidif url
Source code in meta/mw.py
26 27 28 29 30 31 |
|
SMWAccess
access to semantic MediaWiki
Source code in meta/mw.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
|
__init__(wikiId='wiki', debug=False)
constructor
Source code in meta/mw.py
68 69 70 71 72 73 74 75 |
|
getMwContexts()
get the contexts
Source code in meta/mw.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
|
getSMW(wikiId)
get the semantic mediawiki access
Source code in meta/mw.py
77 78 79 80 81 82 83 84 85 |
|
profiler
Created on 2022-11-18
@author: wf
Profiler
simple profiler
Source code in meta/profiler.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
|
__init__(msg, profile=True)
construct me with the given msg and profile active flag
Parameters:
Name | Type | Description | Default |
---|---|---|---|
msg |
str
|
the message to show if profiling is active |
required |
profile |
bool
|
True if messages should be shown |
True
|
Source code in meta/profiler.py
15 16 17 18 19 20 21 22 23 24 25 26 27 |
|
time(extraMsg='')
time the action and print if profile is active
Source code in meta/profiler.py
29 30 31 32 33 34 35 36 |
|
sidif2linkml
Created on 2023-02-20
@author: wf
SiDIF2LinkML
converter between SiDIF and LINKML
Source code in meta/sidif2linkml.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
|
asYaml(common_property_slots=True, delim='_')
convert my context
Parameters:
Name | Type | Description | Default |
---|---|---|---|
common_property_slots |
bool
|
if True reuse slots |
True
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
the yaml markup |
Source code in meta/sidif2linkml.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
|
smw_type
SMW_Type
dataclass
an SMW_Type is a data type which determines the possible values for that type e.g. a Boolean can hold true/false values while a Number can hold 3.1459 or 20. A Page can hold the name of a Wiki page see https://semantic-mediawiki.org/wiki/Help:List_of_datatypes
Source code in meta/smw_type.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
|
askQuery()
classmethod
get the ask Query for SMW_Type
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
the mediawiki markup for the ask query |
Source code in meta/smw_type.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
|
fromDict(data)
classmethod
create a SMW_Type from the given dict
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
dict
|
the dict to create the SMW_Type from |
required |
Returns:
Name | Type | Description |
---|---|---|
SMW_Type |
SMW_Type
|
the freshly created SMW_Type |
Source code in meta/smw_type.py
45 46 47 48 49 50 51 52 53 54 55 56 57 |
|
uml
Created on 2020-11-12
@author: wf
PlantUml
Bases: object
Plant UML support
Source code in meta/uml.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
|
__init__(copyRight=None, title=None, debug=False, withSkin=True, withAt=False, doc_width=40)
Constructor
Source code in meta/uml.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
|
asUmlDict(dif)
return the given DataInterchange as an UML Dict
Source code in meta/uml.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
|
atIt(markup)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
markup |
str
|
the markup |
required |
Returns: str: markup with @startuml and @enduml
Source code in meta/uml.py
122 123 124 125 126 127 128 129 130 131 132 133 134 |
|
fromDIF(dif)
create a UML from a Data Interchange
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dif |
DataInterchange
|
|
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
the planuml markup |
Source code in meta/uml.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
|
fromUmlDict(umlDict)
convert the given umlDict Dict to a plantuml string
Parameters:
Name | Type | Description | Default |
---|---|---|---|
umlDict |
Dict
|
the dictionary of packages,classes and properties |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
the planuml markup |
Source code in meta/uml.py
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
|
multi_line_doc(doc, width)
Returns the given documentation as a multiline string with a limited length per line. Lines are broken at whitespace.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
doc |
str
|
the documentation to wrap |
required |
width |
int
|
The maximum length of each line. |
required |
Returns: str: the Multiline string.
Source code in meta/uml.py
136 137 138 139 140 141 142 143 144 145 146 147 148 |
|
version
Created on 2023-02-19
@author: wf
Version
Bases: object
Version handling for pyMetaModel
Source code in meta/version.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
|