mirror of
https://github.com/p2p-ld/nwb-linkml.git
synced 2024-11-10 00:34:29 +00:00
30 lines
752 B
Python
30 lines
752 B
Python
|
"""
|
||
|
Practice translation of namespaces to linkml just as a warmup to
|
||
|
see what kind of operations we'll need
|
||
|
|
||
|
Notes:
|
||
|
- Handling "namespace" imports within namespaces separately as prefixes
|
||
|
"""
|
||
|
from typing import List
|
||
|
from dataclasses import dataclass
|
||
|
|
||
|
|
||
|
from nwb_schema_language import Namespace
|
||
|
from linkml.utils.schema_builder import SchemaBuilder
|
||
|
|
||
|
from linkml_runtime.linkml_model import SchemaDefinition
|
||
|
|
||
|
|
||
|
|
||
|
# top-level attributes
|
||
|
def build_schema(namespace: Namespace) -> SchemaDefinition:
|
||
|
return SchemaDefinition(
|
||
|
id=namespace.name,
|
||
|
name=namespace.name,
|
||
|
title=namespace.full_name,
|
||
|
version=namespace.version,
|
||
|
imports=[schema.source for schema in namespace.schema_ if schema.source is not None]
|
||
|
)
|
||
|
|
||
|
|