sioyek-python-extensions
sioyek-python-extensions copied to clipboard
Problem with argument parsing
The scripts fail for me with errors about arguments: they seem to be quoted and parsed incorrectly. For example, when trying to use _add_text
I get
ValueError: invalid literal for int() with base 10: '"15'
when Iām on page 15 of the document.
I think instead of
new_command _add_text python -m sioyek.add_text "%{sioyek_path}" "%{local_database}" "%{shared_database}" "%{file_path}" "%{selected_rect}" "%{command_text}"
You should use
new_command _add_text python -m sioyek.add_text "%{sioyek_path}" "%{local_database}" "%{shared_database}" "%{file_path}" %{selected_rect} "%{command_text}"
on some platforms.
That worked; thank you. (Iām on Debian, python 3.9.2.)
On Window11 22H2,
# new_command _add_text python -m sioyek.add_text "%{sioyek_path}" "%{local_database}" "%{shared_database}" "%{file_path}" "%{selected_rect}" "%{command_text}"
new_command _add_text python -m sioyek.add_text "%{sioyek_path}" "%{local_database}" "%{shared_database}" "%{file_path}" %{selected_rect} "%{command_text}"
# new_command _add_red_text python -m sioyek.add_text "%{sioyek_path}" "%{local_database}" "%{shared_database}" "%{file_path}" "%{selected_rect}" "%{command_text}" fontsize=5 text_color=255,0,0
new_command _add_red_text python -m sioyek.add_text "%{sioyek_path}" "%{local_database}" "%{shared_database}" "%{file_path}" %{selected_rect} "%{command_text}" fontsize=5 text_color=255,0,0
Both are none responded.
Other extension commands work fine!
I installed an old version of the Python extension. After uninstalling it with python -m pip uninstall sioyek
and then python -m pip install sioyek
I can use the extension again.šššš
A better fix (albeit one needing a name change) might be to simply pass the selected_rectangle
to clean_path
(it worked for me anyhow) to remove the the quotes (as that's all clean_path
does).
Git diff for reference:
diff --git a/src/sioyek/add_text.py b/src/sioyek/add_text.py
index 5ad5b70..54352e2 100644
--- a/src/sioyek/add_text.py
+++ b/src/sioyek/add_text.py
@@ -37,7 +37,7 @@ if __name__ == '__main__':
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]
+ rect_string = clean_path(sys.argv[5])
added_text = sys.argv[6]
params = parse_params(sys.argv[7:])