@@ -65,7 +65,9 @@ def generate_components(components_source, project_shortname,
65
65
file = sys .stderr )
66
66
sys .exit (1 )
67
67
68
- metadata = json .loads (out .decode (), object_pairs_hook = OrderedDict )
68
+ jsondata_unicode = json .loads (out .decode (), object_pairs_hook = OrderedDict )
69
+ metadata = byteify (jsondata_unicode )
70
+
69
71
generator_methods = [generate_class_file ]
70
72
71
73
if rprefix :
@@ -89,7 +91,8 @@ def generate_components(components_source, project_shortname,
89
91
90
92
if rprefix :
91
93
with open ('package.json' , 'r' ) as f :
92
- pkg_data = json .load (f , object_pairs_hook = OrderedDict )
94
+ jsondata_unicode = json .load (f , object_pairs_hook = OrderedDict )
95
+ pkg_data = byteify (jsondata_unicode )
93
96
94
97
generate_exports (
95
98
project_shortname , components , metadata , pkg_data , prefix
@@ -133,5 +136,16 @@ def cli():
133
136
rprefix = args .r_prefix )
134
137
135
138
139
+ def byteify (input_object ):
140
+ if isinstance (input_object , dict ):
141
+ return {byteify (key ): byteify (value )
142
+ for key , value in input_object .iteritems ()}
143
+ elif isinstance (input_object , list ):
144
+ return [byteify (element ) for element in input_object ]
145
+ elif isinstance (input_object , unicode ):
146
+ return input_object .encode ('utf-8' )
147
+ return input_object
148
+
149
+
136
150
if __name__ == '__main__' :
137
151
cli ()
0 commit comments