-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PAGE API: add __hash__ to generated code #443
Conversation
Codecov Report
@@ Coverage Diff @@
## master #443 +/- ##
==========================================
- Coverage 81.91% 80.13% -1.79%
==========================================
Files 39 40 +1
Lines 2328 2376 +48
Branches 429 433 +4
==========================================
- Hits 1907 1904 -3
- Misses 348 399 +51
Partials 73 73
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic! This works fine, and paves the way for the other additions as requested in #240...
Cannot recreate the PAGE XML with generateDS 2.30.11. With 2.35.18 it works but now the namespaces are missing again :/ @bertsky Can you please check whether this works as expected besides the missing PAGE nsprefix? |
... so instances of generateDS-generated class can be used as keys in dict etc.
I think the issue is that generateDS tries to use IMHO this needs to be fixed up-stream. In the meantime, I found that a sed one-liner after schema generation can fix the enum types. Test case to verify: def test_simple_types(self):
regions = self.pcgts.get_Page().get_TextRegion()
reg = regions[0]
self.assertTrue(isinstance(reg.get_type(), str))
self.assertEqual(reg.get_type(), TextTypeSimpleType.CREDIT)
self.assertTrue(isinstance(TextTypeSimpleType.CREDIT, str))
self.assertEqual(reg.get_type(), 'credit')
self.assertTrue(isinstance(TextTypeSimpleType.CREDIT, str))
reg.set_type(TextTypeSimpleType.PAGENUMBER)
self.assertEqual(reg.get_type(), 'page-number')
self.assertTrue(isinstance(reg.get_type(), str)) |
Great! So the generateDS problem is fairly limited and we can hope to live with it. Just of curiosity, because the diff of the generated source does not show it: What happens to non-string |
grep -r 'str, Enum' ocrd_models
ocrd_models/ocrd_models/ocrd_page_generateds.py:class AlignSimpleType(str, Enum):
ocrd_models/ocrd_models/ocrd_page_generateds.py:class ChartTypeSimpleType(str, Enum):
ocrd_models/ocrd_models/ocrd_page_generateds.py:class ColourDepthSimpleType(str, Enum):
ocrd_models/ocrd_models/ocrd_page_generateds.py:class ColourSimpleType(str, Enum):
ocrd_models/ocrd_models/ocrd_page_generateds.py:class GraphicsTypeSimpleType(str, Enum):
ocrd_models/ocrd_models/ocrd_page_generateds.py:class GroupTypeSimpleType(str, Enum):
ocrd_models/ocrd_models/ocrd_page_generateds.py:class PageTypeSimpleType(str, Enum):
ocrd_models/ocrd_models/ocrd_page_generateds.py:class ProductionSimpleType(str, Enum):
ocrd_models/ocrd_models/ocrd_page_generateds.py:class ReadingDirectionSimpleType(str, Enum):
ocrd_models/ocrd_models/ocrd_page_generateds.py:class TextDataTypeSimpleType(str, Enum):
ocrd_models/ocrd_models/ocrd_page_generateds.py:class TextLineOrderSimpleType(str, Enum):
ocrd_models/ocrd_models/ocrd_page_generateds.py:class TextTypeSimpleType(str, Enum):
ocrd_models/ocrd_models/ocrd_page_generateds.py:class underlineStyleType(str, Enum): |
... so instances of generateDS-generated class can be used as keys in dict etc.