Use tqdm to show progress bars when performing long operations, like importing each type of data and flushing alternative names for each model.
Also includes PEP-8 fixes for touched files.
The weird
data = self.get_data('...')
total = sum(1 for _ in data)
data = self.get_data('...')
is due to the fact that get_data() returns a generator instead of a list, so by the time the total is calculated the generator is reading the end of the file (so it must be reset). The get_data() function can be updated to calculate the total itself and return a (total, <generator>) tuple instead, which would make the syntax much more readable and prevent the generator from being created twice during every import. I left this change out to ease review of this PR, and I'll probably fix this in a future PR if nobody else gets to it first.
Use tqdm to show progress bars when performing long operations, like importing each type of data and flushing alternative names for each model.
Also includes PEP-8 fixes for touched files.
The weird
is due to the fact that
get_data()
returns a generator instead of a list, so by the time the total is calculated the generator is reading the end of the file (so it must be reset). Theget_data()
function can be updated to calculate thetotal
itself and return a(total, <generator>)
tuple instead, which would make the syntax much more readable and prevent the generator from being created twice during every import. I left this change out to ease review of this PR, and I'll probably fix this in a future PR if nobody else gets to it first.