from opt import requires

"""
Explanation: This details how the requires decorator can be used.
End of explanation
"""


@requires('pandas')
def test():
    import pandas
    print('yay pandas version {}'.format(pandas.__version__))

test()

"""
Explanation: The function takes an arbitrary number of strings that describe the dependencies introduced by the class or function.
End of explanation
"""


@requires("notarealmodule")
def test2():
    print("you shouldn't see this")

test2()

"""
Explanation: So, neat. What if we didn't have the module needed?
End of explanation
"""


def passer():
    if verbose:
        missing = [arg for i,arg in enumerate(args) if not available[i]]
        print("missing dependencies: {d}".format(d=missing))
        print("not running {}".format(function.__name__))
    else:
        pass

"""
Explanation: So, if the requirements aren't met, your original function is replaced with a new function.
it looks kind of like this:
End of explanation
"""


@requires("notarealmodule", verbose=False)
def test3():
    print("you shouldn't see this, either")

test3()

"""
Explanation: By deafult, the function is replaced with a verbose version. If you pass verbose=False, then the function gets replaced with a nonprinting version.
End of explanation
"""


@requires("notarealmodule")
class OLS_mock(object):
    def __init__(self, *args, **kwargs):
        for arg in args:
            print(arg)

OLS_mock(1,2,3,4,5, w='Tom')

@requires("pymc3")
class BayesianHLM(object):
    def __init__(self, *args, **kwargs):
                    print(arg)for arg in args[0:]:


BayesianHLM(1,2,3,4,5, w='Tom')

"""
Explanation: The cool thing is, this works on class definitions as well:
End of explanation
"""


