Revision 135
Added by Aaron Marcuse-Kubitza about 13 years ago
map | ||
---|---|---|
7 | 7 |
|
8 | 8 |
shopt -s nullglob |
9 | 9 |
|
10 |
test -n "$n" || n=2 |
|
11 |
let n++ # account for header row |
|
10 |
test -n "$n" || export n=2 |
|
12 | 11 |
|
13 | 12 |
. ../util/env_password in_password |
14 | 13 |
|
... | ... | |
17 | 16 |
../../mappings/extract_plot_map |
18 | 17 |
../../mappings/join_all_vegbank |
19 | 18 |
|
20 |
function importCsv()
|
|
19 |
function trace()
|
|
21 | 20 |
{ |
22 |
(set -x; head -"$n" "$in") |
|
21 |
( |
|
22 |
echo -n "$PS4" |
|
23 |
for arg in "$@"; do printf "%q " "$arg"; done |
|
24 |
echo "${_in+<$_in}" "${_out+>$_out}" |
|
25 |
) >&2 |
|
23 | 26 |
} |
24 | 27 |
|
25 |
function importDb()
|
|
28 |
function fromCsv()
|
|
26 | 29 |
{ |
27 |
echo "$PS4. \"$in\"" >&2
|
|
28 |
. "$in"
|
|
30 |
(_in="$in"; trace)
|
|
31 |
"$1" <"$in" || exit
|
|
29 | 32 |
} |
30 | 33 |
|
31 |
function exportXml()
|
|
34 |
function fromDb()
|
|
32 | 35 |
{ |
36 |
trace . "$in" |
|
37 |
(. "$in"; "$1") || exit |
|
38 |
} |
|
39 |
|
|
40 |
function toXml() |
|
41 |
{ |
|
33 | 42 |
out="$stem.$out_fmt.xml" |
34 | 43 |
(set -x; ../map "../../mappings/$src-$out_fmt.$table.csv" >"output/$out"\ |
35 | 44 |
&& diff "accepted_output/$out" "output/$out") |
36 | 45 |
} |
37 | 46 |
|
38 |
function exportDb()
|
|
47 |
function toDb()
|
|
39 | 48 |
{ |
40 | 49 |
(set -x; ../map2vegbank "../../mappings/$src-VegBank.$table.csv") |
41 | 50 |
} |
... | ... | |
48 | 57 |
|
49 | 58 |
# Test exporting to XML |
50 | 59 |
for out_fmt in VegX VegBank; do |
51 |
if test "$ext" == "csv"; then importCsv|exportXml
|
|
52 |
elif test "$ext" == "sh"; then (importDb; exportXml)
|
|
60 |
if test "$ext" == "csv"; then fromCsv toXml
|
|
61 |
elif test "$ext" == "sh"; then fromDb toXml
|
|
53 | 62 |
fi |
54 | 63 |
done |
55 | 64 |
|
56 | 65 |
# Test exporting to VegBank db |
57 |
if test "$ext" == "csv"; then importCsv|exportDb
|
|
58 |
elif test "$ext" == "sh"; then (importDb; exportDb)
|
|
66 |
if test "$ext" == "csv"; then fromCsv toDb
|
|
67 |
elif test "$ext" == "sh"; then fromDb toDb
|
|
59 | 68 |
fi |
60 | 69 |
done |
Also available in: Unified diff
map: Implemented DB input support for querying a single table