@@ -1085,15 +1085,15 @@ class TargetFile(BaseFile):
1085
1085
Attributes:
1086
1086
length: An integer indicating the length of the target file.
1087
1087
hashes: A dictionary of hash algorithm names to hash values.
1088
- targetname: An optional string denoting the target file name .
1088
+ path: A string denoting the target file path .
1089
1089
unrecognized_fields: Dictionary of all unrecognized fields.
1090
1090
"""
1091
1091
1092
1092
def __init__ (
1093
1093
self ,
1094
1094
length : int ,
1095
1095
hashes : Dict [str , str ],
1096
- targetname : Optional [ str ] = None ,
1096
+ path : str ,
1097
1097
unrecognized_fields : Optional [Mapping [str , Any ]] = None ,
1098
1098
) -> None :
1099
1099
@@ -1102,23 +1102,21 @@ def __init__(
1102
1102
1103
1103
self .length = length
1104
1104
self .hashes = hashes
1105
- self .targetname = targetname
1105
+ self .path = path
1106
1106
self .unrecognized_fields = unrecognized_fields or {}
1107
1107
1108
1108
@property
1109
1109
def custom (self ) -> Any :
1110
1110
return self .unrecognized_fields .get ("custom" , None )
1111
1111
1112
1112
@classmethod
1113
- def from_dict (
1114
- cls , target_dict : Dict [str , Any ], targetname : Optional [str ] = None
1115
- ) -> "TargetFile" :
1113
+ def from_dict (cls , target_dict : Dict [str , Any ], path : str ) -> "TargetFile" :
1116
1114
"""Creates TargetFile object from its dict representation."""
1117
1115
length = target_dict .pop ("length" )
1118
1116
hashes = target_dict .pop ("hashes" )
1119
1117
1120
1118
# All fields left in the target_dict are unrecognized.
1121
- return cls (length , hashes , targetname , target_dict )
1119
+ return cls (length , hashes , path , target_dict )
1122
1120
1123
1121
def to_dict (self ) -> Dict [str , Any ]:
1124
1122
"""Returns the JSON-serializable dictionary representation of self."""
@@ -1184,7 +1182,9 @@ def from_dict(cls, signed_dict: Dict[str, Any]) -> "Targets":
1184
1182
delegations = Delegations .from_dict (delegations_dict )
1185
1183
res_targets = {}
1186
1184
for target_path , target_info in targets .items ():
1187
- res_targets [target_path ] = TargetFile .from_dict (target_info )
1185
+ res_targets [target_path ] = TargetFile .from_dict (
1186
+ target_info , target_path
1187
+ )
1188
1188
# All fields left in the targets_dict are unrecognized.
1189
1189
return cls (* common_args , res_targets , delegations , signed_dict )
1190
1190
0 commit comments