@@ -21,14 +21,17 @@ def restore_variables(content):
21
21
22
22
23
23
def lint_error (name , error ):
24
- code = error [ 'code' ]
25
- line_no = error [ 'line_no' ]
26
- line_pos = error [ 'line_pos' ]
27
- description = error [ 'description' ]
24
+ code = error . get ( 'code' , 'UNKNOWN' )
25
+ line_no = error . get ( 'line_no' , 0 )
26
+ line_pos = error . get ( 'line_pos' , 0 )
27
+ description = error . get ( 'description' , 'Unknown error' )
28
28
print (f'{ name } :{ line_no } :{ line_pos } : { code } { description } ' )
29
29
30
30
31
31
def fix_and_lint (script ):
32
+ if not script or not os .path .exists (script ):
33
+ return False
34
+
32
35
name = ''
33
36
content = ''
34
37
with open (script , 'r' ) as file :
@@ -54,14 +57,13 @@ def fix_and_lint(script):
54
57
55
58
56
59
if __name__ == '__main__' and sys .argv [1 ]:
57
- scripts = sys .argv [1 ].split (' ' )
58
- ignored_files = sys .argv [3 ]
59
- if ignored_files :
60
+ scripts = [ s for s in sys .argv [1 ].split (' ' ) if s . strip ()]
61
+ ignored_files = sys .argv [3 ] if len ( sys . argv ) > 3 else None
62
+ if ignored_files and os . path . exists ( ignored_files ) :
60
63
with open (ignored_files , 'r' ) as ignored_file :
61
- ignored_scripts = ignored_file .read ().split ('\n ' )
64
+ ignored_scripts = [ s . strip () for s in ignored_file .read ().split ('\n ' ) if s . strip ()]
62
65
for ignored_script in ignored_scripts :
63
- if ignored_script :
64
- scripts = list (filter (lambda x : not x .endswith (ignored_script ), scripts ))
66
+ scripts = list (filter (lambda x : not x .endswith (ignored_script ), scripts ))
65
67
66
68
pool = mp .Pool (processes = int (mp .cpu_count () / 2 ))
67
69
output = pool .map (fix_and_lint , scripts )
0 commit comments