File: wo.py

package info (click to toggle)
eprover 2.6%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 21,288 kB
  • sloc: ansic: 331,111; csh: 12,026; python: 10,178; awk: 5,825; makefile: 461; sh: 389
file content (38 lines) | stat: -rwxr-xr-x 822 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python2.7
# ----------------------------------
#
# Usage: wo.py <s1> <s2>
#
# Return all lines from <s1> that do not occur in <s2>
#

import sys
import re
import string
import pylib_io

def id(string):
    return string

def firstfield(str):
    parts = string.split(str)
    if(len(parts)>0):
        return parts[0]
    return ""


def without(file_source, file_remove, abstract_fun):
    source = {}
    lines = file_remove.readlines()
    for line in lines:
        source[abstract_fun(line)] = 1;
    lines = file_source.readlines()
    for line in lines:
        if(not (abstract_fun(line) in source)):
            sys.stdout.write(line)

pylib_io.check_argc(2)
file_source = pylib_io.flexopen(sys.argv[1], "r")
file_remove = pylib_io.flexopen(sys.argv[2], "r")

without(file_source, file_remove, id)