#NEWLINE# def convert( config ) : #NEWLINE# #INDENT# '\n    Convert a file to selected format.\n\n    :param config: Config instance \n    :type config: Config\n    \n    :raises: TypeError, ValueError, IOError\n    ' #NEWLINE# if ( not isinstance ( config , Config ) ) : #NEWLINE# #INDENT# raise TypeError ( ( "Expected Config, got '%s' instead" % type ( config ) ) ) #NEWLINE# #UNINDENT# if ( ( config . scope is not None ) and ( config . excluded is not None ) ) : #NEWLINE# #INDENT# raise ValueError ( "Scope and excluded can't be set simultaneously" ) #NEWLINE# #UNINDENT# if config . excluded : #NEWLINE# #INDENT# excluded_hosts = [ x . strip ( ) . replace ( '\n' , '' ) . replace ( '\t' , '' ) . replace ( '\r' , '' ) for x in open ( config . excluded , 'rU' ) . readlines ( ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# excluded_hosts = None #NEWLINE# #UNINDENT# if config . scope : #NEWLINE# #INDENT# scope_hosts = [ x . strip ( ) . replace ( '\n' , '' ) . replace ( '\t' , '' ) . replace ( '\r' , '' ) for x in open ( config . scope , 'rU' ) . readlines ( ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# scope_hosts = None #NEWLINE# #UNINDENT# openvas_info = openvas_parser ( config . input_files , excluded_hosts = excluded_hosts , scope_hosts = scope_hosts ) #NEWLINE# output_file = config . output_file #NEWLINE# lang = config . lang #NEWLINE# if output_file . endswith ( 'docx' ) : #NEWLINE# #INDENT# from . libs.exporters.word import export_to_word #NEWLINE# template = config . template #NEWLINE# export_to_word ( openvas_info , output_file , template ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if output_file . endswith ( 'xlsx' ) : #NEWLINE# #INDENT# from . libs.exporters.excel import export_to_excel #NEWLINE# export_to_excel ( openvas_info , output_file , lang ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( 'Extension not found!' )