Stop using formats.py in metadata.py

Currently we have one use of tuf/formats.py in tuf/api/metadata.py.
If we do the conversion of the expires string in metadata.py,
we can keep the two implementations separate.

Signed-off-by: Velichka Atanasova <avelichka@vmware.com>
This commit is contained in:
Velichka Atanasova 2021-06-02 14:37:29 +03:00
parent 0b54cafa94
commit 4e8a0fe140

View file

@ -25,7 +25,7 @@
from securesystemslib.storage import FilesystemBackend, StorageBackendInterface
from securesystemslib.util import persist_temp_file
from tuf import exceptions, formats
from tuf import exceptions
from tuf.api.serialization import (
MetadataDeserializer,
MetadataSerializer,
@ -384,7 +384,7 @@ def _common_fields_from_dict(
# Convert 'expires' TUF metadata string to a datetime object, which is
# what the constructor expects and what we store. The inverse operation
# is implemented in '_common_fields_to_dict'.
expires = formats.expiry_string_to_datetime(expires_str)
expires = datetime.strptime(expires_str, "%Y-%m-%dT%H:%M:%SZ")
return version, spec_version, expires
def _common_fields_to_dict(self) -> Dict[str, Any]: