-
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.
Fixed sytleguide and type assignment.
- Loading branch information
1 parent
661482d
commit 019cef9
Showing
7 changed files
with
49 additions
and
42 deletions.
There are no files selected for viewing
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_DEFULAT_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_DEFULAT_MAPPING.get(type) |
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
22 changes: 0 additions & 22 deletions
22
packages/service/ni_measurement_plugin_sdk_service/_internal/parameter/default_value.py
This file was deleted.
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
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