Project

General

Profile

« Previous | Next » 

Revision 1402

bin/map: Parse any prefixes in map input column name. They will later be used to check for versions of columns with a prefix added when processing CSV/DB inputs.

View differences:

bin/map
101 101
            stream = open(map_path, 'rb')
102 102
            reader = csv.reader(stream)
103 103
            in_label, out_label = reader.next()[:2]
104
            
104 105
            def split_col_name(name):
105
                name, sep, root = name.partition(':')
106
                return name.partition('[')[0], sep != '', root
106
                label, sep, root = name.partition(':')
107
                label, sep2, prefixes_str = label.partition('[')
108
                prefixes_str = strings.remove_suffix(']', prefixes_str)
109
                prefixes = strings.split(',', prefixes_str)
110
                return label, sep != '', root, prefixes
107 111
                    # extract datasrc from "datasrc[data_format]"
108
            in_label, in_is_xpaths, in_root = split_col_name(in_label)
112
            
113
            in_label, in_is_xpaths, in_root, prefixes = split_col_name(in_label)
109 114
            in_label_ref[0] = in_label
110 115
            update_in_label()
111
            out_label, out_is_xpaths, out_root = split_col_name(out_label)
116
            out_label, out_is_xpaths, out_root = split_col_name(out_label)[:3]
112 117
            has_types = out_root.startswith('/*s/') # outer elements are types
118
            
113 119
            for row in reader:
114 120
                in_, out = row[:2]
115 121
                if out != '':
116 122
                    if out_is_xpaths: out = xpath.parse(out_root+out)
117 123
                    mappings.append((in_, out))
124
            
118 125
            stream.close()
119 126
            
120 127
            root.ownerDocument.documentElement.tagName = out_label

Also available in: Unified diff