MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / path_progress_message

Function path_progress_message

src/commoncode/cliutils.py:394–413  ·  view source on GitHub ↗

Return a styled message suitable for progress display when processing a path for an `item` tuple of (location, rid, scan_errors, *other items)

(item, verbose=False, prefix="Scanned: ")

Source from the content-addressed store, hash-verified

392
393
394def path_progress_message(item, verbose=False, prefix="Scanned: "):
395 """
396 Return a styled message suitable for progress display when processing a path
397 for an `item` tuple of (location, rid, scan_errors, *other items)
398 """
399 if not item:
400 return ""
401 location = item[0]
402 errors = item[2]
403 location = toascii(location)
404 progress_line = location
405 if not verbose:
406 max_file_name_len = file_name_max_len()
407 # do not display a file name in progress bar if there is no space available
408 if max_file_name_len <= 10:
409 return ""
410 progress_line = fixed_width_file_name(location, max_file_name_len)
411
412 color = "red" if errors else "green"
413 return style(prefix) + style(progress_line, fg=color)
414
415
416# CLI help groups

Callers

nothing calls this directly

Calls 3

toasciiFunction · 0.90
file_name_max_lenFunction · 0.85
fixed_width_file_nameFunction · 0.85

Tested by

no test coverage detected