chat: changed default glob to '*.msg' in all ChatDB functions
This commit is contained in:
parent
114282dfd8
commit
480987774d
@ -52,7 +52,7 @@ def read_dir(dir_path: Path,
|
|||||||
Parameters:
|
Parameters:
|
||||||
* 'dir_path': source directory
|
* 'dir_path': source directory
|
||||||
* 'glob': if specified, files will be filtered using 'path.glob()',
|
* '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
|
* 'mfilter': use with 'Message.from_file()' to filter messages
|
||||||
when reading them.
|
when reading them.
|
||||||
"""
|
"""
|
||||||
@ -295,7 +295,7 @@ class ChatDB(Chat):
|
|||||||
# a MessageFilter that all messages must match (if given)
|
# a MessageFilter that all messages must match (if given)
|
||||||
mfilter: Optional[MessageFilter] = None
|
mfilter: Optional[MessageFilter] = None
|
||||||
# the glob pattern for all messages
|
# the glob pattern for all messages
|
||||||
glob: Optional[str] = None
|
glob: str = f'*{msg_suffix}'
|
||||||
# message format (for writing)
|
# message format (for writing)
|
||||||
mformat: MessageFormat = Message.default_format
|
mformat: MessageFormat = Message.default_format
|
||||||
|
|
||||||
@ -311,7 +311,7 @@ class ChatDB(Chat):
|
|||||||
def from_dir(cls: Type[ChatDBInst],
|
def from_dir(cls: Type[ChatDBInst],
|
||||||
cache_path: Path,
|
cache_path: Path,
|
||||||
db_path: Path,
|
db_path: Path,
|
||||||
glob: Optional[str] = None,
|
glob: str = f'*{msg_suffix}',
|
||||||
mfilter: Optional[MessageFilter] = None,
|
mfilter: Optional[MessageFilter] = None,
|
||||||
loc: msg_location = msg_location.DB) -> ChatDBInst:
|
loc: msg_location = msg_location.DB) -> ChatDBInst:
|
||||||
"""
|
"""
|
||||||
@ -320,8 +320,7 @@ class ChatDB(Chat):
|
|||||||
Parameters:
|
Parameters:
|
||||||
* 'cache_path': path to the directory for temporary messages
|
* 'cache_path': path to the directory for temporary messages
|
||||||
* 'db_path': path to the directory for persistent messages
|
* 'db_path': path to the directory for persistent messages
|
||||||
* 'glob': if specified, files will be filtered using 'path.glob()',
|
* 'glob': if specified, files will be filtered using 'path.glob()'
|
||||||
otherwise it uses 'path.iterdir()'.
|
|
||||||
* 'mfilter': use with 'Message.from_file()' to filter messages
|
* 'mfilter': use with 'Message.from_file()' to filter messages
|
||||||
when reading them.
|
when reading them.
|
||||||
"""
|
"""
|
||||||
@ -400,7 +399,7 @@ class ChatDB(Chat):
|
|||||||
def msg_gather(self,
|
def msg_gather(self,
|
||||||
loc: msg_location,
|
loc: msg_location,
|
||||||
require_file_path: bool = False,
|
require_file_path: bool = False,
|
||||||
glob: Optional[str] = None,
|
glob: str = f'*{msg_suffix}',
|
||||||
mfilter: Optional[MessageFilter] = None) -> list[Message]:
|
mfilter: Optional[MessageFilter] = None) -> list[Message]:
|
||||||
"""
|
"""
|
||||||
Gather and return messages from the given locations:
|
Gather and return messages from the given locations:
|
||||||
@ -520,7 +519,7 @@ class ChatDB(Chat):
|
|||||||
else:
|
else:
|
||||||
return len(self.msg_find([message], loc=msg_location.DB)) > 0
|
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,
|
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
|
existing ones are replaced. A message is determined as 'existing' if a message
|
||||||
@ -563,7 +562,7 @@ class ChatDB(Chat):
|
|||||||
self.messages += messages
|
self.messages += messages
|
||||||
self.msg_sort()
|
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.
|
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
|
# (re)add it to the internal list
|
||||||
self.msg_add([message])
|
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,
|
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
|
existing ones are replaced. A message is determined as 'existing' if a message
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user