Revision 3902
Added by Aaron Marcuse-Kubitza over 12 years ago
union | ||
---|---|---|
18 | 18 |
ignore = opts.env_flag('ignore') |
19 | 19 |
header_num = util.cast(int, opts.get_env_var('header_num')) |
20 | 20 |
# selects which map's header to use as the output header |
21 |
all_ = opts.env_flag('all') # doesn't merge mappings that are in both maps |
|
21 | 22 |
try: _prog_name, map_1_path = sys.argv |
22 | 23 |
except ValueError: |
23 |
raise SystemExit('Usage: env [ignore=1] [header_num={0|1}] '+sys.argv[0]
|
|
24 |
+' <map_0 map_1 [| '+sys.argv[0]+' map_2]... >union_map')
|
|
24 |
raise SystemExit('Usage: env [ignore=1] [header_num={0|1}] [all=1] '
|
|
25 |
+sys.argv[0]+' <map_0 map_1 [| '+sys.argv[0]+' map_2]... >out_map')
|
|
25 | 26 |
|
26 | 27 |
headers = [None]*2 |
27 | 28 |
|
... | ... | |
45 | 46 |
writer.writerow(maps.merge_headers(*headers, **dict(prefer=header_num))) |
46 | 47 |
mappings = set() |
47 | 48 |
for row in map_0_reader: |
48 |
if row[0] != '': |
|
49 |
if not all_ and row[0] != '':
|
|
49 | 50 |
mappings.add(row[0]) |
50 | 51 |
if row[1] != '': mappings.add(row[1]) |
51 | 52 |
writer.writerow(row) |
Also available in: Unified diff
union: Added full flag to turn off merging mappings that are in both maps, in order to review inputs which appear in both maps but map to different places