File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
10
10
11
11
- Don't fail if compiled translation files (.mo) don't exist, and Django isn't installed
12
12
- Fix some incorrect assumptions about types
13
+ - Allow XML IDs to be attributes
13
14
14
15
## [ 0.15.1] - 2020-10-21
15
16
Original file line number Diff line number Diff line change @@ -413,17 +413,19 @@ def do_unflatten(self):
413
413
)
414
414
415
415
def inthere (unflattened , id_name ):
416
- if self .xml :
416
+ if self .xml and not isinstance (unflattened .get (self .id_name ), Cell ):
417
+ # For an XML tag
417
418
return unflattened [id_name ]["text()" ].cell_value
418
419
else :
420
+ # For a JSON, or an XML attribute
419
421
return unflattened [id_name ].cell_value
420
422
421
423
if (
422
424
self .id_name in unflattened
423
425
and inthere (unflattened , self .id_name )
424
426
in main_sheet_by_ocid [root_id_or_none ]
425
427
):
426
- if self .xml :
428
+ if self .xml and not isinstance ( unflattened . get ( self . id_name ), Cell ) :
427
429
unflattened_id = unflattened .get (self .id_name )[
428
430
"text()"
429
431
].cell_value
@@ -1120,7 +1122,11 @@ def __repr__(self):
1120
1122
def append (self , item ):
1121
1123
if self .keyfield in item :
1122
1124
if self .xml :
1123
- if isinstance (item [self .keyfield ]["text()" ], Cell ):
1125
+ if isinstance (item [self .keyfield ], Cell ):
1126
+ # For an XML attribute
1127
+ key = item [self .keyfield ].cell_value
1128
+ elif isinstance (item [self .keyfield ]["text()" ], Cell ):
1129
+ # For an XML tag
1124
1130
key = item [self .keyfield ]["text()" ].cell_value
1125
1131
else :
1126
1132
key = item [self .keyfield ]["text()" ]
You can’t perform that action at this time.
0 commit comments