mirror of
https://github.com/nexus-stc/hyperboria
synced 2024-12-05 01:12:55 +01:00
23 lines
618 B
Python
23 lines
618 B
Python
|
from typing import Union
|
||
|
|
||
|
from nexus.models.proto.scimag_pb2 import Scimag as ScimagPb
|
||
|
from nexus.models.proto.scitech_pb2 import Scitech as ScitechPb
|
||
|
|
||
|
from .scimag import ScimagView
|
||
|
from .scitech import ScitechView
|
||
|
|
||
|
pb_registry = {
|
||
|
'scimag': ScimagPb,
|
||
|
'scitech': ScitechPb,
|
||
|
}
|
||
|
|
||
|
views_registry = {
|
||
|
'scimag': ScimagView,
|
||
|
'scitech': ScitechView,
|
||
|
}
|
||
|
|
||
|
|
||
|
def parse_typed_document_to_view(typed_document_pb) -> Union[ScimagView, ScitechView]:
|
||
|
document_pb = getattr(typed_document_pb, typed_document_pb.WhichOneof('document'))
|
||
|
return views_registry[typed_document_pb.WhichOneof('document')](document_pb)
|