Skip to content

Commit

Permalink
make empty_subscription a public entry point
Browse files Browse the repository at this point in the history
  • Loading branch information
petersilva committed Aug 8, 2024
1 parent 61ad1b9 commit d870027
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions sarracenia/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1340,7 +1340,10 @@ def _resolve_exchange(self):
if hasattr(self, 'exchangeSplit') and hasattr(self, 'no') and (self.no > 0):
self.exchange += "%02d" % self.no

def _empty_subscription(self) -> dict:
def empty_subscription(self) -> dict:
"""
return an empty_subscrption based on current options.
"""
new_subscriptions={}
for i in [ 'auto_delete', 'broker', 'durable', 'exchange', 'expire', 'message_ttl', 'prefetch', \
'qos', 'queueBind', 'queueDeclare', 'queueName', 'topicPrefix' ]:
Expand Down Expand Up @@ -1373,7 +1376,7 @@ def _parse_subscription(self, subtopic_string):
subtopic = subtopic_string.split('/')

if hasattr(self, 'exchange') and hasattr(self, 'topicPrefix'):
new_subscription=self._empty_subscription()
new_subscription=self.empty_subscription()
new_subscription['subtopic'] = subtopic

self.subscriptions.append(new_subscription)
Expand Down Expand Up @@ -2450,7 +2453,7 @@ def __call__(self, parser, namespace, values, option_string):
else:
topicPrefix = namespace.topicPrefix.split('/')

new_subscription = namespace._empty_subscription()
new_subscription = namespace.empty_subscription()
new_subscription['topicPrefix'] = topicPrefix
new_subscription['subtopic'] = values

Expand Down

0 comments on commit d870027

Please sign in to comment.