PackagePath

Warning

🚧 Sprout is still in active development and evolving quickly, so the documentation and functionality may not work as described and could undergo substantial changes 🚧

PackagePath(self, path: Path | None = None)

Gets the absolute path to a specific file or folder in a data package.

The functions in this class are used to get the absolute path to a specific file or folder in a data package. They are intended as convenience functions to provide easy and quick access to required files and folders within a data package. These functions have these characteristics in common:

Outputs a PackagePath object representing the structure of a data package.

Parameters

path : Path | None = None

Provide a path to the package directory. Defaults to the current working directory.

Examples

from pathlib import Path

import seedcase_sprout as sp

# With default path
sp.PackagePath().properties()
sp.PackagePath().readme()

# With custom path
my_path = Path("my/path")
sp.PackagePath(my_path).properties()
sp.PackagePath(my_path).readme()
PosixPath('/home/runner/work/seedcase-sprout/seedcase-sprout/datapackage.json')
PosixPath('/home/runner/work/seedcase-sprout/seedcase-sprout/README.md')
PosixPath('my/path/datapackage.json')
PosixPath('my/path/README.md')

Methods

Name Description
properties Path to the datapackage.json file.
readme Path to the README.md file.
resource Path to the specified resources/<name>/ folder.
resource_batch Path to the specific resource’s batch/ folder.
resource_batch_files Paths to all the files in the specific resource’s batch/ folder.
resource_data Path to the specific resource’s data file.
resources Path to the resources/ folder.
root Path to the root folder of the package.

properties

PackagePath.properties()

Path to the datapackage.json file.

readme

PackagePath.readme()

Path to the README.md file.

resource

PackagePath.resource(resource_name: str)

Path to the specified resources/<name>/ folder.

Parameters

resource_name : str

The name of the resource. Use ResourceProperties.name to get the correct resource name.

resource_batch

PackagePath.resource_batch(resource_name: str)

Path to the specific resource’s batch/ folder.

Parameters

resource_name : str

The name of the resource. Use ResourceProperties.name to get the correct resource name.

resource_batch_files

PackagePath.resource_batch_files(resource_name: str)

Paths to all the files in the specific resource’s batch/ folder.

Parameters

resource_name : str

The name of the resource. Use ResourceProperties.name to get the correct resource name.

resource_data

PackagePath.resource_data(resource_name: str)

Path to the specific resource’s data file.

Parameters

resource_name : str

The name of the resource. Use ResourceProperties.name to get the correct resource name.

resources

PackagePath.resources()

Path to the resources/ folder.

root

PackagePath.root()

Path to the root folder of the package.