Convert can.Logger and can.LogReader into functions#1703
Convert can.Logger and can.LogReader into functions#1703zariiii9003 merged 9 commits intohardbyte:mainfrom
can.Logger and can.LogReader into functions#1703Conversation
ae5d6dd to
daf8602
Compare
can/io/logger.py
Outdated
| def _get_logger_for_suffix(suffix: str) -> Type[MessageWriter]: | ||
| try: | ||
| logger_type = MESSAGE_WRITERS[suffix] | ||
| if logger_type is None: |
There was a problem hiding this comment.
How can a None value make its way into the dictionary? Is there a root cause that would help the user mitigate the problem?
There was a problem hiding this comment.
This was already there since the mf4-PR, but you're right, it's not necessary. I removed it.
can/io/logger.py
Outdated
| File will automatically recompress upon close. | ||
| """ | ||
| Logs CAN messages to a file. | ||
| real_suffix = pathlib.Path(filename).suffixes[-2].lower() |
There was a problem hiding this comment.
This will throw an IndexError if the filename does not have the necessary number of suffixes. Might be better to catch the case and raise an appropriate message.
There was a problem hiding this comment.
I added a check for the the length of suffixes
|
The front page of python-can in github gives this code in the Example usage section: so we might have a lot of people building their code on top of the idea of the |
It still works the same way as before. |
9aea2e0 to
4727ea6
Compare
can.Loggerandcan.LogReaderinto functionslisteners.rstintonotifier.rstandfile_io.rst.