marcus-nystrom / Titta

Python and PsychoPy interface to Tobii eye trackers using Tobii Pro SDK
Other
64 stars 27 forks source link

Issue with Inaccurate File Type Detection #52

Closed mao-dongyang closed 8 months ago

mao-dongyang commented 8 months ago

The current implementation for file type detection in the code is not robust, leading to potential errors under certain conditions. Specifically, the following code segment may result in incorrect file type determination: https://github.com/marcus-nystrom/Titta/blob/d970df502480d912cf7ed9b0f9221976fff55429/titta/TalkToProLab.py#L326 The issue arises when there are multiple dots (.) in the file name or path. For instance, in the case of C:\Users\MDY\AppData\Local\Temp\tmp435q8bsg.opensesame_pool\test.jpeg, the file_ext variable will contain opensesame_pool\test as the supposed file extension, leading to a "File type not supported" error. This is particularly problematic when working with Titta for Opensesame plugin development.

The recommended fix is to replace file_ext = media_name.split('.')[1] with file_ext = media_name.split('.')[-1]. This modification ensures the correct extraction of the file extension, enhancing the code's robustness. I have already submitted a Pull Request addressing this issue and would appreciate your consideration for acceptance.

marcus-nystrom commented 8 months ago

Thanks for spotting this and thanks for the pull request! I accepted it.