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

KeyError when the directory_tree plugin is disabled #1445

Open
ethical-haquer opened this issue Mar 10, 2024 · 2 comments
Open

KeyError when the directory_tree plugin is disabled #1445

ethical-haquer opened this issue Mar 10, 2024 · 2 comments

Comments

@ethical-haquer
Copy link
Contributor

When the directory_tree plugin is disabled, multiple other plugins: filemanager, git_right_click, git_status, hide_project, and python_venv, fail with a KeyError:

Traceback (most recent call last):
  File "/home/ethical_haquer/porcupine-venv/lib/python3.11/site-packages/porcupine/pluginloader.py", line 191, in _run_setup_and_set_status
    info.module.setup()
  File "/home/ethical_haquer/porcupine-venv/lib/python3.11/site-packages/porcupine/plugins/filemanager.py", line 419, in setup
    tree = get_directory_tree()
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/ethical_haquer/porcupine-venv/lib/python3.11/site-packages/porcupine/plugins/directory_tree.py", line 522, in get_directory_tree
    return get_horizontal_panedwindow().nametowidget("directory_tree_container.directory_tree")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/tkinter/__init__.py", line 1563, in nametowidget
    w = w.children[n]
        ~~~~~~~~~~^^^
KeyError: 'directory_tree_container'

KeyError

@ethical-haquer ethical-haquer changed the title Setup failed when the directory_tree plugin is disabled KeyError when the directory_tree plugin is disabled Mar 10, 2024
@Akuli
Copy link
Owner

Akuli commented Mar 10, 2024

Ideally there would be a way for plugins to depend on each other. For example, if you disable filemanager and directory_tree, and then enable filemanager, it would be nice if the plugin manager told you that you need to enable directory_tree first. This is similar to how sudo apt install foo also installs all dependencies of foo.

There is setup_before and setup_after, which controls the order in which plugins are loaded, but it's not quite the same thing. Even though the filemanager plugin defines setup_after = ["directory_tree"], Porcupine will attempt to set it up without the directory_tree if directory_tree is disabled.

@Akuli
Copy link
Owner

Akuli commented Mar 24, 2024

Making plugins depend on each other could look something like this:

dont_setup_without = ["directory_tree"]

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

2 participants