@@ -93,7 +93,7 @@ def __init__(self, schema_filename=None, root_schema_dict=None, main_sheet_name=
93
93
self .root_schema_dict = root_schema_dict
94
94
95
95
def parse (self ):
96
- fields = self .parse_schema_dict (self . main_sheet_name , '' , self .root_schema_dict )
96
+ fields = self .parse_schema_dict ('' , self .root_schema_dict )
97
97
for field , title in fields :
98
98
if self .use_titles :
99
99
if not title :
@@ -103,14 +103,14 @@ def parse(self):
103
103
else :
104
104
self .main_sheet .append (field )
105
105
106
- def parse_schema_dict (self , parent_name , parent_path , schema_dict , parent_id_fields = None , title_lookup = None ):
106
+ def parse_schema_dict (self , parent_path , schema_dict , parent_id_fields = None , title_lookup = None ):
107
107
if parent_path :
108
108
parent_path = parent_path + '/'
109
109
parent_id_fields = parent_id_fields or []
110
110
title_lookup = self .title_lookup if title_lookup is None else title_lookup
111
111
if 'properties' in schema_dict :
112
112
if 'id' in schema_dict ['properties' ]:
113
- id_fields = parent_id_fields + [parent_name + '/ id' ]
113
+ id_fields = parent_id_fields + [parent_path + ' id' ]
114
114
else :
115
115
id_fields = parent_id_fields
116
116
@@ -125,7 +125,6 @@ def parse_schema_dict(self, parent_name, parent_path, schema_dict, parent_id_fie
125
125
if 'object' in property_type_set :
126
126
self .flattened [parent_path + property_name ] = "object"
127
127
for field , child_title in self .parse_schema_dict (
128
- parent_name + '/' + property_name ,
129
128
parent_path + property_name ,
130
129
property_schema_dict ,
131
130
parent_id_fields = id_fields ,
@@ -150,22 +149,20 @@ def parse_schema_dict(self, parent_name, parent_path, schema_dict, parent_id_fie
150
149
raise ValueError
151
150
elif 'object' in type_set :
152
151
if title :
153
- title_lookup [title ].property_name = property_name + '[]'
154
- if hasattr (property_schema_dict ['items' ], '__reference__' ):
155
- sub_sheet_name = property_schema_dict ['items' ].__reference__ ['$ref' ].split ('/' )[- 1 ]
156
- else :
157
- sub_sheet_name = property_name
152
+ title_lookup [title ].property_name = property_name + '/0'
153
+
154
+ sub_sheet_name = ('_' .join (x [:3 ] for x in parent_path .split ('/' )) + property_name )[:31 ]
158
155
159
- self .sub_sheet_mapping [parent_name + '/' + property_name ] = sub_sheet_name
156
+ # self.sub_sheet_mapping[parent_name+'/'+property_name] = sub_sheet_name
160
157
161
158
if sub_sheet_name not in self .sub_sheets :
162
159
self .sub_sheets [sub_sheet_name ] = Sheet (root_id = self .root_id , name = sub_sheet_name )
163
160
sub_sheet = self .sub_sheets [sub_sheet_name ]
164
161
sub_sheet .title_lookup = title_lookup .get (title )
165
162
166
163
for field in id_fields :
167
- sub_sheet .add_field (field + ':' + property_name , id_field = True )
168
- fields = self .parse_schema_dict (parent_name + '/' + property_name + '[]' ,
164
+ sub_sheet .add_field (field , id_field = True )
165
+ fields = self .parse_schema_dict (
169
166
parent_path + property_name ,
170
167
property_schema_dict ['items' ],
171
168
parent_id_fields = id_fields ,
@@ -180,10 +177,10 @@ def parse_schema_dict(self, parent_name, parent_path, schema_dict, parent_id_fie
180
177
else :
181
178
sub_sheet .add_field (child_title )
182
179
else :
183
- sub_sheet .add_field (field )
180
+ sub_sheet .add_field (parent_path + property_name + '/' + field )
184
181
if self .rollup and 'rollUp' in property_schema_dict and field in property_schema_dict ['rollUp' ]:
185
182
rolledUp .add (field )
186
- yield property_name + '[] /' + field , (title + ':' + child_title if title and child_title else None )
183
+ yield property_name + '/0 /' + field , (title + ':' + child_title if title and child_title else None )
187
184
188
185
# Check that all items in rollUp are in the schema
189
186
if self .rollup and 'rollUp' in property_schema_dict :
@@ -209,6 +206,6 @@ def parse_schema_dict(self, parent_name, parent_path, schema_dict, parent_id_fie
209
206
'so this property has been ignored.' .format (
210
207
repr (property_type_set ),
211
208
property_name ,
212
- parent_name ))
209
+ parent_path ))
213
210
else :
214
- warn ('Skipping field "{}", because it has no properties.' .format (parent_name ))
211
+ warn ('Skipping field "{}", because it has no properties.' .format (parent_path ))
0 commit comments