from inspect import *


def get_class_members(klass):
    ret = dir(klass)
    if hasattr(klass, '__bases__'):
        for base in klass.__bases__:
            ret = ret + get_class_members(base)
    return ret


def uniq(seq):
    """ the 'set()' way ( use dict when there's no set ) """
    return list(set(seq))


def fiko2Dict(obj):
    # code borrowed from the rlcompleter module ( see the code for Completer::attr_matches() )
    ret = dir(obj)
    if "__builtins__" in ret:
        ret.remove("__builtins__")

    if hasattr(obj, '__class__'):
        ret.append('__class__')
        ret.extend(get_class_members(obj.__class__))

        ret = uniq(ret)
    ret = filter(lambda x: not x.startswith('_'), ret)

    rslt = {
        "method": { },
        "property": { }
    }
    for attr in list(ret):
        if "toDict" not in attr:
            _at = getattr(obj, attr, None)
            if ismethod(_at):
                rslt["method"][attr] = _at
            else:
                rslt["property"][attr] = _at

    return rslt


class ObjeOzellikler(object):
    metodlar = []
    ozellikler = []


def listOzellikler(obj) -> ObjeOzellikler:
    # code borrowed from the rlcompleter module ( see the code for Completer::attr_matches() )
    ret = dir(obj)
    if "__builtins__" in ret:
        ret.remove("__builtins__")

    if hasattr(obj, '__class__'):
        ret.append('__class__')
        ret.extend(get_class_members(obj.__class__))

        ret = uniq(ret)
    ret = filter(lambda x: not x.startswith('_'), ret)

    rslt = ObjeOzellikler()

    for attr in list(ret):
        print(attr)
        if "listeOzellikler" not in attr:
            rslt.metodlar.append(attr)

    return rslt
