progress bar updated

This commit is contained in:
vy.boyko 2024-10-16 12:20:50 +03:00
parent a5444a864a
commit 9bba32a197
3 changed files with 6 additions and 10 deletions

2
.gitignore vendored
View File

@ -1,4 +1,4 @@
temp/**
.idea
.idea/**
poetry.lock

View File

@ -7,6 +7,7 @@ readme = "README.md"
[tool.poetry.dependencies]
python = "^3.12"
tqdm = "^4.66.5"
[build-system]

View File

@ -2,6 +2,8 @@ import argparse
import re
from datetime import datetime
import os
from tqdm import tqdm
parser = argparse.ArgumentParser(prog='java-logs-analyzer')
parser.add_argument('-l', '--logs', help='Logs file')
@ -54,17 +56,10 @@ def _parse(line: str) -> (bool, str, str, str, str, str, str):
with open(args.logs, 'r') as file:
read_len = 0
last_percent = -1
percent = 0
progress = tqdm(total=file_len, unit='b', unit_scale=2)
for line in file:
l = line.strip()
read_len += len(line)
percent = round(read_len / file_len * 100, 2)
cur_percent = round(percent / 10, 0)
if last_percent != cur_percent:
print(f"{percent}%", end='\r')
last_percent = cur_percent
progress.update(len(line))
(is_parsed, year, month, day, hour, minute, second) = _parse(l)
if is_parsed:
if first_line is None: