Prototype Pydantic declarative scheme (#3)

* Update quickstart examples

* Implementation dump: Pydantic decorators but still java api compatible

* Cleanup for publishing
This commit is contained in:
Pascal Su
2025-10-31 17:12:10 +01:00
committed by GitHub
parent 59ba208f0a
commit 9928ab797e
88 changed files with 10021 additions and 1150 deletions
@@ -0,0 +1,48 @@
#!/usr/bin/env python3
"""
Python QuickStart Read Example
Mirrors the Java QuickStartRead.java for exact compatibility demonstration
"""
import sys
sys.path.append('src')
from lib_ro_crate_schema.crate.schema_facade import SchemaFacade
from python_quickstart_write import write_example_crate
# Constants (matching Java pattern exactly)
TMP_EXAMPLE_CRATE = "output_crates/example-crate"
def read_example_crate():
"""
Python QuickStart Read matching Java QuickStartRead structure exactly
Demonstrates compatibility between Java and Python RO-Crate implementations
"""
# First call write example to ensure crate exists (as requested)
write_example_crate()
# Load RO-Crate from directory (matching Java from_ro_crate pattern)
schemaFacade = SchemaFacade.from_ro_crate(TMP_EXAMPLE_CRATE)
# Display types (matching Java getTypes() approach)
types = schemaFacade.getTypes()
print("📚 Types in the crate:")
for typeObj in types:
print(f"- Type {typeObj.getId()}: {typeObj.getComment() if typeObj.getComment() else ''}")
entries = schemaFacade.getEntries(typeObj.getId())
for entry in entries:
print(f"{entry.getId()} ({entry.getClassId()}): {entry.properties}")
# Display property types
print("📚 Properties in the crate:")
properties = schemaFacade.getPropertyTypes()
for prop in properties:
print(f"{prop.getId()}: {prop.getComment() if prop.getComment() else ''} Range: {prop.getRange()}")
if __name__ == "__main__":
read_example_crate()