Skip to content
This repository has been archived by the owner on May 16, 2022. It is now read-only.

Commit

Permalink
Add filename pattern test tool
Browse files Browse the repository at this point in the history
Signed-off-by: Igor Shishkin <[email protected]>
  • Loading branch information
teran committed Jan 21, 2020
1 parent cf0b6ab commit c326f34
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 2 deletions.
24 changes: 22 additions & 2 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,32 @@ brews:
description: "Canon ES-E1 CSV parsing tool to generate EXIF data for film scans"
test: |
system "#{bin}/eos-1v-tagger -version"
system "#{bin}/eos-1v-fpt -version"
install: |
bin.install "eos-1v-tagger"
bin.install "eos-1v-fpt"
builds:
- env:
- id: eos-1v-tagger
binary: eos-1v-tagger
env:
- CGO_ENABLED=0
main: ./cmd/tagger/
main:
./cmd/tagger/main.go
goos:
- darwin
- linux
- windows
goarch:
- 386
- amd64
ldflags:
- -s -w -X main.ldVersion={{.Version}} -X main.ldTimestamp={{.Timestamp}}
- id: eos-1v-fpt
binary: eos-1v-fpt
env:
- CGO_ENABLED=0
main:
./cmd/filename-pattern-tester/main.go
goos:
- darwin
- linux
Expand Down
78 changes: 78 additions & 0 deletions cmd/filename-pattern-tester/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package main

import (
"flag"
"fmt"
"os"
"runtime"
"strconv"
"time"

format "github.com/teran/eos-1v-tagger/format"
)

// LD vars
var (
ldVersion = "undefined"
ldTimestamp = "0"
)

func main() {
var (
pattern string
startCameraID int
endCameraID int
startFilmID int
endFilmID int
startFrameNo int
endFrameNo int
displayVersion bool
)

versionString := fmt.Sprintf("Version: %s, build with %s at %s\n", ldVersion, runtime.Version(), func() string {
tsI, err := strconv.ParseInt(ldTimestamp, 10, 64)
if err != nil {
panic(err)
}
return time.Unix(tsI, 0).Format(time.RFC3339)
}())

flag.Usage = func() {
fmt.Printf("Trivial tool to test filename pattern\n")
fmt.Printf("The tool allows to generate amount of cameraID's, filmID's and frameID's to visually check the pattern\n\n")
flag.PrintDefaults()
fmt.Print(versionString)
}

flag.StringVar(&pattern, "filename-pattern", "FILM_${cameraID:02d}${filmID:03d}${frameNo:05d}.dng", "filename pattern to render")
flag.IntVar(&startCameraID, "start-camera-id", 9, "generate cameraID's starting this ID")
flag.IntVar(&endCameraID, "end-camera-id", 11, "generate cameraID's to this ID")
flag.IntVar(&startFilmID, "start-film-id", 99, "generate filmID's starting this ID")
flag.IntVar(&endFilmID, "end-film-id", 101, "generate filmID's to this ID")
flag.IntVar(&startFrameNo, "start-frame-no", 9, "generate frameNo's starting this No")
flag.IntVar(&endFrameNo, "end-frame-no", 11, "generate frameNo's to this No")
flag.BoolVar(&displayVersion, "version", false, "display version and exit")
flag.Parse()

if displayVersion {
fmt.Print(versionString)
os.Exit(1)
}

fmt.Printf("rendering pattern: '%s'\n\n", pattern)

for cameraID := startCameraID; cameraID < endCameraID; cameraID++ {
fmt.Printf("cameraID = %d\n", cameraID)
for filmID := startFilmID; filmID < endFilmID; filmID++ {
fmt.Printf(" filmID = %d\n", filmID)
for frameNo := startFrameNo; frameNo < endFrameNo; frameNo++ {
filename := format.Format(pattern, map[string]interface{}{
"filmID": filmID,
"cameraID": cameraID,
"frameNo": frameNo,
})
fmt.Printf(" %d: %s\n", frameNo, filename)
}
}
}
}

0 comments on commit c326f34

Please sign in to comment.