Browse Source

Using tqdm description instead of printing

master
Kenneth Bruen 3 years ago
parent
commit
34dc772aea
Signed by: kbruen
GPG Key ID: C1980A470C3EE5B1
  1. 5
      convert.py

5
convert.py

@ -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)
if not TQDM_IMPORTED:
print(f'Adding {company_common_name or f}...') print(f'Adding {company_common_name or f}...')
for el_tren in tqdm(el_trenuri.findall("./Tren")): 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…
Cancel
Save