ahrm / sioyek-python-extensions

Python wrapper and simple addons for sioyek PDF viewer
GNU General Public License v3.0
170 stars 7 forks source link

clean_path missing in python package for rect_string #17

Open cemkaya-mpi opened 1 year ago

cemkaya-mpi commented 1 year ago

Hello,

add_text and remove_annotations did not work for me. I had to modify rect_string = sys.argv[5] to rect_string = clean_path(sys.argv[5])

in order for the plugins to work. Otherwise, I get

line 7, in parse_rect
    page = int(parts[0])
           ^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: '"2'
Asem-Ashraf commented 11 months ago

I had that same problem. Solved it by removing the quotes '"' around %{selected_rect} , %{command_text} and in your case would be around %{file_path} as well in the commands in the prefs_user.config file as they where not being filtered out in the script while they are being parsed in python.

The biggest give away was the " in the error before the '"2'

this happens because, for some reason, the rectangle size and added text are not parsed as clean strings which keeps a \" in the begining and end of these arguemnts, which are present in the argument in the prefs_user.config file.

This is the add_text.py

if __name__ == '__main__':

    SIOYEK_PATH = clean_path(sys.argv[1])
    LOCAL_DATABASE_PATH = clean_path(sys.argv[2])
    SHARED_DATABASE_PATH = clean_path(sys.argv[3])
    FILE_PATH = clean_path(sys.argv[4])
    rect_string = sys.argv[5]
    added_text = sys.argv[6]
mostafatouny commented 3 months ago

+1 Solved my problem too