'''
Remove lines with specific strings from file
'''

fdIn = open('log.dilum9', 'r')
fdOut = open('log.dilum_9_step_1.txt', 'w')

for line in fdIn:
    if '.edu' in line: continue
    elif '.ac' in line: continue
    elif 'at java' in line: continue
    elif 'at Sword.' in line: continue
    elif 'planetlab' in line: continue
    elif 'planet-lab' in line: continue
    elif 'planet_lab' in line: continue
    elif '.au' in line: continue
    elif '.be' in line: continue
    elif '.ca' in line: continue
    elif '.ch' in line: continue
    elif '.cz' in line: continue
    elif '.de' in line: continue
    elif '.fr' in line: continue
    elif '.gr' in line: continue
    elif '.hu' in line: continue
    elif '.in' in line: continue
    elif '.it' in line: continue
    elif '.mx' in line: continue
    elif '.pl' in line: continue
    elif '.pt' in line: continue
    elif '.ru' in line: continue
    elif '.us' in line: continue
    elif '.ve' in line: continue
    elif '.com' in line: continue
    elif '.net' in line: continue
    elif '.org' in line: continue
    elif '%' in line: continue
    elif '</group</request>' in line: continue
    elif 'Lowest match cost: 0.0' in line: continue
    elif 'Name: 1' in line: continue
    elif 'Name: 2' in line: continue
    elif 'Name: 3' in line: continue
    elif 'Name: 4' in line: continue
    elif 'Name: 5' in line: continue
    elif 'Name: 6' in line: continue
    elif 'Name: 7' in line: continue
    elif 'Name: 8' in line: continue
    elif 'Name: 9' in line: continue
    elif 'Name: Grou' in line: continue
    elif '... 9 more' in line: continue
    elif 'An error occurred when deleting request.xml' in line: continue
    elif 'Group Size:' in line: continue
    elif 'Max Latency:' in line: continue
    elif 'Min Latency:' in line: continue
    elif 'Overall Group Cost:' in line: continue
    elif '-------------------' in line: continue

    if line[-10:] == '</request\n': continue
    elif line[-9:] == '</reques\n': continue
    elif line[-8:] == '</reque\n': continue
    elif line[-6:] == '</req\n': continue
    elif line[-6:] == '</re\n': continue
    elif line[-4:] == '</r\n': continue
    elif line[-4:] == '</\n': continue

    if 'log:' in line: line = line.replace('log:', '')
    elif 'log.1308246253:' in line: line = line.replace('log.1308246253:', '')
    elif 'log.1303748492:' in line: line = line.replace('log.1303748492:', '')
    elif 'log.1306508935:' in line: line = line.replace('log.1306508935:', '')
    elif 'log.1295702352:' in line: line = line.replace('log.1295702352:', '')
    elif 'log.1295703000:' in line: line = line.replace('log.1295703000:', '')
    elif 'log.1295985621:' in line: line = line.replace('log.1295985621:', '')
    elif 'log.1296594179:' in line: line = line.replace('log.1296594179:', '')

    fdOut.write(line)

fdIn.close()
fdOut.close()
