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

Add Exclusion Filters #705

Merged
merged 23 commits into from
Dec 29, 2020
Merged

Add Exclusion Filters #705

merged 23 commits into from
Dec 29, 2020

Conversation

glubsy
Copy link
Contributor

@glubsy glubsy commented Sep 1, 2020

  • Allow users to specify files to filter out during scan by using regular expressions
  • Set the default directory states according to regular expressions.
  • File names and file paths are matched against regular expressions: only regexes with path separators are matches against the full path to the file, other regexes are matched against the filename only. This allows for more precise filtering.
  • Two different implementations: one around a python list, and one around a python dict, but same features (I think the dict implementation might be a bit more efficient, so we use that by default now).
  • Regexes can be combined (union) for possibly better performance, although my experiments didn't show meaningful results.
  • Also added test suites.

* Added initial draft for test suit
* Fixed small logging bug
* Concatenating regexes into one Pattern might yield better performance under (un)certain conditions.
* Filenames are tested against regexes with no os.sep in them. This may or may not be what we want to do.
And alternative would be to test against the whole (absolute) path of each file, which would filter more agressively.
* We need to set the Details Dialog's previous instance to None when recreating a new Results window
otherwise Qt crashes since we are probably dereferencing a dangling reference.
* Also fixes Results tab not showing up when selecting it from the View menu.
* The custom QStackWidget+QTabBar class did not manage the tabs properly because the indices in the stackwidget were not aligned with the ones in the tab bar.
* Properly disable exclude list action when it is the currently displayed widget.
* Merge action callbacks for triggering ignore list or exclude list to avoid repeating code and remove unused checks for tab visibility.
* Remove unused SetTabVisible() function.
* When recreating the Results window, the menubar had duplicate items added each time.
* Removing the underlying C++ object is apparently enough to fix the issue.
* SetParent(None) can still be used in case of floating windows
* Add testing feature to Exclusion dialog to allow users to test regexes against an arbitrary string.
* Fixed test suites.
* Improve comments and help dialog box.
@glubsy
Copy link
Contributor Author

glubsy commented Sep 1, 2020

2020-09-01_22-47-57
This GIF doesn't show it, but when mouse hovering over the red "denied" icon, there's a tooltip showing the error generated by the faulty regex.

This is based on the details dialog improvement branch.
Also to note, this includes commits which fix rather serious bugs in the tabbed window feature (namely 3382bd5, 26d1894, 584e9c9)

Regarding the regex union feature, here is a script I wrote to roughly compare performance based on time.
Unfortunately, the results vary a lot, sometimes unions are faster, sometimes they are not. There's probably a better way to test these but that's all I had time for.
In the end I doubt it matters very much.

* In some themes, the color picker widgets get stretched, while the color picker for the details dialog group doesn't.
This should keep them a bit more consistent across themes.
* Sometimes, the splitter doesn't fully reach the table maximum height, and the scrollbar is still displayed on the right because a few pixels are still hidden.
* It seems the splitter handle counts towards the total height of the widget (the table), so we add it to the maximum height of the table
* The scrollbar disappears when we reach just above the actual table's height
@glubsy
Copy link
Contributor Author

glubsy commented Nov 5, 2020

Side note: just noticed detwinner also added a similar regex-based filter for file paths. 😉

screen

Copy link
Owner

@arsenetar arsenetar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few minor things here, also I am getting failures on the new directories and exclude tests.

FAILED core/tests/directories_test.py::TestExcludeList::test_exclude_refined - AssertionError: 6 != 5
FAILED core/tests/directories_test.py::TestExcludeList::test_get_state_returns_excluded_for_hidden_directories_and_files - AssertionError: 3 != 1
FAILED core/tests/directories_test.py::TestExcludeDict::test_exclude_refined - AssertionError: 6 != 5
FAILED core/tests/directories_test.py::TestExcludeDict::test_get_state_returns_excluded_for_hidden_directories_and_files - AssertionError: 3 != 1
FAILED core/tests/directories_test.py::TestExcludeListunion::test_exclude_refined - AssertionError: 6 != 5
FAILED core/tests/directories_test.py::TestExcludeListunion::test_get_state_returns_excluded_for_hidden_directories_and_files - AssertionError: 3 != 1
FAILED core/tests/directories_test.py::TestExcludeDictunion::test_exclude_refined - AssertionError: 6 != 5
FAILED core/tests/directories_test.py::TestExcludeDictunion::test_get_state_returns_excluded_for_hidden_directories_and_files - AssertionError: 3 != 1
FAILED core/tests/exclude_test.py::TestCaseCompiledList::test_compiled_files - AssertionError: 1 != 6
FAILED core/tests/exclude_test.py::TestCaseCompiledDict::test_compiled_files - AssertionError: 1 != 6

qt/app.py Show resolved Hide resolved
qt/tabbed_window.py Outdated Show resolved Hide resolved
qt/tabbed_window.py Outdated Show resolved Hide resolved
tox.ini Outdated Show resolved Hide resolved
qt/preferences_dialog.py Outdated Show resolved Hide resolved
@arsenetar arsenetar mentioned this pull request Dec 28, 2020
12 tasks
@glubsy
Copy link
Contributor Author

glubsy commented Dec 29, 2020

That's odd. I don't get any failure during the tests. The Continuous Integration system doesn't seem to produce these either. Could it be that these occur on Windows only?

Edit: nevermind, I forgot you had set up a Windows machine for the CI too. Still no error there.
I'll run these tests in Win10 and see if I can reproduce.

@arsenetar
Copy link
Owner

@glubsy the tox environment for windows does not actually run the tests... so the CI will not catch that. I should change it to actually run the test, all it does right now is run build and packaging.

@arsenetar
Copy link
Owner

@glubsy I updated the CI to actually run the tests on windows, which should help show these failures, we do have a minor conflict with my changes in the tox.ini now as I brought in another change there. I took a brief look at the tests that were failing and it seems to be that some of these have path separators in the regex which might explain why they are not filtering out when they should be (windows paths using different separator).

@glubsy
Copy link
Contributor Author

glubsy commented Dec 29, 2020

Sorry for the late reply. I could indeed reproduce the issue on Windows 7 and already fixed half of it. I'll push the rest of the changes in a bit (it's 5AM here, I have to take a break).

Thanks for updating the CI!

Dark green lacks contrast against black foreground font
* For some reason the table view doesn't update properly after the test string button is clicked nor when the input field is edited
* The table rows only get repainted the rows properly after receiving a mouse click event
* This doesn't happen on Linux
@arsenetar arsenetar merged commit 7f691d3 into arsenetar:master Dec 29, 2020
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

Successfully merging this pull request may close these issues.

2 participants