#NEWLINE# def page_count( pdflatex_stdout , paper_dir ) : #NEWLINE# #INDENT# '\n    Parse pdflatex output for paper count, and store in a .ini file.\n    ' #NEWLINE# if ( pdflatex_stdout is None ) : #NEWLINE# #INDENT# print ( '*** WARNING: PDFLaTeX failed to generate output.' ) #NEWLINE# return #NEWLINE# #UNINDENT# regexp = re . compile ( 'Output written on paper.pdf \\((\\d+) pages' ) #NEWLINE# cfgname = os . path . join ( paper_dir , 'paper_stats.json' ) #NEWLINE# d = options . cfg2dict ( cfgname ) #NEWLINE# for line in pdflatex_stdout . splitlines ( ) : #NEWLINE# #INDENT# m = regexp . match ( line ) #NEWLINE# if m : #NEWLINE# #INDENT# pages = m . groups ( ) [ 0 ] #NEWLINE# d . update ( { #NEWLINE# #INDENT# 'pages' : int ( pages ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# options . dict2cfg ( d , cfgname )