-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
63 lines (52 loc) · 1.29 KB
/
main.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
package main
import (
"fmt"
"log"
"os"
"github.com/gradienthealth/dicom-protos/gen"
"github.com/gradienthealth/dicom-protos/parse"
)
func generateFile(name string) *os.File {
out, err := os.Create(name)
if err != nil {
log.Printf("Couldn't create file %s \n", name)
log.Panic(err)
}
return out
}
func main() {
af, err := os.Open("dicom-standard/standard/attributes.json")
if err != nil {
log.Panic(err)
}
defer af.Close()
mf, err := os.Open("dicom-standard/standard/modules.json")
if err != nil {
log.Panic(err)
}
defer mf.Close()
mta, err := os.Open("dicom-standard/standard/module_to_attributes.json")
if err != nil {
log.Panic(err)
}
defer mta.Close()
// Generate Sequences
seqOut := generateFile("protos/Sequences.proto")
fmt.Fprintln(seqOut, gen.ProtoHeader)
fmt.Fprintln(seqOut, "import \"Attributes.proto\";")
fmt.Fprintln(seqOut, "")
defer seqOut.Close()
attrOut := generateFile("protos/Attributes.proto")
fmt.Fprintln(attrOut, gen.ProtoHeader)
fmt.Fprintln(attrOut, "")
defer attrOut.Close()
modules, err := parse.Parse(af, mf, mta)
if err != nil {
log.Panic()
}
numModules, err := gen.ProtosToFile("protos", modules)
if err != nil {
log.Panic("Issue with generating protos", err)
}
log.Printf("Complete. Generated protos for %d modules.", numModules)
}