Skip to content

Commit

Permalink
split extensive into an helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-mangin committed Oct 17, 2024
1 parent 972a096 commit 0cea371
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/exabgp/reactor/api/command/neighbor.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,12 @@ def as_dict(cls, answer):
return formated

@classmethod
def extensive(cls, answer):
def formated_dict(cls, answer):
if answer['duration']:
duration = cls.extensive_kv % ('up for', timedelta(seconds=answer['duration']), '', '')
else:
duration = cls.extensive_kv % ('down for', timedelta(seconds=answer['down']), '', '')

formated = {
'peer-address': answer['peer-address'],
'local-address': cls.extensive_kv % ('local', answer['local-address'], '', ''),
Expand All @@ -154,7 +155,11 @@ def extensive(cls, answer):
),
}

return cls.extensive_template % formated
return formated

@classmethod
def extensive(cls, answer):
return cls.extensive_template % cls.formated_dict(answer)

@classmethod
def summary(cls, answer):
Expand Down

0 comments on commit 0cea371

Please sign in to comment.