aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2024-07-24 10:27:24 -0300
committerSilvio Rhatto <rhatto@riseup.net>2024-07-24 10:27:24 -0300
commit74e8fdd014365ccbdee950311293617c82518f3a (patch)
tree0e666465587bfa7ffb27c82b41ef11877e911b8a
parent3ed90fbd9ce5a807b3745c09fc57f0151eca87c4 (diff)
downloadfinder-74e8fdd014365ccbdee950311293617c82518f3a.tar.gz
finder-74e8fdd014365ccbdee950311293617c82518f3a.tar.bz2
Fix: plugin: opener: searcher: file: ignore logic
-rw-r--r--TODO.md2
-rw-r--r--packages/finder/plugin/searcher/file/name.py17
2 files changed, 13 insertions, 6 deletions
diff --git a/TODO.md b/TODO.md
index 04e66eb..c0ee504 100644
--- a/TODO.md
+++ b/TODO.md
@@ -48,7 +48,7 @@
* [ ] Autodetection depending on file or dir passed as argument (like
automatically detects a CSV file).
* [ ] Toggles:
- * [ ] Ignore VCS files (like `.git` folder).
+ * [ ] Files and folders to ignore.
* [ ] Search processing regexps or not (`text` or `re.escape(text)`).
* [ ] Sorting criteria.
* [ ] Whether to list folders (and not just files).
diff --git a/packages/finder/plugin/searcher/file/name.py b/packages/finder/plugin/searcher/file/name.py
index 97bba89..5f6fde5 100644
--- a/packages/finder/plugin/searcher/file/name.py
+++ b/packages/finder/plugin/searcher/file/name.py
@@ -32,19 +32,26 @@ class FinderPluginFileNameSearcher():
self.items = []
async def finder(self):
- path = self.path
+ path = self.path
+ ignore_folders = [ '.git', '__pycache__' ]
+ ignore_files = [ '.gitignore' ]
for parent, dirs, files in os.walk(self.path):
- # Ignore Git folders
- if '.git' in dirs:
- dirs.remove('.git')
- continue
+ # Ignore folders
+ for ignore_folder in ignore_folders:
+ if ignore_folder in dirs:
+ dirs.remove(ignore_folder)
# Currently we're not listing folders
#for folder in dirs:
# self.items.append(os.path.join(parent, folder))
for file in files:
+ # Ignore files
+ for ignore_file in ignore_files:
+ if file == ignore_file:
+ continue
+
self.items.append(os.path.join(parent, file))
return self.items