Using tqdm description instead of printing
This commit is contained in:
parent
f1724eb90c
commit
34dc772aea
1 changed files with 5 additions and 2 deletions
|
@ -4,9 +4,11 @@ import xml.etree.ElementTree as ET
|
||||||
from itertools import takewhile
|
from itertools import takewhile
|
||||||
try:
|
try:
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
|
TQDM_IMPORTED = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
def tqdm(iter, *args, **kargs):
|
def tqdm(iter, *args, **kargs):
|
||||||
return iter
|
return iter
|
||||||
|
TQDM_IMPORTED = False
|
||||||
|
|
||||||
def get_database_connection():
|
def get_database_connection():
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
@ -158,8 +160,9 @@ def main():
|
||||||
|
|
||||||
trains = find_trains(con)
|
trains = find_trains(con)
|
||||||
|
|
||||||
print(f'Adding {company_common_name or f}...')
|
if not TQDM_IMPORTED:
|
||||||
for el_tren in tqdm(el_trenuri.findall("./Tren")):
|
print(f'Adding {company_common_name or f}...')
|
||||||
|
for el_tren in tqdm(el_trenuri.findall("./Tren"), desc=company_common_name or f):
|
||||||
train_number_str = el_tren.attrib['Numar']
|
train_number_str = el_tren.attrib['Numar']
|
||||||
train_number = train_number_stoi(train_number_str)
|
train_number = train_number_stoi(train_number_str)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue