#NEWLINE# @ cli . command ( ) #NEWLINE# @ click . option ( '--format' , '-f' , type = click . Choice ( [ 'html' , 'rst' , 'odt' ] ) , default = 'html' ) #NEWLINE# @ click . option ( '--destpath' , '-d' , default = '.' ) #NEWLINE# @ click . argument ( 'filenames' , nargs = ( - 1 ) ) #NEWLINE# def files( format , destpath , filenames ) : #NEWLINE# #INDENT# for f in filenames : #NEWLINE# #INDENT# ( filename , ext ) = os . path . splitext ( os . path . basename ( f ) ) #NEWLINE# output_filename = os . path . join ( destpath , ( ( filename + '.' ) + format ) ) #NEWLINE# with open ( f ) as input , open ( output_filename , 'w' ) as output : #NEWLINE# #INDENT# builder = SchemaHelpBuilder ( json . load ( input ) , fmt = format ) #NEWLINE# if ( format == 'html' ) : #NEWLINE# #INDENT# output . write ( builder . html ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( format == 'rst' ) : #NEWLINE# #INDENT# output . write ( builder . rst ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# logging . info ( 'Wrote {0} to {1}' . format ( f , output_filename ) )