Closed aleksandra-kim closed 6 years ago
Original comment by Chris Mutel (Bitbucket: cmutel, GitHub: cmutel).
I would have to think about this a bit more; my first reaction is that you could subclass pretty easily, so would be negative for now:
#!python
class NewBackend(SQLiteBackend):
def _efficient_write_many(self, *args, **kwargs):
do_some_signal_stuff()
super()._efficient_write_many(*args, **kwargs)
some_more_signal_stuff()
_efficient_write_many
isn't really private (i.e. I don't think it would change), just not something that people should use directly.
But! I definitely could be convinced otherwise.
Original comment by Adrian Haas (Bitbucket: haasad, GitHub: haasad).
Agreed. This is much more elegant. However i would like to have access to the index variable in the for
-loop to update the progressbar.
for index, (key, ds) in enumerate(data.items()):
Would it be an option to put the inner part of the for loop in its own function? In this case I could subclass it in the way you proposed above.
def _inside(self, index, key, ds):
for exchange in ds.get('exchanges', []):
...
Original report by Adrian Haas (Bitbucket: haasad, GitHub: haasad).
I'm working on a feature for the Activity Browser to import databases (see this pull request). Since importing takes quite a long time, I want to have progress signals.
I currently have a working solution where I subclass the
SQLiteBackend
and reimplement the private_efficient_write_many
method. This is really not ideal and not future-proof. Would you be willing to accept a pull request to let bw2data (and later also bw2io) emit pyqt signals?I imagine this to look something like this:
add an option
bw2data.config.activity_browser=True
where the signals are defined in their own class that are accessible via
bw2data.signals