# Path: lacli/log.py
# def getLogger(logger='lacli'):
#     return lacore.log.getLogger(logger)


import os
import multiprocessing
from progressbar import (ProgressBar, Bar,
                         ETA, FileTransferSpeed)
from lacli.log import getLogger
from abc import ABCMeta, abstractmethod
from logutils.queue import QueueListener
    __metaclass__ = ABCMeta

    def __init__(self, *args, **kwargs):
        self.tx = {}
        self.progress = kwargs.pop('progress', 0)
        super(BaseProgressHandler, self).__init__(*args, **kwargs)

    def update_current(self, msg):
        self.tx[msg['part']] = int(msg['tx'])
        return sum(self.tx.values())

    def save_current(self):
        self.progress += sum(self.tx.values())
        self.tx = {}

    def handle(self, msg):
        if 'part' in msg:
            self.update(self.progress + self.update_current(msg))
        elif 'save' in msg:
            self.keydone(msg)
            self.save_current()

    def __enter__(self):
        q = super(BaseProgressHandler, self).__enter__()
        progressToQueue(q)
        self.start(initval=self.progress)
        return q

    @abstractmethod
    def keydone(self, msg):

# Path: lacli/log.py
# def getLogger(logger='lacli'):
#     return lacore.log.getLogger(logger)


# Path: lacli/progress.py
import os
import multiprocessing
from progressbar import (ProgressBar, Bar,
                         ETA, FileTransferSpeed)
from lacli.log import getLogger
from abc import ABCMeta, abstractmethod
from logutils.queue import QueueListener

    __metaclass__ = ABCMeta

    def __init__(self, *args, **kwargs):
        self.tx = {}
        self.progress = kwargs.pop('progress', 0)
        super(BaseProgressHandler, self).__init__(*args, **kwargs)

    def update_current(self, msg):
        self.tx[msg['part']] = int(msg['tx'])
        return sum(self.tx.values())

    def save_current(self):
        self.progress += sum(self.tx.values())
        self.tx = {}

    def handle(self, msg):
        if 'part' in msg:
            self.update(self.progress + self.update_current(msg))
        elif 'save' in msg:
            self.keydone(msg)
            self.save_current()

    def __enter__(self):
        q = super(BaseProgressHandler, self).__enter__()
        progressToQueue(q)
        self.start(initval=self.progress)
        return q

    @abstractmethod
    def keydone(self, msg):

        getLogger().debug("saved key: {key} ({size})".format(msg))