Skip to content

Commit edfc5c6

Browse files
authored
Merge pull request #653 from DocNow/fix-progress-pipes
Fix #652
2 parents b09ba6e + 027df81 commit edfc5c6

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

twarc/decorators2.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def __init__(self, infile, outfile, **kwargs):
242242
] = "{l_bar}{bar}| Processed {n_fmt}/{total_fmt} lines of input file [{elapsed}<{remaining}, {rate_fmt}{postfix}]"
243243

244244
# Warn for large (> 1 GB) input files:
245-
if (os.stat(infile.name).st_size / (1024 * 1024 * 1024)) > 1:
245+
if not disable and (os.stat(infile.name).st_size / (1024 * 1024 * 1024)) > 1:
246246
click.echo(
247247
click.style(
248248
f"Input File Size is {os.stat(infile.name).st_size / (1024*1024):.2f} MB, it may take a while to process. CTRL+C to stop.",
@@ -252,10 +252,11 @@ def __init__(self, infile, outfile, **kwargs):
252252
err=True,
253253
)
254254

255-
with open(infile.name, "r", encoding="utf-8", errors="ignore") as f:
256-
total_lines = sum(1 for _ in f)
255+
def total_lines():
256+
with open(infile.name, "r", encoding="utf-8", errors="ignore") as f:
257+
return sum(1 for _ in f)
257258

258-
kwargs["total"] = total_lines if not disable else 1
259+
kwargs["total"] = total_lines() if not disable else 1
259260
super().__init__(**kwargs)
260261

261262
def update_with_result(

0 commit comments

Comments
 (0)