summaryrefslogtreecommitdiffhomepage
path: root/scripts/gen-dcoins
blob: 1c2ca48c592e1f2d17b40f296e92b151d94e51f2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/sh

readonly tmp=`mktemp`
trap "rm -f $tmp" HUP INT KILL TERM EXIT

grep -Eo '^[A-Z]{2}' data/coins   \
| sort                            \
| uniq                            \
| join -t '	' - data/country-info \
| cut -f1,3                       \
| sort -k2 >$tmp


for cc in `cut -f1 $tmp`
do
	gawk -v CC="$cc" -v denom=$1 '
	@include "scripts/getcls.awk"

	FILENAME ~ /\/tmp\/.*/ && $1 == CC {
		gsub(/^.../, "")
		print "section .cl-section .slant-down {"
		print "div {"
		print "table .coin-table cellspacing=\"0\" {"
		printf "thead {tr {th {-%s}}}\n", $0
		print "tbody {"
	}

	$1 == CC && /.. start/ {
		sub(/.. start/, "")
		printf "tr .new-design {th {-%s}}\n", $0
		next
	}

	$1 == CC {
		y = $10
		if ($11 != "")
			y_ = $11
		printf "trX {"

		switch (denom) {
		case 0.01:
			i = 2
			break
		case 0.02:
			i = 3
			break
		case 0.05:
			i = 4
			break
		case 0.10:
			i = 5
			break
		case 0.20:
			i = 6
			break
		case 0.50:
			i = 7
			break
		case 1.00:
			i = 8
			break
		case 2.00:
			i = 9
			break
		}

		# Greece 2002 needs special handling
		if (CC == "GR" && $10 == 2002 && $11 == "MM") {
			if (i <= 5)
				y_ = "F"
			else if (i <= 7)
				y_ = "E"
			else
				y_ = "S"
		}

		if ($i != "/") {
			if ($11 != "")
				printf "td .%s {-%s @sup{-%s}}", getcls($i), y, y_
			else
				printf "td .%s {-%s}", getcls($i), y
		}
		print "}"
	}

	END {
		print "__MARKER__"
		print "}}}}"
	}
	' $tmp data/coins \
	| scripts/last-of-design.sed
done