mirror of
https://github.com/Unidata/python-awips.git
synced 2025-02-23 14:57:56 -05:00
38 lines
776 B
Python
38 lines
776 B
Python
|
|
||
|
import dynamicserialize
|
||
|
from dynamicserialize.dstypes.java.awt import Point
|
||
|
from dynamicserialize.dstypes.com.raytheon.uf.common.pypies import PointTest
|
||
|
|
||
|
def readObject():
|
||
|
f = open('/tmp/javaPoints')
|
||
|
data = f.read()
|
||
|
f.close()
|
||
|
return data
|
||
|
|
||
|
def writeObject():
|
||
|
data = PointTest()
|
||
|
p1 = Point()
|
||
|
p1.setX(26)
|
||
|
p1.setY(9)
|
||
|
p2 = Point()
|
||
|
p2.setX(144)
|
||
|
p2.setY(-7)
|
||
|
points = [p1, p2]
|
||
|
data.setPoints(points)
|
||
|
b = dynamicserialize.serialize(data)
|
||
|
f = open('/tmp/pythonPoints', 'w')
|
||
|
f.write(b)
|
||
|
f.close()
|
||
|
print("wrote to /tmp/pythonPoints")
|
||
|
|
||
|
def main():
|
||
|
data = readObject()
|
||
|
obj = dynamicserialize.deserialize(data)
|
||
|
print(obj)
|
||
|
print(obj.getPoints())
|
||
|
|
||
|
writeObject()
|
||
|
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
main()
|