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


from functools import update_wrapper, wraps
from twisted.internet import defer
from lacli.log import getLogger


class login_async(object):
    def __init__(self, f, obj=None):
        self.f = f
        self.obj = obj
        update_wrapper(self, self.f)

    def __get__(self, obj, cls):
        return wraps(self.f)(login(self.f, obj))

    def dologin(self, prefs):
        return self.obj.registry.cmd.login.login_async(
            prefs.get('user'), prefs.get('pass'))

    @defer.inlineCallbacks
    def loginfirst(self, prefs, *args, **kwargs):
        try:
            yield self.dologin(prefs)
            r = yield self.f(self.obj, *args, **kwargs)
            defer.returnValue(r)
        except Exception:

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


# Path: lacli/loginutil.py
from functools import update_wrapper, wraps
from twisted.internet import defer
from lacli.log import getLogger



class login_async(object):
    def __init__(self, f, obj=None):
        self.f = f
        self.obj = obj
        update_wrapper(self, self.f)

    def __get__(self, obj, cls):
        return wraps(self.f)(login(self.f, obj))

    def dologin(self, prefs):
        return self.obj.registry.cmd.login.login_async(
            prefs.get('user'), prefs.get('pass'))

    @defer.inlineCallbacks
    def loginfirst(self, prefs, *args, **kwargs):
        try:
            yield self.dologin(prefs)
            r = yield self.f(self.obj, *args, **kwargs)
            defer.returnValue(r)
        except Exception:

            getLogger().debug("unhandled error in login decorator",