Revision 161
Added by Aaron Marcuse-Kubitza almost 13 years ago
map | ||
---|---|---|
8 | 8 |
shopt -s nullglob |
9 | 9 |
|
10 | 10 |
test -n "$n" || export n=2 |
11 |
|
|
12 | 11 |
. ../util/env_password in_password |
13 | 12 |
|
13 |
make --directory=../../mappings |
|
14 | 14 |
|
15 |
# Update generated mappings |
|
16 |
../../mappings/extract_plot_map |
|
17 |
../../mappings/join_all_vegbank |
|
18 |
|
|
19 | 15 |
function trace() |
20 | 16 |
{ |
21 | 17 |
( |
... | ... | |
25 | 21 |
) >&2 |
26 | 22 |
} |
27 | 23 |
|
28 |
function fromCsv()
|
|
24 |
function map()
|
|
29 | 25 |
{ |
30 |
(_in="$in"; trace) |
|
31 |
"$1" <"$in" || exit |
|
26 |
map="../../mappings/$src-$out_fmt.$table.csv" |
|
27 |
if test -e "$map" -a -e "$in"; then |
|
28 |
( |
|
29 |
ext="${in##*.}" # after last "." |
|
30 |
if test "$ext" == "sh"; then |
|
31 |
trace . "$in" |
|
32 |
(. "$in"; "$1") |
|
33 |
else |
|
34 |
(_in="$in"; trace) |
|
35 |
"$1" <"$in" |
|
36 |
fi |
|
37 |
) || exit # abort tester |
|
38 |
fi |
|
32 | 39 |
} |
33 | 40 |
|
34 |
function fromDb() |
|
35 |
{ |
|
36 |
trace . "$in" |
|
37 |
(. "$in"; "$1") || exit |
|
38 |
} |
|
39 |
|
|
40 | 41 |
function toXml() |
41 | 42 |
{ |
42 | 43 |
out="$stem.$out_fmt.xml" |
43 | 44 |
( |
44 | 45 |
set -x |
45 |
../map "../../mappings/$src-$out_fmt.$table.csv" >"output/$out" || exit
|
|
46 |
diff "accepted_output/$out" "output/$out" || true |
|
46 |
../map "$map" >"output/$out" || exit
|
|
47 |
diff "accepted_output/$out" "output/$out" || true # ignore exit status
|
|
47 | 48 |
) |
48 | 49 |
} |
49 | 50 |
|
50 | 51 |
function toDb() |
51 | 52 |
{ |
52 |
(set -x; ../map2vegbank "../../mappings/$src-VegBank.$table.csv")
|
|
53 |
(set -x; ../map2vegbank "$map")
|
|
53 | 54 |
} |
54 | 55 |
|
55 |
for in in input/*.{csv,sh}; do |
|
56 |
ext="${in##*.}" # after last "." |
|
56 |
for in in input/*; do |
|
57 | 57 |
stem="$(basename -- "${in%.*}")" # remove extension and dir |
58 | 58 |
src="${stem%.*}" # before last "." |
59 | 59 |
table="${stem##*.}" # after last "." |
60 | 60 |
|
61 |
# Test exporting to XML |
|
62 |
for out_fmt in VegX VegBank; do |
|
63 |
if test "$ext" == "csv"; then fromCsv toXml |
|
64 |
elif test "$ext" == "sh"; then fromDb toXml |
|
65 |
fi |
|
66 |
done |
|
67 |
|
|
68 |
# Test exporting to VegBank db |
|
69 |
if test "$ext" == "csv"; then fromCsv toDb |
|
70 |
elif test "$ext" == "sh"; then fromDb toDb |
|
71 |
fi |
|
61 |
for out_fmt in VegX VegBank; do map toXml; done # source to XML |
|
62 |
out_fmt=VegBank |
|
63 |
# VegX to VegBank |
|
64 |
( |
|
65 |
src=VegX |
|
66 |
in="output/$stem.$src.xml" |
|
67 |
stem="$stem.2-step" |
|
68 |
map toXml |
|
69 |
) || exit |
|
70 |
map toDb # source to VegBank db |
|
72 | 71 |
done |
Also available in: Unified diff
map: Added support for XML input