Closed Marty56 closed 2 years ago
Can you post your config? Something is wrong with your filters. Maybe also run organize check [configfile] --debug
Ah I see. Maybe you have left the filters empty?
filters:
actions:
- ...
This breaks the migration detection currently. In that case just delete the filters:
line
No I did not leave filters empty. In the following you find the start of my config file.
Description: >
regex auf Dateinamen
- regex: '(?P<year>20 # Jahr fängt mit 20 an
\d{2}) # gefolgt von zwei Zahlen
- # dann Bindestrich
[01] # die ersten Ziffer des Monats muss 1 oder 0 sein
\d # das zweite Zeichen eine Zahl
- # dann Bindestrich
[0-3] # Tag darf mit 0,1,2 oder 3 anfangen
\d. # und dem zweiten Zeichen eine Zahl
*\. # dann beliebige Zeichen bis zum .
pdf # dann muss pdf kommen. Filenamen mit mehreren Pkt sind nicht erlaubt
Debug Support mit Ausgabe des gefundenen Inhalts im Log File
- filecontent:
- '(?P<inhalt>.*)'
actions:
- echo: "Debug\n\n {filecontent.inhalt}"
my_python_script: &calcperiod_april |
def calcperiod(startofperiod):
if ( int(path.stem[5:7]) >= startofperiod):
return (path.stem[0:4] + '-' + str(int(path.stem[0:4]) + 1))
else:
return ( str(int(path.stem[0:4]) - 1) + '-' + path.stem[0:4] )
return {"period":calcperiod(4)}
my_python_script: &calcperiod_june |
def calcperiod(startofperiod):
if ( int(path.stem[5:7]) >= startofperiod):
return (path.stem[0:4] + '-' + str(int(path.stem[0:4]) + 1))
else:
return ( str(int(path.stem[0:4]) - 1) + '-' + path.stem[0:4] )
return {"period":calcperiod(6)}
rules:
#------------------------------------------------------------------------------------
# München: Versicherungsrechnungen
#------------------------------------------------------------------------------------
- locations:
- $SOURCE/steuerrelevante Rechnungen
filters:
- regex: '(?P<year>20\d{2})-[01]\d-[0-3]\d.*\.pdf'
- filecontent:
- '(HUK-COBURG)|(ADAC)|(Meine HUK24)|(860/359006-M-63)|(Sozialversicherung)'
- filecontent:
- '(?P<strasse>Brückl)'
actions:
- macos_tags:
- Steuer {regex.year} (purple)
- Versi {regex.year} (green)
- move: '$DESTINATION/Versicherungen/{regex.year}/'
- echo: "\n Das Pdf File {path.name} wurde dem Jahr {regex.year} zugeordnet\n
und unter Versicherungen/{regex.year} abgelegt.\n
(HUK-COBURG ODER Meine HUK24 ODER 860/359006-M-63 ODER ADAC ODER Sozialversicherung) UND {filecontent.strasse}\n
gefunden.\n
----------------------------------------------------------------------------------\n\n"
#------------------------------------------------------------------------------------
# München: Versorgerrechnungen
#------------------------------------------------------------------------------------
- locations:
- $SOURCE/steuerrelevante Rechnungen
filters:
- regex: '(?P<year>20\d{2})-[01]\d-[0-3]\d.*\.pdf'
- filecontent:
- '(Versorgung)|(Abwasser)|(Schmutzwasser)|(Abfall)'
- filecontent:
- 'Brückl'
actions:
- echo: "Das Pdf File {path.name} wurde dem Jahr {regex.year} zugeordnet"
- echo: "und unter /Stadtwerke/{regex.year}/ abgelegt"
- echo: "(Versorung ODER Abwasser ODER Schmutzwasser ODER Abfall) UND Brückl gefunden"
- macos_tags:
- Steuer {regex.year} (purple)
- Versorg {regex.year} (orange)
- move: '$DESTINATION/Versorger/{regex.year}/'
- echo: "----------------------------------------------------------------------------------\n\n"
Got it. Give me a second.
Just released v2.0.1. Can you update and try again?
organize sim --config-file='/Users/martinklimke/Library/Mobile Documents/com~apple~CloudDocs/Documents/Organize/Rules/config.yaml'
Deprecated: The --config-file option can now be omitted. See organize --help.
organize 2.0.1
Config: "/Users/martinklimke/Library/Mobile Documents/com~apple~CloudDocs/Documents/Organize/Rules/config.yaml"
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ │
│ /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/organize/core.py:1 │
│ 34 in replace_with_instances │
│ │
│ 131 │ │ _locations = [] │
│ 132 │ │ for options in ensure_list(rule["locations"]): │
│ 133 │ │ │ try: │
│ ❱ 134 │ │ │ │ instance = instantiate_location( │
│ 135 │ │ │ │ │ options=options, │
│ 136 │ │ │ │ │ default_max_depth=default_depth, │
│ 137 │ │ │ │ ) │
│ /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/organize/core.py:8 │
│ 6 in instantiate_location │
│ │
│ 83 │ else: │
│ 84 │ │ walker = options["walker"] │
│ 85 │ │
│ ❱ 86 │ fs, fs_path = fs_path_from_options( │
│ 87 │ │ path=options.get("path", "/"), │
│ 88 │ │ filesystem=options.get("filesystem"), │
│ 89 │ ) │
│ │
│ /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/organize/utils.py: │
│ 107 in fs_path_from_options │
│ │
│ 104 │ path = expand_user(path) │
│ 105 │ │
│ 106 │ if not filesystem: │
│ ❱ 107 │ │ return (open_fs(path), "/") │
│ 108 │ else: │
│ 109 │ │ if isinstance(filesystem, str): │
│ 110 │ │ │ filesystem = expand_user(filesystem) │
│ │
│ /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/fs/opener/registry │
│ .py:229 in open_fs │
│ │
│ 226 │ │ if isinstance(fs_url, FS): │
│ 227 │ │ │ _fs = fs_url │
│ 228 │ │ else: │
│ ❱ 229 │ │ │ _fs, _path = self.open( │
│ 230 │ │ │ │ fs_url, │
│ 231 │ │ │ │ writeable=writeable, │
│ 232 │ │ │ │ create=create, │
│ │
│ /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/fs/opener/registry │
│ .py:186 in open │
│ │
│ 183 │ │ │
│ 184 │ │ opener = self.get_opener(protocol) │
│ 185 │ │ │
│ ❱ 186 │ │ open_fs = opener.open_fs(fs_url, parse_result, writeable, create, cwd) │
│ 187 │ │ return open_fs, open_path │
│ 188 │ │
│ 189 │ def open_fs( │
│ │
│ /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/fs/opener/osfs.py: │
│ 40 in open_fs │
│ │
│ 37 │ │ │
│ 38 │ │ _path = abspath(join(cwd, expanduser(parse_result.resource))) │
│ 39 │ │ path = normpath(_path) │
│ ❱ 40 │ │ osfs = OSFS(path, create=create) │
│ 41 │ │ return osfs │
│ 42 │
│ │
│ /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/fs/osfs.py:142 in │
│ __init__ │
│ │
│ 139 │ │ else: │
│ 140 │ │ │ if not os.path.isdir(_root_path): │
│ 141 │ │ │ │ message = "root path '{}' does not exist".format(_root_path) │
│ ❱ 142 │ │ │ │ raise errors.CreateFailed(message) │
│ 143 │ │ │
│ 144 │ │ _meta = self._meta = { │
│ 145 │ │ │ "network": False, │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
CreateFailed: root path '/Users/martinklimke/Users/martinklimke/Library/Mobile
Documents/com~apple~CloudDocs/Documents/Organize/category folders/steuerrelevante Rechnungen' does not exist
The above exception was the direct cause of the following exception:
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ │
│ /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/organize/cli.py:86 │
│ in run_local │
│ │
│ 83 │ │ config_dir, config_name = split(config_path) │
│ 84 │ │ config = open_fs(config_dir).readtext(config_name) │
│ 85 │ │ os.chdir(working_dir) │
│ ❱ 86 │ │ core.run(rules=config, simulate=simulate) │
│ 87 │ except NeedsMigrationError as e: │
│ 88 │ │ console.error(e, title="Config needs migration") │
│ 89 │ │ console.warn( │
│ /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/organize/core.py:3 │
│ 00 in run │
│ │
│ 297 │ │ config.validate(rules) │
│ 298 │ │
│ 299 │ # instantiate │
│ ❱ 300 │ warnings = replace_with_instances(rules) │
│ 301 │ for msg in warnings: │
│ 302 │ │ console.warn(msg) │
│ 303 │
│ │
│ /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/organize/core.py:1 │
│ 43 in replace_with_instances │
│ │
│ 140 │ │ │ │ if isinstance(options, dict) and options.get("ignore_errors", False): │
│ 141 │ │ │ │ │ warnings.append(str(e)) │
│ 142 │ │ │ │ else: │
│ ❱ 143 │ │ │ │ │ raise ValueError("Invalid location %s" % options) from e │
│ 144 │ │ │
│ 145 │ │ # filters are optional │
│ 146 │ │ _filters = [] │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
ValueError: Invalid location $SOURCE/steuerrelevante Rechnungen
Please try {env.SOURCE}
instead of $SOURCE
.
Thank you a lot for testing!
organize sim --config-file='/Users/martinklimke/Library/Mobile Documents/com~apple~CloudDocs/Documents/Organize/Rules/config.yaml'
Deprecated: The --config-file option can now be omitted. See organize --help.
organize 2.0.1
Config: "/Users/martinklimke/Library/Mobile Documents/com~apple~CloudDocs/Documents/Organize/Rules/config.yaml"
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ │
│ /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/organize/core.py:1 │
│ 34 in replace_with_instances │
│ │
│ 131 │ │ _locations = [] │
│ 132 │ │ for options in ensure_list(rule["locations"]): │
│ 133 │ │ │ try: │
│ ❱ 134 │ │ │ │ instance = instantiate_location( │
│ 135 │ │ │ │ │ options=options, │
│ 136 │ │ │ │ │ default_max_depth=default_depth, │
│ 137 │ │ │ │ ) │
│ /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/organize/core.py:8 │
│ 6 in instantiate_location │
│ │
│ 83 │ else: │
│ 84 │ │ walker = options["walker"] │
│ 85 │ │
│ ❱ 86 │ fs, fs_path = fs_path_from_options( │
│ 87 │ │ path=options.get("path", "/"), │
│ 88 │ │ filesystem=options.get("filesystem"), │
│ 89 │ ) │
│ │
│ /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/organize/utils.py: │
│ 107 in fs_path_from_options │
│ │
│ 104 │ path = expand_user(path) │
│ 105 │ │
│ 106 │ if not filesystem: │
│ ❱ 107 │ │ return (open_fs(path), "/") │
│ 108 │ else: │
│ 109 │ │ if isinstance(filesystem, str): │
│ 110 │ │ │ filesystem = expand_user(filesystem) │
│ │
│ /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/fs/opener/registry │
│ .py:229 in open_fs │
│ │
│ 226 │ │ if isinstance(fs_url, FS): │
│ 227 │ │ │ _fs = fs_url │
│ 228 │ │ else: │
│ ❱ 229 │ │ │ _fs, _path = self.open( │
│ 230 │ │ │ │ fs_url, │
│ 231 │ │ │ │ writeable=writeable, │
│ 232 │ │ │ │ create=create, │
│ │
│ /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/fs/opener/registry │
│ .py:186 in open │
│ │
│ 183 │ │ │
│ 184 │ │ opener = self.get_opener(protocol) │
│ 185 │ │ │
│ ❱ 186 │ │ open_fs = opener.open_fs(fs_url, parse_result, writeable, create, cwd) │
│ 187 │ │ return open_fs, open_path │
│ 188 │ │
│ 189 │ def open_fs( │
│ │
│ /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/fs/opener/osfs.py: │
│ 40 in open_fs │
│ │
│ 37 │ │ │
│ 38 │ │ _path = abspath(join(cwd, expanduser(parse_result.resource))) │
│ 39 │ │ path = normpath(_path) │
│ ❱ 40 │ │ osfs = OSFS(path, create=create) │
│ 41 │ │ return osfs │
│ 42 │
│ │
│ /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/fs/osfs.py:142 in │
│ __init__ │
│ │
│ 139 │ │ else: │
│ 140 │ │ │ if not os.path.isdir(_root_path): │
│ 141 │ │ │ │ message = "root path '{}' does not exist".format(_root_path) │
│ ❱ 142 │ │ │ │ raise errors.CreateFailed(message) │
│ 143 │ │ │
│ 144 │ │ _meta = self._meta = { │
│ 145 │ │ │ "network": False, │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
CreateFailed: <exception str() failed>
The above exception was the direct cause of the following exception:
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ │
│ /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/organize/cli.py:86 │
│ in run_local │
│ │
│ 83 │ │ config_dir, config_name = split(config_path) │
│ 84 │ │ config = open_fs(config_dir).readtext(config_name) │
│ 85 │ │ os.chdir(working_dir) │
│ ❱ 86 │ │ core.run(rules=config, simulate=simulate) │
│ 87 │ except NeedsMigrationError as e: │
│ 88 │ │ console.error(e, title="Config needs migration") │
│ 89 │ │ console.warn( │
│ /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/organize/core.py:3 │
│ 00 in run │
│ │
│ 297 │ │ config.validate(rules) │
│ 298 │ │
│ 299 │ # instantiate │
│ ❱ 300 │ warnings = replace_with_instances(rules) │
│ 301 │ for msg in warnings: │
│ 302 │ │ console.warn(msg) │
│ 303 │
│ │
│ /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/organize/core.py:1 │
│ 43 in replace_with_instances │
│ │
│ 140 │ │ │ │ if isinstance(options, dict) and options.get("ignore_errors", False): │
│ 141 │ │ │ │ │ warnings.append(str(e)) │
│ 142 │ │ │ │ else: │
│ ❱ 143 │ │ │ │ │ raise ValueError("Invalid location %s" % options) from e │
│ 144 │ │ │
│ 145 │ │ # filters are optional │
│ 146 │ │ _filters = [] │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
ValueError: Invalid location ${env.SOURCE}/steuerrelevante Rechnungen
Have to leave for 30 minutes. Hope you find the bug. I love the program and also the new features.
Got the bug. Happy to hear that!
v2.0.2 is ready
organize sim --config-file='/Users/martinklimke/Library/Mobile Documents/com~apple~CloudDocs/Documents/Organize/Rules/config.yaml'
Deprecated: The --config-file option can now be omitted. See organize --help.
organize 2.0.3
Config: "/Users/martinklimke/Library/Mobile Documents/com~apple~CloudDocs/Documents/Organize/Rules/config.yaml"
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ │
│ /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/organize/core.py:1 │
│ 34 in replace_with_instances │
│ │
│ 131 │ │ _locations = [] │
│ 132 │ │ for options in ensure_list(rule["locations"]): │
│ 133 │ │ │ try: │
│ ❱ 134 │ │ │ │ instance = instantiate_location( │
│ 135 │ │ │ │ │ options=options, │
│ 136 │ │ │ │ │ default_max_depth=default_depth, │
│ 137 │ │ │ │ ) │
│ /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/organize/core.py:8 │
│ 6 in instantiate_location │
│ │
│ 83 │ else: │
│ 84 │ │ walker = options["walker"] │
│ 85 │ │
│ ❱ 86 │ fs, fs_path = fs_path_from_options( │
│ 87 │ │ path=options.get("path", "/"), │
│ 88 │ │ filesystem=options.get("filesystem"), │
│ 89 │ ) │
│ │
│ /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/organize/utils.py: │
│ 111 in fs_path_from_options │
│ │
│ 108 │ │ │ filesystem = expand_args(filesystem) │
│ 109 │ │ │ return (open_fs(filesystem), path) # type: ignore │
│ 110 │ │ return (filesystem, path) │
│ ❱ 111 │ return (open_fs(path), "/") │
│ 112 │
│ 113 │
│ 114 def is_same_resource(fs1: FS, path1: str, fs2: FS, path2: str): │
│ │
│ /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/fs/opener/registry │
│ .py:229 in open_fs │
│ │
│ 226 │ │ if isinstance(fs_url, FS): │
│ 227 │ │ │ _fs = fs_url │
│ 228 │ │ else: │
│ ❱ 229 │ │ │ _fs, _path = self.open( │
│ 230 │ │ │ │ fs_url, │
│ 231 │ │ │ │ writeable=writeable, │
│ 232 │ │ │ │ create=create, │
│ │
│ /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/fs/opener/registry │
│ .py:186 in open │
│ │
│ 183 │ │ │
│ 184 │ │ opener = self.get_opener(protocol) │
│ 185 │ │ │
│ ❱ 186 │ │ open_fs = opener.open_fs(fs_url, parse_result, writeable, create, cwd) │
│ 187 │ │ return open_fs, open_path │
│ 188 │ │
│ 189 │ def open_fs( │
│ │
│ /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/fs/opener/osfs.py: │
│ 40 in open_fs │
│ │
│ 37 │ │ │
│ 38 │ │ _path = abspath(join(cwd, expanduser(parse_result.resource))) │
│ 39 │ │ path = normpath(_path) │
│ ❱ 40 │ │ osfs = OSFS(path, create=create) │
│ 41 │ │ return osfs │
│ 42 │
│ │
│ /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/fs/osfs.py:142 in │
│ __init__ │
│ │
│ 139 │ │ else: │
│ 140 │ │ │ if not os.path.isdir(_root_path): │
│ 141 │ │ │ │ message = "root path '{}' does not exist".format(_root_path) │
│ ❱ 142 │ │ │ │ raise errors.CreateFailed(message) │
│ 143 │ │ │
│ 144 │ │ _meta = self._meta = { │
│ 145 │ │ │ "network": False, │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
CreateFailed: root path '/Users/martinklimke/$/Users/martinklimke/Library/Mobile
Documents/com~apple~CloudDocs/Documents/Organize/category folders/steuerrelevante Rechnungen' does not exist
The above exception was the direct cause of the following exception:
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ │
│ /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/organize/cli.py:86 │
│ in run_local │
│ │
│ 83 │ │ config_dir, config_name = split(config_path) │
│ 84 │ │ config = open_fs(config_dir).readtext(config_name) │
│ 85 │ │ os.chdir(working_dir) │
│ ❱ 86 │ │ core.run(rules=config, simulate=simulate) │
│ 87 │ except NeedsMigrationError as e: │
│ 88 │ │ console.error(e, title="Config needs migration") │
│ 89 │ │ console.warn( │
│ /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/organize/core.py:3 │
│ 00 in run │
│ │
│ 297 │ │ config.validate(rules) │
│ 298 │ │
│ 299 │ # instantiate │
│ ❱ 300 │ warnings = replace_with_instances(rules) │
│ 301 │ for msg in warnings: │
│ 302 │ │ console.warn(msg) │
│ 303 │
│ │
│ /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/organize/core.py:1 │
│ 43 in replace_with_instances │
│ │
│ 140 │ │ │ │ if isinstance(options, dict) and options.get("ignore_errors", False): │
│ 141 │ │ │ │ │ warnings.append(str(e)) │
│ 142 │ │ │ │ else: │
│ ❱ 143 │ │ │ │ │ raise ValueError("Invalid location %s (%s)" % (options, e)) from e │
│ 144 │ │ │
│ 145 │ │ # filters are optional │
│ 146 │ │ _filters = [] │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
ValueError: Invalid location ${env.SOURCE}/steuerrelevante Rechnungen (root path
'/Users/martinklimke/$/Users/martinklimke/Library/Mobile Documents/com~apple~CloudDocs/Documents/Organize/category
folders/steuerrelevante Rechnungen' does not exist)
I changed by to $Source. This removes the error. I will try now with my productive config.
Productive config is also working. Great! Thanks for the fast response.
Wohooo, thanks for the patience! 🎉
I have changed my rule file according migration documentation. Getting the following error: