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

Option to follow links #32

Open
Marwe opened this issue Mar 11, 2022 · 7 comments
Open

Option to follow links #32

Marwe opened this issue Mar 11, 2022 · 7 comments
Labels
Feedback required We are waiting for you...

Comments

@Marwe
Copy link

Marwe commented Mar 11, 2022

An improvement for our workflows would be to allow following links.
We use (soft) links within the filesystem to use the data in different contexts, but the plugin stops at links and does not follow them.
Files in linked directories are not available, since the link itself does not match the pattern.

A global fix is relatively easy, I implemented it with the additional option followlinks=True in os.walk, but maybe for an implementation an option with a GUI checkbox would be better (settings object in LoadThemAllDialog.py)? The latter needs changes in different places.

git diff
diff --git a/LoadFiles.py b/LoadFiles.py
index 4089109..69b3718 100644
--- a/LoadFiles.py
+++ b/LoadFiles.py
@@ -66,7 +66,7 @@ class LoadFiles():
         self.progressBar.setMaximum(0)  # ProgressBar in busy mode
         layerPaths = []
 
-        for root, dirs, files in os.walk(self.baseDir):
+        for root, dirs, files in os.walk(self.baseDir,followlinks=True):
             # files = [self.decodeName(f) for f in files]
             for file_ in files:
                 QApplication.processEvents()  # TODO: Perhaps better by chunks?
@gacarrillor
Copy link
Owner

We can follow the configuration object approach. The behavior would be disabled by default, since there is some risk of infinite recursion if a link points to a parent dir that os.walk() has to visit (see to the docs).

Could you create a PR with this feature?

@Marwe
Copy link
Author

Marwe commented Mar 16, 2022

I am working on it, and have a draft in my fork already, but need to look into it more deeply why it does not yet work as expected...

@gacarrillor
Copy link
Owner

Good! Feel free to ask in this thread anything you need, although I see your fork already has a good shape.
What exactly doesn't work? The follow links itself or anything related to the plugin's GUI?

@gacarrillor
Copy link
Owner

Hi @Marwe, just revisiting some issues.

Did you managed to get it work?

@gacarrillor gacarrillor added the Feedback required We are waiting for you... label Jan 23, 2023
@Marwe
Copy link
Author

Marwe commented Jan 24, 2023

No, I am missing a potentially small piece, as it seems and did not find time to dig into it again. If you want to look at the current state see branch followlinks:
https://github.com/Marwe/loadthemall/tree/followlinks
I will try to look into it again, thanks for your heads up.

BTW, I added a make target deploy in branch deploy, if you are interested. cp and change the Makefile.ini.template path to your dev profile in QGIS, then a make deploy should do.
https://github.com/Marwe/loadthemall/tree/deploy
Ah, sorry, the branch contains the crap from followlinks, too. Well, needs some more love or cherrypick.

@Marwe
Copy link
Author

Marwe commented Jan 25, 2023

Hm, currently I get a ModuleNotFoundError: No module named 'resources_rc' while loading.

@gacarrillor
Copy link
Owner

BTW, I added a make target deploy in branch deploy, if you are interested. cp and change the Makefile.ini.template path to your dev profile in QGIS, then a make deploy should do.

Nice idea!

No, I am missing a potentially small piece, as it seems and did not find time to dig into it again. If you want to look at the current state see branch followlinks:

Just to know, what's the current issue?

Hm, currently I get a ModuleNotFoundError: No module named 'resources_rc' while loading.

Check that you have resources/resources_rc.py. If not, you might be missing a make before the make build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feedback required We are waiting for you...
Projects
None yet
Development

No branches or pull requests

2 participants