bagit

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: Apache-2.0 Imports: 16 Imported by: 5

README

bagit-gython

Go Reference

bagit-gython is an experimental library that wraps bagit-python using an embedded modern Python interpreter. Its goal is to make Python's battle-tested implementation available to the Go ecosystem, avoiding the need to reimplement it from scratch. By leveraging Python's well-tested version, bagit-gython benefits from the extensive community of users and the robustness of the existing implementation.

It depends on go-embed-python, a CGO-free library that provides an embedded distribution of Python compatible with a number of architecture and operative systems.

Installing

Using bagit-python is easy. First, use go get to install the latest version of the library.

go get -u github.com/artefactual-labs/bagit-gython

Next, include bagit-gython in your application:

import "github.com/artefactual-labs/bagit-gython"

Usage

Check out example, a small program that imports bagit-python to validate a bag:

$ go run ./example/ -validate /tmp/invalid-bag/
Validation failed: invalid: Payload-Oxum validation failed. Expected 1 files and 0 bytes but found 2 files and 0 bytesexit status 1

$ go run ./example/ -validate /tmp/valid-bag/
Valid!

Supported architectures

  • darwin-amd64
  • darwin-arm64
  • linux-amd64
  • linux-arm64
  • windows-amd64

These are the platform-architecture combinations for which go-embed-python provides compatibility.

Version of bagit-python

The specific version of bagit-python used by this project is specified in the internal/dist/requirements.txt file. Instead of using the latest official release, we are using a commit from the main branch that includes compatibility fixes for recent Python releases. This commit has not yet been included in an official release.

Acknowledgement

License

Apache 2.0. See LICENSE.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalid indicates that bag validation failed. If there is a validation
	// error message, ErrInvalid will be wrapped so make sure to use
	// `errors.Is(err, ErrInvalid)` to test equivalency.
	ErrInvalid = errors.New("invalid")

	// ErrBusy is returned when an operation is attempted on BagIt while it is
	// already processing another command. This ensures that only one command is
	// processed at a time, preventing race conditions and ensuring the
	// integrity of the shared resources.
	ErrBusy = errors.New("runner is busy")
)

Functions

This section is empty.

Types

type BagIt

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

BagIt is an abstraction to work with BagIt packages that embeds Python and the bagit-python.

func NewBagIt

func NewBagIt() (*BagIt, error)

NewBagIt creates and initializes a new BagIt instance. This constructor is computationally expensive as it sets up an embedded Python environment and extracts necessary libraries. It's recommended to create a single instance and share it across your application to avoid repeatedly installing Python.

func (*BagIt) Cleanup

func (b *BagIt) Cleanup() error

func (*BagIt) Make

func (b *BagIt) Make(path string) error

func (*BagIt) Validate

func (b *BagIt) Validate(path string) error

Directories

Path Synopsis
example module
internal

Jump to

Keyboard shortcuts

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