Skip to content

Commit

Permalink
add prefix property to subhub
Browse files Browse the repository at this point in the history
  • Loading branch information
semiversus committed Oct 11, 2018
1 parent d2c0001 commit 607a48c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions broqer/hub/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,8 @@ def __init__(self, hub: Hub, prefix: str) -> None:

def __getitem__(self, topic: str) -> Topic:
return self._hub[self._prefix + topic]

@property
def prefix(self):
""" the prefix of this sub hub """
return self._prefix[:-1]
3 changes: 2 additions & 1 deletion test/test_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,5 @@ def test_sub_hub():

sub_hub['value3'].assign(Value(3))

assert hub['prefix.value3'] is sub_hub['value3']
assert hub['prefix.value3'] is sub_hub['value3']
assert sub_hub.prefix == 'prefix'

0 comments on commit 607a48c

Please sign in to comment.