From f3cd617a3c1a24cb20d98d5a2cbc4e7b8dccb750 Mon Sep 17 00:00:00 2001 From: synkd Date: Wed, 24 Aug 2022 15:25:57 -0400 Subject: [PATCH] Refactor to accept dictionary as manifest category After discussing this PR in the Satellite Automation channel, I am going in a different direction here. Instead of ingesting the settings from external frameworks, Manifester's `__init__` method will now accept a either a dictionary or a string as the `manifest_category` argument. This should allow greater flexibility with how Manifester's settings are stored and accessed when used with external frameworks and also reduce the risk of settings collisions resulting from Manifester loading all the settings of such a framework. --- manifester/manifester.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/manifester/manifester.py b/manifester/manifester.py index fdaea30..941cac3 100644 --- a/manifester/manifester.py +++ b/manifester/manifester.py @@ -12,13 +12,14 @@ class Manifester: def __init__(self, manifest_category, allocation_name=None, **kwargs): + if isinstance(manifest_category, dict): + self.manifest_data = manifest_category + else: + self.manifest_data = settings.manifest_category.get(manifest_category) self.allocation_name = allocation_name or "".join( random.sample(string.ascii_letters, 10) ) - self.manifest_data = settings.manifest_category.get(manifest_category) - self.offline_token = kwargs.get( - "offline_token", self.manifest_data.get("offline_token", settings.offline_token) - ) + self.offline_token = kwargs.get("offline_token", self.manifest_data.offline_token) self.subscription_data = self.manifest_data.subscription_data self.sat_version = kwargs.get("sat_version", self.manifest_data.sat_version) self.token_request_data = {