|
4 | 4 | from __future__ import annotations |
5 | 5 |
|
6 | 6 | from dataclasses import dataclass, field, fields |
7 | | -from typing import Any, Dict, Optional |
| 7 | +from typing import Any, Dict, Generator, Optional |
8 | 8 |
|
9 | 9 | from .base import NetworkManagerSettingsMixin |
10 | 10 | from .adsl import AdslSettings |
@@ -463,6 +463,33 @@ def update(self, other: ConnectionProfile) -> None: |
463 | 463 |
|
464 | 464 | setattr(my_settings, setting_field_name, other_setting) |
465 | 465 |
|
| 466 | + def update_secrets_generator( |
| 467 | + self) -> Generator[str, ConnectionProfile, None]: |
| 468 | + for attr_name, value in vars(self).items(): |
| 469 | + if value is None: |
| 470 | + continue |
| 471 | + |
| 472 | + if not isinstance(value, NetworkManagerSettingsMixin): |
| 473 | + continue |
| 474 | + |
| 475 | + secret_setting_name = value.secret_name |
| 476 | + |
| 477 | + if not secret_setting_name: |
| 478 | + continue |
| 479 | + |
| 480 | + secret_profile = yield secret_setting_name |
| 481 | + current_setting_secrets = getattr(secret_profile, attr_name) |
| 482 | + |
| 483 | + for secret_attribute in value.secret_fields_names: |
| 484 | + setattr( |
| 485 | + value, |
| 486 | + secret_attribute, |
| 487 | + getattr( |
| 488 | + current_setting_secrets, |
| 489 | + secret_attribute, |
| 490 | + ), |
| 491 | + ) |
| 492 | + |
466 | 493 |
|
467 | 494 | SETTING_DBUS_NAME_TO_NAME: Dict[str, str] = { |
468 | 495 | f.metadata['dbus_name']: f.name |
|
0 commit comments