<s> """<STR_LIT>""" <EOL> from jupyter_core . paths import jupyter_config_dir <EOL> from traitlets . config . manager import BaseJSONConfigManager <EOL> from notebook . services . config import ConfigManager as FrontendConfigManager <EOL> def install_server_extension ( enable = True ) : <EOL> """<STR_LIT>""" <EOL> server = BaseJSONConfigManager ( config_dir = jupyter_config_dir ( ) ) <EOL> server_cfg = server . get ( '<STR_LIT>' ) <EOL> app_cfg = server_cfg . get ( '<STR_LIT>' , { } ) <EOL> server_extensions = app_cfg . get ( '<STR_LIT>' , [ ] ) <EOL> server_ext = '<STR_LIT>' <EOL> server_changed = False <EOL> if enable and server_ext not in server_extensions : <EOL> server_extensions . append ( server_ext ) <EOL> server_changed = True <EOL> elif ( not enable ) and server_ext in server_extensions : <EOL> server_extensions . remove ( server_ext ) <EOL> server_changed = True <EOL> if server_changed : <EOL> server . update ( '<STR_LIT>' , { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : server_extensions , <EOL> } <EOL> } ) <EOL> frontend = FrontendConfigManager ( ) <EOL> frontend . update ( '<STR_LIT>' , { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : enable or None , <EOL> } <EOL> } ) </s>
