def get_caller(skip=0, get_dump=False):
    # this whole thing fails if we're not in a valid directory
    try:
        cwd = os.getcwd()
    except __HOLE__ as e:
        return '~could not get caller (current directory not valid)~'

    stack = inspect.stack(3)
    if len(inspect.stack()) < 3 + skip:
        return 'top'
    output = None
    last_caller = None
    for record in stack[2 + skip:]:
        caller = record[3]
        frame = record[0]

        try:
            if 'self' in frame.f_locals:
                try:
                    output = '%s->%s' % (frame.f_locals['self'].name, caller)
                except Exception as e:
                    pass
                finally:
                    if output is None:
                        output = '%s->%s' % (
                            frame.f_locals['self'].__class__.__name__, caller)
            else:
                last_caller = caller
            if get_dump:
                output = output + "\n" + \
                    "\t".join(dump(frame.f_locals['self'], 'self'))

        except Exception as e:
            pass
        if output is not None:
            return output

    if output is None:
        return last_caller
dataset/ETHPy150Open mono/bockbuild/bockbuild/util/util.py/get_caller