Add MessageTag.present, to see if a tag is present (even without value)

This commit is contained in:
jesopo 2019-06-19 22:36:42 +01:00
parent e55cd1e98e
commit 9457430c15

View file

@ -317,6 +317,8 @@ class MessageTag(object):
def get_value(self, tags: typing.Dict[str, str]) -> typing.Optional[str]: def get_value(self, tags: typing.Dict[str, str]) -> typing.Optional[str]:
key = list(set(tags.keys())&self._names) key = list(set(tags.keys())&self._names)
return tags[key[0]] if key else None return tags[key[0]] if key else None
def present(self, tags: typing.Dict[str, str]) -> bool:
return bool(set(tags.keys())&self._names)
def match(self, tag: str) -> typing.Optional[str]: def match(self, tag: str) -> typing.Optional[str]:
key = list(set([tag])&self._names) key = list(set([tag])&self._names)
return key[0] if key else None return key[0] if key else None