stbkit.api.experimental¶
experimental ¶
将来の公開を意図した、暫定公開API
※このモジュール内のAPIは暫定的なものであり、今後変更される可能性があります。 仕様が固まったものはstbkit.apiへ移し、このモジュールからは段階的に外します。 継続的に利用するコードから使う場合は、この点を了解したうえで、バージョンを固定して使用してください。 互換性に関する方針は、GitHubリポジトリのCOMPATIBILITY.mdを参照してください。
ReferenceElementNotFoundError ¶
Bases: StbError
参照先の要素が見つからない場合の例外
id_nodeやid_sectionなどの参照解決時に要素が見つからなかったときに投げます
CollectingReporter ¶
CollectingReporter(*, default_code: Code | None = None, default_phase: Phase | None = None)
Bases: _BaseReporter
メッセージをメモリ上へ蓄積するReporter。
ログ出力は行わず、処理後にreportでまとめて取り出します。
引数:
| 名前 | タイプ | デスクリプション | デフォルト |
|---|---|---|---|
default_code
|
Code | None
|
デフォルトのcode。 |
None
|
default_phase
|
Phase | None
|
デフォルトのphase。 |
None
|
ソースコード位置: python/stbkit-core/src/stbkit/core/stb_reporting.py
751 752 753 754 755 756 757 758 | |
debug ¶
debug(message: str, *, code: Code | None = None, phase: Phase | None = None, element_guid: str | None = None, xpath: str | None = None, value: str | None = None, stb_element: StBridgeElement | None = None, attr_name: str | None = None, ref_element_guid: str | None = None, ref_xpath: str | None = None, ref_value: str | None = None, ref_stb_element: StBridgeElement | None = None, ref_attr_name: str | None = None) -> None
DEBUGレベルのメッセージを記録します。
引数:
| 名前 | タイプ | デスクリプション | デフォルト |
|---|---|---|---|
message
|
str
|
メッセージ |
必須 |
code
|
Code | None
|
分類コード。 |
None
|
phase
|
Phase | None
|
処理段階。 |
None
|
element_guid
|
str | None
|
対象要素のGUID。 |
None
|
xpath
|
str | None
|
対象箇所のXPath。 |
None
|
value
|
str | None
|
実際の値。 |
None
|
stb_element
|
StBridgeElement | None
|
対象要素。 |
None
|
attr_name
|
str | None
|
対象属性名(Python名)。 |
None
|
ref_element_guid
|
str | None
|
比較対象要素のGUID。 |
None
|
ref_xpath
|
str | None
|
比較対象のXPath。 |
None
|
ref_value
|
str | None
|
期待される値、または比較対象の値。 |
None
|
ref_stb_element
|
StBridgeElement | None
|
比較対象の要素。 |
None
|
ref_attr_name
|
str | None
|
比較対象の属性名。 |
None
|
ソースコード位置: python/stbkit-core/src/stbkit/core/stb_reporting.py
353 354 355 356 357 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 | |
info ¶
info(message: str, *, code: Code | None = None, phase: Phase | None = None, element_guid: str | None = None, xpath: str | None = None, value: str | None = None, stb_element: StBridgeElement | None = None, attr_name: str | None = None, ref_element_guid: str | None = None, ref_xpath: str | None = None, ref_value: str | None = None, ref_stb_element: StBridgeElement | None = None, ref_attr_name: str | None = None) -> None
infoレベルのメッセージを記録します。
引数:
| 名前 | タイプ | デスクリプション | デフォルト |
|---|---|---|---|
message
|
str
|
メッセージ |
必須 |
code
|
Code | None
|
分類コード。 |
None
|
phase
|
Phase | None
|
処理段階。 |
None
|
element_guid
|
str | None
|
対象要素のGUID。 |
None
|
xpath
|
str | None
|
対象箇所のXPath。 |
None
|
value
|
str | None
|
実際の値。 |
None
|
stb_element
|
StBridgeElement | None
|
対象要素。 |
None
|
attr_name
|
str | None
|
対象属性名(Python名)。 |
None
|
ref_element_guid
|
str | None
|
比較対象要素のGUID。 |
None
|
ref_xpath
|
str | None
|
比較対象のXPath。 |
None
|
ref_value
|
str | None
|
期待される値、または比較対象の値。 |
None
|
ref_stb_element
|
StBridgeElement | None
|
比較対象の要素。 |
None
|
ref_attr_name
|
str | None
|
比較対象の属性名。 |
None
|
ソースコード位置: python/stbkit-core/src/stbkit/core/stb_reporting.py
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 | |
warning ¶
warning(message: str, *, code: Code | None = None, phase: Phase | None = None, element_guid: str | None = None, xpath: str | None = None, value: str | None = None, stb_element: StBridgeElement | None = None, attr_name: str | None = None, ref_element_guid: str | None = None, ref_xpath: str | None = None, ref_value: str | None = None, ref_stb_element: StBridgeElement | None = None, ref_attr_name: str | None = None) -> None
warningレベルのメッセージを記録します。
引数:
| 名前 | タイプ | デスクリプション | デフォルト |
|---|---|---|---|
message
|
str
|
メッセージ |
必須 |
code
|
Code | None
|
分類コード。 |
None
|
phase
|
Phase | None
|
処理段階。 |
None
|
element_guid
|
str | None
|
対象要素のGUID。 |
None
|
xpath
|
str | None
|
対象箇所のXPath。 |
None
|
value
|
str | None
|
実際の値。 |
None
|
stb_element
|
StBridgeElement | None
|
対象要素。 |
None
|
attr_name
|
str | None
|
対象属性名(Python名)。 |
None
|
ref_element_guid
|
str | None
|
比較対象要素のGUID。 |
None
|
ref_xpath
|
str | None
|
比較対象のXPath。 |
None
|
ref_value
|
str | None
|
期待される値、または比較対象の値。 |
None
|
ref_stb_element
|
StBridgeElement | None
|
比較対象の要素。 |
None
|
ref_attr_name
|
str | None
|
比較対象の属性名。 |
None
|
ソースコード位置: python/stbkit-core/src/stbkit/core/stb_reporting.py
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 | |
error ¶
error(message: str, *, code: Code | None = None, phase: Phase | None = None, element_guid: str | None = None, xpath: str | None = None, value: str | None = None, stb_element: StBridgeElement | None = None, attr_name: str | None = None, ref_element_guid: str | None = None, ref_xpath: str | None = None, ref_value: str | None = None, ref_stb_element: StBridgeElement | None = None, ref_attr_name: str | None = None) -> None
errorレベルのメッセージを記録します。
引数:
| 名前 | タイプ | デスクリプション | デフォルト |
|---|---|---|---|
message
|
str
|
メッセージ |
必須 |
code
|
Code | None
|
分類コード。 |
None
|
phase
|
Phase | None
|
処理段階。 |
None
|
element_guid
|
str | None
|
対象要素のGUID。 |
None
|
xpath
|
str | None
|
対象箇所のXPath。 |
None
|
value
|
str | None
|
実際の値。 |
None
|
stb_element
|
StBridgeElement | None
|
対象要素。 |
None
|
attr_name
|
str | None
|
対象属性名(Python名)。 |
None
|
ref_element_guid
|
str | None
|
比較対象要素のGUID。 |
None
|
ref_xpath
|
str | None
|
比較対象のXPath。 |
None
|
ref_value
|
str | None
|
期待される値、または比較対象の値。 |
None
|
ref_stb_element
|
StBridgeElement | None
|
比較対象の要素。 |
None
|
ref_attr_name
|
str | None
|
比較対象の属性名。 |
None
|
ソースコード位置: python/stbkit-core/src/stbkit/core/stb_reporting.py
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 546 547 548 549 550 551 552 553 554 555 | |
set_context ¶
set_context(*, code: Code | None = None, phase: Phase | None = None) -> None
ソースコード位置: python/stbkit-core/src/stbkit/core/stb_reporting.py
714 715 716 717 718 719 720 | |
context ¶
context(*, code: Code | None = None, phase: Phase | None = None) -> Generator[Reporter, None, None]
ソースコード位置: python/stbkit-core/src/stbkit/core/stb_reporting.py
722 723 724 725 726 727 728 729 730 731 | |
bind ¶
bind(*, code: Code | None = None, phase: Phase | None = None) -> Reporter
デフォルト値を固定した新しいReporterを返します。
自身の状態は変更しません。withを使わずにデフォルト値を固定したい場合に使用します。
引数:
| 名前 | タイプ | デスクリプション | デフォルト |
|---|---|---|---|
code
|
Code | None
|
固定する分類コード。 |
None
|
phase
|
Phase | None
|
固定する処理段階。 |
None
|
戻り値:
| 名前 | タイプ | デスクリプション |
|---|---|---|
Reporter |
Reporter
|
固定した値を補って自身へ委譲するReporter。 |
Examples: >>> reporter2 = reporter.bind(code=Code.SCHEMA_ERROR, phase=Phase.LOAD) >>> reporter2.error("スキーマ違反がありました")
ソースコード位置: python/stbkit-core/src/stbkit/core/stb_reporting.py
596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 | |
is_valid ¶
is_valid(*, min_level: Severity = WARNING) -> bool
指定した重大度以上のメッセージが無いかどうかを返します。 min_levelを指定しない場合はWARNING以上のメッセージが無いかどうかを返します。
引数:
| 名前 | タイプ | デスクリプション | デフォルト |
|---|---|---|---|
min_level
|
Severity
|
不適合とみなす最低の重大度。 省略した場合WARNING以上のメッセージがあるかどうかを判定します。 |
WARNING
|
戻り値:
| 名前 | タイプ | デスクリプション |
|---|---|---|
bool |
bool
|
min_level以上のメッセージが1件も無ければTrue。 |
ソースコード位置: python/stbkit-core/src/stbkit/core/stb_reporting.py
813 814 815 816 817 818 819 820 821 822 823 824 | |
Reporter ¶
Bases: ABC
処理メッセージの記録先の基底クラス。
debug・info・warning・errorが受け取る引数は共通です。 codeとphaseの優先度は、引数>set_contextやcontextで設定した既定値>bindで束縛した値です。
debug ¶
debug(message: str, *, code: Code | None = None, phase: Phase | None = None, element_guid: str | None = None, xpath: str | None = None, value: str | None = None, stb_element: StBridgeElement | None = None, attr_name: str | None = None, ref_element_guid: str | None = None, ref_xpath: str | None = None, ref_value: str | None = None, ref_stb_element: StBridgeElement | None = None, ref_attr_name: str | None = None) -> None
DEBUGレベルのメッセージを記録します。
引数:
| 名前 | タイプ | デスクリプション | デフォルト |
|---|---|---|---|
message
|
str
|
メッセージ |
必須 |
code
|
Code | None
|
分類コード。 |
None
|
phase
|
Phase | None
|
処理段階。 |
None
|
element_guid
|
str | None
|
対象要素のGUID。 |
None
|
xpath
|
str | None
|
対象箇所のXPath。 |
None
|
value
|
str | None
|
実際の値。 |
None
|
stb_element
|
StBridgeElement | None
|
対象要素。 |
None
|
attr_name
|
str | None
|
対象属性名(Python名)。 |
None
|
ref_element_guid
|
str | None
|
比較対象要素のGUID。 |
None
|
ref_xpath
|
str | None
|
比較対象のXPath。 |
None
|
ref_value
|
str | None
|
期待される値、または比較対象の値。 |
None
|
ref_stb_element
|
StBridgeElement | None
|
比較対象の要素。 |
None
|
ref_attr_name
|
str | None
|
比較対象の属性名。 |
None
|
ソースコード位置: python/stbkit-core/src/stbkit/core/stb_reporting.py
353 354 355 356 357 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 | |
info ¶
info(message: str, *, code: Code | None = None, phase: Phase | None = None, element_guid: str | None = None, xpath: str | None = None, value: str | None = None, stb_element: StBridgeElement | None = None, attr_name: str | None = None, ref_element_guid: str | None = None, ref_xpath: str | None = None, ref_value: str | None = None, ref_stb_element: StBridgeElement | None = None, ref_attr_name: str | None = None) -> None
infoレベルのメッセージを記録します。
引数:
| 名前 | タイプ | デスクリプション | デフォルト |
|---|---|---|---|
message
|
str
|
メッセージ |
必須 |
code
|
Code | None
|
分類コード。 |
None
|
phase
|
Phase | None
|
処理段階。 |
None
|
element_guid
|
str | None
|
対象要素のGUID。 |
None
|
xpath
|
str | None
|
対象箇所のXPath。 |
None
|
value
|
str | None
|
実際の値。 |
None
|
stb_element
|
StBridgeElement | None
|
対象要素。 |
None
|
attr_name
|
str | None
|
対象属性名(Python名)。 |
None
|
ref_element_guid
|
str | None
|
比較対象要素のGUID。 |
None
|
ref_xpath
|
str | None
|
比較対象のXPath。 |
None
|
ref_value
|
str | None
|
期待される値、または比較対象の値。 |
None
|
ref_stb_element
|
StBridgeElement | None
|
比較対象の要素。 |
None
|
ref_attr_name
|
str | None
|
比較対象の属性名。 |
None
|
ソースコード位置: python/stbkit-core/src/stbkit/core/stb_reporting.py
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 | |
warning ¶
warning(message: str, *, code: Code | None = None, phase: Phase | None = None, element_guid: str | None = None, xpath: str | None = None, value: str | None = None, stb_element: StBridgeElement | None = None, attr_name: str | None = None, ref_element_guid: str | None = None, ref_xpath: str | None = None, ref_value: str | None = None, ref_stb_element: StBridgeElement | None = None, ref_attr_name: str | None = None) -> None
warningレベルのメッセージを記録します。
引数:
| 名前 | タイプ | デスクリプション | デフォルト |
|---|---|---|---|
message
|
str
|
メッセージ |
必須 |
code
|
Code | None
|
分類コード。 |
None
|
phase
|
Phase | None
|
処理段階。 |
None
|
element_guid
|
str | None
|
対象要素のGUID。 |
None
|
xpath
|
str | None
|
対象箇所のXPath。 |
None
|
value
|
str | None
|
実際の値。 |
None
|
stb_element
|
StBridgeElement | None
|
対象要素。 |
None
|
attr_name
|
str | None
|
対象属性名(Python名)。 |
None
|
ref_element_guid
|
str | None
|
比較対象要素のGUID。 |
None
|
ref_xpath
|
str | None
|
比較対象のXPath。 |
None
|
ref_value
|
str | None
|
期待される値、または比較対象の値。 |
None
|
ref_stb_element
|
StBridgeElement | None
|
比較対象の要素。 |
None
|
ref_attr_name
|
str | None
|
比較対象の属性名。 |
None
|
ソースコード位置: python/stbkit-core/src/stbkit/core/stb_reporting.py
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 | |
error ¶
error(message: str, *, code: Code | None = None, phase: Phase | None = None, element_guid: str | None = None, xpath: str | None = None, value: str | None = None, stb_element: StBridgeElement | None = None, attr_name: str | None = None, ref_element_guid: str | None = None, ref_xpath: str | None = None, ref_value: str | None = None, ref_stb_element: StBridgeElement | None = None, ref_attr_name: str | None = None) -> None
errorレベルのメッセージを記録します。
引数:
| 名前 | タイプ | デスクリプション | デフォルト |
|---|---|---|---|
message
|
str
|
メッセージ |
必須 |
code
|
Code | None
|
分類コード。 |
None
|
phase
|
Phase | None
|
処理段階。 |
None
|
element_guid
|
str | None
|
対象要素のGUID。 |
None
|
xpath
|
str | None
|
対象箇所のXPath。 |
None
|
value
|
str | None
|
実際の値。 |
None
|
stb_element
|
StBridgeElement | None
|
対象要素。 |
None
|
attr_name
|
str | None
|
対象属性名(Python名)。 |
None
|
ref_element_guid
|
str | None
|
比較対象要素のGUID。 |
None
|
ref_xpath
|
str | None
|
比較対象のXPath。 |
None
|
ref_value
|
str | None
|
期待される値、または比較対象の値。 |
None
|
ref_stb_element
|
StBridgeElement | None
|
比較対象の要素。 |
None
|
ref_attr_name
|
str | None
|
比較対象の属性名。 |
None
|
ソースコード位置: python/stbkit-core/src/stbkit/core/stb_reporting.py
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 546 547 548 549 550 551 552 553 554 555 | |
set_context ¶
set_context(*, code: Code | None = None, phase: Phase | None = None) -> None
以後に記録するメッセージのcode,phaseのデフォルトを更新します。
基底クラスでは何もしないので、継承先で実装します。
引数:
| 名前 | タイプ | デスクリプション | デフォルト |
|---|---|---|---|
code
|
Code | None
|
以後で記録するときのcode。Noneの場合は変更しません。 |
None
|
phase
|
Phase | None
|
以後で記録するときのphase。Noneの場合は変更しません。 |
None
|
例:
>>> reporter.set_context(code=Code.SCHEMA_ERROR, phase=Phase.LOAD)
>>> reporter.error("スキーマ違反がありました")
ソースコード位置: python/stbkit-core/src/stbkit/core/stb_reporting.py
557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 | |
context ¶
context(*, code: Code | None = None, phase: Phase | None = None) -> Generator[Reporter, None, None]
code,phaseのデフォルト値を一時的に変更し、ブロックを抜けるときに元へ戻します。
基底クラスでは何も変更せず、自身をそのまま返すため、継承先で実装します。
引数:
| 名前 | タイプ | デスクリプション | デフォルト |
|---|---|---|---|
code
|
Code | None
|
ブロック内で使用するcode。 |
None
|
phase
|
Phase | None
|
ブロック内で使用するphase。 |
None
|
返す:
| 名前 | タイプ | デスクリプション |
|---|---|---|
Reporter |
Reporter
|
デフォルトを変更したReporter。 |
例:
>>> with reporter.context(code=Code.SCHEMA_ERROR, phase=Phase.LOAD):
... reporter.error("スキーマ違反がありました")
ソースコード位置: python/stbkit-core/src/stbkit/core/stb_reporting.py
574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 | |
bind ¶
bind(*, code: Code | None = None, phase: Phase | None = None) -> Reporter
デフォルト値を固定した新しいReporterを返します。
自身の状態は変更しません。withを使わずにデフォルト値を固定したい場合に使用します。
引数:
| 名前 | タイプ | デスクリプション | デフォルト |
|---|---|---|---|
code
|
Code | None
|
固定する分類コード。 |
None
|
phase
|
Phase | None
|
固定する処理段階。 |
None
|
戻り値:
| 名前 | タイプ | デスクリプション |
|---|---|---|
Reporter |
Reporter
|
固定した値を補って自身へ委譲するReporter。 |
Examples: >>> reporter2 = reporter.bind(code=Code.SCHEMA_ERROR, phase=Phase.LOAD) >>> reporter2.error("スキーマ違反がありました")
ソースコード位置: python/stbkit-core/src/stbkit/core/stb_reporting.py
596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 | |
ReportingResult ¶
Bases: list[_ReportItem]
メッセージリスト
to_dict ¶
to_dict() -> list[dict[str, object]]
記録されたメッセージをdictに変換します。 Returns: list[dict[str, object]]: 記録されたメッセージをdictのリスト形式で返します。
ソースコード位置: python/stbkit-core/src/stbkit/core/stb_reporting.py
271 272 273 274 275 276 | |
to_text ¶
to_text(*, has_timestamp: bool = False, has_code: bool = True, has_phase: bool = True, has_path: bool = True, show_level: Severity = WARNING, separator: str = ' ') -> str
記録されたメッセージをテキストに変換します。
引数:
| 名前 | タイプ | デスクリプション | デフォルト |
|---|---|---|---|
has_timestamp
|
bool
|
timestampを含めるかどうか。 |
False
|
has_code
|
bool
|
codeを含めるかどうか。 |
True
|
has_phase
|
bool
|
phaseを含めるかどうか。 |
True
|
has_path
|
bool
|
xpathを含めるかどうか。 |
True
|
show_level
|
Severity
|
出力する最低の重大度。これ未満のメッセージは除きます。 |
WARNING
|
戻り値:
| 名前 | タイプ | デスクリプション |
|---|---|---|
str |
str
|
改行区切りのテキスト。該当するメッセージが無い場合は空文字列。 |
ソースコード位置: python/stbkit-core/src/stbkit/core/stb_reporting.py
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 | |
get_repository ¶
get_repository(stb: StBridge) -> RepositoryV2_1_1
get_repository(stb: StBridge) -> RepositoryV2_1_0
get_repository(stb: StBridge) -> RepositoryV2_0_2
get_repository(stb: StBridgeRoot) -> RepositoryBase
get_repository(stb: StBridgeRoot) -> RepositoryBase
ST-Bridgeモデルの参照解決をおこなうリポジトリを取得する。
作成時に参照解決用の索引を作るため、モデルを変更した場合はrefresh()を呼び出す必要があります
引数:
| 名前 | タイプ | デスクリプション | デフォルト |
|---|---|---|---|
stb
|
StBridgeRoot
|
ST-Bridgeのルート要素 |
必須 |
戻り値:
| 名前 | タイプ | デスクリプション |
|---|---|---|
RepositoryBase |
RepositoryBase
|
stbのバージョンに対応するリポジトリ。 |
発生:
| タイプ | デスクリプション |
|---|---|
TypeError
|
引数に対応していないバージョンのモデルを渡した場合。 |
例:
>>> import stbkit.api
>>> import stbkit.api.experimental
>>> stb = stbkit.api.load_latest("model.stb")
>>> repo = stbkit.api.experimental.get_repository(stb)
ソースコード位置: python/stbkit-core/src/stbkit/core/repository/__init__.py
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 | |
from_dict ¶
from_dict(data: Mapping[str, Any], *, root_type: type[T], _profile: DictProfile = DEFAULT, logger: Logger | None = None, reporter: Reporter | None = None) -> T
from_dict(data: Mapping[str, Any], *, root_type: None = None, _profile: DictProfile = DEFAULT, logger: Logger | None = None, reporter: Reporter | None = None) -> StBridgeRoot
from_dict(data: Mapping[str, Any], *, root_type: type[StBridgeRoot] | None = None, _profile: DictProfile = DEFAULT, logger: Logger | None = None, reporter: Reporter | None = None) -> StBridgeRoot
辞書からST-Bridgeのモデルへの変換。
値不正はloadと同様に、不正値等は退避しつつ、可能な範囲で読み込みます。
root_typeを指定した場合は、その型に読み込みます。 root_typeを省略した場合は、辞書のversionから読み込む型を判断します。
引数:
| 名前 | タイプ | デスクリプション | デフォルト |
|---|---|---|---|
data
|
Mapping[str, Any]
|
読み込む辞書。 |
必須 |
root_type
|
type[StBridgeRoot] | None
|
戻り値の型。Noneの場合はdataのversionから決定します。 |
None
|
_profile
|
DictProfile
|
辞書の変換ルール。検証中のため指定せず規定値を利用してください。 |
DEFAULT
|
logger
|
Logger | None
|
出力先Logger |
None
|
reporter
|
Reporter | None
|
出力先Reporter。 |
None
|
戻り値:
| 名前 | タイプ | デスクリプション |
|---|---|---|
StBridgeRoot |
StBridgeRoot
|
ST-Bridgeモデル。 |
発生:
| タイプ | デスクリプション |
|---|---|
SchemaError
|
|
UnsupportedStbVersionError
|
|
ValueError
|
入力の辞書が循環参照している場合、または同じフィールドへ 対応する辞書キーが衝突した場合。 |
例:
>>> import stbkit.api as api
>>> stb_dict = api.experimental.to_dict(stb)
>>> new_stb = api.experimental.from_dict(stb_dict)
ソースコード位置: python/stbkit-core/src/stbkit/core/serialization/_dict_converter.py
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 | |
to_dict ¶
to_dict(element: StBridgeElement, *, _profile: DictProfile = DEFAULT, logger: Logger | None = None, reporter: Reporter | None = None) -> dict[str, Any]
ST-Bridge要素を辞書へ変換します。
ルート要素以外も変換できます。 モデル内のリストや辞書は複製します。 辞書を変更しても、入力モデルには影響しません。
引数:
| 名前 | タイプ | デスクリプション | デフォルト |
|---|---|---|---|
element
|
StBridgeElement
|
変換するST-Bridgeの要素。 |
必須 |
_profile
|
DictProfile
|
辞書の変換ルール。検証中のため、指定せず既定値を使用してください。 |
DEFAULT
|
logger
|
Logger | None
|
出力先Logger。 |
None
|
reporter
|
Reporter | None
|
出力先Reporter。 |
None
|
戻り値:
| タイプ | デスクリプション |
|---|---|
dict[str, Any]
|
dict[str, Any]: ST-Bridgeの辞書。 |
発生:
| タイプ | デスクリプション |
|---|---|
TypeError
|
フィールドの値がモデルの型定義と一致しない場合。 |
ValueError
|
要素が循環参照している場合、辞書キーが衝突した場合、 または要素のからバージョン解決ができない場合。 |
例:
>>> import stbkit.api
>>> raw = stbkit.api.experimental.to_dict(stb)
ソースコード位置: python/stbkit-core/src/stbkit/core/serialization/_dict_converter.py
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 | |