summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjvoisin2018-06-10 00:07:49 +0200
committerjvoisin2018-06-10 00:07:49 +0200
commit0079b4e8e92ea89a2ce692fa3ca0cedf51c002a1 (patch)
treeb95d0c2e4cc7e89308aa71974e7428645cd54dfe
parent3cba2944d70b8f5675eeb1bc0f50b71ce4065548 (diff)
Improve a bit how we're handling "problematic" files in the CLI
-rwxr-xr-xmat215
1 files changed, 10 insertions, 5 deletions
diff --git a/mat2 b/mat2
index 87fa66c..7a210d5 100755
--- a/mat2
+++ b/mat2
@@ -13,7 +13,10 @@ from libmat2 import parser_factory, unsupported_extensions
13__version__ = '0.1.1' 13__version__ = '0.1.1'
14 14
15def __check_file(filename: str, mode: int = os.R_OK) -> bool: 15def __check_file(filename: str, mode: int = os.R_OK) -> bool:
16 if not os.path.isfile(filename): 16 if not os.path.exists(filename):
17 print("[-] %s is doesn't exist." % filename)
18 return False
19 elif not os.path.isfile(filename):
17 print("[-] %s is not a regular file." % filename) 20 print("[-] %s is not a regular file." % filename)
18 return False 21 return False
19 elif not os.access(filename, mode): 22 elif not os.access(filename, mode):
@@ -89,12 +92,14 @@ def show_parsers():
89 92
90def __get_files_recursively(files): 93def __get_files_recursively(files):
91 for f in files: 94 for f in files:
92 if os.path.isfile(f): 95 if os.path.isdir(f):
93 yield f
94 else:
95 for path, _, _files in os.walk(f): 96 for path, _, _files in os.walk(f):
96 for _f in _files: 97 for _f in _files:
97 yield os.path.join(path, _f) 98 fname = os.path.join(path, _f)
99 if __check_file(fname):
100 yield fname
101 elif __check_file(f):
102 yield f
98 103
99def main(): 104def main():
100 arg_parser = create_arg_parser() 105 arg_parser = create_arg_parser()