diff options
author | Nick White <git@njw.name> | 2021-12-20 12:33:14 +0000 |
---|---|---|
committer | Nick White <git@njw.name> | 2021-12-20 12:33:14 +0000 |
commit | 59573b1fb8e5a47f924a636f0f46bd64ed19747e (patch) | |
tree | 4771ddac41aa11e3ab04e59abeb507e06667db1a | |
parent | 2e3bef288256fe25f982b9adeaacd2930cccd21e (diff) |
whitespace and error clarity changes
-rw-r--r-- | cmd/getpipelinebook/main.go | 4 | ||||
-rw-r--r-- | cmd/rescribe/main.go | 14 | ||||
-rw-r--r-- | internal/pipeline/get.go | 5 |
3 files changed, 9 insertions, 14 deletions
diff --git a/cmd/getpipelinebook/main.go b/cmd/getpipelinebook/main.go index 965f9f7..bc4150d 100644 --- a/cmd/getpipelinebook/main.go +++ b/cmd/getpipelinebook/main.go @@ -124,9 +124,9 @@ func main() { verboselog.Println("Downloading PDFs") pipeline.DownloadPdfs(bookname, bookname, conn) } - + if *png { - verboselog.Println("Downloading best PNGs") + verboselog.Println("Downloading best PNGs") pipeline.DownloadBestPngs(bookname, bookname, conn) } diff --git a/cmd/rescribe/main.go b/cmd/rescribe/main.go index 89eb590..8224830 100644 --- a/cmd/rescribe/main.go +++ b/cmd/rescribe/main.go @@ -471,21 +471,19 @@ func startProcess(logger log.Logger, tessCommand string, bookdir string, booknam if err != nil { log.Fatalf("Error moving hocr %s to hocr directory: %v", v, err) } - + pngname := strings.Replace(v, ".hocr", ".png", 1) err = os.MkdirAll(filepath.Join(savedir, "png"), 0755) if err != nil { - log.Fatalf("Error creating hocr directory: %v", err) + log.Fatalf("Error creating png directory: %v", err) } - + err = os.Rename(pngname, filepath.Join(savedir, "png", filepath.Base(pngname))) if err != nil { - log.Fatalf("Error moving png %s to hocr directory: %v", pngname, err) + log.Fatalf("Error moving png %s to png directory: %v", pngname, err) } - - } - + } // For simplicity, remove .binarised.pdf and rename .colour.pdf to .pdf _ = os.Remove(filepath.Join(savedir, bookname+".binarised.pdf")) @@ -549,7 +547,7 @@ func downloadbook(dir string, name string, conn Pipeliner) error { if err != nil { return fmt.Errorf("Error downloading best pages: %v", err) } - + err1 := pipeline.DownloadBestPngs(dir, name, conn) if err1 != nil { return fmt.Errorf("Error downloading best pngs: %v", err) diff --git a/internal/pipeline/get.go b/internal/pipeline/get.go index 2559857..e9bb8b1 100644 --- a/internal/pipeline/get.go +++ b/internal/pipeline/get.go @@ -39,7 +39,6 @@ func DownloadBestPages(dir string, name string, conn Downloader) error { } func DownloadBestPngs(dir string, name string, conn Downloader) error { - key := filepath.Join(name, "best") fn := filepath.Join(dir, "best") err := conn.Download(conn.WIPStorageId(), key, fn) @@ -51,8 +50,7 @@ func DownloadBestPngs(dir string, name string, conn Downloader) error { return fmt.Errorf("Failed to open best file: %v", err) } defer f.Close() - - + s := bufio.NewScanner(f) for s.Scan() { imgname := strings.Replace(s.Text(), ".hocr", ".png", 1) @@ -67,7 +65,6 @@ func DownloadBestPngs(dir string, name string, conn Downloader) error { return nil } - func DownloadPdfs(dir string, name string, conn Downloader) error { for _, suffix := range []string{".colour.pdf", ".binarised.pdf"} { key := filepath.Join(name, name+suffix) |