Add a no_such_file rule

This commit is contained in:
mcarton
2015-05-15 18:03:17 +02:00
parent 371a4b0ad3
commit 3c4f9d50a9
2 changed files with 27 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
import re
patterns = (
r"mv: cannot move '[^']*' to '([^']*)': No such file or directory",
r"cp: cannot create regular file '([^']*)': No such file or directory",
)
def match(command, settings):
for pattern in patterns:
if re.search(pattern, command.stderr):
return True
return False
def get_new_command(command, settings):
for pattern in patterns:
file = re.findall(pattern, command.stderr)
if file:
file = file[0]
dir = file[0:file.rfind('/')]
return 'mkdir -p {} && {}'.format(dir, command.script)