Skip to content

Commit

Permalink
ocrd_page: enums constants should be str, #451
Browse files Browse the repository at this point in the history
  • Loading branch information
kba committed Apr 23, 2020
1 parent b416b1f commit 52b1a37
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ generate-page: repo/assets
--disable-generatedssuper-lookup \
--user-methods=$(GDS_PAGE_USER) \
repo/assets/data/schema/data/$(PAGE_VERSION).xsd
# hack to prevent #451
sed -i 's,(Enum):$$,(object):,' $(GDS_PAGE)
# hack to prevent #451: enum keys will be strings
sed -i 's/(Enum):$$/(str, Enum):/' $(GDS_PAGE)

#
# Repos
Expand Down
28 changes: 14 additions & 14 deletions ocrd_models/ocrd_models/ocrd_page_generateds.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-

#
# Generated Thu Apr 23 14:47:51 2020 by generateDS.py version 2.35.20.
# Generated Thu Apr 23 15:06:47 2020 by generateDS.py version 2.35.20.
# Python 3.6.9 (default, Apr 18 2020, 01:56:04) [GCC 8.4.0]
#
# Command line options:
Expand Down Expand Up @@ -945,14 +945,14 @@ def _cast(typ, value):
#


class AlignSimpleType(object):
class AlignSimpleType(str, Enum):
LEFT='left'
CENTRE='centre'
RIGHT='right'
JUSTIFY='justify'


class ChartTypeSimpleType(object):
class ChartTypeSimpleType(str, Enum):
BAR='bar'
LINE='line'
PIE='pie'
Expand All @@ -961,14 +961,14 @@ class ChartTypeSimpleType(object):
OTHER='other'


class ColourDepthSimpleType(object):
class ColourDepthSimpleType(str, Enum):
BILEVEL='bilevel'
GREYSCALE='greyscale'
COLOUR='colour'
OTHER='other'


class ColourSimpleType(object):
class ColourSimpleType(str, Enum):
BLACK='black'
BLUE='blue'
BROWN='brown'
Expand All @@ -987,7 +987,7 @@ class ColourSimpleType(object):
OTHER='other'


class GraphicsTypeSimpleType(object):
class GraphicsTypeSimpleType(str, Enum):
LOGO='logo'
LETTERHEAD='letterhead'
DECORATION='decoration'
Expand All @@ -1001,7 +1001,7 @@ class GraphicsTypeSimpleType(object):
OTHER='other'


class GroupTypeSimpleType(object):
class GroupTypeSimpleType(str, Enum):
PARAGRAPH='paragraph'
LIST='list'
LISTITEM='list-item'
Expand All @@ -1011,7 +1011,7 @@ class GroupTypeSimpleType(object):
OTHER='other'


class PageTypeSimpleType(object):
class PageTypeSimpleType(str, Enum):
FRONTCOVER='front-cover'
BACKCOVER='back-cover'
TITLE='title'
Expand All @@ -1022,7 +1022,7 @@ class PageTypeSimpleType(object):
OTHER='other'


class ProductionSimpleType(object):
class ProductionSimpleType(str, Enum):
"""Text production type"""
PRINTED='printed'
TYPEWRITTEN='typewritten'
Expand All @@ -1032,14 +1032,14 @@ class ProductionSimpleType(object):
OTHER='other'


class ReadingDirectionSimpleType(object):
class ReadingDirectionSimpleType(str, Enum):
LEFTTORIGHT='left-to-right'
RIGHTTOLEFT='right-to-left'
TOPTOBOTTOM='top-to-bottom'
BOTTOMTOTOP='bottom-to-top'


class TextDataTypeSimpleType(object):
class TextDataTypeSimpleType(str, Enum):
XSDDECIMAL='xsd:decimal' # Examples: "123.456", "+1234.456", "-1234.456", "-.456", "-456"
XSDFLOAT='xsd:float' # Examples: "123.456", "+1234.456", "-1.2344e56", "-.45E-6", "INF", "-INF", "NaN"
XSDINTEGER='xsd:integer' # Examples: "123456", "+00000012", "-1", "-456"
Expand All @@ -1051,14 +1051,14 @@ class TextDataTypeSimpleType(object):
OTHER='other' # An XSD type that is not listed or a custom type (use dataTypeDetails attribute).


class TextLineOrderSimpleType(object):
class TextLineOrderSimpleType(str, Enum):
TOPTOBOTTOM='top-to-bottom'
BOTTOMTOTOP='bottom-to-top'
LEFTTORIGHT='left-to-right'
RIGHTTOLEFT='right-to-left'


class TextTypeSimpleType(object):
class TextTypeSimpleType(str, Enum):
PARAGRAPH='paragraph'
HEADING='heading'
CAPTION='caption'
Expand All @@ -1079,7 +1079,7 @@ class TextTypeSimpleType(object):
OTHER='other'


class underlineStyleType(object):
class underlineStyleType(str, Enum):
SINGLE_LINE='singleLine'
DOUBLE_LINE='doubleLine'
OTHER='other'
Expand Down
1 change: 1 addition & 0 deletions tests/model/test_ocrd_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ def test_simple_types(self):
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))


Expand Down

0 comments on commit 52b1a37

Please sign in to comment.