log.py 753 B

12345678910111213141516171819202122232425262728293031
  1. from progress.bar import IncrementalBar
  2. def to_color(s, c):
  3. return f'\x1b[{c}m{s}\x1b[0m' if use_color else s
  4. def out_line(s='', color=37, indent=0, thread_name=None):
  5. t = ''
  6. if thread_name is not None and show_threads:
  7. t = to_color(f'<{thread_name}> ', thread_color)
  8. print(t + ' ' * indent + to_color(s, color))
  9. def out(s='', color=37, indent=0, thread_name=None):
  10. for line in s.split('\n'):
  11. out_line(line, color, indent, thread_name)
  12. def get_progress_bar(**kwargs):
  13. bar = IncrementalBar(**kwargs)
  14. bar.suffix = "%(index)d / %(max)d (%(elapsed_td)s)"
  15. return bar
  16. use_color = True
  17. show_threads = True
  18. thread_color = 34
  19. # stuff for progress bars
  20. export_task_count = 0
  21. filtered_export_task_count = 0