diff --git a/chatmastermind/chat.py b/chatmastermind/chat.py index 5f15a64..6ea28ff 100644 --- a/chatmastermind/chat.py +++ b/chatmastermind/chat.py @@ -52,7 +52,7 @@ def read_dir(dir_path: Path, Parameters: * 'dir_path': source directory * 'glob': if specified, files will be filtered using 'path.glob()', - otherwise it uses '*{msg_suffix}'. + otherwise it reads all files with the default message suffix * 'mfilter': use with 'Message.from_file()' to filter messages when reading them. """ @@ -295,7 +295,7 @@ class ChatDB(Chat): # a MessageFilter that all messages must match (if given) mfilter: Optional[MessageFilter] = None # the glob pattern for all messages - glob: Optional[str] = None + glob: str = f'*{msg_suffix}' # message format (for writing) mformat: MessageFormat = Message.default_format @@ -311,7 +311,7 @@ class ChatDB(Chat): def from_dir(cls: Type[ChatDBInst], cache_path: Path, db_path: Path, - glob: Optional[str] = None, + glob: str = f'*{msg_suffix}', mfilter: Optional[MessageFilter] = None, loc: msg_location = msg_location.DB) -> ChatDBInst: """ @@ -320,8 +320,7 @@ class ChatDB(Chat): Parameters: * 'cache_path': path to the directory for temporary messages * 'db_path': path to the directory for persistent messages - * 'glob': if specified, files will be filtered using 'path.glob()', - otherwise it uses 'path.iterdir()'. + * 'glob': if specified, files will be filtered using 'path.glob()' * 'mfilter': use with 'Message.from_file()' to filter messages when reading them. """ @@ -400,7 +399,7 @@ class ChatDB(Chat): def msg_gather(self, loc: msg_location, require_file_path: bool = False, - glob: Optional[str] = None, + glob: str = f'*{msg_suffix}', mfilter: Optional[MessageFilter] = None) -> list[Message]: """ Gather and return messages from the given locations: @@ -520,7 +519,7 @@ class ChatDB(Chat): else: return len(self.msg_find([message], loc=msg_location.DB)) > 0 - def cache_read(self, glob: Optional[str] = None, mfilter: Optional[MessageFilter] = None) -> None: + def cache_read(self, glob: str = f'*{msg_suffix}', mfilter: Optional[MessageFilter] = None) -> None: """ Read messages from the cache directory. New ones are added to the internal list, existing ones are replaced. A message is determined as 'existing' if a message @@ -563,7 +562,7 @@ class ChatDB(Chat): self.messages += messages self.msg_sort() - def cache_clear(self, glob: Optional[str] = None) -> None: + def cache_clear(self, glob: str = f'*{msg_suffix}') -> None: """ Delete all message files from the cache dir and remove them from the internal list. """ @@ -587,7 +586,7 @@ class ChatDB(Chat): # (re)add it to the internal list self.msg_add([message]) - def db_read(self, glob: Optional[str] = None, mfilter: Optional[MessageFilter] = None) -> None: + def db_read(self, glob: str = f'*{msg_suffix}', mfilter: Optional[MessageFilter] = None) -> None: """ Read messages from the DB directory. New ones are added to the internal list, existing ones are replaced. A message is determined as 'existing' if a message