Project

General

Profile

« Previous | Next » 

Revision 2023

union: Omit mappings that are mapped to in the input map, in addition to mappings that were overridden. This prevents multiple outputs being created for both the renamed and original mappings, causing duplicate output nodes when one XML tree is used for all rows.

View differences:

union
37 37
        raise SystemExit('Map error: '
38 38
        'Map 0 column 0 label doesn\'t contain map 1 column 0 label')
39 39
    
40
    # Pass through map 0, storing which inputs it defines
40
    # Pass through map 0, storing which mappings it defines
41 41
    writer = csv.writer(sys.stdout)
42 42
    writer.writerow(maps.merge_headers(*headers, **dict(prefer=header_num)))
43
    inputs = set()
43
    mappings = set()
44 44
    for row in map_0_reader:
45
        if row[0] != '': inputs.add(row[0])
45
        if row[0] != '':
46
            mappings.add(row[0])
47
            if row[1] != '': mappings.add(row[1])
46 48
        writer.writerow(row)
47 49
    
48 50
    if combinable:
49
        # Add entries in map 1 that weren't already defined
51
        # Add mappings in map 1 that weren't already defined or mapped to
50 52
        for row in map_1_reader:
51
            if row[0] != '' and row[0] not in inputs: writer.writerow(row)
53
            if row[0] != '' and row[0] not in mappings: writer.writerow(row)
52 54
    
53 55
    stream.close()
54 56

  

Also available in: Unified diff