<s> import sys <EOL> import os <EOL> import subprocess <EOL> import hashlib <EOL> import expected <EOL> import static_pdfs <EOL> source_pdfs = static_pdfs . pdffiles [ <NUM_LIT:0> ] <EOL> source_pdfs = dict ( ( os . path . basename ( x ) , x ) for x in source_pdfs ) <EOL> result_dir = expected . result_dir <EOL> for subdir in sorted ( os . listdir ( result_dir ) ) : <EOL> dstd = os . path . join ( result_dir , subdir ) <EOL> if not os . path . isdir ( dstd ) : <EOL> continue <EOL> for pdffile in sorted ( os . listdir ( dstd ) ) : <EOL> testname = '<STR_LIT>' % ( subdir , pdffile ) <EOL> srcf = source_pdfs . get ( pdffile ) <EOL> dstf = os . path . join ( dstd , pdffile ) <EOL> if pdffile not in source_pdfs : <EOL> print ( '<STR_LIT>' % testname ) <EOL> continue <EOL> with open ( dstf , '<STR_LIT:rb>' ) as f : <EOL> data = f . read ( ) <EOL> hash = hashlib . md5 ( data ) . hexdigest ( ) <EOL> skipset = set ( ( hash , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:!>' + hash ) ) <EOL> if expected . results [ testname ] & skipset : <EOL> print ( '<STR_LIT>' % testname ) <EOL> continue <EOL> if os . path . exists ( '<STR_LIT>' ) : <EOL> os . remove ( '<STR_LIT>' ) <EOL> builtdiff = False <EOL> while <NUM_LIT:1> : <EOL> sys . stdout . write ( '''<STR_LIT>''' % testname ) <EOL> sel = raw_input ( ) <EOL> if sel == '<STR_LIT:q>' : <EOL> raise SystemExit ( <NUM_LIT:0> ) <EOL> if sel == '<STR_LIT:n>' : <EOL> break <EOL> if sel == '<STR_LIT:c>' : <EOL> subprocess . call ( ( '<STR_LIT>' , '<STR_LIT>' , srcf , dstf , <EOL> '<STR_LIT>' ) ) <EOL> builtdiff = True <EOL> continue <EOL> if sel == '<STR_LIT:f>' : <EOL> subprocess . call ( ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> continue <EOL> if sel == '<STR_LIT:o>' : <EOL> subprocess . call ( ( '<STR_LIT>' , srcf , dstf ) ) <EOL> continue <EOL> if sel == '<STR_LIT:a>' : <EOL> if builtdiff : <EOL> subprocess . call ( ( '<STR_LIT>' , srcf , dstf , '<STR_LIT>' ) ) <EOL> else : <EOL> subprocess . call ( ( '<STR_LIT>' , srcf , dstf ) ) <EOL> continue <EOL> if sel in '<STR_LIT>' : <EOL> results = ( hash if sel == '<STR_LIT:g>' else <EOL> '<STR_LIT>' if sel == '<STR_LIT:s>' else '<STR_LIT:!>' + hash ) <EOL> with open ( expected . expectedf , '<STR_LIT:a>' ) as f : <EOL> f . write ( '<STR_LIT>' % ( testname , results ) ) <EOL> break </s>
