def print_source(self, side, args, line): '''Print(if can) source of method or function or class''' obj = get_value_in_context(args.arg, side, self.shell) try: source = side.get_source(obj) if is_remote(obj) else get_source(obj) except (TypeError, IOError) as exc: print_err(exc, debug=debug) return display_html(highlight_python_source(source), raw=True)
def set_method(self, side, args, line, cell): '''Change method some method Example: %%set_method MySpider.my_aswesome_method_name def some_method(self, arg): pass ''' obj, method_name = split_on_last_method(args) obj = get_value_in_context(obj, side, self.shell) side.set_method(obj, method_name, cell)
def print_source(self, side, args, line): '''Print(if can) source of method or function or class''' obj = get_value_in_context(args.arg, side, self.shell) try: source = side.get_source(obj) if is_remote(obj) else get_source( obj) except (TypeError, IOError) as exc: print_err(exc, debug=debug) return display_html(highlight_python_source(source), raw=True)