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)
| 371 | |
| 372 | |
| 373 | def 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 | |
| 394 | def path_progress_message(item, verbose=False, prefix="Scanned: "): |
no outgoing calls
no test coverage detected