#NEWLINE# @ cli . command ( ) #NEWLINE# @ click . option ( '--format' , '-f' , type = click . Choice ( [ 'html' , 'rst' ] ) , default = 'html' ) #NEWLINE# @ click . option ( '--destpath' , '-d' , default = '.' ) #NEWLINE# @ click . argument ( 'urls' , nargs = ( - 1 ) ) #NEWLINE# def urls( format , destpath , urls ) : #NEWLINE# #INDENT# for url in url : #NEWLINE# #INDENT# p_url = urlparse ( url ) #NEWLINE# filename = p_url . path . split ( '/' ) [ ( - 1 ) ] #NEWLINE# if ( '.' in filename ) : #NEWLINE# #INDENT# ( filename , ext ) = os . path . splitext ( filename ) #NEWLINE# #UNINDENT# output_filename = os . path . join ( destpath , ( ( filename + '.' ) + format ) ) #NEWLINE# resource = requests . get ( url ) #NEWLINE# if resource . ok : #NEWLINE# #INDENT# with 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# else : #NEWLINE# #INDENT# if ( format == 'odt' ) : #NEWLINE# #INDENT# output . write ( builder . odt ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# logging . info ( 'Wrote {0} to {1}' . format ( url , output_filename ) )