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

Support negating and ANDing (and XORing?) selectors #10

Open
jwodder opened this issue Apr 27, 2024 · 2 comments
Open

Support negating and ANDing (and XORing?) selectors #10

jwodder opened this issue Apr 27, 2024 · 2 comments
Labels
c:selectors enhancement New feature or request therefor

Comments

@jwodder
Copy link
Owner

jwodder commented Apr 27, 2024

No description provided.

@jwodder jwodder added enhancement New feature or request therefor c:selectors labels Apr 27, 2024
@isidroas
Copy link

That reminds me of the posix find command.

For example the following command,

$ find  \( -name '*.py' -a -executable \) -o iname 'run_*.py'

would be equivalent to the following Python expression,

SelectAny(
    SelectAll(SelectGlob('*.py'), SelectPerm(exec=True)),
    SelectGlob('run_*.py', case_insensitive=True)
)

or more succintly, using operators:

( SelectGlob('*.py') and SelectPerm(exec=True) ) or SelectGlob('run_*.py', case_insensitive=True)

@isidroas
Copy link

isidroas commented Nov 4, 2024

offtopic: I am thinking on a library with the following characteristics:

  • It only filters and sorts.
  • The walking is performed by the user.
  • Non intrusive.
  • Selectors can be translated partially to find arguments

For example:

 def user_code(path, filterer: Filter, sorter: Sorter):
     print(path)
     for child in sorted(filter(path.iterdir(), filterer), key=sorter):
         user_code(child, filterer, sorter)

Let me know if you are interested, think that we could merge the projects or have any ideas/precautions.

Thank in advance. Your project deserves more stars.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c:selectors enhancement New feature or request therefor
Projects
None yet
Development

No branches or pull requests

2 participants