diff --git a/edosl0util/crio.py b/edosl0util/crio.py index c125c406f1b6e9bbc311e87caddba65adb8ce218..776978c15a125497bad05b2c7ab33874e9c8846f 100644 --- a/edosl0util/crio.py +++ b/edosl0util/crio.py @@ -1,8 +1,8 @@ - """PDS construction record input and output""" import ctypes as c import numbers + from edosl0util.headers import BaseStruct, DaySegmentedTimecode @@ -51,7 +51,9 @@ def read(cr_file): def read_struct(f, struct): rv = struct_to_dict(struct.from_buffer_copy(f.read(c.sizeof(struct)))) rv = {k: v for k, v in rv.items() if not k.startswith('spare_')} # no spare fields - return {k: int(v) if isinstance(v, numbers.Integral) else v for k, v in rv.items()} # no longs + return {k: int(v) if isinstance(v, numbers.Integral) else v for k, v in + rv.items()} # no longs + return main() @@ -88,7 +90,13 @@ def write(cr, out_file): def write_struct(data, struct, out): fields = [f[0] for f in struct._fields_] - struct_data = {k: v for k, v in data.items() if k in fields} + struct_data = {} + for k, v in data.items(): + if k in fields: + if isinstance(v, str): + struct_data[k] = v.encode('utf-8') + else: + struct_data[k] = v out.write(memoryview(struct(**struct_data))) main()