Skip to content

Commit

Permalink
remove metadata.id, metadata.type duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
brambg committed May 11, 2023
1 parent f128bbb commit c38ee80
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions pagexml/model/physical_document_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,10 @@ def __init__(self, doc_id: Union[None, str] = None, doc_type: Union[None, str, L
self.type = doc_type
self.main_type = 'doc'
self.metadata = metadata if metadata else {}
if self.id and 'id' not in self.metadata:
self.metadata['id'] = self.id
if self.metadata and 'type' not in self.metadata:
self.metadata['type'] = self.type
# if self.id and 'id' not in self.metadata:
# self.metadata['id'] = self.id
# if self.metadata and 'type' not in self.metadata:
# self.metadata['type'] = self.type
self.reading_order: Dict[int, str] = reading_order if reading_order else {}
self.reading_order_number = {}
self.parent: Union[StructureDoc, None] = None
Expand Down
4 changes: 2 additions & 2 deletions tests/physical_document_model_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def test_json(self):
json_data = doc.json
self.assertEqual('doc1', json_data['id'])
self.assertEqual('book', json_data['type'])
self.assertEqual({'title': 'The Great Gatsby', 'id': 'doc1', 'type': 'book'}, json_data['metadata'])
self.assertEqual({'title': 'The Great Gatsby'}, json_data['metadata'])
self.assertEqual({}, json_data.get('reading_order', {}))

doc.reading_order = {1: 'page1', 2: 'page2', 3: 'page3'}
Expand Down Expand Up @@ -156,7 +156,7 @@ def test_json(self):
expected_json = {
'id': 'doc1',
'type': 'book',
'metadata': {'author': 'Jane Doe', 'id': 'doc1', 'type': 'book'},
'metadata': {'author': 'Jane Doe'},
'coords': [(0, 0), (0, 10), (10, 10), (10, 0)]
}
self.assertEqual(expected_json, self.doc.json)
Expand Down

0 comments on commit c38ee80

Please sign in to comment.