path_resource_raw_files

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 🚧

core.path_resource_raw_files(package_id: int, resource_id: int)

Gets the absolute path to the raw files of the specified resource.

Parameters

package_id : int

The ID of the package.

resource_id : int

The ID of the resource.

Returns

list[Path]

A list of paths to the specified resource’s raw files.

Raises

NotADirectoryError

If the package_id doesn’t exist or the resource_id doesn’t exist within the package.

Examples

import os
import tempfile

import seedcase_sprout.core as sp

# Create a temporary directory for the example
with tempfile.TemporaryDirectory() as temp_dir:
    os.environ["SPROUT_GLOBAL"] = temp_dir

    # Create a package and resource structure first
    sp.create_package_structure(path=sp.path_packages())
    sp.create_resource_structure(path=sp.path_resources(package_id=1))

    # TODO: Add data/raw files to resource
    # sp.write_resource_data_to_raw(
    #     path=sp.path_resource_raw(package_id=1, resource_id=1),
    #     data="path/to/data.csv")

    # Get the path to the resource's raw files
    sp.path_resource_raw_files(package_id=1, resource_id=1)
[PosixPath('/tmp/tmp9vacplil/packages/1/datapackage.json'),
 PosixPath('/tmp/tmp9vacplil/packages/1/README.md'),
 PosixPath('/tmp/tmp9vacplil/packages/1/resources')]
[PosixPath('/tmp/tmp9vacplil/packages/1/resources/1'),
 PosixPath('/tmp/tmp9vacplil/packages/1/resources/1/raw')]
[]