(structure, end_physical_index)
| 431 | |
| 432 | |
| 433 | def post_processing(structure, end_physical_index): |
| 434 | # First convert page_number to start_index in flat list |
| 435 | for i, item in enumerate(structure): |
| 436 | item['start_index'] = item.get('physical_index') |
| 437 | if i < len(structure) - 1: |
| 438 | if structure[i + 1].get('appear_start') == 'yes': |
| 439 | item['end_index'] = structure[i + 1]['physical_index']-1 |
| 440 | else: |
| 441 | item['end_index'] = structure[i + 1]['physical_index'] |
| 442 | else: |
| 443 | item['end_index'] = end_physical_index |
| 444 | tree = list_to_tree(structure) |
| 445 | if len(tree)!=0: |
| 446 | return tree |
| 447 | else: |
| 448 | ### remove appear_start |
| 449 | for node in structure: |
| 450 | node.pop('appear_start', None) |
| 451 | node.pop('physical_index', None) |
| 452 | return structure |
| 453 | |
| 454 | def clean_structure_post(data): |
| 455 | if isinstance(data, dict): |
no test coverage detected