apertium-python icon indicating copy to clipboard operation
apertium-python copied to clipboard

Doesn't work when folder names consist of whitespace

Open ardakshalkar opened this issue 3 years ago • 10 comments

Because of utils.py, function parse_mode_file cmd.split just splits by whitespace, so if username, or any folder name consist of space makes an error

ardakshalkar avatar Jan 21 '23 19:01 ardakshalkar

One thing I guess would work is enclosing the path in quotes so that it is treated as a single component. But yes it's best to avoid using spaces in user or file names.

tkj2410 avatar Mar 18 '23 19:03 tkj2410

Language pairs should install modes.xml so apertium-python doesn't have to parse shell scripts (badly)

unhammer avatar Mar 18 '23 19:03 unhammer

I attempted several methods including parsing with shlex, regular expression(re) and using r-string to treat the backslash character () as a literal character, none of them appear to resolve this problem. It would be a more prudent approach to install language pairs using modes.xml instead of relying on parsing shell scripts. @unhammer I am willing to give it a try. Could you please provide me with some guidance on how to proceed with this? Thanks!

lakshay-nasa avatar Mar 18 '23 21:03 lakshay-nasa

Rightly said, Parsing shell scripts can be slow and error-prone, especially with complex data. using modes.xml, should determine which language pair to use avoiding the need of parsing.

tkj2410 avatar Mar 19 '23 12:03 tkj2410

I also tried several methods but I think we can minimize the parse steps by using Python language as it does single parser testing whereas if we go for C++, C, and Java, two parsers will be tested.

sinchannroy avatar Mar 22 '23 02:03 sinchannroy

We can add modes.xml to https://github.com/apertium/apertium/blob/main/apertium.m4#L151 so that all languages and pairs will install it. Or I can force it in the packaging system, though that's less ideal.

TinoDidriksen avatar Mar 22 '23 18:03 TinoDidriksen

+1 to m4

unhammer avatar Mar 22 '23 19:03 unhammer

one more thing i think can be done is to use escape character '\' when the folder name consist any whitespace.

Himanshu-Vishwas avatar Mar 27 '23 07:03 Himanshu-Vishwas

one more thing i think can be done is to use escape character '' when the folder name consist any whitespace.

yeah i think that will be a great step in solving the problem.

sinchannroy avatar Mar 28 '23 06:03 sinchannroy

That's great.......! Give this a try.

Himanshu-Vishwas avatar Mar 28 '23 11:03 Himanshu-Vishwas