

@option('-l', '--language', action='store', nargs=1, help=('Possible languages to be displayed within the iframe. ' + 'Possible values are: python, python2, python3, java, javascript'))
def cell_tutor(self, language=None):
    '\n        %%tutor [--language=LANGUAGE] - show cell with \n        Online Python Tutor.\n\n        Defaults to use the language of the current kernel.\n        \'python\' is an alias for \'python3\'.\n\n        Examples:\n           %%tutor -l python3\n           a = 1\n           b = 1\n           a + b\n\n           [You will see an iframe with the pythontutor.com page \n           including the code above.]\n\n           %%tutor --language=java\n           \n           public class Test {\n               public Test() {\n               }\n               public static void main(String[] args) {\n                   int x = 1;\n                   System.out.println("Hi");\n               }\n           }\n        '
    if (language is None):
        language = self.kernel.language_info['name']
    if (language not in ['python', 'python2', 'python3', 'java', 'javascript']):
        raise ValueError("{} not supported. Only the following options are allowed: 'python2', 'python3', 'java', 'javascript'".format(language))
    url = 'https://pythontutor.com/iframe-embed.html#code='
    url += quote(self.code)
    url += '&origin=opt-frontend.js&cumulative=false&heapPrimitives=false'
    url += '&textReferences=false&'
    if (language in ['python3', 'python']):
        url += 'py=3&rawInputLstJSON=%5B%5D&curInstr=0&codeDivWidth=350&codeDivHeight=400'
    elif (language == 'python2'):
        url += 'py=2&rawInputLstJSON=%5B%5D&curInstr=0&codeDivWidth=350&codeDivHeight=400'
    elif (language == 'java'):
        url += 'py=java&rawInputLstJSON=%5B%5D&curInstr=0&codeDivWidth=350&codeDivHeight=400'
    elif (language == 'javascript'):
        url += 'py=js&rawInputLstJSON=%5B%5D&curInstr=0&codeDivWidth=350&codeDivHeight=400'
    self.kernel.Display(IFrame(url, height=500, width='100%'))
    self.evaluate = False

dataset/ETHPy150Open Calysto/metakernel/metakernel/magics/tutor_magic.py TutorMagic.cell_tutor/original