1
1
# Copyright the TUF contributors
2
2
# SPDX-License-Identifier: MIT OR Apache-2.0
3
3
4
- """Trusted collection of client-side TUF Metadata
4
+ """Trusted collection of client-side TUF Metadata.
5
5
6
6
``TrustedMetadataSet`` keeps track of the current valid set of metadata for the
7
7
client, and handles almost every step of the "Detailed client workflow" (
71
71
72
72
73
73
class TrustedMetadataSet (abc .Mapping ):
74
- """Internal class to keep track of trusted metadata in ``Updater``
74
+ """Internal class to keep track of trusted metadata in ``Updater``.
75
75
76
76
``TrustedMetadataSet`` ensures that the collection of metadata in it is valid
77
77
and trusted through the whole client update workflow. It provides easy ways
78
78
to update the metadata with the caller making decisions on what is updated.
79
79
"""
80
80
81
81
def __init__ (self , root_data : bytes ):
82
- """Initialize ``TrustedMetadataSet`` by loading trusted root metadata
82
+ """Initialize ``TrustedMetadataSet`` by loading trusted root metadata.
83
83
84
84
Args:
85
85
root_data: Trusted root metadata as bytes. Note that this metadata
@@ -99,36 +99,36 @@ def __init__(self, root_data: bytes):
99
99
self ._load_trusted_root (root_data )
100
100
101
101
def __getitem__ (self , role : str ) -> Metadata :
102
- """Return current ``Metadata`` for ``role``"""
102
+ """Return current ``Metadata`` for ``role``. """
103
103
return self ._trusted_set [role ]
104
104
105
105
def __len__ (self ) -> int :
106
- """Return number of ``Metadata`` objects in ``TrustedMetadataSet``"""
106
+ """Return number of ``Metadata`` objects in ``TrustedMetadataSet``. """
107
107
return len (self ._trusted_set )
108
108
109
109
def __iter__ (self ) -> Iterator [Metadata ]:
110
- """Return iterator over ``Metadata`` objects in ``TrustedMetadataSet``"""
110
+ """Return iterator over ``Metadata`` objects in ``TrustedMetadataSet``. """
111
111
return iter (self ._trusted_set .values ())
112
112
113
113
# Helper properties for top level metadata
114
114
@property
115
115
def root (self ) -> Metadata [Root ]:
116
- """Get current root ``Metadata``"""
116
+ """Get current root ``Metadata``. """
117
117
return self ._trusted_set [Root .type ]
118
118
119
119
@property
120
120
def timestamp (self ) -> Metadata [Timestamp ]:
121
- """Get current timestamp ``Metadata``"""
121
+ """Get current timestamp ``Metadata``. """
122
122
return self ._trusted_set [Timestamp .type ]
123
123
124
124
@property
125
125
def snapshot (self ) -> Metadata [Snapshot ]:
126
- """Get current snapshot ``Metadata``"""
126
+ """Get current snapshot ``Metadata``. """
127
127
return self ._trusted_set [Snapshot .type ]
128
128
129
129
@property
130
130
def targets (self ) -> Metadata [Targets ]:
131
- """Get current top-level targets ``Metadata``"""
131
+ """Get current top-level targets ``Metadata``. """
132
132
return self ._trusted_set [Targets .type ]
133
133
134
134
# Methods for updating metadata
@@ -251,7 +251,7 @@ def update_timestamp(self, data: bytes) -> Metadata[Timestamp]:
251
251
return new_timestamp
252
252
253
253
def _check_final_timestamp (self ) -> None :
254
- """Raise if timestamp is expired"""
254
+ """Raise if timestamp is expired. """
255
255
256
256
if self .timestamp .signed .is_expired (self .reference_time ):
257
257
raise exceptions .ExpiredMetadataError ("timestamp.json is expired" )
@@ -345,7 +345,7 @@ def update_snapshot(
345
345
return new_snapshot
346
346
347
347
def _check_final_snapshot (self ) -> None :
348
- """Raise if snapshot is expired or meta version does not match"""
348
+ """Raise if snapshot is expired or meta version does not match. """
349
349
350
350
if self .snapshot .signed .is_expired (self .reference_time ):
351
351
raise exceptions .ExpiredMetadataError ("snapshot.json is expired" )
0 commit comments