capturegraph.data.load.traversal
#
CaptureGraph Data Traversal#
Load CaptureGraph target directories as typed Python objects for convenient traversal. This module provides the primary API for accessing captured data.
Example
Functions:
| Name | Description |
|---|---|
load_directory |
Recursively load a directory based on its manifest |
Classes:
| Name | Description |
|---|---|
CaptureTarget |
Top-level entry point (loads capture_target_manifest.json) |
CaptureTarget
#
Bases: Dict
Top-level entry point for loading a CaptureGraph target.
A CaptureTarget represents a capture project directory that contains a
capture_target_manifest.json file defining its structure.
Inherits from Dict, providing attribute-style access to all loaded data.
Example
import capturegraph.data as cg
from pathlib import Path
target = cg.CaptureTarget(Path("./MyCapture"))
print(target.reference) # Path to reference.heic
# Vectorized access across all sessions
ratings = target.surveys.tastiness_rating
print(f"Average: {sum(r for r in ratings if r) / len([r for r in ratings if r])}")
Attributes:
| Name | Type | Description |
|---|---|---|
_path |
The directory path on disk |
|
_manifest |
The raw ProcedureManifest (for introspection) |
Source code in capturegraph-lib/capturegraph/data/load/traversal.py
path
property
#
The directory path on disk.
manifest
property
#
Access the raw manifest for introspection.
__init__(path)
#
Load a CaptureTarget from a directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Union[str, Path]
|
Path to the target directory (must contain capture_target_manifest.json) |
required |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the manifest file doesn't exist |
Source code in capturegraph-lib/capturegraph/data/load/traversal.py
load_directory(path, manifest)
#
Recursively load a directory based on its manifest.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to the directory |
required |
manifest
|
ProcedureManifest
|
The manifest defining the directory's structure |
required |
Returns:
| Type | Description |
|---|---|
Dict
|
Dict with attributes for all files, sequences, directories, and sessions |
Dict
|
defined in the manifest. |