GiorgosXou / TUIFIManager

A cross-platform terminal-based termux-oriented file manager (and component), meant to be used with a Uni-Curses project or as is.
GNU General Public License v3.0
697 stars 13 forks source link

SyntaxWarning: invalid escape sequence '\.' python 3.12. #111

Closed GiorgosXou closed 5 months ago

GiorgosXou commented 5 months ago

Since python 3.12 this kind of warnings appeared, I just solved them them but the one which is visible and intercepts the program, might need to be fixed manually by user ...

https://github.com/home-assistant/core/issues/110263

GiorgosXou commented 5 months ago

it's the one caused by the cmds.conf entry "yat | copy | 'pattern':'.+\.txt'... due to ast.literal_eval(...)

GiorgosXou commented 5 months ago

ok I think i solved it

GiorgosXou commented 5 months ago

👋 FIX Here

go to ~/.config/tuifi/cmds.conf and change "yat | copy | 'pattern':'.+\.txt'.. to "yat | copy | 'pattern':'.+\\.txt'..

Sigmanificient commented 4 months ago

You could use raw string r'.+\.txt', they are meant for storing things like regex pattern that can have "illegal character sequences"

GiorgosXou commented 4 months ago

@Sigmanificient it's due to variable evaluation: https://github.com/GiorgosXou/TUIFIManager/blob/1ccb8f255d1ae43bef240fdd024bb7a8f67e9bbe/TUIFIManager/__init__.py#L1102

(Discord disabled my account btw :/ | Probably due to experimenting with their private api)

Sigmanificient commented 4 months ago

you may want to refactor that line

ln = line.split('|') #  command, args, type, comment | using "|" because this is an __illegal_filename_characters
self.command_events[ln[0].strip()] = (self.command_types[ln[1].strip()], ast.literal_eval('{'+ln[2].strip()+'}'), ln[3].strip())
cmd, args, typ, comment = map(str.strip, line.split('|'))  # using "|" because this is an __illegal_filename_characters
self.command_events[cmd] = (self.command_types[args], ast.literal_eval('{'+typ+'}'), comment)