Given a sequence (queryset, generator, tuple, list) of dicts import them into the given model

    FIXME: How is this differenct from import_items above?

    clear = model or queryset to be deleted/cleared 
        False: do not clear/delete anything
        None: clear/delete the dest_qs
        True: clear all records in dest_qs.model (e.g. dest_qs.model.objects.all().delete())

    Typical Usage:
    
    >> from src_app.models import SrcModel
    >> from dest_app.models import DestModel
    >> filter_dict={"model__startswith": "LC", "recvdat__gt":'2013-03-31'}
    >> dest = DestModel.objects.filter(**filter_dict)
    >> src = SrcModel.objects.filter(**filter_dict)
    >> src.count(), dest.count()
    >> from pug.dj import db
    >> db.import_queryset_batches(src, dest, batch_len=1000, clear=dest, dry_run=False, verbosity=2)

def import_queryset_batches(qs, dest_qs,  batch_len=500, clear=None, dry_run=True, verbosity=1):
    """Given a sequence (queryset, generator, tuple, list) of dicts import them into the given model

    FIXME: How is this differenct from import_items above?

    clear = model or queryset to be deleted/cleared 
        False: do not clear/delete anything
        None: clear/delete the dest_qs
        True: clear all records in dest_qs.model (e.g. dest_qs.model.objects.all().delete())

    Typical Usage:
    
    >> from src_app.models import SrcModel
    >> from dest_app.models import DestModel
    >> filter_dict={"model__startswith": "LC", "recvdat__gt":'2013-03-31'}
    >> dest = DestModel.objects.filter(**filter_dict)
    >> src = SrcModel.objects.filter(**filter_dict)
    >> src.count(), dest.count()
    >> from pug.dj import db
    >> db.import_queryset_batches(src, dest, batch_len=1000, clear=dest, dry_run=False, verbosity=2)
    """
    qs = get_queryset(qs)
    dest_qs = get_queryset(dest_qs)
    dest_model = get_model(dest_qs)

    N = qs.count()

    if verbosity > 0:
        print('Loading %r records from the queryset provided...' % N)
    qs = qs.values()

    if clear is None:
        clear = dest_qs
    if clear and not dry_run:
        if clear == True:
            clear = dest_model.objects.all()
        if verbosity > 0:
            print "WARNING: Deleting %d records from %r !!!!!!!" % (clear.count(), clear.model)
        clear.delete()
    if verbosity > 0:
        widgets = [pb.Counter(), '/%d rows: ' % N, pb.Percentage(), ' ', pb.RotatingMarker(), ' ', pb.Bar(),' ', pb.ETA()]
        pbar = pb.ProgressBar(widgets=widgets, maxval=N).start()
    for batch_num, dict_batch in enumerate(generate_queryset_batches(qs, batch_len)):
        if verbosity > 2:
            print(repr(dict_batch))
        item_batch = []
        for d in dict_batch:
            if verbosity > 2:
                print(repr(d))
            m = dest_model()
            try:
                m.import_item(d, verbosity=verbosity)
            except:
                m = django_object_from_row(d, dest_model)
            item_batch += [m]
        if verbosity and verbosity < 2:
            pbar.update(batch_num * batch_len + len(dict_batch))
        elif verbosity > 1:
            print(('DRYRUN:  ' if dry_run else '') + 'Writing {0} items in batch {1} out of {2} batches to the {3} model...'.format(
                len(item_batch), batch_num, int(N / float(batch_len)), dest_model))
        if not dry_run:
            dest_model.objects.bulk_create(item_batch)
    if verbosity > 0:
        pbar.finish()