-
Notifications
You must be signed in to change notification settings - Fork 275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move metadata class model de/serialization to sub-package #1279
Merged
lukpueh
merged 18 commits into
theupdateframework:develop
from
lukpueh:external_serializer
Mar 10, 2021
+364
−181
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
3d8cade
Add metadata serialization sub-package
lukpueh 4a22b4a
Add concrete de/serializer implementations
lukpueh 499f1c8
Adopt serialization sub-package in metadata API
lukpueh 240fb54
Use custom errors in serializer.json sub-package
lukpueh e1be085
Move to/from_dict metadata API methods to util
lukpueh 8e9afc9
Revert "Move to/from_dict metadata API methods..."
lukpueh 2f57eb8
Add SPDX style license and copyright boilerplate
lukpueh 2b40857
Re-word serialization cyclic import code comments
lukpueh aa8225c
Mark kwargs in metadata API methods as Optional
lukpueh d823c8f
Rename a few variables in tuf.api
lukpueh aba6ba3
Use named argument instead of clarifying comment
lukpueh f8fc5e2
Reduce JSON-bias in metadata class model
lukpueh ace25e4
Demystify from/to_dict methods in Signed baseclass
lukpueh 326d2af
Fix blank lines in tuf.api as per styleguide
lukpueh ab92ba2
Fix inconsistent returns in json serializers
lukpueh bd94f6d
Remove py2 compat from api.serialization package
lukpueh a53d68b
Re-word api.serializer.json docstrings
lukpueh ef91964
Call mixin-style parent methods on cls/self
lukpueh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
"""TUF role metadata de/serialization. | ||
joshuagl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
This sub-package provides abstract base classes and concrete implementations to | ||
serialize and deserialize TUF role metadata and metadata parts. | ||
|
||
Any custom de/serialization implementations should inherit from the abstract | ||
base classes defined in this __init__.py module. | ||
|
||
- Metadata de/serializers are used to convert to and from wireline formats. | ||
- Signed serializers are used to canonicalize data for cryptographic signatures | ||
generation and verification. | ||
|
||
""" | ||
import abc | ||
|
||
class MetadataDeserializer(): | ||
"""Abstract base class for deserialization of Metadata objects. """ | ||
__metaclass__ = abc.ABCMeta | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: now that we are only supporting Python3 we can switch to less confusing metaclass syntax, either import abc
class MetadataDeserializer(ABC): or import abc
class MetadataDeserializer(metaclass=ABCMeta): we can handle this in a future PR, though. |
||
|
||
@abc.abstractmethod | ||
def deserialize(self, raw_data: bytes) -> "Metadata": | ||
"""Deserialize passed bytes to Metadata object. """ | ||
raise NotImplementedError | ||
|
||
|
||
class MetadataSerializer(): | ||
"""Abstract base class for serialization of Metadata objects. """ | ||
__metaclass__ = abc.ABCMeta | ||
|
||
@abc.abstractmethod | ||
def serialize(self, metadata_obj: "Metadata") -> bytes: | ||
"""Serialize passed Metadata object to bytes. """ | ||
raise NotImplementedError | ||
|
||
|
||
class SignedSerializer(): | ||
"""Abstract base class for serialization of Signed objects. """ | ||
__metaclass__ = abc.ABCMeta | ||
|
||
@abc.abstractmethod | ||
def serialize(self, signed_obj: "Signed") -> bytes: | ||
"""Serialize passed Signed object to bytes. """ | ||
raise NotImplementedError |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to ignore all files under a certain folder?
That way you would be able to ignore everything under
tuf/api
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope (see my comment). I even looked at the implementation of
--ignore
and--ignore-patterns
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC there's a corresponding ticket on the pylint issue tracker.