Skip to content

file_ops

File Operations ModuleLink

A comprehensive module for managing file system operations in a hierarchical database structure, providing functionality for loading, storing, and manipulating scans, filesets, and individual files in a structured database environment.

Key FeaturesLink

  • Scan Management: Load and manipulate scan data structures with associated metadata
  • Fileset Handling: Create, load, and delete filesets with their corresponding files and metadata
  • File Operations: Manage individual files within filesets, including metadata handling
  • Directory Structure Management: Create and maintain hierarchical directory structures for scans and filesets
  • Metadata Management: Load and store metadata for scans, filesets, and individual files
  • Error Handling: Comprehensive error checking and logging for file operations
  • Data Serialization: JSON-based serialization for storing and loading data structures

Usage ExamplesLink

>>> from plantdb.commons.fsdb.file_ops import _load_scans,_make_scan, _store_scan, _delete_scan
>>> from plantdb.commons.test_database import test_database
>>> # Initialize the database (creates base directory if needed)
>>> db = test_database(no_auth=True)
>>> db.connect()
>>> # Load all scans
>>> scans = _load_scans(db)
>>> # Create and store a new scan
>>> scan = db.create_scan("scan_001")
>>> _make_scan(scan)
PosixPath('/tmp/ROMI_DB_sgqmij8t/scan_001')
>>> _store_scan(scan)
>>> # Delete a scan
>>> _delete_scan(scan)