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

Python filter does not filter when returned None or False #426

Open
kisst opened this issue Dec 5, 2024 · 0 comments
Open

Python filter does not filter when returned None or False #426

kisst opened this issue Dec 5, 2024 · 0 comments
Labels

Comments

@kisst
Copy link

kisst commented Dec 5, 2024

Describe the bug
I tired to use organize to clean up the backup folders left behind a FF plugin, but even after the python filter returned False ( or None ) it still get included in the action. Based on https://github.com/tfeldmann/organize/blob/main/organize/filters/python.py#L24 it should work, but unsure if I just read the docs wrong.

Environment (please complete the following information):

  • OS: Debian GNU/Linux 12 (bookworm)
  • Output of organize --version: v3.3.0

Your config file

rules:
  - name: Clean up old FF backups
    locations: ~/Downloads
    targets: dirs
    filters:
      - name:
          startswith: "STG-backups-FF-"
      - python: |
          import sys, subprocess
          result = subprocess.run(['flatpak', 'info', 'org.mozilla.firefox'], stdout=subprocess.PIPE)
          for line in result.stdout.decode('utf-8').split('\n'):
              if 'Version' in line:
                  firefox_version = line.split(':')[1].strip()
                  break
          if path.stem.endswith(firefox_version):
              # sys.exit("Don't do it")
              return None
          else:
              return True
          return not path.stem.endswith(firefox_version)
    actions:
      - echo: "Would delete {path}"
@kisst kisst added the bug label Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant