progress bar updated
This commit is contained in:
parent
a5444a864a
commit
9bba32a197
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,4 +1,4 @@
|
||||
temp/**
|
||||
.idea
|
||||
.idea/**
|
||||
|
||||
poetry.lock
|
||||
|
@ -7,6 +7,7 @@ readme = "README.md"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.12"
|
||||
tqdm = "^4.66.5"
|
||||
|
||||
|
||||
[build-system]
|
||||
|
13
src/app.py
13
src/app.py
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user