organize icon indicating copy to clipboard operation
organize copied to clipboard

Python code fails on accessing filecontent data

Open andrej1919 opened this issue 2 years ago • 0 comments

Describe the bug A clear and concise description of what the bug is. Organize returns an error: (python) ERROR! 'dict' object has no attribute 'dateslo'. The same Python code works just fine if I use a fake variable like date_var = '5. 6. 2023' and use date_var instead of filecontent.dateslo, which reads the date from the PDF.

Screenshots If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • OS: Operating System: Manjaro Linux KDE Plasma Version: 5.27.6 KDE Frameworks Version: 5.108.0 Qt Version: 5.15.10 Kernel Version: 6.4.6-1-MANJARO (64-bit) Graphics Platform: X11
  • Output of organize --version: organize, version 2.4.0

Your config file

  - name: "testing"
    locations:
      - ~/Downloads 
    subfolders: false
    filters:
      - extension: pdf
      - filecontent: 'Some company name'
      - filecontent: 'Some code: 4999BFV3P22OW90'
      - filecontent: 'Statement on a date (?P<date_slo>\d{1,2}\. \s*\d{1,2}\. \s*\d{4})'
      - python: |
          import datetime
          date_result=datetime.datetime.strptime(filecontent.date_slo, "%d. %m. %Y").strftime("%Y-%m-%d")
          return {"parsed_date": date_result}
      - lastmodified  
    actions:
      - echo: "statement on {python.parsed_date}" 

andrej1919 avatar Aug 06 '23 12:08 andrej1919