#!/usr/bin/env python2.2 import os THRESHOLD=10 ENV=3 def kill_white_space(line): return line.replace(" ","").replace("\n","").replace("\t","") def test_dup(name1,name2): file1=open(name1) file2=open(name2) orig_lines1=file1.readlines() orig_lines2=file2.readlines() lines1=[] for i in range(len(orig_lines1)): line=kill_white_space(orig_lines1[i]) if not line: continue t={} t["content"]=line t["orig_nr"]=i lines1.append(t) lines2=[] for i in range(len(orig_lines2)): line=kill_white_space(orig_lines2[i]) if not line: continue t={} t["content"]=line t["orig_nr"]=i lines2.append(t) nr1=-1 while nr1THRESHOLD and nr1==0: nr1+=inc continue if inc>THRESHOLD: #print "%d %d %d %d %d"%(nr1,nr2,inc,len(lines1),len(lines2)) orig_start1=lines1[nr1]["orig_nr"] orig_start2=lines2[nr2]["orig_nr"] orig_end1=lines1[nr1+inc]["orig_nr"] orig_end2=lines2[nr2+inc]["orig_nr"] print "### %s:%d-%d %s:%d-%d"%( name1,orig_start1+1,orig_end1+1, name2,orig_start2+1,orig_end2+1) if 1: for y in range(ENV): print "A %s"%(orig_lines1[orig_start1-(ENV-y)]), for y in range(ENV): print "B %s"%(orig_lines2[orig_start2-(ENV-y)]), for x in orig_lines1[orig_start1:orig_end1]: print " "+x, try: for y in range(ENV): print "A %s"%(orig_lines1[orig_end1+y+1]), except: pass try: for y in range(ENV): print "B %s"%(orig_lines2[orig_end2+y+1]), except: pass print nr1+=inc files=""" diplodlg.c chatline.c cityrep.c cma_fe.c colors.c connectdlg.c dialogs.c finddlg.c gamedlgs.c gotodlg.c graphics.c gtkpixcomm.c gui_main.c gui_stuff.c happiness.c helpdlg.c inputdlg.c inteldlg.c mapctrl.c mapview.c menu.c messagedlg.c messagewin.c plrdlg.c repodlgs.c resources.c spaceshipdlg.c wldlg.c citydlg.c """ for i in files.splitlines(): a="client/gui-gtk/"+i b="client/gui-xaw/"+i if os.path.isfile(a) and os.path.isfile(b): test_dup(a,b)