Revision 1705
Added by Aaron Marcuse-Kubitza almost 13 years ago
bin/ch_root | ||
---|---|---|
8 | 8 |
|
9 | 9 |
sys.path.append(os.path.dirname(__file__)+"/../lib") |
10 | 10 |
|
11 |
import maps |
|
11 | 12 |
import opts |
12 | 13 |
|
13 | 14 |
def main(): |
... | ... | |
26 | 27 |
cols = reader.next() |
27 | 28 |
for i in xrange(len(configs)): |
28 | 29 |
config = configs[i] |
29 |
label, sep, config['root'] = cols[i].partition(':')
|
|
30 |
cols[i] = label+sep+config['out_root']
|
|
30 |
label, config['root'] = maps.col_info(cols[i], require_root=True)[:2]
|
|
31 |
cols[i] = label+':'+config['out_root']
|
|
31 | 32 |
config['in_root_re'] = r'^'+re.escape(config['in_root'])+r'(?=\b|\W|$)' |
32 | 33 |
writer.writerow(cols) |
33 | 34 |
for row in reader: |
bin/map | ||
---|---|---|
14 | 14 |
|
15 | 15 |
import csvs |
16 | 16 |
import exc |
17 |
import maps |
|
17 | 18 |
import opts |
18 | 19 |
import Parser |
19 | 20 |
import profiling |
... | ... | |
137 | 138 |
return label, sep != '', root, prefixes |
138 | 139 |
# extract datasrc from "datasrc[data_format]" |
139 | 140 |
|
140 |
in_label, in_is_xpaths, in_root, prefixes = split_col_name(in_label) |
|
141 |
in_label, in_root, prefixes = maps.col_info(in_label) |
|
142 |
in_is_xpaths = in_root != None |
|
141 | 143 |
in_label_ref[0] = in_label |
142 | 144 |
update_in_label() |
143 |
out_label, out_is_xpaths, out_root = split_col_name(out_label)[:3] |
|
144 |
has_types = out_root.startswith('/*s/') # outer elements are types |
|
145 |
out_label, out_root = maps.col_info(out_label)[:2] |
|
146 |
out_is_xpaths = out_root != None |
|
147 |
if out_is_xpaths: has_types = out_root.startswith('/*s/') |
|
148 |
# outer elements are types |
|
145 | 149 |
|
146 | 150 |
for row in reader: |
147 | 151 |
in_, out = row[:2] |
bin/repl | ||
---|---|---|
3 | 3 |
# A->C or B->C |
4 | 4 |
|
5 | 5 |
import csv |
6 |
import os.path |
|
6 | 7 |
import re |
7 | 8 |
import sys |
8 | 9 |
|
10 |
sys.path.append(os.path.dirname(__file__)+"/../lib") |
|
11 |
|
|
12 |
import maps |
|
13 |
|
|
9 | 14 |
def main(): |
10 | 15 |
try: _prog_name, repl_path = sys.argv[:2] |
11 | 16 |
except ValueError: |
... | ... | |
37 | 42 |
reader = csv.reader(sys.stdin) |
38 | 43 |
writer = csv.writer(sys.stdout) |
39 | 44 |
cols = reader.next() |
40 |
label, sep, root = cols[col_num].partition(':')
|
|
45 |
label, root = maps.col_info(cols[col_num])[:2]
|
|
41 | 46 |
if label != repl_in: raise SystemExit('Map error: Map column '+ |
42 | 47 |
str(col_num)+' label "'+label+'" doesn\'t match replacements input ' |
43 | 48 |
'column label "'+repl_in+'"') |
Also available in: Unified diff
ch_root, repl, map: Use new maps.col_info() instead of parsing col name manually. This allows maps with prefixes containing ":" to be supported, without the ":" being misinterpreted as the label-root separator.