mirror of
https://github.com/pbnjay/grate.git
synced 2024-12-04 19:45:34 +02:00
misc cleanups
This commit is contained in:
parent
d9793eb9dd
commit
d9b725da93
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
cmd/grate2tsv/results
|
||||
testdata
|
||||
|
||||
*.pprof
|
||||
*.pdf
|
@ -1,7 +1,6 @@
|
||||
package commonxl
|
||||
|
||||
import (
|
||||
"log"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
@ -55,7 +54,7 @@ func timeFmtFunc(f string) FmtFunc {
|
||||
}
|
||||
t = x.ConvertToDate(fval)
|
||||
}
|
||||
log.Println("formatting date", t, "with", f, "=", t.Format(f))
|
||||
//log.Println("formatting date", t, "with", f, "=", t.Format(f))
|
||||
return t.Format(f)
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package simple
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@ -19,7 +20,7 @@ type simpleFile struct {
|
||||
|
||||
// List the individual data tables within this source.
|
||||
func (t *simpleFile) List() ([]string, error) {
|
||||
return []string{t.filename}, nil
|
||||
return []string{filepath.Base(t.filename)}, nil
|
||||
}
|
||||
|
||||
func (t *simpleFile) Close() error {
|
||||
|
@ -14,6 +14,8 @@ import (
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"unicode/utf16"
|
||||
|
||||
"github.com/pbnjay/grate"
|
||||
)
|
||||
|
||||
const fullAssertions = true
|
||||
@ -111,14 +113,14 @@ func (d *Document) load(rx io.ReadSeeker) error {
|
||||
h := &header{}
|
||||
err = binary.Read(br, binary.LittleEndian, h)
|
||||
if h.Signature != 0xe11ab1a1e011cfd0 {
|
||||
return errors.New("ole2: invalid format")
|
||||
return grate.ErrNotInFormat // errors.New("ole2: invalid format")
|
||||
}
|
||||
if h.ByteOrder != 0xFFFE {
|
||||
return errors.New("ole2: invalid format")
|
||||
return grate.ErrNotInFormat //errors.New("ole2: invalid format")
|
||||
}
|
||||
if fullAssertions {
|
||||
if h.ClassID[0] != 0 || h.ClassID[1] != 0 {
|
||||
return errors.New("ole2: invalid CLSID")
|
||||
return grate.ErrNotInFormat //errors.New("ole2: invalid CLSID")
|
||||
}
|
||||
if h.MajorVersion != 3 && h.MajorVersion != 4 {
|
||||
return errors.New("ole2: unknown major version")
|
||||
|
@ -4,8 +4,6 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"github.com/pbnjay/grate"
|
||||
)
|
||||
|
||||
// Open a Compound File Binary Format document.
|
||||
@ -17,7 +15,7 @@ func Open(filename string) (*Document, error) {
|
||||
}
|
||||
err = d.load(f)
|
||||
if err != nil {
|
||||
return nil, grate.WrapErr(err, grate.ErrNotInFormat)
|
||||
return nil, err
|
||||
}
|
||||
return d, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user