Indicio-tech / pydid

Python library for validating, constructing, and representing DIDs and DID Documents
Apache License 2.0
11 stars 12 forks source link

Add remove functionality to builders, rework context managers #9

Closed dbluhm closed 3 years ago

dbluhm commented 3 years ago

This PR adds remove operations to the various builders and reworks the context manager usage. Now, instead of being required to use the context manager to add to different scopes of the document, the context manager acts as just a space saver, allowing defaults to specified for all the methods to be added and handling identifier generation. This means the following is now possible:

builder = DIDDocumentBuilder("did:example:123")
vmethod = builder.verification_methods.add(
    ident="123", suite=VerificationSuite("Example", "publicKeyExample"), material="abc"
)
with builder.authentication.defaults(suite=VerificationSuite("Example", "publckKeyExample")) as auth:
    auth.reference(vmethod.id)
    auth.embed("some material")
    auth.embed("another material")