4949from scancode .api import get_licenses
5050from scancode .api import get_file_infos
5151from scancode .api import get_package_infos
52+ from scancode .api import get_emails
53+ from scancode .api import get_urls
5254
5355
5456info_text = '''
@@ -216,6 +218,8 @@ class ScanCommand(utils.BaseCommand):
216218@click .option ('-c' , '--copyright' , is_flag = True , default = False , help = 'Scan <input> for copyrights. [default]' )
217219@click .option ('-l' , '--license' , is_flag = True , default = False , help = 'Scan <input> for licenses. [default]' )
218220@click .option ('-p' , '--package' , is_flag = True , default = False , help = 'Scan <input> for packages. [default]' )
221+ @click .option ('--email' , is_flag = True , default = False , help = 'Scan <input> for emails.' )
222+ @click .option ('--url' , is_flag = True , default = False , help = 'Scan <input> for urls.' )
219223@click .option ('-i' , '--info' , is_flag = True , default = False , help = 'Scan <input> for files information.' )
220224
221225@click .option ('-f' , '--format' , is_flag = False , default = 'json' , show_default = True , metavar = '<style>' ,
@@ -229,24 +233,24 @@ class ScanCommand(utils.BaseCommand):
229233@click .option ('--version' , is_flag = True , is_eager = True , callback = print_version , help = 'Show the version and exit.' )
230234
231235def scancode (ctx , input , output_file , copyright , license , package , # @ReservedAssignment
232- info , format , verbose , quiet , * args , ** kwargs ): # @ReservedAssignment
233- """scan the <input> file or directory for origin and license and save results to the <output_file>.
236+ email , url , info , format , verbose , quiet , * args , ** kwargs ): # @ReservedAssignment
237+ """scan the <input> file or directory for origin clues and license and save results to the <output_file>.
234238
235239 The scan results are printed on terminal if <output_file> is not provided.
236240 """
237- possible_scans = [copyright , license , package , info ]
241+ possible_scans = [copyright , license , package , email , url , info ]
238242 # Default scan when no options is provided
239243 if not any (possible_scans ):
240244 copyright = True # @ReservedAssignment
241245 license = True # @ReservedAssignment
242246 package = True
243247
244- results = scan (input , copyright , license , package , info , verbose , quiet )
248+ results = scan (input , copyright , license , package , email , url , info , verbose , quiet )
245249 save_results (results , format , input , output_file )
246250
247251
248252def scan (input_path , copyright = True , license = True , package = True , # @ReservedAssignment
249- info = True , verbose = False , quiet = False ): # @ReservedAssignment
253+ email = False , url = False , info = True , verbose = False , quiet = False ): # @ReservedAssignment
250254 """
251255 Do the scans proper, return results.
252256 """
@@ -259,6 +263,8 @@ def scan(input_path, copyright=True, license=True, package=True, # @ReservedAss
259263 'copyrights' : copyright and get_copyrights ,
260264 'licenses' : license and get_licenses ,
261265 'packages' : package and get_package_infos ,
266+ 'emails' : email and get_emails ,
267+ 'urls' : url and get_urls ,
262268 'infos' : info and get_file_infos ,
263269 }
264270
@@ -270,14 +276,12 @@ def scan_start():
270276 """Progress event displayed at start of scan"""
271277 return style ('Scanning files...' , fg = 'green' )
272278
273-
274279 def scan_event (item ):
275280 """Progress event displayed each time a file is scanned"""
276281 if item :
277282 line = verbose and item or fileutils .file_name (item ) or ''
278283 return 'Scanning: %(line)s' % locals ()
279284
280-
281285 def scan_end ():
282286 """Progress event displayed at end of scan"""
283287 has_warnings = False
@@ -289,7 +293,6 @@ def scan_end():
289293 summary .append (style ('Scanning done.' , fg = summary_color , reset = True ))
290294 return '\n ' .join (summary )
291295
292-
293296 ignored = partial (ignore .is_ignored , ignores = ignore .ignores_VCS , unignores = {})
294297 resources = fileutils .resource_iter (abs_input , ignored = ignored )
295298
@@ -340,7 +343,7 @@ def save_results(results, format, input, output_file): # @ReservedAssignment
340343 if format not in formats :
341344 # render using a user-provided custom format template
342345 if not os .path .isfile (format ):
343- click .secho ('\n Invalid template passed.' , err = True , fg = 'red' )
346+ click .secho ('\n Invalid template passed.' , err = True , fg = 'red' )
344347 else :
345348 output_file .write (as_template (results , template = format ))
346349 elif format == 'html' :
0 commit comments