-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathscript.go
54 lines (45 loc) · 997 Bytes
/
script.go
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
package chile
import (
"context"
"github.com/whitewater-guide/gorge/core"
)
type optionsChile struct{}
type scriptChile struct {
name string
selectFormURL string
webmapIDPageURL string
webmapURLFormat string
xlsURL string
skipCookies bool
core.LoggingScript
}
func (s *scriptChile) ListGauges() (core.Gauges, error) {
fromKml, err := s.getKMLGauges()
if err != nil {
return nil, err
}
fromWeb, err := s.getWebGauges()
if err != nil {
return nil, err
}
result := core.Gauges{}
for _, v := range fromKml {
result = append(result, v)
}
for k, v := range fromWeb {
if _, ok := fromKml[k]; !ok {
result = append(result, v)
}
}
return result, nil
}
func (s *scriptChile) Harvest(ctx context.Context, recv chan<- *core.Measurement, errs chan<- error, codes core.StringSet, since int64) {
defer close(recv)
defer close(errs)
code, err := codes.Only()
if err != nil {
errs <- err
return
}
s.parseXLS(recv, errs, code, since)
}