visualdynamics.report.features¶
features
¶
Report features: optional additions to a report, each turned on or off.
A report carries the keys of the features enabled on it
(Report.features). With none enabled, the report renders exactly as
it would without this module: the same page, byte for byte. Each
feature changes only what its description says, and only when it is
enabled, so a lab turns on what its reports need and nothing else
moves.
The registry (FEATURES) lists every feature, including those not yet
built, so the selection tool shows what is planned. A feature that is
not built is marked unavailable and cannot be enabled. A feature can
need another feature (requires names its key), or a capability the
package does not have yet (CAPABILITIES); while a requirement is not
met, the feature cannot be enabled and the tool says what is missing.
The three presets (PRESETS) are starting points: the default (no
features, today's report), a test report, and a flash report. A preset
may name features that are not available yet; applying it enables the
ones that are and says which it skipped and why.
configure is the one place a report's features change, and refuses
an unknown key, an unavailable feature or an unmet requirement before
changing anything. Project.report_features and the report editor's
Report Features panel both call it.
Classes:
| Name | Description |
|---|---|
ReportFeature |
One optional addition to a report. |
Capability |
Something a feature needs that the package itself must provide. |
Preset |
A named set of features to start from. |
FeatureSelection |
What |
Functions:
| Name | Description |
|---|---|
unmet |
What stands between feature |
reason |
|
enabled |
The features that act on |
defaults |
The features a new report starts with: those whose |
configure |
Change which features are enabled on |
preset_of |
The preset whose available features are exactly |
Classes¶
ReportFeature
dataclass
¶
ReportFeature(key: str, title: str, group: str, description: str, requires: tuple[str, ...] = (), default: bool = False, available: bool = True)
One optional addition to a report.
key is what a report stores and a script names. title and
description are what the selection tool shows: the title on the
check box, the description beneath it and in its tooltip. group is
one of GROUPS. requires names what must be in place first: the
key of another feature, which must be enabled, or the key of a
capability in CAPABILITIES, which the package must have. default
is whether a new report starts with the feature on; every feature
is off by default. available is False for a feature that is
registered so the tool can show it but is not built yet.
Capability
dataclass
¶
Something a feature needs that the package itself must provide.
label names it in a reason ("needs the multi-point composite").
probe answers whether this installation has it.
Preset
dataclass
¶
A named set of features to start from.
FeatureSelection
dataclass
¶
What configure left enabled, and what it has to say.
enabled is the report's features afterwards, in registry order.
notes says what was skipped or turned off along the way: a
preset's unavailable features, or a feature turned off because a
feature it needs was.
Functions:¶
unmet
¶
What stands between feature key and being enabled, in words.
Empty when nothing does. An unbuilt feature says 'not yet
available' first and then what it will wait on; a built one names
each feature that must be enabled (from enabled) and each
capability this installation does not have. Raises ValueError for
a key that is not a registered feature.
Source code in src/visualdynamics/report/features.py
reason
¶
unmet as one line for the selection tool: '' when the feature
can be enabled.
enabled
¶
The features that act on report when it is rendered.
Read from report.features, kept to the registered, available
features whose requirements are met, in registry order. A key the
registry does not know (written by a later version, say) is kept on
the report but does nothing here.
Source code in src/visualdynamics/report/features.py
defaults
¶
The features a new report starts with: those whose default is
True. None are, so a new report starts as Visual Dynamics writes it.
Source code in src/visualdynamics/report/features.py
configure
¶
configure(report: Any, *, enable: str | Iterable[str] = (), disable: str | Iterable[str] = (), preset: str | None = None) -> FeatureSelection
Change which features are enabled on report.
With preset, the report's features are replaced by the preset's
available ones first, and every feature the preset names but cannot
have is skipped with a note. Then disable turns features off, and
a feature that needs one turned off goes with it, with a note. Then
enable turns features on; a feature needing another may be
enabled in the same call as the one it needs.
Every request is checked before anything changes, so a refused call leaves the report as it was. Refused: an unknown feature or preset, a feature that is not yet available, a feature whose requirement is not met, and a key both enabled and disabled. Keys the registry does not know that are already on the report (from a later version) are kept, except when a preset replaces the set.
Returns:
| Type | Description |
|---|---|
FeatureSelection
|
The features enabled afterwards and the notes. |
Raises:
| Type | Description |
|---|---|
ValueError
|
For a refusal; the message names the feature and the reason. |
TypeError
|
When a key is not a string. |
Source code in src/visualdynamics/report/features.py
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 | |
preset_of
¶
The preset whose available features are exactly keys, or None
when the set matches none of them (a custom choice).