<s> """<STR_LIT>""" <EOL> import shlex <EOL> from jupyterhub . spawner import LocalProcessSpawner <EOL> class DemoFormSpawner ( LocalProcessSpawner ) : <EOL> def _options_form_default ( self ) : <EOL> default_env = "<STR_LIT>" % self . user . name <EOL> return """<STR_LIT>""" . format ( env = default_env ) <EOL> def options_from_form ( self , formdata ) : <EOL> options = { } <EOL> options [ '<STR_LIT>' ] = env = { } <EOL> env_lines = formdata . get ( '<STR_LIT>' , [ '<STR_LIT>' ] ) <EOL> for line in env_lines [ <NUM_LIT:0> ] . splitlines ( ) : <EOL> if line : <EOL> key , value = line . split ( '<STR_LIT:=>' , <NUM_LIT:1> ) <EOL> env [ key . strip ( ) ] = value . strip ( ) <EOL> arg_s = formdata . get ( '<STR_LIT:args>' , [ '<STR_LIT>' ] ) [ <NUM_LIT:0> ] . strip ( ) <EOL> if arg_s : <EOL> options [ '<STR_LIT>' ] = shlex . split ( arg_s ) <EOL> return options <EOL> def get_args ( self ) : <EOL> """<STR_LIT>""" <EOL> argv = super ( ) . get_args ( ) <EOL> if self . user_options . get ( '<STR_LIT>' ) : <EOL> argv . extend ( self . user_options [ '<STR_LIT>' ] ) <EOL> return argv <EOL> def get_env ( self ) : <EOL> env = super ( ) . get_env ( ) <EOL> if self . user_options . get ( '<STR_LIT>' ) : <EOL> env . update ( self . user_options [ '<STR_LIT>' ] ) <EOL> return env <EOL> c . JupyterHub . spawner_class = DemoFormSpawner </s>
