_comms module

pyflyby._comms._reformat_helper(input_code, imports)
pyflyby._comms._register_target(target_name)
pyflyby._comms.collect_code_with_imports_on_top(imports, cell_array)
pyflyby._comms.comm_close_handler(comm, message)
pyflyby._comms.comm_open_handler(comm, message)

Handles comm_open message for pyflyby custom comm messages. https://jupyter-client.readthedocs.io/en/stable/messaging.html#opening-a-comm.

Handler for all PYFLYBY custom comm messages that are opened by the frontend (at this point, just the jupyterlab frontend does this).

pyflyby._comms.extract_import_statements(text)

This is a util for notebook interactions and extracts import statements from some python code. This function also re-orders imports. :param code: The code from which import statements have to be extracted :type code: str

Returns:

The first returned value contains all the import statements. The second returned value is the remaining code after extracting the import statements.

Return type:

(str, str)

pyflyby._comms.in_jupyter()
pyflyby._comms.initialize_comms()
pyflyby._comms.remove_comms()
pyflyby._comms.run_tidy_imports(code)
pyflyby._comms.send_comm_message(target_name, msg)