Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with argument parsing #3

Open
leephillips opened this issue Dec 25, 2022 · 5 comments
Open

Problem with argument parsing #3

leephillips opened this issue Dec 25, 2022 · 5 comments

Comments

@leephillips
Copy link

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.

@ahrm
Copy link
Owner

ahrm commented Dec 25, 2022

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.

@leephillips
Copy link
Author

That worked; thank you. (I’m on Debian, python 3.9.2.)

@wenbopeng
Copy link

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.

image

Other extension commands work fine!

@wenbopeng
Copy link

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.😀😀😀😀

@unsigned-enby
Copy link

unsigned-enby commented Sep 28, 2023

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:])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants