-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into users/tynguyen/metadata_validation
- Loading branch information
Showing
21 changed files
with
844 additions
and
1,033 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
packages/service/ni_measurement_plugin_sdk_service/_internal/parameter/_get_type.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from typing import Any | ||
|
||
from google.protobuf.descriptor_pb2 import FieldDescriptorProto | ||
from google.protobuf.type_pb2 import Field | ||
|
||
_TYPE_DEFAULT_MAPPING = { | ||
Field.TYPE_FLOAT: float(), | ||
Field.TYPE_DOUBLE: float(), | ||
Field.TYPE_INT32: int(), | ||
Field.TYPE_INT64: int(), | ||
Field.TYPE_UINT32: int(), | ||
Field.TYPE_UINT64: int(), | ||
Field.TYPE_BOOL: bool(), | ||
Field.TYPE_STRING: str(), | ||
Field.TYPE_ENUM: int(), | ||
} | ||
|
||
TYPE_FIELD_MAPPING = { | ||
Field.TYPE_FLOAT: FieldDescriptorProto.TYPE_FLOAT, | ||
Field.TYPE_DOUBLE: FieldDescriptorProto.TYPE_DOUBLE, | ||
Field.TYPE_INT32: FieldDescriptorProto.TYPE_INT32, | ||
Field.TYPE_INT64: FieldDescriptorProto.TYPE_INT64, | ||
Field.TYPE_UINT32: FieldDescriptorProto.TYPE_UINT32, | ||
Field.TYPE_UINT64: FieldDescriptorProto.TYPE_UINT64, | ||
Field.TYPE_BOOL: FieldDescriptorProto.TYPE_BOOL, | ||
Field.TYPE_STRING: FieldDescriptorProto.TYPE_STRING, | ||
Field.TYPE_ENUM: FieldDescriptorProto.TYPE_ENUM, | ||
Field.TYPE_MESSAGE: FieldDescriptorProto.TYPE_MESSAGE, | ||
} | ||
|
||
|
||
def get_type_default(type: Field.Kind.ValueType, repeated: bool) -> Any: | ||
"""Get the default value for the give type.""" | ||
if repeated: | ||
return list() | ||
return _TYPE_DEFAULT_MAPPING.get(type) |
Oops, something went wrong.