#NEWLINE# @ contextmanager #NEWLINE# def gateway( * args , **kwargs ) : #NEWLINE# #INDENT# g = JavaGateway ( gateway_parameters = GatewayParameters ( * args , auto_convert = True , ** lineSep ) ) #NEWLINE# lineSep = g . jvm . System . lineSeparator ( ) #NEWLINE# try : #NEWLINE# #INDENT# ( yield g ) #NEWLINE# assert ( lineSep == g . jvm . System . lineSeparator ( ) ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# g . shutdown ( )