20 lines
570 B
Python
20 lines
570 B
Python
import re
|
|
import json
|
|
|
|
class InvalidDataObjectException(Exception):
|
|
def __init__(self, message):
|
|
super().__init__(message)
|
|
|
|
class AbstractDataObject(object):
|
|
invalidChars = re.compile("[#+\s]")
|
|
|
|
def __init__(self, topicPart):
|
|
self.topicPart = topicPart
|
|
|
|
def getTopicPart(self):
|
|
if AbstractDataObject.invalidChars.search(self.topicPart):
|
|
raise InvalidDataObjectException(f"Topic contains invalid characters: {self.topicPart}")
|
|
return self.topicPart
|
|
|
|
def getPayload(self):
|
|
raise NotImplementedError() |