Last change
on this file since 74 was 73, checked in by Bart Vastenhouw, 3 years ago |
Fix for IssueValue hashcode.
|
File size:
679 bytes
|
Rev | Line | |
---|
[73] | 1 | from _decimal import Decimal
|
---|
| 2 |
|
---|
| 3 | from pyson.Deserializer import Deserializer
|
---|
| 4 |
|
---|
| 5 | from geniusweb.issuevalue.DiscreteValue import DiscreteValue
|
---|
| 6 | from geniusweb.issuevalue.NumberValue import NumberValue
|
---|
| 7 | from geniusweb.issuevalue.Value import Value
|
---|
| 8 |
|
---|
| 9 |
|
---|
| 10 | class ValueDeserializer (Deserializer):
|
---|
| 11 | def deserialize(self, data:object, clas: object) -> Value:
|
---|
| 12 | if isinstance(data, float) or isinstance(data, int):
|
---|
| 13 | return NumberValue(Decimal(str(data)))
|
---|
| 14 | if isinstance(data,str):
|
---|
| 15 | return DiscreteValue(data)
|
---|
| 16 | raise ValueError("Expected number or double quoted string but found " + str(data)
|
---|
| 17 | + " of type " + str(type(data)))
|
---|
| 18 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.