bago

package module
v0.0.0-...-64a5475 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2020 License: GPL-3.0 Imports: 19 Imported by: 0

README

Bago

Build Status ReportCard

An implementation of the BagIt specification in Go.

Work in Progress.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseTagFileLine

func ParseTagFileLine(line string) (ret [2]string, err error)

Types

type Bag

type Bag struct {
	backend.Backend // backend interface (usually FSBag)

	Info TagFile // contents of bag-info.txt
	// contains filtered or unexported fields
}

Bag is a bagit repository

func CreateBag

func CreateBag(opts *CreateBagOptions) (bag *Bag, err error)

Create Bag Creates a new Bag with FSBag backend

func OpenBag

func OpenBag(path string) (*Bag, error)

func (*Bag) Hydrate

func (bag *Bag) Hydrate() error

TODO bad function name

func (*Bag) IsComplete

func (b *Bag) IsComplete() (bool, error)

IsComplete returns whether bag satisfies bag completeness conditions. See: https://tools.ietf.org/html/draft-kunze-bagit-16#section-3

func (*Bag) IsValid

func (b *Bag) IsValid() (bool, error)

func (*Bag) IsValidConcurrent

func (b *Bag) IsValidConcurrent(workers int) (bool, error)

IsValid returns whether the bag at path is valid A valid bag is complete and checksums listed in all manifests are correct.

func (*Bag) ValidateManifests

func (b *Bag) ValidateManifests(workers int) (err error)

func (*Bag) WriteBagInfo

func (bag *Bag) WriteBagInfo() error

func (*Bag) WriteBagitTxt

func (bag *Bag) WriteBagitTxt() error

func (*Bag) WritePayloadManifests

func (bag *Bag) WritePayloadManifests() error

func (*Bag) WriteTagManifests

func (bag *Bag) WriteTagManifests() error

type CreateBagOptions

type CreateBagOptions struct {
	SrcDir     string
	DstPath    string
	InPlace    bool
	Algorithms []string
	Info       TagFile
	Workers    int
}

CreateBagOptions is used to pass options to CreateBag()

type EncPath

type EncPath string // A path encoded for manifest (percent encoded)

func EncodePath

func EncodePath(s string) EncPath

EncodePath encodes a path for inclusion in a manifest file

func (EncPath) Decode

func (p EncPath) Decode() string

func (EncPath) Norm

func (s EncPath) Norm() NormPath

type Manifest

type Manifest struct {
	// contains filtered or unexported fields
}

Manifest represents a payload manifest file

func ManfifestsForDir

func ManfifestsForDir(dPath string, algs []string, numWorkers int, prefix string) ([]*Manifest, error)

Manifests for Dir returns a slice of manifests describing contents of a directory.

func (*Manifest) Append

func (man *Manifest) Append(path EncPath, sum []byte) error

Append adds a new entry to the manifest. It returns an error if the entry already exists. The path is encoded.

func (*Manifest) Filename

func (man *Manifest) Filename() string

Filename returns filename for the manifest

func (*Manifest) Write

func (man *Manifest) Write(writer io.Writer) error

type ManifestEntry

type ManifestEntry struct {
	// contains filtered or unexported fields
}

type NormPath

type NormPath string // A path encoded and normalized (Unicode-NFC)

type Payload

type Payload map[NormPath]PayloadEntry

type PayloadEntry

type PayloadEntry struct {
	// contains filtered or unexported fields
}

type Profile

type Profile struct {
	BagItProfileInfo     ProfileInfo          `json:"BagIt-Profile-Info"`
	BagInfo              map[string]TagOption `json:"Bag-Info"`
	ManifestsRequired    []string             `json:"Manifests-Required"`
	AllowFetchTxt        bool                 `json:"Allow-Fetch.txt"`
	Serialization        string               `json:"Serialization"`
	AcceptSerialization  []string             `json:"Accept-Serialization"`
	AcceptBagItVersion   []string             `json:"Accept-BagIt-Version"`
	TagManifestsRequired []string             `json:"Tag-Manifests-Required"`
	TagFilesRequired     []string             `json:"Tag-Files-Required"`
}

func (*Profile) UnmarshalJSON

func (prof *Profile) UnmarshalJSON(b []byte) error

type ProfileInfo

type ProfileInfo struct {
	SourceOrganization     string `json:"Source-Organization"`
	ExternalDescription    string `json:"External-Description"`
	Version                string `json:"Version"`
	BagItProfileIdentifier string `json:"BagIt-Profile-Identifier"`
	ContactName            string `json:"Contact-Name"`
	ContactPhone           string `json:"Contact-Phone"`
	ContactEmail           string `json:"Contact-Email"`
}

type TagFile

type TagFile struct {
	// contains filtered or unexported fields
}

func DefaultBagitTxt

func DefaultBagitTxt() *TagFile

DefaultBagitTxt returns a new TagFile for bagit.txt

func (*TagFile) Append

func (tf *TagFile) Append(label string, value string) []string

func (*TagFile) Set

func (tf *TagFile) Set(label string, value string)

func (*TagFile) Write

func (tf *TagFile) Write(writer io.Writer) error

type TagOption

type TagOption struct {
	Values     []string
	Required   bool
	Repeatable bool
}

func (*TagOption) UnmarshalJSON

func (tag *TagOption) UnmarshalJSON(b []byte) error

type TagSet

type TagSet map[string][]string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL