20
20
$ export HTTPS_PROXY="https://10.10.1.10:1080"
21
21
--debug Print debug information
22
22
--ignore <dirs>... Ignore extra directories, each separated by a comma
23
+ --ignore-errors Ignore errors while scanning files
23
24
--no-follow-links Do not follow symbolic links in the project
24
25
--encoding <charset> Use encoding parameter for file open
25
26
--savepath <file> Save the list of requirements in the given file
@@ -97,11 +98,10 @@ def _open(filename=None, mode="r"):
97
98
file .close ()
98
99
99
100
100
- def get_all_imports (path , encoding = "utf-8" , extra_ignore_dirs = None , follow_links = True ):
101
+ def get_all_imports (path , encoding = "utf-8" , extra_ignore_dirs = None , follow_links = True , ignore_errors = False ):
101
102
imports = set ()
102
103
raw_imports = set ()
103
104
candidates = []
104
- ignore_errors = False
105
105
ignore_dirs = [
106
106
".hg" ,
107
107
".svn" ,
@@ -133,9 +133,9 @@ def get_all_imports(path, encoding="utf-8", extra_ignore_dirs=None, follow_links
133
133
134
134
for file_name in files :
135
135
file_name = os .path .join (root , file_name )
136
- contents = read_file_content (file_name , encoding )
137
136
138
137
try :
138
+ contents = read_file_content (file_name , encoding )
139
139
tree = ast .parse (contents )
140
140
for node in ast .walk (tree ):
141
141
if isinstance (node , ast .Import ):
@@ -145,7 +145,7 @@ def get_all_imports(path, encoding="utf-8", extra_ignore_dirs=None, follow_links
145
145
raw_imports .add (node .module )
146
146
except Exception as exc :
147
147
if ignore_errors :
148
- traceback .print_exc (exc )
148
+ traceback .print_exc ()
149
149
logging .warn ("Failed on file: %s" % file_name )
150
150
continue
151
151
else :
@@ -504,6 +504,7 @@ def init(args):
504
504
encoding = args .get ("--encoding" )
505
505
extra_ignore_dirs = args .get ("--ignore" )
506
506
follow_links = not args .get ("--no-follow-links" )
507
+ ignore_errors = args .get ("--ignore-errors" )
507
508
508
509
scan_noteboooks = args .get ("--scan-notebooks" , False )
509
510
handle_scan_noteboooks ()
@@ -535,6 +536,7 @@ def init(args):
535
536
encoding = encoding ,
536
537
extra_ignore_dirs = extra_ignore_dirs ,
537
538
follow_links = follow_links ,
539
+ ignore_errors = ignore_errors ,
538
540
)
539
541
candidates = get_pkg_names (candidates )
540
542
logging .debug ("Found imports: " + ", " .join (candidates ))
0 commit comments