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)

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

Use the functions in this class to get the absolute path to a specific file or folder in your data package. They are intended as convenience functions to provide you with easy and quick access to required files and folders within your 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.
properties_script Path to the properties script.
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.
resource_properties_script Path to a specific resource’s resource properties script.
resources Path to the resources/ folder.
root Path to the root folder of the package.

properties

PackagePath.properties()

Path to the datapackage.json file.

properties_script

PackagePath.properties_script()

Path to the properties script.

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.

resource_properties_script

PackagePath.resource_properties_script(resource_name: str = '')

Path to a specific resource’s resource properties script.

Parameters

resource_name : str = ''

The name of the resource.

resources

PackagePath.resources()

Path to the resources/ folder.

root

PackagePath.root()

Path to the root folder of the package.