execute self.config. = * expands ~ with expanduser * interprets value with trait if available
(
self, lhs: t.Any, rhs: t.Any, trait: TraitType[t.Any, t.Any] | None = None
)
| 663 | """ |
| 664 | |
| 665 | def _exec_config_str( |
| 666 | self, lhs: t.Any, rhs: t.Any, trait: TraitType[t.Any, t.Any] | None = None |
| 667 | ) -> None: |
| 668 | """execute self.config.<lhs> = <rhs> |
| 669 | |
| 670 | * expands ~ with expanduser |
| 671 | * interprets value with trait if available |
| 672 | """ |
| 673 | value = rhs |
| 674 | if isinstance(value, DeferredConfig): |
| 675 | if trait: |
| 676 | # trait available, reify config immediately |
| 677 | value = value.get_value(trait) |
| 678 | elif isinstance(rhs, DeferredConfigList) and len(rhs) == 1: |
| 679 | # single item, make it a deferred str |
| 680 | value = DeferredConfigString(os.path.expanduser(rhs[0])) |
| 681 | else: |
| 682 | if trait: |
| 683 | value = trait.from_string(value) |
| 684 | else: |
| 685 | value = DeferredConfigString(value) |
| 686 | |
| 687 | *path, key = lhs.split(".") |
| 688 | section = self.config |
| 689 | for part in path: |
| 690 | section = section[part] |
| 691 | section[key] = value |
| 692 | return |
| 693 | |
| 694 | def _load_flag(self, cfg: t.Any) -> None: |
| 695 | """update self.config from a flag, which can be a dict or Config""" |
no test coverage detected