@@ -99,10 +99,13 @@ def get_item_type(el):
9999
100100class DDGDebug :
101101
102- def __init__ (self , enabled = False , ident_match = None ):
102+ def __init__ (self , enabled = False , ident_match = None , debug_abstracts_path = None ):
103103 self .enabled = enabled
104104 self .ident_match = ident_match
105105 self .stat_line_nums = []
106+ self .debug_abstracts_file = sys .stdout
107+ if debug_abstracts_path is not None :
108+ self .debug_abstracts_file = open (debug_abstracts_path , 'w' )
106109
107110 # track the statistics of number of lines used by the entries
108111 def submit_line_num (self , line_num ):
@@ -421,9 +424,9 @@ def process_identifier(out, redirects, root, link, item_ident, item_type,
421424 '''
422425
423426 if debug .enabled :
424- print ("--------------" )
425- print (item_ident )
426- print (abstract )
427+ debug . debug_abstracts_file . write ("--------------\n " )
428+ debug . debug_abstracts_file . write (item_ident + ' \n ' )
429+ debug . debug_abstracts_file . write (abstract + ' \n ' )
427430
428431 # title
429432 line = item_ident + '\t '
@@ -459,13 +462,15 @@ def main():
459462 help = 'Enables debug mode.' )
460463 parser .add_argument ('--debug_ident' , type = str , default = None ,
461464 help = 'Processes only the identifiers that match debug_ident' )
465+ parser .add_argument ('--debug_abstracts_path' , type = str , default = None ,
466+ help = 'Path to print the abstracts before newline stripping occurs' )
462467 args = parser .parse_args ()
463468
464469 # If a the second argument is 'debug', the program switches to debug mode and
465470 # prints everything to stdout. If the third argument is provided, the program
466471 # processes only the identifiers that match the provided string
467472
468- debug = DDGDebug (args .debug , args .debug_ident )
473+ debug = DDGDebug (args .debug , args .debug_ident , args . debug_abstracts_path )
469474
470475 index_file = args .index
471476 output_file = args .output
0 commit comments