@@ -381,6 +381,10 @@ def __init__(
381
381
self , _type : str = None , version : int = None , spec_version : str = None ,
382
382
expires : datetime = None , consistent_snapshot : bool = None ,
383
383
keys : JsonDict = None , roles : JsonDict = None ) -> None :
384
+
385
+ # TODO: Add sensible defaults when we have input validation.
386
+ # See issue https://github.com/theupdateframework/tuf/issues/1140
387
+ # We need default values to create empty objects in Signed.from_dict()
384
388
super ().__init__ (_type , version , spec_version , expires )
385
389
# TODO: Add classes for keys and roles
386
390
self .consistent_snapshot = consistent_snapshot
@@ -493,6 +497,10 @@ def __init__(
493
497
self , _type : str = None , version : int = None , spec_version : str = None ,
494
498
expires : datetime = None , meta : Dict [str , MetadataInfo ]= None
495
499
) -> None :
500
+
501
+ # TODO: Add sensible defaults when we have input validation.
502
+ # See issue https://github.com/theupdateframework/tuf/issues/1140
503
+ # We need default values to create empty objects in Signed.from_dict()
496
504
super ().__init__ (_type , version , spec_version , expires )
497
505
self .meta = meta
498
506
@@ -528,6 +536,8 @@ def update(self, version: int, length: Optional[int] = None,
528
536
hashes : Optional [JsonDict ] = None ) -> None :
529
537
"""Assigns passed info about snapshot metadata to meta dict. """
530
538
539
+ # TODO: Consider renaming this function:
540
+ # see: https://github.com/theupdateframework/tuf/issues/1230
531
541
self .meta ['snapshot.json' ] = MetadataInfo (version , length , hashes )
532
542
533
543
@@ -549,6 +559,10 @@ def __init__(
549
559
self , _type : str = None , version : int = None , spec_version : str = None ,
550
560
expires : datetime = None , meta : Dict [str , MetadataInfo ]= None
551
561
) -> None :
562
+
563
+ # TODO: Add sensible defaults when we have input validation.
564
+ # See issue https://github.com/theupdateframework/tuf/issues/1140
565
+ # We need default values to create empty objects in Signed.from_dict()
552
566
super ().__init__ (_type , version , spec_version , expires )
553
567
self .meta = meta
554
568
@@ -587,6 +601,9 @@ def update(
587
601
self , rolename : str , version : int , length : Optional [int ] = None ,
588
602
hashes : Optional [JsonDict ] = None ) -> None :
589
603
"""Assigns passed (delegated) targets role info to meta dict. """
604
+
605
+ # TODO: Consider renaming this function:
606
+ # see: https://github.com/theupdateframework/tuf/issues/1230
590
607
metadata_fn = f'{ rolename } .json'
591
608
592
609
self .meta [metadata_fn ] = MetadataInfo (version , length , hashes )
@@ -697,6 +714,10 @@ def __init__(
697
714
self , _type : str = None , version : int = None , spec_version : str = None ,
698
715
expires : datetime = None , targets : Dict [str , TargetInfo ]= None ,
699
716
delegations : JsonDict = None ) -> None :
717
+
718
+ # TODO: Add sensible defaults when we have input validation.
719
+ # See issue https://github.com/theupdateframework/tuf/issues/1140
720
+ # We need default values to create empty objects in Signed.from_dict()
700
721
super ().__init__ (_type , version , spec_version , expires )
701
722
self .targets = targets
702
723
@@ -737,5 +758,8 @@ def to_dict(self) -> JsonDict:
737
758
# Modification.
738
759
def update (self , filename : str , fileinfo : JsonDict ) -> None :
739
760
"""Assigns passed target file info to meta dict. """
761
+
762
+ # TODO: Consider renaming this function:
763
+ # see: https://github.com/theupdateframework/tuf/issues/1230
740
764
self .targets [filename ] = TargetInfo (fileinfo ['length' ],
741
765
fileinfo ['hashes' ], fileinfo .get ('custom' ))
0 commit comments