mirror of
https://github.com/nexus-stc/hyperboria
synced 2024-12-21 09:07:46 +01:00
681817ceae
GitOrigin-RevId: 83514338be1d662518bab9fe5ab6eefef98f229f
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)
|