Writing IPython Notebook Extensions That Can Perform Analysis Per Cell

I am trying to write an extension for IPython notebook that will run code analysis on each cell and then output messages through the logger (this could be a PEP8 analysis for example to take a simple example). The trick is that I want to be able to load the extension once at the top of the laptop and apply it to all cells.

It is possible to define custom linear and cellular magic (see here ), but you need to put a magic command in each cell, whereas I would like for all code cells.

I also found that it is possible to register a class that pre-filters the code input using ip.prefilter_manager.registre_transformer

, but that works based on a string that is not good enough.

Does anyone have any suggestions on how to register a function that can parse the contents of all cells when they are executed and add log messages to the output of a given cell?

I know there is a PEP8 extension for IPython notebook, but that requires a magic %% pep8 command to be placed in each cell, and I want to change it to be a more global setting in notebook.

+3


source to share





All Articles