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

Function file_name_max_len

src/commoncode/cliutils.py:373–391  ·  view source on GitHub ↗

Return the max length of a path given the current terminal width. A progress bar is composed of these elements: [-----------------------------------#] 1667 Scanned: tu-berlin.yml - the bar proper which is BAR_WIDTH characters - one space - the number of files. We set it

(used_width=BAR_WIDTH + 1 + 7 + 1 + 8 + 1)

Source from the content-addressed store, hash-verified

371
372
373def file_name_max_len(used_width=BAR_WIDTH + 1 + 7 + 1 + 8 + 1):
374 """
375 Return the max length of a path given the current terminal width.
376
377 A progress bar is composed of these elements:
378 [-----------------------------------#] 1667 Scanned: tu-berlin.yml
379 - the bar proper which is BAR_WIDTH characters
380 - one space
381 - the number of files. We set it to 7 chars, eg. 9 999 999 files
382 - one space
383 - the word Scanned: 8 chars
384 - one space
385 - the file name proper
386 The space usage is therefore:
387 BAR_WIDTH + 1 + 7 + 1 + 8 + 1 + the file name length
388 """
389 term_width, _height = shutil.get_terminal_size()
390 max_filename_length = term_width - used_width
391 return max_filename_length
392
393
394def path_progress_message(item, verbose=False, prefix="Scanned: "):

Callers 1

path_progress_messageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected