@@ -88,6 +88,16 @@ def edit_node(self, json_data):
8888 else :
8989 raise Exception ("Unable to edit node document." )
9090
91+ def _byteify (self , input ):
92+ if isinstance (input , dict ):
93+ return {self ._byteify (key ):self ._byteify (value ) for key ,value in input .iteritems ()}
94+ elif isinstance (input , list ):
95+ return [self ._byteify (element ) for element in input ]
96+ elif isinstance (input , unicode ):
97+ return input .encode ('utf-8' )
98+ else :
99+ return input
100+
91101 def get_info (self ):
92102 """
93103 Retrieve's the OSDF server's information/contact document
@@ -96,6 +106,8 @@ def get_info(self):
96106
97107 info = json .loads ( osdf_response ['content' ] )
98108
109+ info = self ._byteify (info )
110+
99111 return info
100112
101113 def get_node (self , node_id ):
@@ -119,6 +131,8 @@ def get_node(self, node_id):
119131
120132 data = json .loads ( osdf_response ['content' ] )
121133
134+ data = self ._byteify (data )
135+
122136 return data
123137
124138 def get_schema (self , namespace , schema_name ):
@@ -144,6 +158,8 @@ def get_schema(self, namespace, schema_name):
144158
145159 schema_data = json .loads ( osdf_response ['content' ] )
146160
161+ schema_data = self ._byteify (schema_data )
162+
147163 return schema_data
148164
149165 def get_aux_schema (self , namespace , aux_schema_name ):
@@ -169,6 +185,8 @@ def get_aux_schema(self, namespace, aux_schema_name):
169185
170186 aux_schema_data = json .loads ( osdf_response ['content' ] )
171187
188+ aux_schema_data = self ._byteify (aux_schema_data )
189+
172190 return aux_schema_data
173191
174192 def insert_node (self , json_data ):
@@ -267,6 +285,8 @@ def query(self, namespace, query, page=1):
267285
268286 data = json .loads ( osdf_response ['content' ] )
269287
288+ data = self ._byteify (data )
289+
270290 return data
271291
272292 def query_all_pages (self , namespace , query ):
0 commit comments