Skip to content

Commit

Permalink
updating aspace version, removing XML validation
Browse files Browse the repository at this point in the history
  • Loading branch information
dmnyu committed Jul 18, 2024
1 parent 0cc7b33 commit 018e9db
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 54 deletions.
22 changes: 2 additions & 20 deletions aspace_xport/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package aspace_xport
import (
"bufio"
"fmt"
"github.com/nyudlts/go-aspace"
"os"
"os/exec"
"path/filepath"
"strings"
"time"

"github.com/nyudlts/go-aspace"
)

var (
Expand All @@ -27,7 +28,6 @@ type ExportOptions struct {
Format ExportFormat
UnpublishedNotes bool
UnpublishedResources bool
Validate bool
Workers int
Reformat bool
}
Expand Down Expand Up @@ -161,15 +161,6 @@ func exportMarc(info ResourceInfo, res aspace.Resource, workerID int) ExportResu
//validate the output
warning := false
var warningType = ""
if exportOptions.Validate == true {
err = aspace.ValidateMARC(marcBytes)
if err != nil {
warning = true
warningType = "failed MARC21 validation, writing to invalid directory"
LogOnly(fmt.Sprintf("worker %d resource %s - %s %s %s", workerID, res.URI, res.EADID, warningType, err.Error()), WARNING)
marcPath = filepath.Join(exportOptions.WorkDir, info.RepoSlug, "invalid", marcFilename)
}
}

//write the marc file
err = os.WriteFile(marcPath, marcBytes, 0777)
Expand Down Expand Up @@ -203,15 +194,6 @@ func exportEAD(info ResourceInfo, res aspace.Resource, workerID int) ExportResul
//validate the output
warning := false
var warningType = ""
if exportOptions.Validate == true {
err = aspace.ValidateEAD(eadBytes)
if err != nil {
warning = true
warningType = "failed EAD2002 validation, writing to invalid directory"
LogOnly(fmt.Sprintf("worker %d - resource %s - %s %s", workerID, res.URI, res.EADID, warningType), WARNING)
outputFile = filepath.Join(exportOptions.WorkDir, info.RepoSlug, "invalid", eadFilename)
}
}

//create the output file
err = os.WriteFile(outputFile, eadBytes, 0777)
Expand Down
10 changes: 3 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
module github.com/nyudlts/aspace-export

go 1.19
go 1.22

require github.com/nyudlts/go-aspace v0.3.8-0.20220214182818-e92697d431b8
require github.com/nyudlts/go-aspace v0.6.1

require (
github.com/lestrrat-go/libxml2 v0.0.0-20201123224832-e6d9de61b80d // indirect
github.com/pkg/errors v0.9.1 // indirect
gopkg.in/yaml.v2 v2.3.0 // indirect
)
require gopkg.in/yaml.v2 v2.3.0 // indirect
24 changes: 3 additions & 21 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/lestrrat-go/libxml2 v0.0.0-20201123224832-e6d9de61b80d h1:7uUkdtm6TC3olmG0I9lIAwBJQianl8YT5H8zcw6Mkpk=
github.com/lestrrat-go/libxml2 v0.0.0-20201123224832-e6d9de61b80d/go.mod h1:fy/ZVbgyB83mtricxwSW3zqIRXWOVpKG2PvdUDFeC58=
github.com/nyudlts/go-aspace v0.3.8-0.20220214182818-e92697d431b8 h1:QxT20pOJtQYY492CKoH+QFr71h+RT/TdAZ0Zgj3nsW0=
github.com/nyudlts/go-aspace v0.3.8-0.20220214182818-e92697d431b8/go.mod h1:/E+T2G7pMgH7T9WJsIqGGxSwvL4y4YDOe/ZUIN6pwAY=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/nyudlts/go-aspace v0.6.1 h1:BWHTeFg/NGfs13pkmwXJA6yowJN36B/aukmJbJQaX0I=
github.com/nyudlts/go-aspace v0.6.1/go.mod h1:XjLzY7ig8xq5qgFpfyIXb6BJQ68f9e6V5zkI8nF7EHc=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
10 changes: 4 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ package main
import (
"flag"
"fmt"
export "github.com/nyudlts/aspace-export/aspace_xport"
"github.com/nyudlts/go-aspace"
"os"
"path/filepath"
"time"

export "github.com/nyudlts/aspace-export/aspace_xport"
"github.com/nyudlts/go-aspace"
)

const appVersion = "v1.0.0b"
const appVersion = "v1.1.0"

var (
config string
Expand All @@ -28,7 +29,6 @@ var (
timeout int
unpublishedNotes bool
unpublishedResources bool
validate bool
version bool
workDir string
workers int
Expand All @@ -41,7 +41,6 @@ func init() {
flag.IntVar(&resource, "resource", 0, "ID of a single resource to be exported")
flag.IntVar(&timeout, "timeout", 20, "client timeout")
flag.IntVar(&workers, "workers", 8, "number of concurrent workers")
flag.BoolVar(&validate, "validate", false, "perform ead2 schema validation")
flag.StringVar(&exportLoc, "export-location", ".", "location to export finding aids")
flag.BoolVar(&help, "help", false, "display the help message")
flag.BoolVar(&version, "version", false, "display the version of the tool and go-aspace library")
Expand Down Expand Up @@ -218,7 +217,6 @@ func main() {
Format: xportFormat,
UnpublishedNotes: unpublishedNotes,
UnpublishedResources: unpublishedResources,
Validate: validate,
Workers: workers,
Reformat: reformat,
}
Expand Down

0 comments on commit 018e9db

Please sign in to comment.