-
Notifications
You must be signed in to change notification settings - Fork 3
/
values_handlers.go
68 lines (61 loc) · 1.06 KB
/
values_handlers.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package cwl
import (
"strings"
)
func (l *loader) SeqToValue(n node) (Value, error) {
vals := []Value{}
for _, c := range n.Children {
var a Value
err := l.load(c, &a)
if err != nil {
return nil, err
}
vals = append(vals, a)
}
return vals, nil
}
func (l *loader) MappingToValue(n node) (Value, error) {
class := findKey(n, "class")
switch strings.ToLower(class) {
case "file":
f := File{}
err := l.load(n, &f)
if err != nil {
return nil, err
}
return f, nil
case "directory":
f := Directory{}
err := l.load(n, &f)
if err != nil {
return nil, err
}
return f, nil
}
vals := map[string]Value{}
for _, kv := range itermap(n) {
k := kv.k
v := kv.v
var a Value
err := l.load(v, &a)
if err != nil {
return nil, err
}
vals[k] = a
}
return vals, nil
}
func (l *loader) MappingToValueMap(n node) (map[string]Value, error) {
vals := Values{}
for _, kv := range itermap(n) {
k := kv.k
v := kv.v
var a Value
err := l.load(v, &a)
if err != nil {
return nil, err
}
vals[k] = a
}
return vals, nil
}