#NEWLINE# @ click . command ( help = 'Load a document from disk.' ) #NEWLINE# @ click . argument ( 'input_file' , type = click . File ( 'rb' ) ) #NEWLINE# @ click . option ( '--format' , default = 'corejson' , type = click . Choice ( [ 'corejson' , 'hal' , 'hyperschema' , 'openapi' ] ) ) #NEWLINE# def load( input_file , format ) : #NEWLINE# #INDENT# input_bytes = input_file . read ( ) #NEWLINE# input_file . close ( ) #NEWLINE# decoder = { #NEWLINE# #INDENT# 'corejson' : coreapi . codecs . CoreJSONCodec ( ) , #NEWLINE# 'hal' : coreapi . codecs . HALCodec ( ) , #NEWLINE# 'hyperschema' : coreapi . codecs . HyperschemaCodec ( ) , #NEWLINE# 'openapi' : coreapi . codecs . OpenAPICodec ( ) , #NEWLINE# #UNINDENT# } [ format ] #NEWLINE# history = get_history ( ) #NEWLINE# doc = decoder . load ( input_bytes ) #NEWLINE# click . echo ( display ( input_bytes ) ) #NEWLINE# if isinstance ( doc , coreapi . Document ) : #NEWLINE# #INDENT# history = history . add ( doc ) #NEWLINE# set_document ( doc ) #NEWLINE# set_history ( history )