3 Commits

Author SHA1 Message Date
juk0de 568646e782 configuration: added 'asdict()' as an instance function 2023-08-19 08:16:13 +02:00
juk0de 9c2456da2c added testcases for messages.py 2023-08-19 08:16:13 +02:00
juk0de 837c5ecfa8 added new module 'message.py' 2023-08-19 08:16:13 +02:00
+4 -2
View File
@@ -97,7 +97,7 @@ class Message():
path: Optional[pathlib.Path] path: Optional[pathlib.Path]
# @classmethod # @classmethod
# def from_file(cls: Type[MessageInst], path: str) -> MessageInst: # def from_file(cls: Type[MessageInst], path: pathlib.Path) -> MessageInst:
# """ # """
# Create a Message from the given file. Expects the following file structure: # Create a Message from the given file. Expects the following file structure:
# * TagLine (from 'self.tags') # * TagLine (from 'self.tags')
@@ -107,7 +107,7 @@ class Message():
# """ # """
# pass # pass
def to_file(self, path: str) -> None: def to_file(self, path: Optional[pathlib.Path]) -> None:
""" """
Write Message to the given file. Creates the following file structure: Write Message to the given file. Creates the following file structure:
* TagLine (from 'self.tags') * TagLine (from 'self.tags')
@@ -116,6 +116,8 @@ class Message():
* Answer.Header * Answer.Header
* Answer * Answer
""" """
if not path and not self.path:
raise MessageError('Got no valid path to write message')
pass pass
def asdict(self) -> dict[str, Any]: def asdict(self) -> dict[str, Any]: