Skip to content

Commit

Permalink
Add basic context manager functionality
Browse files Browse the repository at this point in the history
This change adds a basic content manager that creates the manifest on enter and deletes the allocation on exit.
This can certainly be beefed up!
  • Loading branch information
JacobCallahan committed Aug 10, 2022
1 parent f344a97 commit 951bfbe
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions manifester/manifester.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,3 +323,13 @@ def get_manifest(self):
subscription_data=sub,
)
return self.trigger_manifest_export()

def __enter__(self):
try:
return self.get_manifest()
except:
self.delete_subscription_allocation()
raise

def __exit__(self, *tb_args):
self.delete_subscription_allocation()

0 comments on commit 951bfbe

Please sign in to comment.