def __init__(self, cb, args, kwargs): self.callback = cb self.args = args or [] self.kwargs = kwargs or {} self.callback_name = cb.__name__ self.callback_filename = os.path.split(get_function_code(cb).co_filename)[-1] self.callback_lineno = get_function_code(cb).co_firstlineno + 1
def _get_file_name(func): try: name = inspect.getfile(func) except AttributeError: name = get_function_code(func).co_filename return os.path.abspath(name)
def _get_line_number(func): try: return inspect.getlineno(func) except AttributeError: return get_function_code(func).co_firstlineno