

def _dispatch_safari_jupyter(self, cmd):
    cmd = self.clean_cmd(cmd)
    cmd = self.escape_dquote(cmd)
    cmd = cmd.replace('\n', '\\n')
    script = '\n        on run argv\n            tell application "Safari"\n                tell front window\'s current tab to do JavaScript "\n                    var mycell = IPython.notebook.get_selected_cell();\n                    mycell.set_text(\\"" & item 1 of argv & "\\");\n                    mycell.execute();\n                    var nextcell = IPython.notebook.insert_cell_below();\n                    IPython.notebook.select_next();\n                    IPython.notebook.scroll_to_cell(IPython.notebook.find_cell_index(nextcell));\n                "\n            end tell\n        end run\n        '
    subprocess.call(['osascript', '-e', script, cmd])

dataset/ETHPy150Open randy3k/SendTextPlus/textsender.py TextSender._dispatch_safari_jupyter/original