python-tuf/tuf
Lukas Puehringer f63dce6ddd Refactor metadata constructors and add factory
This commit better separates the Metadata class model from the
Metadata wireline format, by tailoring the constructors
towards class-based parameters and adding an additional
factory classmethod that creates Metadata objects based on the
wireline json/dictionary metadata representation. (pythonic
way of constructor overloading).

This 'from_dict' factory method recurses into the 'from_dict'
methods of each contained complex field/attribute that is also
represented by a class. Currently 'signed' is the only such
attribute.

This commit further:
- Changes optional constructor keyword arguments to mandatory
positional arguments: Reduces code and simplifies usage by
restricting it. For now, users are unlikely to call
constructor directly anyway, but the 'from_dict' factory (or
its 'from_json_file' wrapper) instead.

- Removes Signed.__expiration (datetime) vs. Signed.expires
(datestring) dichotomy: Keeping only one representation of the
same attribute in memory makes the interface simpler and less
ambiguous. We choose the datetime object, because it is more
convenient to modify. Transformation from and to the string
format required by the tuf wireline format is performed in the
corresponding metadata de/serialization methods, i.e.
('to_dict' and 'from_dict').

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
2020-09-10 16:18:28 +02:00
..
api Refactor metadata constructors and add factory 2020-09-10 16:18:28 +02:00
client Port to new securesystemslib w abstract filesystem 2020-05-12 22:16:50 +01:00
scripts Merge pull request #989 from joshuagl/logger 2020-03-11 14:33:35 +01:00
__init__.py release: 0.12.2 2020-01-10 15:43:44 -05:00
ATTACKS.md fix-up the document spelling mistake 2019-08-27 14:41:24 +08:00
developer_tool.py Port to new securesystemslib w abstract filesystem 2020-05-12 22:16:50 +01:00
download.py Use __name__ for loggers, per convention 2020-03-03 10:36:39 +00:00
exceptions.py Use __name__ for loggers, per convention 2020-03-03 10:36:39 +00:00
formats.py Improve accuracy of CUSTOM_SCHEMA definition 2020-04-30 22:17:31 +01:00
keydb.py Use __name__ for loggers, per convention 2020-03-03 10:36:39 +00:00
log.py Use __name__ for loggers, per convention 2020-03-03 10:36:39 +00:00
mirrors.py Remove deprecated securesystemslib.formats schemas 2019-09-17 10:28:10 +01:00
README-developer-tools.md Remove or edit remaining instances of 'restricted paths' 2018-01-19 14:20:38 -05:00
README.md Link to CLI.md from getting started and readme docs 2018-02-06 17:00:24 -05:00
repository_lib.py Load full target file info for delegated targets 2020-06-09 16:48:42 +03:00
repository_tool.py Load full target file info for delegated targets 2020-06-09 16:48:42 +03:00
roledb.py Use __name__ for loggers, per convention 2020-03-03 10:36:39 +00:00
settings.py Port to new securesystemslib w abstract filesystem 2020-05-12 22:16:50 +01:00
sig.py Use __name__ for loggers, per convention 2020-03-03 10:36:39 +00:00
unittest_toolbox.py Rename license files in modules 2018-02-05 11:31:19 -05:00