summaryrefslogtreecommitdiff
path: root/d1pkgweb.go
blob: 89fa764be9879bd744bc7daf2ecf6adb04e4f362 (plain)
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
package main

import (
	"bufio"
	"d1pkgweb/deb822"
	"fmt"
	"os"
	"strings"
)

func main() {

	args := os.Args

	if len(args) < 2 {
		fmt.Printf("Usage: %s <filein>\n", args[0])
		return
	}

	fnames := args[1:]
	for _, fname := range fnames {
		nameComps := strings.Split(fname, "_")
		suite := nameComps[3]
		component := nameComps[4]
		f, err := os.Open(fname)
		if err != nil {
			defer f.Close()
		}
		if err != nil {
			fmt.Printf("Error opening file %s\n", fname)

		} else {
			r := bufio.NewScanner(f)

			if r != nil {
				for s, err := deb822.ScanStanza(r); s["Package"] != ""; s, err = deb822.ScanStanza(r) {
					if err == nil {
						deb822.Stanza2HtmlPage(s, pkgTempl, ".", suite, component)
					} else {
						fmt.Printf("error: %s\n", err)
					}
					//WriteFiles(s, num, "./files/")
				}
			}
		}
	}
}