From b4849ccab46cf3f55f109436153e45a175888792 Mon Sep 17 00:00:00 2001 From: Nick White Date: Tue, 14 Apr 2020 11:07:07 +0100 Subject: Remove unused PreprocPattern, allow sensible defaults with aws setup, and add a little more documentation --- aws.go | 11 +++++++---- graph.go | 4 ++++ pdf.go | 1 + 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/aws.go b/aws.go index 70189ea..59f1a7e 100644 --- a/aws.go +++ b/aws.go @@ -20,7 +20,7 @@ import ( "github.com/aws/aws-sdk-go/service/sqs" ) -const PreprocPattern = `_bin[0-9].[0-9].png` +const defaultAwsRegion = `eu-west-2` type Qmsg struct { Id, Handle, Body string @@ -35,8 +35,11 @@ type ObjMeta struct { Date time.Time } +// AwsConn contains the necessary things to interact with various AWS +// services in ways useful for the bookpipeline package. It is +// designed to be generic enough to swap in other backends easily. type AwsConn struct { - // these need to be set before running Init() + // these should be set before running Init(), or left to defaults Region string Logger *log.Logger @@ -53,10 +56,10 @@ type AwsConn struct { // MinimalInit does the bare minimum to initialise aws services func (a *AwsConn) MinimalInit() error { if a.Region == "" { - return errors.New("No Region set") + a.Region = defaultAwsRegion } if a.Logger == nil { - return errors.New("No logger set") + a.Logger = log.New(os.Stdout, "", 0) } var err error diff --git a/graph.go b/graph.go index 8d6c857..a7b46bc 100644 --- a/graph.go +++ b/graph.go @@ -32,6 +32,8 @@ type GraphConf struct { Pgnum, Conf float64 } +// createLine creates a horizontal line with a particular y value for +// a graph func createLine(xvalues []float64, y float64, c drawing.Color) chart.ContinuousSeries { var yvalues []float64 for range xvalues { @@ -46,10 +48,12 @@ func createLine(xvalues []float64, y float64, c drawing.Color) chart.ContinuousS } } +// Graph creates a graph of the confidence of each page in a book func Graph(confs map[string]*Conf, bookname string, w io.Writer) error { return GraphOpts(confs, bookname, "Page number", true, w) } +// Graph creates a graph of confidences func GraphOpts(confs map[string]*Conf, bookname string, xaxis string, guidelines bool, w io.Writer) error { if len(confs) < 2 { return errors.New("Not enough valid confidences") diff --git a/pdf.go b/pdf.go index a03aecc..f8217ba 100644 --- a/pdf.go +++ b/pdf.go @@ -31,6 +31,7 @@ func pxToPt(i int) float64 { return float64(i) / pageWidth } +// Fpdf abstracts the gofpdf.Fpdf adding some useful methods type Fpdf struct { fpdf *gofpdf.Fpdf } -- cgit v1.2.1-24-ge1ad