create_package_structure

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.create_package_structure(path: Path)

Sets up the folder structure for a new package.

This is the first function to use to create a new data package. It assigns a package ID and then creates a package folder and all the necessary files for a package (excluding the resources), outputting the file paths for the created files.

Parameters

path : Path

The path to the folder containing the packages. Use path_packages() to provide the correct path location.

Returns

list[Path]

A list of paths to the two created files, datapackage.json and README.md, and the created folder resources/.

Raises

NotADirectoryError

If the directory in the path doesn’t exist.

FileNotFoundError

If a file could not be created.

TypeError

If datapackage.json could not be created.

Examples

import tempfile
from pathlib import Path

import seedcase_sprout.core as sp

# Create a temporary directory for the example
with tempfile.TemporaryDirectory() as temp_dir:
    temp_path = Path(temp_dir)

    # Create a package structure
    sp.create_package_structure(path=temp_path)
[PosixPath('/tmp/tmpowd839r9/1/datapackage.json'),
 PosixPath('/tmp/tmpowd839r9/1/README.md'),
 PosixPath('/tmp/tmpowd839r9/1/resources')]