ocrd_models.ocrd_page_generateds   F
last analyzed

Complexity

Total Complexity 5361

Size/Duplication

Total Lines 16884
Duplicated Lines 27.03 %

Importance

Changes 0
Metric Value
wmc 5361
eloc 14042
dl 4563
loc 16884
rs 0.8
c 0
b 0
f 0

1795 Methods

Rating   Name   Duplication   Size   Complexity  
A GdsCollector_.write_messages() 0 3 2
A GdsCollector_.__init__() 0 5 2
A GdsCollector_.clear_messages() 0 2 1
A GdsCollector_.print_messages() 0 3 2
A GdsCollector_.add_message() 0 2 1
A GeneratedsSuper.utcoffset() 0 2 1
A GdsCollector_.get_messages() 0 2 1
A GeneratedsSuper.tzname() 0 2 1
A GeneratedsSuper.dst() 0 2 1
A GeneratedsSuper.__init__() 0 3 1
A MemberSpec_.get_data_type() 0 8 3
A MetadataType.__hash__() 0 2 1
A MetadataType.get_externalRef() 0 2 1
A MetadataType._exportAttributes() 0 4 3
A PageType.get_ImageRegion() 0 2 1
A PageType.set_ReadingOrder() 0 2 1
A PageType.add_Labels() 0 2 1
A MixedContainer.getName() 0 2 1
A GeneratedsSuper.get_class_obj_() 0 12 5
A PageType.get_imageXResolution() 0 2 1
A GeneratedsSuper.gds_validate_boolean() 0 7 2
A PageType.insert_NoiseRegion_at() 0 2 1
A PageType.get_MapRegion() 0 2 1
A MetadataType.factory() 0 10 4
A PageType.replace_CustomRegion_at() 0 2 1
A PageType.replace_UnknownRegion_at() 0 2 1
A GeneratedsSuper.gds_validate_base64() 0 2 1
B PageType.export() 0 23 8
A PageType.get_CustomRegion() 0 2 1
A MixedContainer.__init__() 0 5 1
A PageType.get_ChemRegion() 0 2 1
A PageType.set_UserDefined() 0 2 1
C LabelsType._buildAttributes() 0 17 9
A PageType.replace_MapRegion_at() 0 2 1
A PageType.set_primaryScript() 0 2 1
A PcGtsType.set_Page() 0 2 1
B PcGtsType.to_etree() 0 18 7
B PageType.validate_LanguageSimpleType() 0 13 6
A GeneratedsSuper.gds_validate_float_list() 0 9 3
A PageType.set_Layers() 0 2 1
A MetadataType.get_UserDefined() 0 2 1
A MetadataType.get_Created() 0 2 1
A GeneratedsSuper.gds_parse_boolean() 0 9 3
A PageType.set_imageXResolution() 0 2 1
A MemberSpec_.get_data_type_chain() 0 1 1
A LabelsType._buildChildren() 0 6 2
A PageType.get_primaryScript() 0 2 1
A LabelsType.set_externalModel() 0 2 1
A PageType.replace_GraphicRegion_at() 0 2 1
A LabelsType.get_externalModel() 0 2 1
A MetadataItemType.factory() 0 10 4
A PageType.set_readingDirection() 0 2 1
A PageType.replace_LineDrawingRegion_at() 0 2 1
A PageType.insert_SeparatorRegion_at() 0 2 1
A PcGtsType.get_ns_prefix_() 0 2 1
A PageType.set_UnknownRegion() 0 2 1
A PageType.get_primaryLanguage() 0 2 1
A PcGtsType.id() 0 6 2
A LabelsType.insert_Label_at() 0 2 1
A PageType.set_GraphicRegion() 0 2 1
A GeneratedsSuper.gds_format_integer() 0 2 1
A PageType.insert_ChartRegion_at() 0 2 1
A MetadataItemType.set_type() 0 2 1
A PageType.set_ns_prefix_() 0 2 1
A PageType.set_TextStyle() 0 2 1
A GeneratedsSuper.gds_parse_string() 0 2 1
A PageType.get_imageWidth() 0 2 1
A PageType.insert_LineDrawingRegion_at() 0 2 1
A PageType.set_AdvertRegion() 0 2 1
A PageType.get_Labels() 0 2 1
A MetadataType.build() 0 11 3
A MetadataType.set_Created() 0 2 1
B PageType.validate_imageResolutionUnitType() 0 13 6
A PageType.set_PrintSpace() 0 2 1
B GeneratedsSuper.gds_format_date() 0 26 6
A PageType.set_CustomRegion() 0 2 1
A PageType.add_SeparatorRegion() 0 2 1
A LabelsType.set_externalId() 0 2 1
C LabelsType._exportAttributes() 13 13 9
A LabelsType.__init__() 0 19 2
A LabelType.factory() 0 10 4
A LabelsType.replace_Label_at() 0 2 1
A LabelsType.get_externalId() 0 2 1
A GeneratedsSuper.gds_parse_date() 13 19 4
A PageType.set_imageResolutionUnit() 0 2 1
A PageType.get_AdvertRegion() 0 2 1
A PageType.get_ns_prefix_() 0 2 1
A GeneratedsSuper.gds_get_node_lineno_() 0 7 3
A GeneratedsSuper.gds_encode() 0 10 3
A LabelsType.set_ns_prefix_() 0 2 1
B PcGtsType.export() 0 23 8
A GeneratedsSuper.gds_format_decimal() 0 7 3
A PageType.add_UnknownRegion() 0 2 1
B GeneratedsSuper.gds_validate_simple_patterns() 0 17 6
A PageType.get_textLineOrder() 0 2 1
A PageType._region_class() 0 2 1
F PageType._exportChildren() 0 77 50
A PageType.get_imageYResolution() 0 2 1
A PageType.insert_TextRegion_at() 0 2 1
A MetadataItemType.get_value() 0 2 1
A PcGtsType.get_Metadata() 0 2 1
B GeneratedsSuper.gds_parse_time() 13 22 5
A LabelsType.__hash__() 0 2 1
B GeneratedsSuper.gds_parse_datetime() 13 28 5
A MixedContainer.exportLiteral() 0 21 3
A GeneratedsSuper.gds_format_string() 0 2 1
A MetadataItemType.add_Labels() 0 2 1
A PageType.add_AdvertRegion() 0 2 1
A PcGtsType.get_Page() 0 2 1
A PageType.add_GraphicRegion() 0 2 1
A PageType.set_MusicRegion() 0 2 1
A PageType.set_textLineOrder() 0 2 1
A PageType.set_LineDrawingRegion() 0 2 1
A PageType.get_secondaryLanguage() 0 2 1
A PageType.insert_CustomRegion_at() 0 2 1
A PageType.insert_MapRegion_at() 0 2 1
A PageType.replace_TableRegion_at() 0 2 1
A PageType.__hash__() 0 2 1
A PageType.get_ReadingOrder() 0 2 1
A MetadataType.set_MetadataItem() 0 2 1
A PageType.insert_AdvertRegion_at() 0 2 1
A MetadataItemType.set_date() 0 2 1
A GeneratedsSuper.gds_format_boolean() 0 2 1
A MetadataItemType.get_Labels() 0 2 1
F PageType._buildAttributes() 0 78 33
A PageType.get_custom() 0 2 1
A MemberSpec_.get_name() 0 1 1
A PageType.set_imageFilename() 0 2 1
A PageType.set_imageWidth() 0 2 1
B PcGtsType._exportChildren() 0 11 6
A MemberSpec_.__init__() 0 8 1
B PageType.validate_TextLineOrderSimpleType() 0 13 6
A LabelsType.get_ns_prefix_() 0 2 1
A PageType.get_MusicRegion() 0 2 1
A PageType.set_TableRegion() 0 2 1
A MemberSpec_.get_choice() 0 1 1
A PageType.add_ImageRegion() 0 2 1
A PageType.add_TextRegion() 0 2 1
A PageType.get_GraphicRegion() 0 2 1
A PageType.set_SeparatorRegion() 0 2 1
A LabelType.set_type() 0 2 1
A PageType.get_AlternativeImage() 0 2 1
A PageType.set_imageYResolution() 0 2 1
A GeneratedsSuper.gds_validate_string() 0 5 2
B LabelType.export() 0 22 8
B PageType.validate_ScriptSimpleType() 0 13 6
A GeneratedsSuper.gds_validate_decimal() 0 6 2
A GeneratedsSuper.gds_format_base64() 0 2 1
A LabelsType.factory() 0 10 4
A GeneratedsSuper.gds_djo_etl_transform() 0 2 1
A PageType.set_custom() 0 2 1
A GeneratedsSuper.gds_validate_integer_list() 0 9 3
A MetadataType.set_Creator() 0 2 1
F MetadataType._exportChildren() 0 27 14
A MetadataItemType.get_type() 0 2 1
A PageType.factory() 0 10 4
A PcGtsType._buildAttributes() 0 5 3
A LabelsType.add_Label() 0 2 1
A PageType.replace_NoiseRegion_at() 0 2 1
A PageType.add_AlternativeImage() 0 2 1
A PageType.insert_TableRegion_at() 0 2 1
A GeneratedsSuper.gds_validate_date() 0 2 1
A PageType.set_secondaryScript() 0 2 1
A GeneratedsSuper.gds_validate_builtin_ST_() 0 8 3
A PageType.insert_MathsRegion_at() 0 2 1
A PageType.get_LineDrawingRegion() 0 2 1
A GeneratedsSuper.gds_validate_integer() 0 6 2
A LabelsType.set_Label() 0 2 1
A PcGtsType._buildChildren() 0 11 3
A PcGtsType.set_ns_prefix_() 0 2 1
A LabelType.get_value() 0 2 1
A PageType.replace_SeparatorRegion_at() 0 2 1
A PageType.set_Border() 0 2 1
F PageType.to_etree() 0 97 44
A PageType.set_primaryLanguage() 0 2 1
A MetadataItemType.replace_Labels_at() 0 2 1
A MetadataType.get_Creator() 0 2 1
A GeneratedsSuper.__eq__() 0 9 2
A PageType.set_AlternativeImage() 0 2 1
A PageType.add_MathsRegion() 0 2 1
A MemberSpec_.get_container() 0 1 1
A LabelsType.set_comments() 0 2 1
A GeneratedsSuper.get_path_() 0 6 1
B MixedContainer.to_etree_simple() 0 14 8
A PcGtsType.__hash__() 0 2 1
A PcGtsType.factory() 0 10 4
A PcGtsType.has__content() 0 8 3
A GeneratedsSuper.gds_reverse_node_mapping() 0 3 1
A PageType.set_secondaryLanguage() 0 2 1
A MetadataItemType.insert_Labels_at() 0 2 1
A GeneratedsSuper.gds_format_float_list() 0 4 3
B GeneratedsSuper.gds_check_cardinality_() 0 28 8
A GeneratedsSuper.gds_sqa_etl_transform_db_obj() 0 2 1
F PageType.has__content() 0 30 25
A PcGtsType.set_Metadata() 0 2 1
A PageType.get_NoiseRegion() 0 2 1
B LabelType._exportAttributes() 10 10 7
A GeneratedsSuper.gds_format_decimal_list() 0 4 3
A PageType.id() 0 6 2
A PageType.insert_ImageRegion_at() 0 2 1
A PcGtsType.build() 0 11 3
A LabelType._exportChildren() 0 2 1
A LabelType.__hash__() 0 2 1
B PageType.validate_PageTypeSimpleType() 0 13 6
A PageType.get_imageFilename() 0 2 1
A GeneratedsSuper.gds_format_double_list() 0 4 3
A PageType.get_secondaryScript() 0 2 1
A MetadataType.get_MetadataItem() 0 2 1
A GeneratedsSuper.gds_build_any() 0 5 1
A PageType.get_imageHeight() 0 2 1
B LabelsType.export() 0 23 8
A GeneratedsSuper.__str__() 0 27 4
A GeneratedsSuper.convert_unicode() 0 9 4
A MixedContainer.export() 0 12 4
A PcGtsType.__init__() 0 12 1
B MetadataItemType.validate_typeType() 0 13 6
A GeneratedsSuper.__ne__() 0 2 1
A PcGtsType._exportAttributes() 0 4 3
A LabelsType.set_prefix() 0 2 1
A MetadataType.replace_MetadataItem_at() 0 2 1
B MixedContainer.to_etree() 0 20 7
F PageType.__init__() 0 137 18
A LabelsType.get_comments() 0 2 1
A MetadataItemType._exportChildren() 0 8 4
A LabelType._buildChildren() 0 2 1
A PageType.get_type() 0 2 1
A PageType.get_PrintSpace() 0 2 1
A MemberSpec_.set_container() 0 1 1
A GeneratedsSuper.gds_djo_etl_transform_db_obj() 0 2 1
A PageType.replace_TextRegion_at() 0 2 1
A MetadataItemType.set_Labels() 0 2 1
B GeneratedsSuper.gds_format_time() 30 30 6
A GeneratedsSuper.gds_validate_time() 0 2 1
A GeneratedsSuper.gds_validate_boolean_list() 0 11 3
A GeneratedsSuper.gds_parse_decimal() 0 6 2
A MetadataType.__init__() 0 31 4
A MemberSpec_.set_choice() 0 1 1
B LabelType._buildAttributes() 0 13 7
A MixedContainer.getValue() 0 2 1
A PageType.build() 0 11 3
A PageType.insert_ChemRegion_at() 0 2 1
A GeneratedsSuper.gds_validate_double() 0 6 2
A PcGtsType.get_pcGtsId() 0 2 1
A PageType.get_conf() 0 2 1
A MemberSpec_.set_name() 0 1 1
A MetadataType.set_ns_prefix_() 0 2 1
F PageType._buildChildren() 0 121 25
A GeneratedsSuper.gds_parse_float() 0 6 2
A PageType.get_readingDirection() 0 2 1
A PageType.get_ChartRegion() 0 2 1
A MetadataItemType.set_value() 0 2 1
A PageType.get_TextRegion() 0 2 1
B MixedContainer.exportSimple() 0 20 8
A GeneratedsSuper.gds_sqa_etl_transform() 0 2 1
A PageType.set_type() 0 2 1
A PageType.set_imageHeight() 0 2 1
A PageType.get_imageResolutionUnit() 0 2 1
B LabelType.to_etree() 16 16 7
A PageType.add_TableRegion() 0 2 1
A MemberSpec_.set_optional() 0 1 1
B MetadataType._buildChildren() 0 33 7
A MetadataType.set_UserDefined() 0 2 1
A PageType.get_TableRegion() 0 2 1
A PageType.add_MapRegion() 0 2 1
A PageType.set_ChartRegion() 0 2 1
A LabelType.get_comments() 0 2 1
A MetadataItemType.__init__() 0 22 3
A MetadataItemType.get_date() 0 2 1
A GeneratedsSuper.gds_str_lower() 0 2 1
A GeneratedsSuper.gds_format_double() 0 2 1
A MemberSpec_.get_child_attrs() 0 1 1
D PcGtsType.get_AllAlternativeImagePaths() 49 49 12
B MetadataItemType.export() 0 23 8
B PageType.validate_ConfSimpleType() 15 15 7
A GeneratedsSuper.gds_validate_defined_ST_() 0 8 3
A MetadataType._buildAttributes() 0 5 3
A MetadataType.get_Comments() 0 2 1
A MemberSpec_.set_data_type() 0 1 1
A MixedContainer.getCategory() 0 2 1
A LabelType.set_ns_prefix_() 0 2 1
A PageType.add_LineDrawingRegion() 0 2 1
A PageType.get_TextStyle() 0 2 1
A GeneratedsSuper.gds_parse_double() 0 6 2
A MetadataItemType.__hash__() 0 2 1
A MetadataItemType._buildChildren() 0 6 2
A PageType.get_Relations() 0 2 1
A PageType.get_Layers() 0 2 1
A PageType.set_orientation() 0 2 2
A MetadataItemType.get_ns_prefix_() 0 2 1
A PageType.set_Labels() 0 2 1
A PageType.replace_MusicRegion_at() 0 2 1
A LabelType.set_comments() 0 2 1
A MixedContainer.getContenttype() 0 2 1
A LabelsType.get_Label() 0 2 1
A MetadataType.insert_MetadataItem_at() 0 2 1
A LabelsType.has__content() 0 7 2
A PageType.set_NoiseRegion() 0 2 1
A LabelType.get_type() 0 2 1
A PageType.replace_AlternativeImage_at() 0 2 1
A PageType.replace_ChartRegion_at() 0 2 1
A MetadataType.get_LastChange() 0 2 1
A MetadataItemType.has__content() 0 7 2
A LabelType.build() 0 11 3
A PageType.get_MathsRegion() 0 2 1
A PageType.set_ChemRegion() 0 2 1
A MetadataItemType.set_name() 0 2 1
A PageType.insert_Labels_at() 0 2 1
C MetadataItemType._buildAttributes() 0 21 10
A PageType.replace_Labels_at() 0 2 1
A PageType.get_SeparatorRegion() 0 2 1
D PcGtsType.prune_ReadingOrder() 18 18 12
A PageType.set_TextRegion() 0 2 1
A LabelType.has__content() 0 7 2
A LabelsType.get_prefix() 0 2 1
A PageType.get_Border() 0 2 1
A LabelsType._exportChildren() 0 8 4
A GeneratedsSuper.gds_format_integer_list() 0 4 3
A GeneratedsSuper.gds_validate_datetime() 0 2 1
A PageType.insert_GraphicRegion_at() 0 2 1
A MemberSpec_.set_child_attrs() 0 1 1
A PageType.add_MusicRegion() 0 2 1
A MetadataItemType.get_name() 0 2 1
A PageType.replace_ChemRegion_at() 0 2 1
A GeneratedsSuper.gds_validate_float() 0 6 2
A LabelType.set_value() 0 2 1
A MetadataType.get_ns_prefix_() 0 2 1
A PageType.get_UnknownRegion() 0 2 1
A PageType.set_conf() 0 2 1
A GeneratedsSuper.get_path_list_() 0 7 3
A MetadataType.set_LastChange() 0 2 1
C MetadataItemType.to_etree() 0 20 9
A GeneratedsSuper.gds_format_float() 0 5 2
A PageType.set_MapRegion() 0 2 1
A PageType.add_CustomRegion() 0 2 1
A PageType.replace_MathsRegion_at() 0 2 1
B MetadataType.export() 0 23 8
A PageType.get_orientation() 0 2 1
A LabelType.__init__() 0 12 1
A GeneratedsSuper.gds_validate_decimal_list() 0 9 3
C MetadataItemType._exportAttributes() 0 13 9
A LabelType.get_ns_prefix_() 0 2 1
B PageType.validate_ReadingDirectionSimpleType() 0 13 6
A MemberSpec_.get_optional() 0 1 1
A PageType.insert_MusicRegion_at() 0 2 1
A PcGtsType.set_pcGtsId() 0 2 1
A PageType.replace_AdvertRegion_at() 0 2 1
A PageType.add_ChartRegion() 0 2 1
A MetadataType.add_MetadataItem() 0 2 1
A PageType.insert_UnknownRegion_at() 0 2 1
A PageType.replace_ImageRegion_at() 0 2 1
A MetadataItemType.build() 0 11 3
A PageType.insert_AlternativeImage_at() 0 2 1
F PageType._exportAttributes() 0 49 33
A GeneratedsSuper.gds_format_boolean_list() 0 4 3
A PageType.set_Relations() 0 2 1
A LabelsType.build() 0 11 3
A GeneratedsSuper.gds_parse_integer() 0 6 2
C MetadataType.to_etree() 0 29 11
A MetadataType.set_Comments() 0 2 1
A GeneratedsSuper.gds_validate_double_list() 0 10 3
B GeneratedsSuper.gds_format_datetime() 36 36 6
A PageType.add_NoiseRegion() 0 2 1
C LabelsType.to_etree() 0 20 9
B MetadataType.has__content() 0 12 7
A PageType.set_MathsRegion() 0 2 1
A MetadataType.set_externalRef() 0 2 1
A PageType.set_ImageRegion() 0 2 1
A PageType.get_UserDefined() 0 2 1
A PageType.add_ChemRegion() 0 2 1
A MetadataItemType.set_ns_prefix_() 0 2 1
A RegionType.get_Labels() 0 2 1
B GraphemesType.export() 0 23 8
A OrderedGroupType.factory() 0 10 4
A OrderedGroupType.insert_OrderedGroupIndexed_at() 0 2 1
A WordType.replace_AlternativeImage_at() 0 2 1
A RegionType.replace_MathsRegion_at() 0 2 1
B OrderedGroupIndexedType.validate_GroupTypeSimpleType() 0 13 6
A RolesType.get_ns_prefix_() 2 2 1
A RelationsType.get_ns_prefix_() 2 2 1
A GraphemeGroupType.set_ns_prefix_() 0 2 1
A MapRegionType.to_etree() 0 9 4
F TextRegionType._exportAttributes() 0 41 27
B GlyphType.__init__() 0 43 4
A UnorderedGroupType.get_RegionRef() 0 2 1
A RegionType.get_AdvertRegion() 0 2 1
A GlyphType.get_production() 0 2 1
A GraphemeType._buildChildren() 0 7 2
B ChemRegionType.export() 23 23 8
B UnorderedGroupType.__init__() 42 42 5
F OrderedGroupType._exportAttributes() 22 22 15
D RegionType._exportAttributes() 0 21 12
A GlyphType.get_comments() 0 2 1
A UnorderedGroupIndexedType.get_caption() 0 2 1
A AdvertRegionType.get_bgColour() 2 2 1
A UnknownRegionType._exportAttributes() 2 2 1
A RegionType.replace_AdvertRegion_at() 0 2 1
A MapRegionType.factory() 0 10 4
C ImageRegionType._exportAttributes() 0 14 9
A MathsRegionType._region_class() 2 2 1
A TableCellRoleType.set_colSpan() 0 2 1
B OrderedGroupType._buildChildren() 26 26 6
F RegionType.has__content() 0 25 20
A OrderedGroupType.set_caption() 0 2 1
A OrderedGroupIndexedType.get_id() 0 2 1
D GraphemeBaseType.to_etree() 0 26 12
A GridPointsType.has__content() 0 7 2
A OrderedGroupIndexedType.get_OrderedGroupIndexed() 0 2 1
A ChartRegionType.get_bgColour() 0 2 1
A GraphicRegionType.get_numColours() 2 2 1
F TextRegionType.to_etree() 0 40 19
C AdvertRegionType.get_AllRegions() 58 58 10
A TextRegionType._buildChildren() 0 17 4
A ChartRegionType.set_ns_prefix_() 0 2 1
A TableCellRoleType._exportChildren() 0 2 1
A GraphemesType.build() 0 11 3
F RegionType._exportChildren() 0 62 40
A GraphemeGroupType.__hash__() 0 2 1
C TextEquivType.to_etree() 0 26 11
A RolesType.set_TableCellRole() 2 2 1
A RegionType.add_NoiseRegion() 0 2 1
D OrderedGroupType._exportChildren() 20 20 12
F TextStyleType.to_etree() 0 50 24
A GraphicRegionType.__init__() 15 15 1
A RelationType.set_SourceRegionRef() 0 2 1
F UnorderedGroupType._exportAttributes() 22 22 15
A TableCellRoleType.set_ns_prefix_() 0 2 1
A TextStyleType.set_fontSize() 0 2 1
A RegionType.add_AlternativeImage() 0 2 1
A GraphemesType.get_ns_prefix_() 0 2 1
A ImageRegionType._buildChildren() 0 3 1
A RegionType.get_TextRegion() 0 2 1
A GlyphType.set_Coords() 0 2 4
A LayerType.set_id() 0 2 1
A TextRegionType.get_primaryScript() 0 2 1
A RegionType.get_id() 0 2 1
A GlyphType.build() 0 11 3
A OrderedGroupType.set_regionRef() 0 2 1
A AlternativeImageType.set_conf() 0 2 1
B BorderType.export() 0 23 8
B UserDefinedType.export() 23 23 8
A TextRegionType.set_readingDirection() 0 2 1
A GraphemeBaseType.get_extensiontype_() 0 1 1
A GlyphType.get_Labels() 0 2 1
B WordType.validate_ProductionSimpleType() 0 13 6
A BaselineType._buildChildren() 0 2 1
A TextLineType.set_readingDirection() 0 2 1
A UserDefinedType._exportAttributes() 2 2 1
A ImageRegionType.__hash__() 0 2 1
A BorderType._buildAttributes() 0 2 1
A OrderedGroupIndexedType.set_UserDefined() 0 2 1
D MusicRegionType._get_recursive_regions() 25 25 12
B UnorderedGroupIndexedType.__init__() 0 44 5
A SeparatorRegionType.set_colour() 2 2 1
A GraphemeBaseType.set_charType() 0 2 1
B GraphemeBaseType.export() 0 23 8
B AlternativeImageType._buildAttributes() 0 15 7
A TextEquivType.get_Unicode() 0 2 1
A NonPrintingCharType.set_ns_prefix_() 0 2 1
A GridType.get_ns_prefix_() 2 2 1
A WordType.replace_Glyph_at() 0 2 1
A TextStyleType.build() 0 11 3
A TextLineType.get_Word() 0 2 1
A RelationsType.has__content() 7 7 2
B TextRegionType.__init__() 0 45 3
A OrderedGroupType.set_continuation() 0 2 1
A PrintSpaceType._buildAttributes() 2 2 1
A NonPrintingCharType.get_ns_prefix_() 0 2 1
A RegionType.get_ns_prefix_() 0 2 1
A RegionType.replace_ChartRegion_at() 0 2 1
A ReadingOrderType.get_conf() 0 2 1
B OrderedGroupType.export() 0 23 8
A RegionType.add_TextRegion() 0 2 1
A RegionType.set_extensiontype_() 0 1 1
A RegionType.set_Roles() 0 2 1
A GraphemeType.set_ns_prefix_() 0 2 1
A UnorderedGroupIndexedType.__hash__() 0 2 1
A NonPrintingCharType._buildChildren() 0 3 1
A UserAttributeType._exportChildren() 0 2 1
A GraphemesType.set_NonPrintingChar() 0 2 1
A UserAttributeType._buildChildren() 0 2 1
A GridType.set_ns_prefix_() 2 2 1
F TextRegionType._buildAttributes() 0 70 29
A BaselineType.build() 0 11 3
A ChartRegionType.build() 0 11 3
A GridType.build() 11 11 3
B UnknownRegionType.export() 23 23 8
A UnorderedGroupIndexedType.replace_Labels_at() 0 2 1
A CoordsType._buildAttributes() 12 12 5
A RelationType._buildChildren() 0 16 4
A TextRegionType._region_class() 0 2 1
A TextEquivType.get_comments() 0 2 1
A RegionType.replace_TableRegion_at() 0 2 1
A UnorderedGroupType.get_UnorderedGroupChildren() 0 6 1
A TextLineType.set_secondaryScript() 0 2 1
A RegionRefType.get_regionRef() 0 2 1
F TableRegionType._buildAttributes() 0 43 19
A UnorderedGroupType.set_OrderedGroup() 0 2 1
A WordType.set_custom() 0 2 1
A UserAttributeType.factory() 0 10 4
A RelationsType._buildChildren() 6 6 2
A UserAttributeType.build() 0 11 3
B GridPointsType.export() 0 22 8
A CustomRegionType._buildAttributes() 0 6 3
B MapRegionType.export() 0 23 8
A RegionType.replace_SeparatorRegion_at() 0 2 1
A TextLineType.get_readingDirection() 0 2 1
A UnknownRegionType.to_etree() 7 7 3
A RegionType.get_AlternativeImage() 0 2 1
A TextStyleType.get_fontFamily() 0 2 1
A GraphicRegionType.get_type() 2 2 1
A MusicRegionType.set_ns_prefix_() 2 2 1
A TableCellRoleType.get_rowSpan() 0 2 1
B OrderedGroupIndexedType.export() 0 23 8
A WordType.get_comments() 0 2 1
F WordType._buildAttributes() 0 38 17
C LineDrawingRegionType._exportAttributes() 14 14 9
F RegionType._buildChildren() 0 96 20
A TextLineType.set_production() 0 2 1
A GraphicRegionType.__hash__() 2 2 1
A OrderedGroupType.set_Labels() 0 2 1
A LayersType.__init__() 11 11 2
A TextLineType.factory() 0 10 4
A TextRegionType.get_readingOrientation() 0 2 1
B TableRegionType.export() 0 23 8
B RegionRefType.export() 0 22 8
A GraphemeBaseType.set_index() 0 2 1
A TableRegionType.set_lineSeparators() 0 2 1
B TextRegionType.validate_ProductionSimpleType() 0 13 6
A GlyphType.set_UserDefined() 0 2 1
A TextLineType.set_id() 0 2 1
A GridType.set_GridPoints() 2 2 1
A OrderedGroupIndexedType.get_UnorderedGroupIndexed() 0 2 1
A TextLineType.set_Labels() 0 2 1
B RegionRefIndexedType.to_etree() 14 14 6
A UnorderedGroupType.get_id() 0 2 1
A RegionType.insert_Labels_at() 0 2 1
A GraphemeBaseType.get_custom() 0 2 1
A UserAttributeType.set_ns_prefix_() 0 2 1
A UnknownRegionType.has__content() 7 7 2
A TableRegionType.get_embText() 0 2 1
A ChartRegionType._region_class() 0 2 1
A GraphemeBaseType.get_id() 0 2 1
A TextStyleType.get_smallCaps() 0 2 1
A GraphemeBaseType.set_ligature() 0 2 1
A OrderedGroupIndexedType.add_RegionRefIndexed() 0 2 1
A AlternativeImageType.get_comments() 0 2 1
A WordType.build() 0 11 3
A ReadingOrderType.build() 0 11 3
A GraphemeGroupType.build() 0 11 3
A CoordsType.get_points() 0 2 1
A RegionType.set_AlternativeImage() 0 2 1
A MathsRegionType.get_orientation() 2 2 1
F OrderedGroupType.to_etree() 0 35 16
C SeparatorRegionType.get_AllRegions() 58 58 10
A UserAttributeType.get_value() 0 2 1
A ChartRegionType._exportChildren() 0 2 1
A TableCellRoleType.factory() 0 10 4
A TableCellRoleType.get_columnIndex() 0 2 1
A WordType.insert_TextEquiv_at() 0 2 1
A LineDrawingRegionType._buildChildren() 3 3 1
A MathsRegionType.__init__() 11 11 1
A GraphicRegionType.get_embText() 2 2 1
A TableCellRoleType.set_columnIndex() 0 2 1
A AdvertRegionType.build() 11 11 3
B TextRegionType.validate_ScriptSimpleType() 0 13 6
F GraphemeBaseType._exportAttributes() 0 27 16
A TableCellRoleType.has__content() 0 7 2
A RegionRefIndexedType.set_regionRef() 0 2 1
A ReadingOrderType.has__content() 0 8 3
A TableRegionType.get_rows() 0 2 1
B TextLineType.__init__() 0 52 5
A GridPointsType.build() 0 11 3
A RegionType.set_ns_prefix_() 0 2 1
B UnorderedGroupIndexedType.has__content() 0 11 6
B PageType.get_ReadingOrderGroups() 35 35 7
A SeparatorRegionType.get_colour() 2 2 1
A UserAttributeType.set_value() 0 2 1
D GraphicRegionType._get_recursive_regions() 25 25 12
F UnorderedGroupIndexedType._buildAttributes() 39 39 19
A RegionType.set_comments() 0 2 1
A WordType.factory() 0 10 4
A UserAttributeType.get_type() 0 2 1
A BaselineType.get_points() 0 2 1
A SeparatorRegionType.__init__() 11 11 1
A RegionType.add_AdvertRegion() 0 2 1
A GraphicRegionType.set_orientation() 2 2 2
A UnknownRegionType._buildAttributes() 2 2 1
A UnorderedGroupIndexedType.get_index() 0 2 1
B AdvertRegionType.export() 23 23 8
A RegionType.add_GraphicRegion() 0 2 1
B UnorderedGroupIndexedType.export() 0 23 8
A TextLineType.set_index() 0 2 1
F OrderedGroupIndexedType._buildAttributes() 39 39 19
A MapRegionType._get_recursive_reading_order() 0 11 5
A TextLineType.get_custom() 0 2 1
A MusicRegionType.get_ns_prefix_() 2 2 1
A UnorderedGroupType.replace_UnorderedGroup_at() 0 2 1
A AlternativeImageType.__init__() 0 12 1
A OrderedGroupIndexedType.build() 0 11 3
D UnorderedGroupIndexedType._exportChildren() 20 20 12
B TextStyleType.__init__() 0 46 1
A TextRegionType.get_type() 0 2 1
A RolesType.__init__() 8 8 1
A BorderType.build() 0 11 3
A GraphemesType.get_NonPrintingChar() 0 2 1
A MathsRegionType.set_bgColour() 2 2 1
A WordType.set_AlternativeImage() 0 2 1
A TextStyleType.get_ns_prefix_() 0 2 1
A UnorderedGroupType.get_custom() 0 2 1
A LayerType._exportChildren() 0 8 4
A MapRegionType.set_orientation() 0 2 2
A GraphicRegionType.set_numColours() 2 2 1
B RelationType._exportChildren() 0 14 8
B GridType.export() 23 23 8
B TextStyleType.export() 0 22 8
A AlternativeImageType._exportChildren() 0 2 1
A GraphemesType.replace_Grapheme_at() 0 2 1
A UnorderedGroupIndexedType.get_Labels() 0 2 1
A BorderType.get_Coords() 0 2 1
A UnorderedGroupIndexedType.set_RegionRef() 0 2 1
A ChemRegionType.set_bgColour() 2 2 1
B ChartRegionType.to_etree() 0 17 8
A TextRegionType.set_secondaryScript() 0 2 1
A UnorderedGroupIndexedType.get_UserDefined() 0 2 1
A WordType.add_TextEquiv() 0 2 1
A OrderedGroupType.clear_AllIndexed() 0 6 1
A GlyphType.set_custom() 0 2 1
A RegionType.get_extensiontype_() 0 1 1
A ChartRegionType.set_type() 0 2 1
A UserDefinedType.has__content() 7 7 2
A RelationType.get_type() 0 2 1
A GraphemeGroupType.insert_NonPrintingChar_at() 0 2 1
A GlyphType.get_custom() 0 2 1
A RelationType.factory() 0 10 4
A RegionType.set_Labels() 0 2 1
A OrderedGroupType.get_OrderedGroupIndexed() 0 2 1
A GridPointsType.set_ns_prefix_() 0 2 1
C GraphicRegionType._buildAttributes() 25 25 11
A NonPrintingCharType.__hash__() 0 2 1
A ChartRegionType.get_numColours() 0 2 1
A LayersType.add_Layer() 2 2 1
A BaselineType.__hash__() 0 2 1
A GlyphType.set_TextStyle() 0 2 1
A WordType.set_TextEquiv() 0 2 1
A CustomRegionType.set_ns_prefix_() 0 2 1
A RegionRefType.__init__() 0 8 1
A RegionType.factory() 0 10 4
A UnorderedGroupType.insert_Labels_at() 0 2 1
A TableRegionType.__hash__() 0 2 1
A CoordsType.__init__() 10 10 1
A LayersType.get_Layer() 2 2 1
A UnorderedGroupType.get_caption() 0 2 1
A CoordsType._buildChildren() 0 2 1
A BaselineType.__init__() 10 10 1
A CoordsType.get_conf() 0 2 1
B LineDrawingRegionType.to_etree() 15 15 7
A UnorderedGroupIndexedType.build() 0 11 3
A UnorderedGroupIndexedType.replace_RegionRef_at() 0 2 1
A RegionRefType.set_ns_prefix_() 0 2 1
A WordType.get_TextEquiv() 0 2 1
A AdvertRegionType._buildAttributes() 12 12 5
A OrderedGroupIndexedType.get_continuation() 0 2 1
A GraphicRegionType.factory() 10 10 4
A RelationsType._buildAttributes() 2 2 1
B TextEquivType.validate_indexType() 11 11 6
A UserDefinedType.__hash__() 2 2 1
B GraphicRegionType.to_etree() 15 15 7
A UnorderedGroupType.insert_OrderedGroup_at() 0 2 1
A TableRegionType.set_columns() 0 2 1
A ChartRegionType.factory() 0 10 4
A ChemRegionType.set_ns_prefix_() 2 2 1
A RegionRefIndexedType._exportChildren() 0 2 1
A GridType.replace_GridPoints_at() 2 2 1
A GraphemeGroupType.__init__() 0 17 3
A WordType.get_readingDirection() 0 2 1
A GraphicRegionType.has__content() 7 7 2
A TextRegionType.set_orientation() 0 2 2
A UserDefinedType.set_UserAttribute() 2 2 1
A TextLineType.insert_TextEquiv_at() 0 2 1
A CustomRegionType.get_ns_prefix_() 0 2 1
B WordType.validate_LanguageSimpleType() 0 13 6
A RegionRefType.has__content() 0 7 2
A UserDefinedType.add_UserAttribute() 2 2 1
F OrderedGroupIndexedType.to_etree() 37 37 17
A OrderedGroupIndexedType.set_type() 0 2 1
A GlyphType.get_TextStyle() 0 2 1
A UnorderedGroupIndexedType.set_OrderedGroup() 0 2 1
A UnorderedGroupIndexedType.set_continuation() 0 2 1
A GraphemeBaseType._buildChildren() 0 6 2
A TextLineType.add_TextEquiv() 0 2 1
A UnorderedGroupType.set_RegionRef() 0 2 1
A GridType.insert_GridPoints_at() 2 2 1
A OrderedGroupIndexedType.set_ns_prefix_() 0 2 1
A CustomRegionType._exportChildren() 0 2 1
A RegionType.insert_CustomRegion_at() 0 2 1
A LayerType.get_zIndex() 0 2 1
A GlyphType.get_UserDefined() 0 2 1
A TextEquivType.get_conf() 0 2 1
A RelationsType.set_ns_prefix_() 2 2 1
A SeparatorRegionType.get_ns_prefix_() 2 2 1
A RegionType.get_NoiseRegion() 0 2 1
A TextStyleType.set_serif() 0 2 1
A ReadingOrderType._exportAttributes() 0 4 3
A UnknownRegionType.set_ns_prefix_() 2 2 1
B TextStyleType.validate_UnderlineStyleSimpleType() 0 13 6
B OrderedGroupType.validate_GroupTypeSimpleType() 0 13 6
A LineDrawingRegionType.__init__() 15 15 1
A GraphemeType._exportAttributes() 0 2 1
A AlternativeImageType.get_conf() 0 2 1
A TableRegionType.get_orientation() 0 2 1
A TextEquivType.set_dataType() 0 2 1
A RegionType.add_Labels() 0 2 1
A OrderedGroupType.add_OrderedGroupIndexed() 0 2 1
A TableRegionType._exportChildren() 0 9 4
A LayerType.insert_RegionRef_at() 0 2 1
A GraphemesType.get_Grapheme() 0 2 1
A RegionType.insert_ImageRegion_at() 0 2 1
A GraphemeBaseType.get_comments() 0 2 1
A WordType.set_Coords() 0 2 4
A TextStyleType.set_underlined() 0 2 1
A GraphemesType.set_ns_prefix_() 0 2 1
A UserDefinedType._buildChildren() 6 6 2
A WordType.set_production() 0 2 1
C ChemRegionType.get_AllRegions() 58 58 10
A RelationsType.__hash__() 2 2 1
C PageType.get_AllRegions() 0 58 10
A WordType.replace_Labels_at() 0 2 1
B MusicRegionType.validate_ColourSimpleType() 13 13 6
A RegionType.set_UserDefined() 0 2 1
A TextLineType.get_Baseline() 0 2 1
A OrderedGroupType.get_id() 0 2 1
C RelationType._buildAttributes() 0 18 9
A AdvertRegionType._region_class() 2 2 1
B NonPrintingCharType.export() 0 23 8
A ChemRegionType.build() 11 11 3
A WordType.get_AlternativeImage() 0 2 1
A NonPrintingCharType._buildAttributes() 0 2 1
A GlyphType.get_id() 0 2 1
A GlyphType.get_symbol() 0 2 1
A TextStyleType.get_letterSpaced() 0 2 1
A RegionRefType.build() 0 11 3
A MusicRegionType.get_orientation() 2 2 1
A WordType.get_TextStyle() 0 2 1
A ReadingOrderType._buildChildren() 0 11 3
B ReadingOrderType.export() 0 23 8
A OrderedGroupIndexedType.insert_UnorderedGroupIndexed_at() 0 2 1
A TextStyleType.get_serif() 0 2 1
A RegionRefIndexedType._exportAttributes() 0 7 5
A AdvertRegionType._exportAttributes() 8 8 5
A GlyphType.insert_AlternativeImage_at() 0 2 1
A GlyphType.__hash__() 0 2 1
A TextRegionType.get_secondaryScript() 0 2 1
B AlternativeImageType.validate_ConfSimpleType() 15 15 7
A TableRegionType._buildChildren() 0 7 2
A UnorderedGroupIndexedType.set_UserDefined() 0 2 1
A OrderedGroupIndexedType.replace_UnorderedGroupIndexed_at() 0 2 1
A RegionType.replace_UnknownRegion_at() 0 2 1
A TableRegionType.set_Grid() 0 2 1
A NoiseRegionType.has__content() 7 7 2
A GraphicRegionType._get_recursive_reading_order() 11 11 5
C LineDrawingRegionType.get_AllRegions() 58 58 10
A TextStyleType.set_fontFamily() 0 2 1
A OrderedGroupType.get_AllIndexed() 22 22 5
A OrderedGroupIndexedType.get_comments() 0 2 1
D ChartRegionType._buildAttributes() 0 30 13
A ImageRegionType.set_bgColour() 0 2 1
A GraphemesType.insert_Grapheme_at() 0 2 1
A TableRegionType.get_lineSeparators() 0 2 1
B UserAttributeType.export() 0 22 8
B BaselineType.export() 0 22 8
A RegionType.set_LineDrawingRegion() 0 2 1
A UnorderedGroupType.set_ns_prefix_() 0 2 1
A UnorderedGroupIndexedType.set_Labels() 0 2 1
A AdvertRegionType.set_ns_prefix_() 2 2 1
A AdvertRegionType._buildChildren() 3 3 1
A NonPrintingCharType._exportAttributes() 0 2 1
A OrderedGroupType.add_UnorderedGroupIndexed() 0 2 1
A TableRegionType.build() 0 11 3
A ChemRegionType._region_class() 2 2 1
A OrderedGroupIndexedType.add_OrderedGroupIndexed() 0 2 1
A LayersType.factory() 10 10 4
B CoordsType.validate_PointsType() 10 10 6
A RelationType.set_TargetRegionRef() 0 2 1
A RegionType.get_Roles() 0 2 1
A OrderedGroupIndexedType.add_Labels() 0 2 1
A ReadingOrderType._buildAttributes() 0 7 3
A TextLineType.set_Baseline() 0 2 1
A BorderType.factory() 0 10 4
A TextRegionType.get_readingDirection() 0 2 1
A RegionType.set_ChartRegion() 0 2 1
A TextRegionType.set_leading() 0 2 1
A LayerType.get_id() 0 2 1
A SeparatorRegionType.get_orientation() 2 2 1
A TextLineType.replace_AlternativeImage_at() 0 2 1
A OrderedGroupIndexedType.set_custom() 0 2 1
A NoiseRegionType.__init__() 7 7 1
A RegionType.add_ImageRegion() 0 2 1
C TextLineType.has__content() 0 14 9
A AlternativeImageType.has__content() 0 7 2
B TextEquivType.export() 0 23 8
A AdvertRegionType.get_orientation() 2 2 1
A ReadingOrderType.get_OrderedGroup() 0 2 1
C GraphicRegionType.get_AllRegions() 58 58 10
B BaselineType.validate_PointsType() 10 10 6
B AlternativeImageType._exportAttributes() 10 10 7
A GridPointsType._exportAttributes() 0 7 5
A ChartRegionType._buildChildren() 0 3 1
A RelationType.set_Labels() 0 2 1
A BaselineType.get_conf() 0 2 1
A GridPointsType._buildChildren() 0 2 1
F UnorderedGroupType.to_etree() 0 35 16
A WordType.set_comments() 0 2 1
A GraphicRegionType.get_ns_prefix_() 2 2 1
A RegionType.set_id() 0 2 1
B ImageRegionType.to_etree() 0 15 7
A GraphemesType.__hash__() 0 2 1
A GraphemesType.set_Grapheme() 0 2 1
A GraphemeBaseType.set_id() 0 2 1
A MathsRegionType._buildChildren() 3 3 1
A MusicRegionType.has__content() 7 7 2
A GridType.factory() 10 10 4
A OrderedGroupIndexedType.get_caption() 0 2 1
A UnorderedGroupType.get_Labels() 0 2 1
A GraphicRegionType.get_orientation() 2 2 1
A MusicRegionType._region_class() 2 2 1
A RolesType._buildChildren() 6 6 2
A LayerType._buildChildren() 0 6 2
A RelationType.get_comments() 0 2 1
A OrderedGroupType.insert_Labels_at() 0 2 1
A TextRegionType.set_TextEquiv() 0 2 1
A UserAttributeType.get_description() 0 2 1
A UserDefinedType.__init__() 11 11 2
A TextEquivType.has__content() 0 8 3
A TextRegionType.set_align() 0 2 1
A GraphemeType._exportChildren() 0 9 4
A GridPointsType.set_points() 0 2 1
A TextRegionType.set_textLineOrder() 0 2 1
B TextEquivType._exportChildren() 0 13 6
B RegionRefIndexedType.export() 0 22 8
A RolesType.to_etree() 13 13 5
A UnorderedGroupType.get_UserDefined() 0 2 1
F GraphemeBaseType._buildAttributes() 0 36 17
A GlyphType.set_production() 0 2 1
A GridType.has__content() 7 7 2
C TableRegionType.to_etree() 0 24 11
A ChemRegionType.get_bgColour() 2 2 1
A GraphemeGroupType.set_NonPrintingChar() 0 2 1
A LayerType.build() 0 11 3
A ImageRegionType.get_embText() 0 2 1
B ReadingOrderType._exportChildren() 0 11 6
A TextRegionType.get_production() 0 2 1
A RelationsType.factory() 10 10 4
A BaselineType.set_points() 0 2 1
A GraphemeGroupType.get_NonPrintingChar() 0 2 1
A RelationsType.replace_Relation_at() 2 2 1
A RegionType.get_LineDrawingRegion() 0 2 1
A RegionType.get_MathsRegion() 0 2 1
A ChemRegionType.factory() 10 10 4
B RelationType.validate_typeType1() 0 13 6
A LayersType.build() 11 11 3
A ChartRegionType.__init__() 0 17 1
A TextStyleType.factory() 0 10 4
A TextStyleType.set_subscript() 0 2 1
A UnorderedGroupType.__hash__() 0 2 1
A ImageRegionType.has__content() 0 7 2
A RelationType.get_id() 0 2 1
A TextLineType.get_Labels() 0 2 1
C MapRegionType.get_AllRegions() 0 58 10
A NonPrintingCharType.__init__() 0 7 1
A TextStyleType.get_fontSize() 0 2 1
A LineDrawingRegionType.get_bgColour() 2 2 1
A WordType.get_language() 0 2 1
B LayerType._exportAttributes() 0 10 7
B ReadingOrderType.to_etree() 0 18 7
A AlternativeImageType.set_filename() 0 2 1
C MusicRegionType.get_AllRegions() 58 58 10
B OrderedGroupIndexedType._buildChildren() 26 26 6
F RegionType.__init__() 0 101 17
C UserAttributeType._buildAttributes() 0 18 9
A RolesType.get_TableCellRole() 2 2 1
A TextStyleType.get_bold() 0 2 1
B UserAttributeType.to_etree() 0 18 8
B UnorderedGroupType._buildChildren() 26 26 6
B TextRegionType.export() 0 23 8
A GraphemeType.get_Coords() 0 2 1
A UserAttributeType.has__content() 0 7 2
A ChemRegionType.get_orientation() 2 2 1
A GraphemesType.has__content() 0 9 4
A TableRegionType.set_embText() 0 2 1
A WordType.replace_TextEquiv_at() 0 2 1
A LineDrawingRegionType.factory() 10 10 4
A RegionRefIndexedType.get_ns_prefix_() 0 2 1
A GraphemeType.build() 0 11 3
A ChartRegionType._get_recursive_reading_order() 0 11 5
A TableRegionType.set_orientation() 0 2 2
A OrderedGroupType.get_Labels() 0 2 1
A GraphemeBaseType.get_ns_prefix_() 0 2 1
A TextLineType.replace_TextEquiv_at() 0 2 1
A RegionType.replace_NoiseRegion_at() 0 2 1
A UnorderedGroupIndexedType.set_comments() 0 2 1
A UnorderedGroupType.set_caption() 0 2 1
A TextLineType.get_index() 0 2 1
A TableCellRoleType._buildChildren() 0 2 1
A MapRegionType.__init__() 0 9 1
A PrintSpaceType.__init__() 8 8 1
A GraphemeType.__init__() 0 9 1
A MapRegionType._exportAttributes() 0 5 3
A OrderedGroupIndexedType.sort_AllIndexed() 14 14 5
A UnorderedGroupType.get_OrderedGroup() 0 2 1
A OrderedGroupType.insert_RegionRefIndexed_at() 0 2 1
A RegionType.set_CustomRegion() 0 2 1
B OrderedGroupIndexedType.__init__() 44 44 5
A GridType.get_GridPoints() 2 2 1
A TableRegionType.has__content() 0 8 3
B GlyphType.validate_ScriptSimpleType() 0 13 6
A SeparatorRegionType._exportAttributes() 8 8 5
A TextRegionType.has__content() 0 10 5
A TextEquivType.set_PlainText() 0 2 1
A RegionType.replace_TextRegion_at() 0 2 1
A OrderedGroupType.sort_AllIndexed() 14 14 5
A LayerType.set_ns_prefix_() 0 2 1
A TextLineType.replace_Word_at() 0 2 1
A RegionType.set_custom() 0 2 1
A OrderedGroupIndexedType.set_id() 0 2 1
A MathsRegionType.build() 11 11 3
B GridPointsType.validate_PointsType() 10 10 6
A TextStyleType.get_strikethrough() 0 2 1
A RolesType.build() 11 11 3
A UnorderedGroupType.get_comments() 0 2 1
A RelationType.get_Labels() 0 2 1
A RegionRefType._buildChildren() 0 2 1
A RegionType.add_CustomRegion() 0 2 1
A MapRegionType.has__content() 0 7 2
A TextRegionType.add_TextEquiv() 0 2 1
A CoordsType.has__content() 0 7 2
A OrderedGroupType.get_custom() 0 2 1
A PrintSpaceType.set_ns_prefix_() 2 2 1
A RegionRefType.__hash__() 0 2 1
A NoiseRegionType.set_ns_prefix_() 2 2 1
A LayersType.set_Layer() 2 2 1
B CoordsType.export() 0 22 8
A RegionType.get_ChemRegion() 0 2 1
A MapRegionType.__hash__() 0 2 1
A GlyphType.set_symbol() 0 2 1
A GlyphType.set_ligature() 0 2 1
A UnorderedGroupIndexedType.add_OrderedGroup() 0 2 1
A BorderType._exportAttributes() 0 2 1
A TextStyleType.get_italic() 0 2 1
B RegionType.export() 0 23 8
A RegionType.replace_AlternativeImage_at() 0 2 1
A TableRegionType.set_lineColour() 0 2 1
A SeparatorRegionType.set_ns_prefix_() 2 2 1
C TableCellRoleType.to_etree() 0 20 9
A UserDefinedType.build() 11 11 3
A TextEquivType.get_dataType() 0 2 1
A CustomRegionType.__init__() 0 9 1
A GraphemesType.insert_NonPrintingChar_at() 0 2 1
A TextStyleType.get_monospace() 0 2 1
A RelationsType.build() 11 11 3
A MathsRegionType.get_ns_prefix_() 2 2 1
A MusicRegionType.to_etree() 11 11 5
A RelationType.set_type() 0 2 1
A GraphemesType.add_Grapheme() 0 2 1
A MapRegionType._buildChildren() 0 3 1
A TextRegionType.set_secondaryLanguage() 0 2 1
A UnorderedGroupIndexedType.get_ns_prefix_() 0 2 1
D TextRegionType._get_recursive_regions() 0 25 12
A OrderedGroupIndexedType.__hash__() 0 2 1
A UnknownRegionType.build() 11 11 3
F OrderedGroupType._buildAttributes() 35 35 17
A RegionType.set_MusicRegion() 0 2 1
B MathsRegionType.validate_ColourSimpleType() 13 13 6
A MapRegionType.get_ns_prefix_() 0 2 1
A CustomRegionType.has__content() 0 7 2
A UnorderedGroupIndexedType.get_UnorderedGroup() 0 2 1
A WordType.add_AlternativeImage() 0 2 1
A AlternativeImageType.get_filename() 0 2 1
A RolesType.has__content() 7 7 2
A TextStyleType.set_underlineStyle() 0 2 1
A GraphemeBaseType.__hash__() 0 2 1
F GlyphType._exportAttributes() 0 22 15
A GraphemeType.factory() 0 10 4
A ChemRegionType._buildAttributes() 12 12 5
A GraphemeBaseType.set_TextEquiv() 0 2 1
A TextLineType.insert_Word_at() 0 2 1
A WordType.add_Glyph() 0 2 1
A TextLineType.set_primaryScript() 0 2 1
A OrderedGroupIndexedType.set_index() 0 2 1
A GraphemeGroupType.factory() 0 10 4
A MusicRegionType._buildAttributes() 12 12 5
A TextRegionType.set_primaryScript() 0 2 1
A ReadingOrderType.factory() 0 10 4
F TextLineType._buildAttributes() 0 42 19
A OrderedGroupIndexedType.set_OrderedGroupIndexed() 0 2 1
A RegionType.set_UnknownRegion() 0 2 1
A TextStyleType.has__content() 0 7 2
A UnorderedGroupIndexedType.add_RegionRef() 0 2 1
A MapRegionType._region_class() 0 2 1
A ChemRegionType._get_recursive_reading_order() 11 11 5
A GraphemeType._buildAttributes() 0 2 1
A UnorderedGroupType.get_UnorderedGroup() 0 2 1
A OrderedGroupType.insert_UnorderedGroupIndexed_at() 0 2 1
A LayersType._buildChildren() 6 6 2
A UserAttributeType.set_name() 0 2 1
B TextRegionType._exportChildren() 0 15 8
A WordType.insert_Glyph_at() 0 2 1
A PrintSpaceType._exportChildren() 8 8 4
A ReadingOrderType.set_OrderedGroup() 0 2 1
A AlternativeImageType.build() 0 11 3
A TableRegionType.get_lineColour() 0 2 1
C TableRegionType.get_AllRegions() 0 58 10
D PageType._get_recursive_regions() 0 25 12
A NonPrintingCharType.to_etree() 0 7 3
D MathsRegionType._get_recursive_regions() 25 25 12
A TextEquivType.set_ns_prefix_() 0 2 1
A ReadingOrderType.set_UnorderedGroup() 0 2 1
A TextRegionType.get_indented() 0 2 1
B ChartRegionType.validate_ChartTypeSimpleType() 0 13 6
A RegionType.add_MathsRegion() 0 2 1
A GlyphType.add_Labels() 0 2 1
A MapRegionType.set_ns_prefix_() 0 2 1
A RegionType.insert_UnknownRegion_at() 0 2 1
A GlyphType.get_Coords() 0 2 1
D ChemRegionType._get_recursive_regions() 25 25 12
A RegionType.insert_GraphicRegion_at() 0 2 1
A OrderedGroupIndexedType.factory() 0 10 4
A PageType._get_recursive_reading_order() 0 11 5
A RegionType.set_ChemRegion() 0 2 1
B RelationsType.export() 23 23 8
A TextRegionType.insert_TextLine_at() 0 2 1
A UnorderedGroupType.add_RegionRef() 0 2 1
B SeparatorRegionType.export() 23 23 8
A RegionType.set_AdvertRegion() 0 2 1
A TableRegionType.set_bgColour() 0 2 1
B BaselineType.validate_ConfSimpleType() 15 15 7
A ChartRegionType.set_bgColour() 0 2 1
A TextLineType.get_primaryLanguage() 0 2 1
A CustomRegionType.__hash__() 0 2 1
A PrintSpaceType.build() 11 11 3
A AdvertRegionType.factory() 10 10 4
A TextStyleType.get_bgColourRgb() 0 2 1
A TextRegionType.set_ns_prefix_() 0 2 1
A TextStyleType.set_bgColour() 0 2 1
A TextLineType.replace_Labels_at() 0 2 1
A UserDefinedType.to_etree() 12 12 5
B TableCellRoleType.export() 0 22 8
A LineDrawingRegionType.build() 11 11 3
A TextLineType.get_secondaryScript() 0 2 1
A AdvertRegionType.set_orientation() 2 2 2
A UnorderedGroupIndexedType.replace_OrderedGroup_at() 0 2 1
A ImageRegionType._exportChildren() 0 2 1
A ImageRegionType.build() 0 11 3
A OrderedGroupType.get_continuation() 0 2 1
B MusicRegionType.export() 23 23 8
A OrderedGroupIndexedType.add_UnorderedGroupIndexed() 0 2 1
A TableCellRoleType.set_rowIndex() 0 2 1
A RegionType.insert_ChartRegion_at() 0 2 1
A GridPointsType.get_index() 0 2 1
A BorderType._exportChildren() 0 8 4
A TableRegionType.set_ns_prefix_() 0 2 1
A ImageRegionType.set_embText() 0 2 1
A RegionType.replace_MusicRegion_at() 0 2 1
A OrderedGroupIndexedType.get_UserDefined() 0 2 1
A RegionRefIndexedType.get_index() 0 2 1
A ChemRegionType.__init__() 11 11 1
A BaselineType.has__content() 0 7 2
F TextLineType._exportAttributes() 0 28 19
A GraphemeType.has__content() 0 8 3
A GraphemeType.get_ns_prefix_() 0 2 1
A WordType.get_id() 0 2 1
A GridPointsType._buildAttributes() 0 10 5
A UserDefinedType._buildAttributes() 2 2 1
A OrderedGroupType.get_UserDefined() 0 2 1
D OrderedGroupIndexedType._exportChildren() 20 20 12
B GraphicRegionType.validate_GraphicsTypeSimpleType() 13 13 6
A LayerType.get_RegionRef() 0 2 1
A ReadingOrderType.set_conf() 0 2 1
A RegionType.get_GraphicRegion() 0 2 1
A OrderedGroupIndexedType.set_caption() 0 2 1
A RegionType.add_MusicRegion() 0 2 1
A RegionType.insert_MusicRegion_at() 0 2 1
A RelationType.get_SourceRegionRef() 0 2 1
A UserDefinedType.insert_UserAttribute_at() 2 2 1
A TextLineType.get_UserDefined() 0 2 1
A OrderedGroupIndexedType.set_continuation() 0 2 1
A OrderedGroupIndexedType.insert_Labels_at() 0 2 1
A TextStyleType.set_bold() 0 2 1
B TextLineType.validate_ScriptSimpleType() 0 13 6
A GraphemeGroupType.to_etree() 0 11 5
A RelationType.insert_Labels_at() 0 2 1
A UnorderedGroupType.add_Labels() 0 2 1
A RegionType.replace_ChemRegion_at() 0 2 1
A TextEquivType.get_PlainText() 0 2 1
A LayersType.insert_Layer_at() 2 2 1
A TextStyleType.set_strikethrough() 0 2 1
A PrintSpaceType.__hash__() 2 2 1
A RolesType.factory() 10 10 4
A UserAttributeType.__init__() 0 14 1
B UnorderedGroupType.validate_GroupTypeSimpleType() 0 13 6
B RolesType.export() 23 23 8
A AdvertRegionType.has__content() 7 7 2
A LineDrawingRegionType.set_embText() 2 2 1
A AdvertRegionType._get_recursive_reading_order() 11 11 5
A UnorderedGroupIndexedType.set_ns_prefix_() 0 2 1
B UserAttributeType.validate_typeType3() 0 13 6
A UserDefinedType.get_ns_prefix_() 2 2 1
A TableRegionType._region_class() 0 2 1
A UnorderedGroupType.get_ns_prefix_() 0 2 1
B OrderedGroupType.__init__() 42 42 5
F WordType.to_etree() 0 43 19
A TextStyleType.get_bgColour() 0 2 1
A RegionType.get_ImageRegion() 0 2 1
A GraphemeBaseType.insert_TextEquiv_at() 0 2 1
A TextLineType.get_AlternativeImage() 0 2 1
A GraphemesType.get_GraphemeGroup() 0 2 1
A WordType.insert_Labels_at() 0 2 1
A BaselineType._exportChildren() 0 2 1
A UnknownRegionType.__init__() 7 7 1
A RelationsType.to_etree() 12 12 5
A ImageRegionType.set_orientation() 0 2 2
C ImageRegionType.get_AllRegions() 0 58 10
A UnorderedGroupIndexedType.factory() 0 10 4
A NoiseRegionType._exportChildren() 2 2 1
A TextRegionType.set_primaryLanguage() 0 2 1
C PageType.get_AllAlternativeImages() 30 30 10
A AdvertRegionType.__hash__() 2 2 1
A RelationType.set_custom() 0 2 1
A LineDrawingRegionType._get_recursive_reading_order() 11 11 5
D LineDrawingRegionType._get_recursive_regions() 25 25 12
B WordType.__init__() 0 48 5
C MathsRegionType.get_AllRegions() 58 58 10
A GlyphType.set_AlternativeImage() 0 2 1
A RelationsType.get_Relation() 2 2 1
A OrderedGroupIndexedType.get_type() 0 2 1
A RelationType.has__content() 0 9 4
B GraphemesType._exportChildren() 0 14 8
A TextEquivType.get_dataTypeDetails() 0 2 1
A AdvertRegionType.to_etree() 11 11 5
A LayerType.factory() 0 10 4
A TextLineType.set_Word() 0 2 1
A WordType.get_UserDefined() 0 2 1
F GlyphType.to_etree() 0 42 18
A TextLineType.get_comments() 0 2 1
A OrderedGroupIndexedType.insert_RegionRefIndexed_at() 0 2 1
F UnorderedGroupIndexedType.to_etree() 37 37 17
A CoordsType.factory() 0 10 4
A SeparatorRegionType._buildChildren() 3 3 1
A WordType.get_Labels() 0 2 1
A RegionType.set_SeparatorRegion() 0 2 1
A BaselineType._exportAttributes() 0 7 5
A GraphemeGroupType.insert_Grapheme_at() 0 2 1
A WordType.get_ns_prefix_() 0 2 1
A UnorderedGroupType.get_regionRef() 0 2 1
A TextLineType.insert_AlternativeImage_at() 0 2 1
D MapRegionType._get_recursive_regions() 0 25 12
A TextLineType.set_AlternativeImage() 0 2 1
A WordType.set_secondaryScript() 0 2 1
A TextStyleType.__hash__() 0 2 1
A UnorderedGroupType.set_UnorderedGroup() 0 2 1
A TextRegionType.add_TextLine() 0 2 1
A MathsRegionType.factory() 10 10 4
A MathsRegionType.__hash__() 2 2 1
A OrderedGroupIndexedType.insert_OrderedGroupIndexed_at() 0 2 1
A BorderType.__init__() 0 8 1
A UnorderedGroupType.get_continuation() 0 2 1
A RegionType.set_continuation() 0 2 1
A GraphemeGroupType.get_Grapheme() 0 2 1
A TableCellRoleType.__hash__() 0 2 1
A RegionType.insert_SeparatorRegion_at() 0 2 1
A UnorderedGroupType.add_OrderedGroup() 0 2 1
B WordType.export() 0 23 8
A RegionType.add_SeparatorRegion() 0 2 1
A CustomRegionType.set_type() 0 2 1
F UnorderedGroupType._buildAttributes() 35 35 17
A LineDrawingRegionType.get_orientation() 2 2 1
A TextLineType.get_TextEquiv() 0 2 1
A RelationsType._exportAttributes() 2 2 1
A UnorderedGroupType.set_UserDefined() 0 2 1
A UserAttributeType.get_name() 0 2 1
A GlyphType.add_AlternativeImage() 0 2 1
A TableCellRoleType.get_rowIndex() 0 2 1
A OrderedGroupType.get_comments() 0 2 1
B OrderedGroupIndexedType.has__content() 0 11 6
A AdvertRegionType._exportChildren() 2 2 1
A ReadingOrderType.get_UnorderedGroup() 0 2 1
A GridType._buildChildren() 6 6 2
A TextLineType.__hash__() 0 2 1
B CoordsType.to_etree() 14 14 6
A TextLineType.add_Labels() 0 2 1
A UnorderedGroupType.insert_UnorderedGroup_at() 0 2 1
B MathsRegionType.export() 23 23 8
A TextRegionType._get_recursive_reading_order() 0 11 5
A UnorderedGroupType.insert_RegionRef_at() 0 2 1
A TextEquivType.__hash__() 0 2 1
B TextRegionType.validate_LanguageSimpleType() 0 13 6
A RegionRefIndexedType._buildAttributes() 0 9 5
A ChartRegionType.__hash__() 0 2 1
A OrderedGroupType.replace_OrderedGroupIndexed_at() 0 2 1
A LayerType.__hash__() 0 2 1
F UnorderedGroupIndexedType._exportAttributes() 25 25 17
A UnorderedGroupIndexedType.set_UnorderedGroup() 0 2 1
A RelationType.build() 0 11 3
A GraphicRegionType._exportChildren() 2 2 1
A BaselineType._buildAttributes() 12 12 5
C TextEquivType._buildAttributes() 0 25 11
A PrintSpaceType.get_Coords() 2 2 1
A OrderedGroupIndexedType.get_RegionRefIndexed() 0 2 1
C OrderedGroupType.extend_AllIndexed() 28 28 11
A LineDrawingRegionType._region_class() 2 2 1
B TextLineType.validate_ReadingDirectionSimpleType() 0 13 6
A TextStyleType.set_letterSpaced() 0 2 1
A OrderedGroupType.set_ns_prefix_() 0 2 1
A GraphemeGroupType.add_NonPrintingChar() 0 2 1
A UnorderedGroupIndexedType.get_RegionRef() 0 2 1
A RegionType.get_comments() 0 2 1
A OrderedGroupIndexedType.set_UnorderedGroupIndexed() 0 2 1
C ImageRegionType._buildAttributes() 0 26 11
A UnorderedGroupIndexedType.get_custom() 0 2 1
A ImageRegionType.get_bgColour() 0 2 1
A MusicRegionType._get_recursive_reading_order() 11 11 5
A LineDrawingRegionType.set_ns_prefix_() 2 2 1
A GraphicRegionType.set_embText() 2 2 1
D ImageRegionType._get_recursive_regions() 0 25 12
A RegionRefIndexedType.__hash__() 0 2 1
A NoiseRegionType.to_etree() 7 7 3
B GraphemeGroupType.export() 0 23 8
B GraphemesType.to_etree() 0 16 7
A TextRegionType.set_production() 0 2 1
B GlyphType.has__content() 0 13 8
A TextStyleType.set_xHeight() 0 2 1
A TextRegionType.build() 0 11 3
A UnknownRegionType._buildChildren() 3 3 1
A TableCellRoleType.set_header() 0 2 1
A MusicRegionType.build() 11 11 3
A RelationsType.insert_Relation_at() 2 2 1
A TextLineType.set_Coords() 0 2 4
A LayersType.get_ns_prefix_() 2 2 1
A CoordsType._exportAttributes() 0 7 5
A UserAttributeType.set_description() 0 2 1
A OrderedGroupIndexedType.replace_RegionRefIndexed_at() 0 2 1
A ChartRegionType.get_type() 0 2 1
A MathsRegionType.set_orientation() 2 2 2
A UserDefinedType._exportChildren() 8 8 4
A RegionType.get_UserDefined() 0 2 1
A NonPrintingCharType.has__content() 0 7 2
A RegionType.add_LineDrawingRegion() 0 2 1
A UnknownRegionType.get_ns_prefix_() 2 2 1
F GlyphType._buildAttributes() 0 41 19
A RegionType.insert_AlternativeImage_at() 0 2 1
A GraphemeBaseType.build() 0 11 3
A GlyphType.set_Labels() 0 2 1
A TextLineType.add_AlternativeImage() 0 2 1
A GraphemeBaseType.get_TextEquiv() 0 2 1
B LayersType.export() 23 23 8
A RegionType.set_TextRegion() 0 2 1
A ImageRegionType._get_recursive_reading_order() 0 11 5
A OrderedGroupIndexedType.get_Labels() 0 2 1
A TextLineType.build() 0 11 3
A TextLineType.get_production() 0 2 1
A ChartRegionType.has__content() 0 7 2
A OrderedGroupType.set_RegionRefIndexed() 0 2 1
A ChemRegionType._buildChildren() 3 3 1
B TextRegionType.validate_TextLineOrderSimpleType() 0 13 6
A PageType.get_AllTextLines() 25 25 4
A WordType.set_language() 0 2 1
A GraphemeGroupType.set_Grapheme() 0 2 1
A MathsRegionType._buildAttributes() 12 12 5
A GridPointsType.__hash__() 0 2 1
A RegionRefIndexedType.set_ns_prefix_() 0 2 1
B UnorderedGroupIndexedType.validate_GroupTypeSimpleType() 0 13 6
A OrderedGroupIndexedType.get_AllIndexed() 22 22 5
C RelationType._exportAttributes() 13 13 9
A GraphemeGroupType._buildAttributes() 0 2 1
A LayerType.has__content() 0 7 2
A CustomRegionType.get_type() 0 2 1
A RegionType.set_Coords() 0 2 4
A ChartRegionType.get_ns_prefix_() 0 2 1
A TextRegionType.replace_TextEquiv_at() 0 2 1
A GridType.__init__() 11 11 2
A ImageRegionType.set_colourDepth() 0 2 1
A BaselineType.set_ns_prefix_() 0 2 1
A TableRegionType._get_recursive_reading_order() 0 11 5
A PrintSpaceType.has__content() 7 7 2
A TextRegionType.get_align() 0 2 1
A TextEquivType.build() 0 11 3
A CoordsType.build() 0 11 3
A UnorderedGroupType.set_custom() 0 2 1
A RegionType.set_GraphicRegion() 0 2 1
A TableCellRoleType.get_colSpan() 0 2 1
A CoordsType.set_ns_prefix_() 0 2 1
A TextStyleType.get_superscript() 0 2 1
A NoiseRegionType.__hash__() 2 2 1
A UnorderedGroupType.set_comments() 0 2 1
A GraphemesType.__init__() 0 21 4
A UnorderedGroupIndexedType.get_regionRef() 0 2 1
A TextLineType.add_Word() 0 2 1
A UnorderedGroupIndexedType.set_regionRef() 0 2 1
A RegionType.set_MathsRegion() 0 2 1
A RegionRefIndexedType.factory() 0 10 4
A TextRegionType.set_TextLine() 0 2 1
A AlternativeImageType.factory() 0 10 4
A BaselineType.factory() 0 10 4
A NoiseRegionType.build() 11 11 3
A WordType.add_Labels() 0 2 1
B GraphemeGroupType._exportChildren() 0 12 6
A TextStyleType.set_textColourRgb() 0 2 1
A TextStyleType.get_underlined() 0 2 1
A GraphemeGroupType.replace_NonPrintingChar_at() 0 2 1
A RegionRefType._buildAttributes() 0 5 3
A TextEquivType.get_ns_prefix_() 0 2 1
B UnorderedGroupType.has__content() 0 11 6
C TextEquivType._exportAttributes() 0 16 11
A RolesType._buildAttributes() 2 2 1
A TextStyleType.get_textColour() 0 2 1
B WordType.has__content() 0 13 8
A OrderedGroupType.set_UserDefined() 0 2 1
C GraphicRegionType._exportAttributes() 14 14 9
A PrintSpaceType.to_etree() 13 13 5
A TableRegionType.__init__() 0 23 1
A TextRegionType.factory() 0 10 4
A PrintSpaceType.factory() 10 10 4
C ChartRegionType._exportAttributes() 0 17 11
A OrderedGroupType.replace_UnorderedGroupIndexed_at() 0 2 1
A TableRegionType.get_bgColour() 0 2 1
A GraphemeBaseType.add_TextEquiv() 0 2 1
B AdvertRegionType.validate_ColourSimpleType() 13 13 6
A ImageRegionType.set_ns_prefix_() 0 2 1
A OrderedGroupIndexedType.get_custom() 0 2 1
A GridType.to_etree() 12 12 5
A RegionType.get_Coords() 0 2 1
A RegionRefIndexedType.__init__() 0 10 1
A CoordsType.__hash__() 0 2 1
A OrderedGroupIndexedType.replace_Labels_at() 0 2 1
A GlyphType.set_ns_prefix_() 0 2 1
A TextRegionType.set_indented() 0 2 1
A TextStyleType.get_reverseVideo() 0 2 1
B RegionType.invalidate_AlternativeImage() 31 31 8
B GridPointsType.to_etree() 14 14 6
A OrderedGroupType.add_Labels() 0 2 1
A TableCellRoleType.build() 0 11 3
A TextLineType.set_custom() 0 2 1
A LayerType.set_RegionRef() 0 2 1
A GraphemeGroupType._exportAttributes() 0 2 1
A OrderedGroupType.set_custom() 0 2 1
A TextEquivType.set_conf() 0 2 1
A BorderType.__hash__() 0 2 1
A RelationsType._exportChildren() 8 8 4
A RegionRefType.get_ns_prefix_() 0 2 1
A GraphemesType._buildAttributes() 0 2 1
A OrderedGroupIndexedType.get_index() 0 2 1
B PageType.invalidate_AlternativeImage() 31 31 8
B TableRegionType.validate_ColourSimpleType() 0 13 6
A SeparatorRegionType.factory() 10 10 4
A UnorderedGroupIndexedType.set_type() 0 2 1
A TextStyleType.set_reverseVideo() 0 2 1
A ChemRegionType.get_ns_prefix_() 2 2 1
A NonPrintingCharType.factory() 0 10 4
A TextLineType.get_id() 0 2 1
A WordType.set_Labels() 0 2 1
A TextStyleType.set_bgColourRgb() 0 2 1
B ImageRegionType.validate_ColourSimpleType() 0 13 6
A RegionType.add_UnknownRegion() 0 2 1
A TextRegionType.get_TextStyle() 0 2 1
A RelationType.add_Labels() 0 2 1
A RelationType.get_ns_prefix_() 0 2 1
A GraphemeBaseType.set_comments() 0 2 1
A RegionRefType.factory() 0 10 4
A BorderType.get_ns_prefix_() 0 2 1
B WordType._buildChildren() 36 36 8
A NoiseRegionType.get_ns_prefix_() 2 2 1
A LineDrawingRegionType.get_ns_prefix_() 2 2 1
A MusicRegionType._buildChildren() 3 3 1
A RelationsType.set_Relation() 2 2 1
A WordType.get_primaryScript() 0 2 1
A GraphemesType._buildChildren() 0 16 4
A RegionType.get_UnknownRegion() 0 2 1
D RegionType._buildAttributes() 0 26 13
A GraphemeBaseType.set_extensiontype_() 0 1 1
A GraphemeGroupType._buildChildren() 0 12 3
A UnorderedGroupIndexedType.add_Labels() 0 2 1
A UnorderedGroupIndexedType.get_comments() 0 2 1
A TextEquivType.set_comments() 0 2 1
A UserDefinedType.get_UserAttribute() 2 2 1
A RegionType.get_TableRegion() 0 2 1
F OrderedGroupIndexedType._exportAttributes() 25 25 17
A TextLineType.set_TextStyle() 0 2 1
A OrderedGroupType.replace_RegionRefIndexed_at() 0 2 1
A GridPointsType.factory() 0 10 4
D TableCellRoleType._buildAttributes() 0 26 13
A GraphemeBaseType.get_charType() 0 2 1
A GlyphType.replace_Labels_at() 0 2 1
A GraphemeBaseType.factory() 0 10 4
A ReadingOrderType.set_ns_prefix_() 0 2 1
A RegionType.__hash__() 0 2 1
A OrderedGroupType.get_type() 0 2 1
A TextRegionType.replace_TextLine_at() 0 2 1
A ChartRegionType.get_orientation() 0 2 1
B UnorderedGroupType.export() 0 23 8
A PrintSpaceType._buildChildren() 6 6 2
A GraphemesType.factory() 0 10 4
A NoiseRegionType._buildChildren() 3 3 1
A TextStyleType.set_ns_prefix_() 0 2 1
A TextStyleType._buildChildren() 0 2 1
A GraphemesType.set_GraphemeGroup() 0 2 1
A OrderedGroupType.get_caption() 0 2 1
B GraphemeBaseType.validate_indexType2() 11 11 6
A OrderedGroupIndexedType.clear_AllIndexed() 0 6 1
A OrderedGroupType.build() 0 11 3
A LayerType.get_ns_prefix_() 0 2 1
A RegionRefIndexedType.build() 0 11 3
A TextLineType.get_TextStyle() 0 2 1
A GraphemeBaseType._exportChildren() 0 8 4
A WordType.set_readingDirection() 0 2 1
A WordType.get_Coords() 0 2 1
A UnorderedGroupIndexedType.insert_RegionRef_at() 0 2 1
A GraphicRegionType.build() 11 11 3
A GraphicRegionType.set_type() 2 2 1
A MathsRegionType.has__content() 7 7 2
A RegionType.get_MusicRegion() 0 2 1
A TextLineType.set_primaryLanguage() 0 2 1
A RolesType.set_ns_prefix_() 2 2 1
A WordType.set_UserDefined() 0 2 1
F TextStyleType._buildAttributes() 0 140 63
A OrderedGroupIndexedType.get_regionRef() 0 2 1
B TextLineType.export() 0 23 8
A WordType.set_Glyph() 0 2 1
A UserDefinedType.replace_UserAttribute_at() 2 2 1
A GridType._exportAttributes() 2 2 1
A LineDrawingRegionType._exportChildren() 2 2 1
A AlternativeImageType.__hash__() 0 2 1
B GlyphType._buildChildren() 36 36 8
A LayerType.replace_RegionRef_at() 0 2 1
A ChartRegionType.set_orientation() 0 2 2
A RegionRefIndexedType.get_regionRef() 0 2 1
A GridPointsType._exportChildren() 0 2 1
A WordType.set_ns_prefix_() 0 2 1
A ReadingOrderType.__hash__() 0 2 1
A GraphemeType.set_Coords() 0 2 1
A TextLineType.set_TextEquiv() 0 2 1
A UnorderedGroupIndexedType.get_OrderedGroup() 0 2 1
A UnorderedGroupIndexedType.insert_Labels_at() 0 2 1
A UserAttributeType.__hash__() 0 2 1
B GlyphType.validate_ProductionSimpleType() 0 13 6
A LayersType._buildAttributes() 2 2 1
A GlyphType.set_script() 0 2 1
A ChemRegionType._exportChildren() 2 2 1
A OrderedGroupType.set_comments() 0 2 1
B OrderedGroupType.has__content() 0 11 6
A UserAttributeType.set_type() 0 2 1
A TextRegionType.get_secondaryLanguage() 0 2 1
B ChartRegionType.export() 0 23 8
A AlternativeImageType.set_ns_prefix_() 0 2 1
B TextRegionType.validate_AlignSimpleType() 0 13 6
A TextEquivType.__init__() 0 20 1
A RelationsType.__init__() 11 11 2
B ImageRegionType.validate_ColourDepthSimpleType() 0 13 6
A TextStyleType._exportChildren() 0 2 1
A OrderedGroupType.get_RegionRefIndexed() 0 2 1
A RegionType.insert_NoiseRegion_at() 0 2 1
A RegionRefType._exportChildren() 0 2 1
A GraphicRegionType._region_class() 2 2 1
A AlternativeImageType._buildChildren() 0 2 1
A RelationType.get_custom() 0 2 1
A MusicRegionType.get_bgColour() 2 2 1
A TableRegionType.get_Grid() 0 2 1
F GlyphType._exportChildren() 26 26 16
A GlyphType.get_ns_prefix_() 0 2 1
B WordType.validate_ReadingDirectionSimpleType() 0 13 6
B TextEquivType.validate_ConfSimpleType() 15 15 7
F TextStyleType._exportAttributes() 0 61 41
B TextStyleType.validate_ColourSimpleType() 0 13 6
A GraphemeGroupType.get_ns_prefix_() 0 2 1
A GraphemeBaseType.set_ns_prefix_() 0 2 1
A GlyphType.replace_AlternativeImage_at() 0 2 1
A WordType.set_id() 0 2 1
B AlternativeImageType.to_etree() 16 16 7
A SeparatorRegionType._get_recursive_reading_order() 11 11 5
A MusicRegionType._exportChildren() 2 2 1
A UnorderedGroupType.set_continuation() 0 2 1
A LineDrawingRegionType.__hash__() 2 2 1
B LineDrawingRegionType.validate_ColourSimpleType() 13 13 6
A TableCellRoleType.get_ns_prefix_() 0 2 1
A TextLineType.set_ns_prefix_() 0 2 1
B GlyphType.export() 0 23 8
A RegionRefType._exportAttributes() 0 4 3
A TextEquivType.set_Unicode() 0 2 1
A RegionType.insert_MathsRegion_at() 0 2 1
C OrderedGroupIndexedType.extend_AllIndexed() 28 28 11
A MathsRegionType._get_recursive_reading_order() 11 11 5
A BaselineType.set_conf() 0 2 1
A UnorderedGroupType.factory() 0 10 4
A ImageRegionType._region_class() 0 2 1
A SeparatorRegionType.has__content() 7 7 2
A MapRegionType._buildAttributes() 0 7 3
A GridType.__hash__() 2 2 1
A TextStyleType.set_superscript() 0 2 1
A TextStyleType.set_italic() 0 2 1
A MapRegionType._exportChildren() 0 2 1
A MusicRegionType.__init__() 11 11 1
A RegionType.add_TableRegion() 0 2 1
A ChartRegionType.set_embText() 0 2 1
A GraphemesType.add_NonPrintingChar() 0 2 1
A SeparatorRegionType._exportChildren() 2 2 1
A UserDefinedType.set_ns_prefix_() 2 2 1
A GlyphType.get_TextEquiv() 0 2 1
A LineDrawingRegionType.get_penColour() 2 2 1
A RegionType.get_custom() 0 2 1
A UnorderedGroupType.set_regionRef() 0 2 1
A NoiseRegionType.factory() 10 10 4
A AdvertRegionType.get_ns_prefix_() 2 2 1
A TextLineType.insert_Labels_at() 0 2 1
A GridType._exportChildren() 8 8 4
B UnorderedGroupIndexedType._buildChildren() 26 26 6
A GlyphType.set_comments() 0 2 1
A RegionType.replace_CustomRegion_at() 0 2 1
A RegionType.set_NoiseRegion() 0 2 1
A GridType.add_GridPoints() 2 2 1
A GlyphType.set_id() 0 2 1
A LineDrawingRegionType.get_embText() 2 2 1
A OrderedGroupIndexedType.set_regionRef() 0 2 1
A TextLineType.set_comments() 0 2 1
A ImageRegionType.get_ns_prefix_() 0 2 1
A GlyphType.set_Graphemes() 0 2 1
A UnorderedGroupIndexedType.get_id() 0 2 1
A LineDrawingRegionType.set_bgColour() 2 2 1
A RegionType.set_TableRegion() 0 2 1
A TextRegionType.get_orientation() 0 2 1
A RelationType.replace_Labels_at() 0 2 1
A BorderType.to_etree() 0 13 5
A MapRegionType.build() 0 11 3
A ImageRegionType.get_orientation() 0 2 1
A GraphemeGroupType.replace_Grapheme_at() 0 2 1
A CoordsType._exportChildren() 0 2 1
A GraphemesType.add_GraphemeGroup() 0 2 1
A RelationsType.add_Relation() 2 2 1
A GraphemeBaseType.set_custom() 0 2 1
A RegionType.insert_AdvertRegion_at() 0 2 1
A LayersType.__hash__() 2 2 1
A RegionType.add_ChemRegion() 0 2 1
A RegionType.get_CustomRegion() 0 2 1
A CustomRegionType._exportAttributes() 0 5 3
A WordType.get_custom() 0 2 1
A SeparatorRegionType.to_etree() 11 11 5
D SeparatorRegionType._get_recursive_regions() 25 25 12
A OrderedGroupIndexedType.set_RegionRefIndexed() 0 2 1
C TableCellRoleType._exportAttributes() 0 16 11
A TextStyleType.get_xHeight() 0 2 1
A MusicRegionType.factory() 10 10 4
A TextStyleType.get_underlineStyle() 0 2 1
A ChemRegionType.__hash__() 2 2 1
A SeparatorRegionType.build() 11 11 3
A UnknownRegionType.__hash__() 2 2 1
A GraphemeBaseType.replace_TextEquiv_at() 0 2 1
C ChartRegionType.get_AllRegions() 0 58 10
A TableRegionType.get_columns() 0 2 1
B TextRegionType.validate_TextTypeSimpleType() 0 13 6
A NonPrintingCharType.build() 0 11 3
B ReadingOrderType.validate_ConfSimpleType() 15 15 7
F RegionType.to_etree() 0 61 28
A GridType._buildAttributes() 2 2 1
A GraphemeGroupType.has__content() 0 9 4
A AdvertRegionType.set_bgColour() 2 2 1
A GraphemesType.insert_GraphemeGroup_at() 0 2 1
A UserAttributeType.get_ns_prefix_() 0 2 1
A CoordsType.get_ns_prefix_() 0 2 1
A GraphicRegionType._buildChildren() 3 3 1
A UserDefinedType.factory() 10 10 4
A TextRegionType.set_TextStyle() 0 2 1
A MapRegionType.get_orientation() 0 2 1
A UnorderedGroupType.get_type() 0 2 1
B LayerType.to_etree() 0 18 8
A ChartRegionType.get_embText() 0 2 1
A MusicRegionType.set_orientation() 2 2 2
A UnorderedGroupType.replace_Labels_at() 0 2 1
A OrderedGroupType.__hash__() 0 2 1
A OrderedGroupType.get_regionRef() 0 2 1
D UnorderedGroupType._exportChildren() 20 20 12
D ChartRegionType._get_recursive_regions() 0 25 12
A LineDrawingRegionType.has__content() 7 7 2
A TableCellRoleType.set_rowSpan() 0 2 1
A TextStyleType.set_kerning() 0 2 1
A OrderedGroupType.add_RegionRefIndexed() 0 2 1
A UnorderedGroupIndexedType.insert_OrderedGroup_at() 0 2 1
B GraphicRegionType.export() 23 23 8
F WordType._exportAttributes() 0 25 17
A LayerType.__init__() 0 17 2
A MathsRegionType.set_ns_prefix_() 2 2 1
A MathsRegionType._exportChildren() 2 2 1
A OrderedGroupType.get_UnorderedGroupIndexed() 0 2 1
A ChemRegionType.set_orientation() 2 2 2
A UnorderedGroupType.build() 0 11 3
A RelationType.set_id() 0 2 1
A TextEquivType.factory() 0 10 4
A TextStyleType.get_kerning() 0 2 1
A RelationType.set_comments() 0 2 1
A GlyphType.get_Graphemes() 0 2 1
A RegionType.replace_GraphicRegion_at() 0 2 1
B LineDrawingRegionType.export() 23 23 8
A RegionRefIndexedType.set_index() 0 2 1
A GlyphType.get_ligature() 0 2 1
A GraphemeBaseType.get_index() 0 2 1
A UnorderedGroupType.add_UnorderedGroup() 0 2 1
A UnknownRegionType.factory() 10 10 4
A UnorderedGroupIndexedType.get_type() 0 2 1
A RegionType.insert_TextRegion_at() 0 2 1
A UnorderedGroupIndexedType.set_index() 0 2 1
B CustomRegionType.export() 0 23 8
B RelationType.export() 0 23 8
A TextRegionType.insert_TextEquiv_at() 0 2 1
A RegionType.replace_Labels_at() 0 2 1
A WordType.__hash__() 0 2 1
A UnorderedGroupType.set_Labels() 0 2 1
B LayerType.export() 0 23 8
B ImageRegionType.export() 0 23 8
A TextRegionType.get_primaryLanguage() 0 2 1
A RelationType.__init__() 0 23 2
A RolesType._exportChildren() 8 8 4
A UnorderedGroupType.set_id() 0 2 1
A RolesType._exportAttributes() 2 2 1
A NonPrintingCharType._exportChildren() 0 2 1
A PrintSpaceType.set_Coords() 2 2 1
A RegionType.get_continuation() 0 2 1
A RegionRefType.set_regionRef() 0 2 1
B GlyphType.invalidate_AlternativeImage() 31 31 8
A ReadingOrderType.get_ns_prefix_() 0 2 1
A AdvertRegionType.__init__() 11 11 1
C RelationType.to_etree() 0 26 11
A UnorderedGroupIndexedType.replace_UnorderedGroup_at() 0 2 1
A UnorderedGroupIndexedType.set_custom() 0 2 1
A RelationType.set_ns_prefix_() 0 2 1
A MusicRegionType.set_bgColour() 2 2 1
A UnknownRegionType._exportChildren() 2 2 1
A GlyphType.replace_TextEquiv_at() 0 2 1
F TextLineType._exportChildren() 0 29 18
A GridPointsType.__init__() 0 10 1
B GraphemeBaseType.validate_charTypeType() 0 13 6
A MathsRegionType._exportAttributes() 8 8 5
A GraphemeType.__hash__() 0 2 1
A TextRegionType.get_leading() 0 2 1
A LineDrawingRegionType.set_penColour() 2 2 1
A OrderedGroupType.get_ns_prefix_() 0 2 1
B BaselineType.to_etree() 14 14 6
A UnorderedGroupType.set_type() 0 2 1
A UnorderedGroupIndexedType.add_UnorderedGroup() 0 2 1
B TextEquivType.validate_TextDataTypeSimpleType() 0 13 6
C UserAttributeType._exportAttributes() 0 13 9
B WordType.invalidate_AlternativeImage() 31 31 8
A MusicRegionType.__hash__() 2 2 1
A TextEquivType.set_index() 0 2 1
D TableRegionType._get_recursive_regions() 0 25 12
A GraphemesType.replace_GraphemeGroup_at() 0 2 1
A OrderedGroupIndexedType.set_Labels() 0 2 1
B AlternativeImageType.export() 0 22 8
A GlyphType.get_AlternativeImage() 0 2 1
A ImageRegionType.factory() 0 10 4
A LayersType.to_etree() 12 12 5
A GridPointsType.get_ns_prefix_() 0 2 1
A CoordsType.set_conf() 0 2 1
A RegionType.insert_ChemRegion_at() 0 2 1
A GraphemesType._exportAttributes() 0 2 1
A OrderedGroupIndexedType.set_comments() 0 2 1
A OrderedGroupIndexedType.get_ns_prefix_() 0 2 1
A TextEquivType._buildChildren() 0 12 3
A TextLineType.get_Coords() 0 2 1
A TextStyleType.set_monospace() 0 2 1
A UnorderedGroupType.replace_RegionRef_at() 0 2 1
A AlternativeImageType.get_ns_prefix_() 0 2 1
A TextStyleType.set_textColour() 0 2 1
A RegionType.replace_ImageRegion_at() 0 2 1
A BaselineType.get_ns_prefix_() 0 2 1
A TextLineType.get_primaryScript() 0 2 1
F TextLineType.to_etree() 0 48 21
A MathsRegionType.to_etree() 11 11 5
B LayerType._buildAttributes() 0 13 7
A WordType.get_secondaryScript() 0 2 1
A LayersType._exportChildren() 8 8 4
A MathsRegionType.get_bgColour() 2 2 1
A GlyphType.add_TextEquiv() 0 2 1
A GlyphType.get_script() 0 2 1
C TextLineType._buildChildren() 0 41 9
A OrderedGroupType.replace_Labels_at() 0 2 1
A AlternativeImageType.set_comments() 0 2 1
C TextRegionType.get_AllRegions() 0 58 10
A OrderedGroupType.set_type() 0 2 1
A NoiseRegionType._buildAttributes() 2 2 1
A RegionType.insert_LineDrawingRegion_at() 0 2 1
A LayerType.set_zIndex() 0 2 1
D AdvertRegionType._get_recursive_regions() 25 25 12
A UnorderedGroupIndexedType.get_UnorderedGroupChildren() 0 6 1
A ChemRegionType._exportAttributes() 8 8 5
A WordType.get_production() 0 2 1
A TextLineType.get_ns_prefix_() 0 2 1
B CoordsType.validate_ConfSimpleType() 15 15 7
B TextLineType.invalidate_AlternativeImage() 31 31 8
A GlyphType.insert_TextEquiv_at() 0 2 1
B TextRegionType.validate_ReadingDirectionSimpleType() 0 13 6
A OrderedGroupIndexedType.replace_OrderedGroupIndexed_at() 0 2 1
A LayerType.set_caption() 0 2 1
A OrderedGroupType.set_UnorderedGroupIndexed() 0 2 1
A ImageRegionType.__init__() 0 15 1
A WordType.set_primaryScript() 0 2 1
A GraphemeBaseType.has__content() 0 7 2
A GridPointsType.get_points() 0 2 1
A TableRegionType.get_ns_prefix_() 0 2 1
A SeparatorRegionType.set_orientation() 2 2 2
A CustomRegionType.to_etree() 0 9 4
A SeparatorRegionType._region_class() 2 2 1
A SeparatorRegionType.__hash__() 2 2 1
A UnorderedGroupIndexedType.get_continuation() 0 2 1
A TextRegionType.set_type() 0 2 1
A TableRegionType.set_rows() 0 2 1
A PrintSpaceType._exportAttributes() 2 2 1
A RolesType.__hash__() 2 2 1
A RegionType.replace_LineDrawingRegion_at() 0 2 1
A TextRegionType.__hash__() 0 2 1
A NoiseRegionType._exportAttributes() 2 2 1
A LayersType.has__content() 7 7 2
A CoordsType.set_points() 0 2 5
A ChemRegionType.to_etree() 11 11 5
A SeparatorRegionType._buildAttributes() 12 12 5
A LayersType._exportAttributes() 2 2 1
A OrderedGroupType.set_id() 0 2 1
F TableRegionType._exportAttributes() 0 23 15
A RegionType.build() 0 11 3
A LayersType.replace_Layer_at() 2 2 1
B ChemRegionType.validate_ColourSimpleType() 13 13 6
A RelationType.get_TargetRegionRef() 0 2 1
B TextLineType.validate_ProductionSimpleType() 0 13 6
B ChartRegionType.validate_ColourSimpleType() 0 13 6
A BorderType.set_Coords() 0 2 4
A TextRegionType.get_TextLine() 0 2 1
A ImageRegionType.get_colourDepth() 0 2 1
A RegionRefIndexedType.has__content() 0 7 2
B SeparatorRegionType.validate_ColourSimpleType() 13 13 6
A RegionRefType.to_etree() 0 12 5
A UnorderedGroupIndexedType.set_id() 0 2 1
A WordType.get_Glyph() 0 2 1
A TextStyleType.get_subscript() 0 2 1
A MusicRegionType._exportAttributes() 8 8 5
A GlyphType.set_TextEquiv() 0 2 1
A LayerType.add_RegionRef() 0 2 1
A WordType.set_TextStyle() 0 2 1
A TableRegionType.factory() 0 10 4
A GraphemeGroupType.add_Grapheme() 0 2 1
A TextRegionType.set_readingOrientation() 0 2 1
A TextLineType.set_UserDefined() 0 2 1
A CustomRegionType.build() 0 11 3
A WordType.insert_AlternativeImage_at() 0 2 1
A UnorderedGroupIndexedType.insert_UnorderedGroup_at() 0 2 1
A GraphemeType.to_etree() 0 10 4
A TextEquivType.set_dataTypeDetails() 0 2 1
B PrintSpaceType.export() 23 23 8
A LineDrawingRegionType.set_orientation() 2 2 2
A TextRegionType.get_ns_prefix_() 0 2 1
A BorderType.has__content() 0 7 2
A RegionType.add_ChartRegion() 0 2 1
B WordType.validate_ScriptSimpleType() 0 13 6
A TableCellRoleType.get_header() 0 2 1
A TextRegionType.get_textLineOrder() 0 2 1
A TableCellRoleType.__init__() 0 16 1
B NoiseRegionType.export() 23 23 8
A CustomRegionType.factory() 0 10 4
A ReadingOrderType.__init__() 0 12 1
A RelationType.__hash__() 0 2 1
A GraphemeBaseType.__init__() 0 24 2
A LayersType.set_ns_prefix_() 2 2 1
A GraphemeBaseType.get_ligature() 0 2 1
A RegionType.insert_TableRegion_at() 0 2 1
A RegionType.set_ImageRegion() 0 2 1
A GlyphType.insert_Labels_at() 0 2 1
A BorderType.set_ns_prefix_() 0 2 1
A OrderedGroupType.set_OrderedGroupIndexed() 0 2 1
A GlyphType.factory() 0 10 4
A BorderType._buildChildren() 0 6 2
A GraphemesType.replace_NonPrintingChar_at() 0 2 1
A RegionType.get_ChartRegion() 0 2 1
A TextEquivType.get_index() 0 2 1
A UnorderedGroupType.replace_OrderedGroup_at() 0 2 1
A CustomRegionType._buildChildren() 0 3 1
A GraphicRegionType.set_ns_prefix_() 2 2 1
B TextLineType.validate_LanguageSimpleType() 0 13 6
A RegionType.get_SeparatorRegion() 0 2 1
A UnorderedGroupIndexedType.set_caption() 0 2 1
A TextRegionType.get_TextEquiv() 0 2 1
A PrintSpaceType.get_ns_prefix_() 2 2 1
A TextStyleType.set_smallCaps() 0 2 1
A RegionRefIndexedType._buildChildren() 0 2 1
C LineDrawingRegionType._buildAttributes() 26 26 11
F WordType._exportChildren() 26 26 16
A ChemRegionType.has__content() 7 7 2
A ChartRegionType.set_numColours() 0 2 1
B GraphemeType.export() 0 23 8
A LayerType.get_caption() 0 2 1
A GridPointsType.set_index() 0 2 1
A TextStyleType.get_textColourRgb() 0 2 1

21 Functions

Rating   Name   Duplication   Size   Complexity  
A parsexml_() 0 16 5
A parsexmlstring_() 0 11 3
A quote_xml_aux() 0 5 1
A encode_str_2_3() 0 2 1
A raise_parse_error() 0 4 2
A getSubclassFromModule_() 0 7 2
A find_attr_value_() 0 15 5
A quote_python() 0 14 5
A quote_xml() 0 16 3
A quote_attrib() 0 14 3
A get_all_text_() 0 9 4
A showIndent() 0 4 3
A _cast() 0 4 3
A get_required_ns_prefix_defs() 0 15 1
A usage() 0 3 1
B parseLiteral() 29 29 5
A main() 0 6 2
B parseString() 33 33 5
A get_root_tag() 0 7 2
B parseEtree() 0 38 7
B parse() 0 30 5

How to fix   Duplicated Code    Complexity   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

Complexity

 Tip:   Before tackling complexity, make sure that you eliminate any duplication first. This often can reduce the size of classes significantly.

Complex classes like ocrd_models.ocrd_page_generateds often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
4
#
5
# Generated Thu Dec 11 12:03:57 2025 by generateDS.py version 2.44.1.
6
# Python 3.8.19 (default, Mar 26 2024, 20:08:11)  [GCC 8.5.0]
7
#
8
# Command line options:
9
#   ('-f', '')
10
#   ('--root-element', 'PcGts')
11
#   ('-o', 'src/ocrd_models/ocrd_page_generateds.py')
12
#   ('--silence', '')
13
#   ('--export', 'write etree')
14
#   ('--disable-generatedssuper-lookup', '')
15
#   ('--user-methods', 'src/ocrd_page_user_methods.py')
16
#
17
# Command line arguments:
18
#   src/ocrd_validators/page.xsd
19
#
20
# Command line:
21
#   /data/ocr-d/ocrd_all/venv38/bin/generateDS -f --root-element="PcGts" -o "src/ocrd_models/ocrd_page_generateds.py" --silence --export="write etree" --disable-generatedssuper-lookup --user-methods="src/ocrd_page_user_methods.py" src/ocrd_validators/page.xsd
22
#
23
# Current working directory (os.getcwd()):
24
#   core
25
#
26
27
import sys
28
try:
29
    ModulenotfoundExp_ = ModuleNotFoundError
30
except NameError:
31
    ModulenotfoundExp_ = ImportError
32
from itertools import zip_longest
33
import os
34
import re as re_
35
import base64
36
import datetime as datetime_
37
import decimal as decimal_
38
from lxml import etree as etree_
39
40
41
Validate_simpletypes_ = True
42
SaveElementTreeNode = True
43
TagNamePrefix = ""
44
if sys.version_info.major == 2:
45
    BaseStrType_ = basestring
46
else:
47
    BaseStrType_ = str
48
49
50
def parsexml_(infile, parser=None, **kwargs):
51
    if parser is None:
52
        # Use the lxml ElementTree compatible parser so that, e.g.,
53
        #   we ignore comments.
54
        try:
55
            parser = etree_.ETCompatXMLParser()
56
        except AttributeError:
57
            # fallback to xml.etree
58
            parser = etree_.XMLParser()
59
    try:
60
        if isinstance(infile, os.PathLike):
61
            infile = os.path.join(infile)
62
    except AttributeError:
63
        pass
64
    doc = etree_.parse(infile, parser=parser, **kwargs)
65
    return doc
66
67
def parsexmlstring_(instring, parser=None, **kwargs):
68
    if parser is None:
69
        # Use the lxml ElementTree compatible parser so that, e.g.,
70
        #   we ignore comments.
71
        try:
72
            parser = etree_.ETCompatXMLParser()
73
        except AttributeError:
74
            # fallback to xml.etree
75
            parser = etree_.XMLParser()
76
    element = etree_.fromstring(instring, parser=parser, **kwargs)
77
    return element
78
79
#
80
# Namespace prefix definition table (and other attributes, too)
81
#
82
# The module generatedsnamespaces, if it is importable, must contain
83
# a dictionary named GeneratedsNamespaceDefs.  This Python dictionary
84
# should map element type names (strings) to XML schema namespace prefix
85
# definitions.  The export method for any class for which there is
86
# a namespace prefix definition, will export that definition in the
87
# XML representation of that element.  See the export method of
88
# any generated element type class for an example of the use of this
89
# table.
90
# A sample table is:
91
#
92
#     # File: generatedsnamespaces.py
93
#
94
#     GenerateDSNamespaceDefs = {
95
#         "ElementtypeA": "http://www.xxx.com/namespaceA",
96
#         "ElementtypeB": "http://www.xxx.com/namespaceB",
97
#     }
98
#
99
# Additionally, the generatedsnamespaces module can contain a python
100
# dictionary named GenerateDSNamespaceTypePrefixes that associates element
101
# types with the namespace prefixes that are to be added to the
102
# "xsi:type" attribute value.  See the _exportAttributes method of
103
# any generated element type and the generation of "xsi:type" for an
104
# example of the use of this table.
105
# An example table:
106
#
107
#     # File: generatedsnamespaces.py
108
#
109
#     GenerateDSNamespaceTypePrefixes = {
110
#         "ElementtypeC": "aaa:",
111
#         "ElementtypeD": "bbb:",
112
#     }
113
#
114
115
try:
116
    from generatedsnamespaces import GenerateDSNamespaceDefs as GenerateDSNamespaceDefs_
117
except ModulenotfoundExp_ :
118
    GenerateDSNamespaceDefs_ = {}
119
try:
120
    from generatedsnamespaces import GenerateDSNamespaceTypePrefixes as GenerateDSNamespaceTypePrefixes_
121
except ModulenotfoundExp_ :
122
    GenerateDSNamespaceTypePrefixes_ = {}
123
124
#
125
# You can replace the following class definition by defining an
126
# importable module named "generatedscollector" containing a class
127
# named "GdsCollector".  See the default class definition below for
128
# clues about the possible content of that class.
129
#
130
try:
131
    from generatedscollector import GdsCollector as GdsCollector_
132
except ModulenotfoundExp_ :
133
134
    class GdsCollector_(object):
135
136
        def __init__(self, messages=None):
137
            if messages is None:
138
                self.messages = []
139
            else:
140
                self.messages = messages
141
142
        def add_message(self, msg):
143
            self.messages.append(msg)
144
145
        def get_messages(self):
146
            return self.messages
147
148
        def clear_messages(self):
149
            self.messages = []
150
151
        def print_messages(self):
152
            for msg in self.messages:
153
                print("Warning: {}".format(msg))
154
155
        def write_messages(self, outstream):
156
            for msg in self.messages:
157
                outstream.write("Warning: {}\n".format(msg))
158
159
160
#
161
# The super-class for enum types
162
#
163
164
try:
165
    from enum import Enum
166
except ModulenotfoundExp_ :
167
    Enum = object
168
169
#
170
# The root super-class for element type classes
171
#
172
# Calls to the methods in these classes are generated by generateDS.py.
173
# You can replace these methods by re-implementing the following class
174
#   in a module named generatedssuper.py.
175
176
177
class GeneratedsSuper(object):
178
    __hash__ = object.__hash__
179
    tzoff_pattern = re_.compile('(\\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00)$')
180
    class _FixedOffsetTZ(datetime_.tzinfo):
181
        def __init__(self, offset, name):
182
            self.__offset = datetime_.timedelta(minutes=offset)
183
            self.__name = name
184
        def utcoffset(self, dt):
185
            return self.__offset
186
        def tzname(self, dt):
187
            return self.__name
188
        def dst(self, dt):
189
            return None
190
    def __str__(self):
191
        settings = {
192
            'str_pretty_print': True,
193
            'str_indent_level': 0,
194
            'str_namespaceprefix': '',
195
            'str_name': self.__class__.__name__,
196
            'str_namespacedefs': '',
197
        }
198
        for n in settings:
199
            if hasattr(self, n):
200
                settings[n] = getattr(self, n)
201
        if sys.version_info.major == 2:
202
            from StringIO import StringIO
203
        else:
204
            from io import StringIO
205
        output = StringIO()
206
        self.export(
207
            output,
208
            settings['str_indent_level'],
209
            pretty_print=settings['str_pretty_print'],
210
            namespaceprefix_=settings['str_namespaceprefix'],
211
            name_=settings['str_name'],
212
            namespacedef_=settings['str_namespacedefs']
213
        )
214
        strval = output.getvalue()
215
        output.close()
216
        return strval
217
    def gds_format_string(self, input_data, input_name=''):
218
        return input_data
219
    def gds_parse_string(self, input_data, node=None, input_name=''):
220
        return input_data
221
    def gds_validate_string(self, input_data, node=None, input_name=''):
222
        if not input_data:
223
            return ''
224
        else:
225
            return input_data
226
    def gds_format_base64(self, input_data, input_name=''):
227
        return base64.b64encode(input_data).decode('ascii')
228
    def gds_validate_base64(self, input_data, node=None, input_name=''):
229
        return input_data
230
    def gds_format_integer(self, input_data, input_name=''):
231
        return '%d' % int(input_data)
232
    def gds_parse_integer(self, input_data, node=None, input_name=''):
233
        try:
234
            ival = int(input_data)
235
        except (TypeError, ValueError) as exp:
236
            raise_parse_error(node, 'Requires integer value: %s' % exp)
237
        return ival
238
    def gds_validate_integer(self, input_data, node=None, input_name=''):
239
        try:
240
            value = int(input_data)
241
        except (TypeError, ValueError):
242
            raise_parse_error(node, 'Requires integer value')
243
        return value
244
    def gds_format_integer_list(self, input_data, input_name=''):
245
        if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_):
246
            input_data = [str(s) for s in input_data]
247
        return '%s' % ' '.join(input_data)
248
    def gds_validate_integer_list(
249
            self, input_data, node=None, input_name=''):
250
        values = input_data.split()
251
        for value in values:
252
            try:
253
                int(value)
254
            except (TypeError, ValueError):
255
                raise_parse_error(node, 'Requires sequence of integer values')
256
        return values
257
    def gds_format_float(self, input_data, input_name=''):
258
        value = ('%.15f' % float(input_data)).rstrip('0')
259
        if value.endswith('.'):
260
            value += '0'
261
        return value
262
263
    def gds_parse_float(self, input_data, node=None, input_name=''):
264
        try:
265
            fval_ = float(input_data)
266
        except (TypeError, ValueError) as exp:
267
            raise_parse_error(node, 'Requires float or double value: %s' % exp)
268
        return fval_
269
    def gds_validate_float(self, input_data, node=None, input_name=''):
270
        try:
271
            value = float(input_data)
272
        except (TypeError, ValueError):
273
            raise_parse_error(node, 'Requires float value')
274
        return value
275
    def gds_format_float_list(self, input_data, input_name=''):
276
        if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_):
277
            input_data = [str(s) for s in input_data]
278
        return '%s' % ' '.join(input_data)
279
    def gds_validate_float_list(
280
            self, input_data, node=None, input_name=''):
281
        values = input_data.split()
282
        for value in values:
283
            try:
284
                float(value)
285
            except (TypeError, ValueError):
286
                raise_parse_error(node, 'Requires sequence of float values')
287
        return values
288
    def gds_format_decimal(self, input_data, input_name=''):
289
        return_value = '%s' % input_data
290
        if '.' in return_value:
291
            return_value = return_value.rstrip('0')
292
            if return_value.endswith('.'):
293
                return_value = return_value.rstrip('.')
294
        return return_value
295
    def gds_parse_decimal(self, input_data, node=None, input_name=''):
296
        try:
297
            decimal_value = decimal_.Decimal(input_data)
298
        except (TypeError, ValueError):
299
            raise_parse_error(node, 'Requires decimal value')
300
        return decimal_value
301
    def gds_validate_decimal(self, input_data, node=None, input_name=''):
302
        try:
303
            value = decimal_.Decimal(input_data)
304
        except (TypeError, ValueError):
305
            raise_parse_error(node, 'Requires decimal value')
306
        return value
307
    def gds_format_decimal_list(self, input_data, input_name=''):
308
        if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_):
309
            input_data = [str(s) for s in input_data]
310
        return ' '.join([self.gds_format_decimal(item) for item in input_data])
311
    def gds_validate_decimal_list(
312
            self, input_data, node=None, input_name=''):
313
        values = input_data.split()
314
        for value in values:
315
            try:
316
                decimal_.Decimal(value)
317
            except (TypeError, ValueError):
318
                raise_parse_error(node, 'Requires sequence of decimal values')
319
        return values
320
    def gds_format_double(self, input_data, input_name=''):
321
        return '%s' % input_data
322
    def gds_parse_double(self, input_data, node=None, input_name=''):
323
        try:
324
            fval_ = float(input_data)
325
        except (TypeError, ValueError) as exp:
326
            raise_parse_error(node, 'Requires double or float value: %s' % exp)
327
        return fval_
328
    def gds_validate_double(self, input_data, node=None, input_name=''):
329
        try:
330
            value = float(input_data)
331
        except (TypeError, ValueError):
332
            raise_parse_error(node, 'Requires double or float value')
333
        return value
334
    def gds_format_double_list(self, input_data, input_name=''):
335
        if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_):
336
            input_data = [str(s) for s in input_data]
337
        return '%s' % ' '.join(input_data)
338
    def gds_validate_double_list(
339
            self, input_data, node=None, input_name=''):
340
        values = input_data.split()
341
        for value in values:
342
            try:
343
                float(value)
344
            except (TypeError, ValueError):
345
                raise_parse_error(
346
                    node, 'Requires sequence of double or float values')
347
        return values
348
    def gds_format_boolean(self, input_data, input_name=''):
349
        return ('%s' % input_data).lower()
350
    def gds_parse_boolean(self, input_data, node=None, input_name=''):
351
        input_data = input_data.strip()
352
        if input_data in ('true', '1'):
353
            bval = True
354
        elif input_data in ('false', '0'):
355
            bval = False
356
        else:
357
            raise_parse_error(node, 'Requires boolean value')
358
        return bval
359
    def gds_validate_boolean(self, input_data, node=None, input_name=''):
360
        if input_data not in (True, 1, False, 0, ):
361
            raise_parse_error(
362
                node,
363
                'Requires boolean value '
364
                '(one of True, 1, False, 0)')
365
        return input_data
366
    def gds_format_boolean_list(self, input_data, input_name=''):
367
        if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_):
368
            input_data = [str(s) for s in input_data]
369
        return '%s' % ' '.join(input_data)
370
    def gds_validate_boolean_list(
371
            self, input_data, node=None, input_name=''):
372
        values = input_data.split()
373
        for value in values:
374
            value = self.gds_parse_boolean(value, node, input_name)
375
            if value not in (True, 1, False, 0, ):
376
                raise_parse_error(
377
                    node,
378
                    'Requires sequence of boolean values '
379
                    '(one of True, 1, False, 0)')
380
        return values
381
    def gds_validate_datetime(self, input_data, node=None, input_name=''):
382
        return input_data
383 View Code Duplication
    def gds_format_datetime(self, input_data, input_name=''):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
384
        if input_data.microsecond == 0:
385
            _svalue = '%04d-%02d-%02dT%02d:%02d:%02d' % (
386
                input_data.year,
387
                input_data.month,
388
                input_data.day,
389
                input_data.hour,
390
                input_data.minute,
391
                input_data.second,
392
            )
393
        else:
394
            _svalue = '%04d-%02d-%02dT%02d:%02d:%02d.%s' % (
395
                input_data.year,
396
                input_data.month,
397
                input_data.day,
398
                input_data.hour,
399
                input_data.minute,
400
                input_data.second,
401
                ('%f' % (float(input_data.microsecond) / 1000000))[2:],
402
            )
403
        if input_data.tzinfo is not None:
404
            tzoff = input_data.tzinfo.utcoffset(input_data)
405
            if tzoff is not None:
406
                total_seconds = tzoff.seconds + (86400 * tzoff.days)
407
                if total_seconds == 0:
408
                    _svalue += 'Z'
409
                else:
410
                    if total_seconds < 0:
411
                        _svalue += '-'
412
                        total_seconds *= -1
413
                    else:
414
                        _svalue += '+'
415
                    hours = total_seconds // 3600
416
                    minutes = (total_seconds - (hours * 3600)) // 60
417
                    _svalue += '{0:02d}:{1:02d}'.format(hours, minutes)
418
        return _svalue
419
    @classmethod
420
    def gds_parse_datetime(cls, input_data):
421
        tz = None
422 View Code Duplication
        if input_data[-1] == 'Z':
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
423
            tz = GeneratedsSuper._FixedOffsetTZ(0, 'UTC')
424
            input_data = input_data[:-1]
425
        else:
426
            results = GeneratedsSuper.tzoff_pattern.search(input_data)
427
            if results is not None:
428
                tzoff_parts = results.group(2).split(':')
429
                tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1])
430
                if results.group(1) == '-':
431
                    tzoff *= -1
432
                tz = GeneratedsSuper._FixedOffsetTZ(
433
                    tzoff, results.group(0))
434
                input_data = input_data[:-6]
435
        time_parts = input_data.split('.')
436
        if len(time_parts) > 1:
437
            micro_seconds = int(float('0.' + time_parts[1]) * 1000000)
438
            input_data = '%s.%s' % (
439
                time_parts[0], "{}".format(micro_seconds).rjust(6, "0"), )
440
            dt = datetime_.datetime.strptime(
441
                input_data, '%Y-%m-%dT%H:%M:%S.%f')
442
        else:
443
            dt = datetime_.datetime.strptime(
444
                input_data, '%Y-%m-%dT%H:%M:%S')
445
        dt = dt.replace(tzinfo=tz)
446
        return dt
447
    def gds_validate_date(self, input_data, node=None, input_name=''):
448
        return input_data
449
    def gds_format_date(self, input_data, input_name=''):
450
        _svalue = '%04d-%02d-%02d' % (
451
            input_data.year,
452
            input_data.month,
453
            input_data.day,
454
        )
455
        try:
456
            if input_data.tzinfo is not None:
457
                tzoff = input_data.tzinfo.utcoffset(input_data)
458
                if tzoff is not None:
459
                    total_seconds = tzoff.seconds + (86400 * tzoff.days)
460
                    if total_seconds == 0:
461
                        _svalue += 'Z'
462
                    else:
463
                        if total_seconds < 0:
464
                            _svalue += '-'
465
                            total_seconds *= -1
466
                        else:
467
                            _svalue += '+'
468
                        hours = total_seconds // 3600
469
                        minutes = (total_seconds - (hours * 3600)) // 60
470
                        _svalue += '{0:02d}:{1:02d}'.format(
471
                            hours, minutes)
472
        except AttributeError:
473
            pass
474
        return _svalue
475
    @classmethod
476
    def gds_parse_date(cls, input_data):
477
        tz = None
478 View Code Duplication
        if input_data[-1] == 'Z':
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
479
            tz = GeneratedsSuper._FixedOffsetTZ(0, 'UTC')
480
            input_data = input_data[:-1]
481
        else:
482
            results = GeneratedsSuper.tzoff_pattern.search(input_data)
483
            if results is not None:
484
                tzoff_parts = results.group(2).split(':')
485
                tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1])
486
                if results.group(1) == '-':
487
                    tzoff *= -1
488
                tz = GeneratedsSuper._FixedOffsetTZ(
489
                    tzoff, results.group(0))
490
                input_data = input_data[:-6]
491
        dt = datetime_.datetime.strptime(input_data, '%Y-%m-%d')
492
        dt = dt.replace(tzinfo=tz)
493
        return dt.date()
494
    def gds_validate_time(self, input_data, node=None, input_name=''):
495
        return input_data
496 View Code Duplication
    def gds_format_time(self, input_data, input_name=''):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
497
        if input_data.microsecond == 0:
498
            _svalue = '%02d:%02d:%02d' % (
499
                input_data.hour,
500
                input_data.minute,
501
                input_data.second,
502
            )
503
        else:
504
            _svalue = '%02d:%02d:%02d.%s' % (
505
                input_data.hour,
506
                input_data.minute,
507
                input_data.second,
508
                ('%f' % (float(input_data.microsecond) / 1000000))[2:],
509
            )
510
        if input_data.tzinfo is not None:
511
            tzoff = input_data.tzinfo.utcoffset(input_data)
512
            if tzoff is not None:
513
                total_seconds = tzoff.seconds + (86400 * tzoff.days)
514
                if total_seconds == 0:
515
                    _svalue += 'Z'
516
                else:
517
                    if total_seconds < 0:
518
                        _svalue += '-'
519
                        total_seconds *= -1
520
                    else:
521
                        _svalue += '+'
522
                    hours = total_seconds // 3600
523
                    minutes = (total_seconds - (hours * 3600)) // 60
524
                    _svalue += '{0:02d}:{1:02d}'.format(hours, minutes)
525
        return _svalue
526
    def gds_validate_simple_patterns(self, patterns, target):
527
        # pat is a list of lists of strings/patterns.
528
        # The target value must match at least one of the patterns
529
        # in order for the test to succeed.
530
        found1 = True
531
        target = str(target)
532
        for patterns1 in patterns:
533
            found2 = False
534
            for patterns2 in patterns1:
535
                mo = re_.search(patterns2, target)
536
                if mo is not None and len(mo.group(0)) == len(target):
537
                    found2 = True
538
                    break
539
            if not found2:
540
                found1 = False
541
                break
542
        return found1
543
    @classmethod
544
    def gds_parse_time(cls, input_data):
545
        tz = None
546 View Code Duplication
        if input_data[-1] == 'Z':
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
547
            tz = GeneratedsSuper._FixedOffsetTZ(0, 'UTC')
548
            input_data = input_data[:-1]
549
        else:
550
            results = GeneratedsSuper.tzoff_pattern.search(input_data)
551
            if results is not None:
552
                tzoff_parts = results.group(2).split(':')
553
                tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1])
554
                if results.group(1) == '-':
555
                    tzoff *= -1
556
                tz = GeneratedsSuper._FixedOffsetTZ(
557
                    tzoff, results.group(0))
558
                input_data = input_data[:-6]
559
        if len(input_data.split('.')) > 1:
560
            dt = datetime_.datetime.strptime(input_data, '%H:%M:%S.%f')
561
        else:
562
            dt = datetime_.datetime.strptime(input_data, '%H:%M:%S')
563
        dt = dt.replace(tzinfo=tz)
564
        return dt.time()
565
    def gds_check_cardinality_(
566
            self, value, input_name,
567
            min_occurs=0, max_occurs=1, required=None):
568
        if value is None:
569
            length = 0
570
        elif isinstance(value, list):
571
            length = len(value)
572
        else:
573
            length = 1
574
        if required is not None :
575
            if required and length < 1:
576
                self.gds_collector_.add_message(
577
                    "Required value {}{} is missing".format(
578
                        input_name, self.gds_get_node_lineno_()))
579
        if length < min_occurs:
580
            self.gds_collector_.add_message(
581
                "Number of values for {}{} is below "
582
                "the minimum allowed, "
583
                "expected at least {}, found {}".format(
584
                    input_name, self.gds_get_node_lineno_(),
585
                    min_occurs, length))
586
        elif length > max_occurs:
587
            self.gds_collector_.add_message(
588
                "Number of values for {}{} is above "
589
                "the maximum allowed, "
590
                "expected at most {}, found {}".format(
591
                    input_name, self.gds_get_node_lineno_(),
592
                    max_occurs, length))
593
    def gds_validate_builtin_ST_(
594
            self, validator, value, input_name,
595
            min_occurs=None, max_occurs=None, required=None):
596
        if value is not None:
597
            try:
598
                validator(value, input_name=input_name)
599
            except GDSParseError as parse_error:
600
                self.gds_collector_.add_message(str(parse_error))
601
    def gds_validate_defined_ST_(
602
            self, validator, value, input_name,
603
            min_occurs=None, max_occurs=None, required=None):
604
        if value is not None:
605
            try:
606
                validator(value)
607
            except GDSParseError as parse_error:
608
                self.gds_collector_.add_message(str(parse_error))
609
    def gds_str_lower(self, instring):
610
        return instring.lower()
611
    def get_path_(self, node):
612
        path_list = []
613
        self.get_path_list_(node, path_list)
614
        path_list.reverse()
615
        path = '/'.join(path_list)
616
        return path
617
    Tag_strip_pattern_ = re_.compile(r'{.*}')
618
    def get_path_list_(self, node, path_list):
619
        if node is None:
620
            return
621
        tag = GeneratedsSuper.Tag_strip_pattern_.sub('', node.tag)
622
        if tag:
623
            path_list.append(tag)
624
        self.get_path_list_(node.getparent(), path_list)
625
    def get_class_obj_(self, node, default_class=None):
626
        class_obj1 = default_class
627
        if 'xsi' in node.nsmap:
628
            classname = node.get('{%s}type' % node.nsmap['xsi'])
629
            if classname is not None:
630
                names = classname.split(':')
631
                if len(names) == 2:
632
                    classname = names[1]
633
                class_obj2 = globals().get(classname)
634
                if class_obj2 is not None:
635
                    class_obj1 = class_obj2
636
        return class_obj1
637
    def gds_build_any(self, node, type_name=None):
638
        # provide default value in case option --disable-xml is used.
639
        content = ""
640
        content = etree_.tostring(node, encoding="unicode")
641
        return content
642
    @classmethod
643
    def gds_reverse_node_mapping(cls, mapping):
644
        return dict(((v, k) for k, v in mapping.items()))
645
    @staticmethod
646
    def gds_encode(instring):
647
        if sys.version_info.major == 2:
648
            if ExternalEncoding:
649
                encoding = ExternalEncoding
650
            else:
651
                encoding = 'utf-8'
652
            return instring.encode(encoding)
653
        else:
654
            return instring
655
    @staticmethod
656
    def convert_unicode(instring):
657
        if isinstance(instring, str):
658
            result = quote_xml(instring)
659
        elif sys.version_info.major == 2 and isinstance(instring, unicode):
660
            result = quote_xml(instring).encode('utf8')
661
        else:
662
            result = GeneratedsSuper.gds_encode(str(instring))
663
        return result
664
    def __eq__(self, other):
665
        def excl_select_objs_(obj):
666
            return (obj[0] != 'parent_object_' and
667
                    obj[0] != 'gds_collector_')
668
        if type(self) != type(other):
669
            return False
670
        return all(x == y for x, y in zip_longest(
671
            filter(excl_select_objs_, self.__dict__.items()),
672
            filter(excl_select_objs_, other.__dict__.items())))
673
    def __ne__(self, other):
674
        return not self.__eq__(other)
675
    # Django ETL transform hooks.
676
    def gds_djo_etl_transform(self):
677
        pass
678
    def gds_djo_etl_transform_db_obj(self, dbobj):
679
        pass
680
    # SQLAlchemy ETL transform hooks.
681
    def gds_sqa_etl_transform(self):
682
        return 0, None
683
    def gds_sqa_etl_transform_db_obj(self, dbobj):
684
        pass
685
    def gds_get_node_lineno_(self):
686
        if (hasattr(self, "gds_elementtree_node_") and
687
                self.gds_elementtree_node_ is not None):
688
            return ' near line {}'.format(
689
                self.gds_elementtree_node_.sourceline)
690
        else:
691
            return ""
692
693
694
def getSubclassFromModule_(module, class_):
695
    '''Get the subclass of a class from a specific module.'''
696
    name = class_.__name__ + 'Sub'
697
    if hasattr(module, name):
698
        return getattr(module, name)
699
    else:
700
        return None
701
702
703
#
704
# If you have installed IPython you can uncomment and use the following.
705
# IPython is available from http://ipython.scipy.org/.
706
#
707
708
## from IPython.Shell import IPShellEmbed
709
## args = ''
710
## ipshell = IPShellEmbed(args,
711
##     banner = 'Dropping into IPython',
712
##     exit_msg = 'Leaving Interpreter, back to program.')
713
714
# Then use the following line where and when you want to drop into the
715
# IPython shell:
716
#    ipshell('<some message> -- Entering ipshell.\nHit Ctrl-D to exit')
717
718
#
719
# Globals
720
#
721
722
ExternalEncoding = ''
723
# Set this to false in order to deactivate during export, the use of
724
# name space prefixes captured from the input document.
725
UseCapturedNS_ = True
726
CapturedNsmap_ = {}
727
Tag_pattern_ = re_.compile(r'({.*})?(.*)')
728
String_cleanup_pat_ = re_.compile(r"[\n\r\s]+")
729
Namespace_extract_pat_ = re_.compile(r'{(.*)}(.*)')
730
CDATA_pattern_ = re_.compile(r"<!\[CDATA\[.*?\]\]>", re_.DOTALL)
731
732
# Change this to redirect the generated superclass module to use a
733
# specific subclass module.
734
CurrentSubclassModule_ = None
735
736
#
737
# Support/utility functions.
738
#
739
740
741
def showIndent(outfile, level, pretty_print=True):
742
    if pretty_print:
743
        for idx in range(level):
744
            outfile.write('    ')
745
746
747
def quote_xml(inStr):
748
    "Escape markup chars, but do not modify CDATA sections."
749
    if not inStr:
750
        return ''
751
    s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr)
752
    s2 = ''
753
    pos = 0
754
    matchobjects = CDATA_pattern_.finditer(s1)
755
    for mo in matchobjects:
756
        s3 = s1[pos:mo.start()]
757
        s2 += quote_xml_aux(s3)
758
        s2 += s1[mo.start():mo.end()]
759
        pos = mo.end()
760
    s3 = s1[pos:]
761
    s2 += quote_xml_aux(s3)
762
    return s2
763
764
765
def quote_xml_aux(inStr):
766
    s1 = inStr.replace('&', '&amp;')
767
    s1 = s1.replace('<', '&lt;')
768
    s1 = s1.replace('>', '&gt;')
769
    return s1
770
771
772
def quote_attrib(inStr):
773
    s1 = (isinstance(inStr, BaseStrType_) and inStr or '%s' % inStr)
774
    s1 = s1.replace('&', '&amp;')
775
    s1 = s1.replace('<', '&lt;')
776
    s1 = s1.replace('>', '&gt;')
777
    s1 = s1.replace('\n', '&#10;')
778
    if '"' in s1:
779
        if "'" in s1:
780
            s1 = '"%s"' % s1.replace('"', "&quot;")
781
        else:
782
            s1 = "'%s'" % s1
783
    else:
784
        s1 = '"%s"' % s1
785
    return s1
786
787
788
def quote_python(inStr):
789
    s1 = inStr
790
    if s1.find("'") == -1:
791
        if s1.find('\n') == -1:
792
            return "'%s'" % s1
793
        else:
794
            return "'''%s'''" % s1
795
    else:
796
        if s1.find('"') != -1:
797
            s1 = s1.replace('"', '\\"')
798
        if s1.find('\n') == -1:
799
            return '"%s"' % s1
800
        else:
801
            return '"""%s"""' % s1
802
803
804
def get_all_text_(node):
805
    if node.text is not None:
806
        text = node.text
807
    else:
808
        text = ''
809
    for child in node:
810
        if child.tail is not None:
811
            text += child.tail
812
    return text
813
814
815
def find_attr_value_(attr_name, node):
816
    attrs = node.attrib
817
    attr_parts = attr_name.split(':')
818
    value = None
819
    if len(attr_parts) == 1:
820
        value = attrs.get(attr_name)
821
    elif len(attr_parts) == 2:
822
        prefix, name = attr_parts
823
        if prefix == 'xml':
824
            namespace = 'http://www.w3.org/XML/1998/namespace'
825
        else:
826
            namespace = node.nsmap.get(prefix)
827
        if namespace is not None:
828
            value = attrs.get('{%s}%s' % (namespace, name, ))
829
    return value
830
831
832
def encode_str_2_3(instr):
833
    return instr
834
835
836
class GDSParseError(Exception):
837
    pass
838
839
840
def raise_parse_error(node, msg):
841
    if node is not None:
842
        msg = '%s (element %s/line %d)' % (msg, node.tag, node.sourceline, )
843
    raise GDSParseError(msg)
844
845
846
class MixedContainer:
847
    # Constants for category:
848
    CategoryNone = 0
849
    CategoryText = 1
850
    CategorySimple = 2
851
    CategoryComplex = 3
852
    # Constants for content_type:
853
    TypeNone = 0
854
    TypeText = 1
855
    TypeString = 2
856
    TypeInteger = 3
857
    TypeFloat = 4
858
    TypeDecimal = 5
859
    TypeDouble = 6
860
    TypeBoolean = 7
861
    TypeBase64 = 8
862
    def __init__(self, category, content_type, name, value):
863
        self.category = category
864
        self.content_type = content_type
865
        self.name = name
866
        self.value = value
867
    def getCategory(self):
868
        return self.category
869
    def getContenttype(self, content_type):
870
        return self.content_type
871
    def getValue(self):
872
        return self.value
873
    def getName(self):
874
        return self.name
875
    def export(self, outfile, level, name, namespace,
876
               pretty_print=True):
877
        if self.category == MixedContainer.CategoryText:
878
            # Prevent exporting empty content as empty lines.
879
            if self.value.strip():
880
                outfile.write(self.value)
881
        elif self.category == MixedContainer.CategorySimple:
882
            self.exportSimple(outfile, level, name)
883
        else:    # category == MixedContainer.CategoryComplex
884
            self.value.export(
885
                outfile, level, namespace, name_=name,
886
                pretty_print=pretty_print)
887
    def exportSimple(self, outfile, level, name):
888
        if self.content_type == MixedContainer.TypeString:
889
            outfile.write('<%s>%s</%s>' % (
890
                self.name, self.value, self.name))
891
        elif self.content_type == MixedContainer.TypeInteger or \
892
                self.content_type == MixedContainer.TypeBoolean:
893
            outfile.write('<%s>%d</%s>' % (
894
                self.name, self.value, self.name))
895
        elif self.content_type == MixedContainer.TypeFloat or \
896
                self.content_type == MixedContainer.TypeDecimal:
897
            outfile.write('<%s>%f</%s>' % (
898
                self.name, self.value, self.name))
899
        elif self.content_type == MixedContainer.TypeDouble:
900
            outfile.write('<%s>%g</%s>' % (
901
                self.name, self.value, self.name))
902
        elif self.content_type == MixedContainer.TypeBase64:
903
            outfile.write('<%s>%s</%s>' % (
904
                self.name,
905
                base64.b64encode(self.value),
906
                self.name))
907
    def to_etree(self, element, mapping_=None, reverse_mapping_=None, nsmap_=None):
908
        if self.category == MixedContainer.CategoryText:
909
            # Prevent exporting empty content as empty lines.
910
            if self.value.strip():
911
                if len(element) > 0:
912
                    if element[-1].tail is None:
913
                        element[-1].tail = self.value
914
                    else:
915
                        element[-1].tail += self.value
916
                else:
917
                    if element.text is None:
918
                        element.text = self.value
919
                    else:
920
                        element.text += self.value
921
        elif self.category == MixedContainer.CategorySimple:
922
            subelement = etree_.SubElement(
923
                element, '%s' % self.name)
924
            subelement.text = self.to_etree_simple()
925
        else:    # category == MixedContainer.CategoryComplex
926
            self.value.to_etree(element)
927
    def to_etree_simple(self, mapping_=None, reverse_mapping_=None, nsmap_=None):
928
        if self.content_type == MixedContainer.TypeString:
929
            text = self.value
930
        elif (self.content_type == MixedContainer.TypeInteger or
931
                self.content_type == MixedContainer.TypeBoolean):
932
            text = '%d' % self.value
933
        elif (self.content_type == MixedContainer.TypeFloat or
934
                self.content_type == MixedContainer.TypeDecimal):
935
            text = '%f' % self.value
936
        elif self.content_type == MixedContainer.TypeDouble:
937
            text = '%g' % self.value
938
        elif self.content_type == MixedContainer.TypeBase64:
939
            text = '%s' % base64.b64encode(self.value)
940
        return text
941
    def exportLiteral(self, outfile, level, name):
942
        if self.category == MixedContainer.CategoryText:
943
            showIndent(outfile, level)
944
            outfile.write(
945
                'model_.MixedContainer(%d, %d, "%s", "%s"),\n' % (
946
                    self.category, self.content_type,
947
                    self.name, self.value))
948
        elif self.category == MixedContainer.CategorySimple:
949
            showIndent(outfile, level)
950
            outfile.write(
951
                'model_.MixedContainer(%d, %d, "%s", "%s"),\n' % (
952
                    self.category, self.content_type,
953
                    self.name, self.value))
954
        else:    # category == MixedContainer.CategoryComplex
955
            showIndent(outfile, level)
956
            outfile.write(
957
                'model_.MixedContainer(%d, %d, "%s",\n' % (
958
                    self.category, self.content_type, self.name,))
959
            self.value.exportLiteral(outfile, level + 1)
960
            showIndent(outfile, level)
961
            outfile.write(')\n')
962
963
964
class MemberSpec_(object):
965
    def __init__(self, name='', data_type='', container=0,
966
            optional=0, child_attrs=None, choice=None):
967
        self.name = name
968
        self.data_type = data_type
969
        self.container = container
970
        self.child_attrs = child_attrs
971
        self.choice = choice
972
        self.optional = optional
973
    def set_name(self, name): self.name = name
974
    def get_name(self): return self.name
975
    def set_data_type(self, data_type): self.data_type = data_type
976
    def get_data_type_chain(self): return self.data_type
977
    def get_data_type(self):
978
        if isinstance(self.data_type, list):
979
            if len(self.data_type) > 0:
980
                return self.data_type[-1]
981
            else:
982
                return 'xs:string'
983
        else:
984
            return self.data_type
985
    def set_container(self, container): self.container = container
986
    def get_container(self): return self.container
987
    def set_child_attrs(self, child_attrs): self.child_attrs = child_attrs
988
    def get_child_attrs(self): return self.child_attrs
989
    def set_choice(self, choice): self.choice = choice
990
    def get_choice(self): return self.choice
991
    def set_optional(self, optional): self.optional = optional
992
    def get_optional(self): return self.optional
993
994
995
def _cast(typ, value):
996
    if typ is None or value is None:
997
        return value
998
    return typ(value)
999
1000
1001
#
1002
# Start enum classes
1003
#
1004
class AlignSimpleType(str, Enum):
1005
    LEFT='left'
1006
    CENTRE='centre'
1007
    RIGHT='right'
1008
    JUSTIFY='justify'
1009
1010
1011
class ChartTypeSimpleType(str, Enum):
1012
    BAR='bar'
1013
    LINE='line'
1014
    PIE='pie'
1015
    SCATTER='scatter'
1016
    SURFACE='surface'
1017
    OTHER='other'
1018
1019
1020
class ColourDepthSimpleType(str, Enum):
1021
    BILEVEL='bilevel'
1022
    GREYSCALE='greyscale'
1023
    COLOUR='colour'
1024
    OTHER='other'
1025
1026
1027
class ColourSimpleType(str, Enum):
1028
    BLACK='black'
1029
    BLUE='blue'
1030
    BROWN='brown'
1031
    CYAN='cyan'
1032
    GREEN='green'
1033
    GREY='grey'
1034
    INDIGO='indigo'
1035
    MAGENTA='magenta'
1036
    ORANGE='orange'
1037
    PINK='pink'
1038
    RED='red'
1039
    TURQUOISE='turquoise'
1040
    VIOLET='violet'
1041
    WHITE='white'
1042
    YELLOW='yellow'
1043
    OTHER='other'
1044
1045
1046
class GraphicsTypeSimpleType(str, Enum):
1047
    LOGO='logo'
1048
    LETTERHEAD='letterhead'
1049
    DECORATION='decoration'
1050
    FRAME='frame'
1051
    HANDWRITTENANNOTATION='handwritten-annotation'
1052
    STAMP='stamp'
1053
    SIGNATURE='signature'
1054
    BARCODE='barcode'
1055
    PAPERGROW='paper-grow'
1056
    PUNCHHOLE='punch-hole'
1057
    OTHER='other'
1058
1059
1060
class GroupTypeSimpleType(str, Enum):
1061
    PARAGRAPH='paragraph'
1062
    LIST='list'
1063
    LISTITEM='list-item'
1064
    FIGURE='figure'
1065
    ARTICLE='article'
1066
    DIV='div'
1067
    OTHER='other'
1068
1069
1070
class LanguageSimpleType(str, Enum):
1071
    """LanguageSimpleType -- ISO 639.x 2016-07-14
1072
    
1073
    """
1074
    ABKHAZ='Abkhaz'
1075
    AFAR='Afar'
1076
    AFRIKAANS='Afrikaans'
1077
    AKAN='Akan'
1078
    ALBANIAN='Albanian'
1079
    AMHARIC='Amharic'
1080
    ARABIC='Arabic'
1081
    ARAGONESE='Aragonese'
1082
    ARMENIAN='Armenian'
1083
    ASSAMESE='Assamese'
1084
    AVARIC='Avaric'
1085
    AVESTAN='Avestan'
1086
    AYMARA='Aymara'
1087
    AZERBAIJANI='Azerbaijani'
1088
    BAMBARA='Bambara'
1089
    BASHKIR='Bashkir'
1090
    BASQUE='Basque'
1091
    BELARUSIAN='Belarusian'
1092
    BENGALI='Bengali'
1093
    BIHARI='Bihari'
1094
    BISLAMA='Bislama'
1095
    BOSNIAN='Bosnian'
1096
    BRETON='Breton'
1097
    BULGARIAN='Bulgarian'
1098
    BURMESE='Burmese'
1099
    CAMBODIAN='Cambodian'
1100
    CANTONESE='Cantonese'
1101
    CATALAN='Catalan'
1102
    CHAMORRO='Chamorro'
1103
    CHECHEN='Chechen'
1104
    CHICHEWA='Chichewa'
1105
    CHINESE='Chinese'
1106
    CHUVASH='Chuvash'
1107
    CORNISH='Cornish'
1108
    CORSICAN='Corsican'
1109
    CREE='Cree'
1110
    CROATIAN='Croatian'
1111
    CZECH='Czech'
1112
    DANISH='Danish'
1113
    DIVEHI='Divehi'
1114
    DUTCH='Dutch'
1115
    DZONGKHA='Dzongkha'
1116
    ENGLISH='English'
1117
    ESPERANTO='Esperanto'
1118
    ESTONIAN='Estonian'
1119
    EWE='Ewe'
1120
    FAROESE='Faroese'
1121
    FIJIAN='Fijian'
1122
    FINNISH='Finnish'
1123
    FRENCH='French'
1124
    FULA='Fula'
1125
    GAELIC='Gaelic'
1126
    GALICIAN='Galician'
1127
    GANDA='Ganda'
1128
    GEORGIAN='Georgian'
1129
    GERMAN='German'
1130
    GREEK='Greek'
1131
    GUARANÍ='Guaraní'
1132
    GUJARATI='Gujarati'
1133
    HAITIAN='Haitian'
1134
    HAUSA='Hausa'
1135
    HEBREW='Hebrew'
1136
    HERERO='Herero'
1137
    HINDI='Hindi'
1138
    HIRI_MOTU='Hiri Motu'
1139
    HUNGARIAN='Hungarian'
1140
    ICELANDIC='Icelandic'
1141
    IDO='Ido'
1142
    IGBO='Igbo'
1143
    INDONESIAN='Indonesian'
1144
    INTERLINGUA='Interlingua'
1145
    INTERLINGUE='Interlingue'
1146
    INUKTITUT='Inuktitut'
1147
    INUPIAQ='Inupiaq'
1148
    IRISH='Irish'
1149
    ITALIAN='Italian'
1150
    JAPANESE='Japanese'
1151
    JAVANESE='Javanese'
1152
    KALAALLISUT='Kalaallisut'
1153
    KANNADA='Kannada'
1154
    KANURI='Kanuri'
1155
    KASHMIRI='Kashmiri'
1156
    KAZAKH='Kazakh'
1157
    KHMER='Khmer'
1158
    KIKUYU='Kikuyu'
1159
    KINYARWANDA='Kinyarwanda'
1160
    KIRUNDI='Kirundi'
1161
    KOMI='Komi'
1162
    KONGO='Kongo'
1163
    KOREAN='Korean'
1164
    KURDISH='Kurdish'
1165
    KWANYAMA='Kwanyama'
1166
    KYRGYZ='Kyrgyz'
1167
    LAO='Lao'
1168
    LATIN='Latin'
1169
    LATVIAN='Latvian'
1170
    LIMBURGISH='Limburgish'
1171
    LINGALA='Lingala'
1172
    LITHUANIAN='Lithuanian'
1173
    LUBA_KATANGA='Luba-Katanga'
1174
    LUXEMBOURGISH='Luxembourgish'
1175
    MACEDONIAN='Macedonian'
1176
    MALAGASY='Malagasy'
1177
    MALAY='Malay'
1178
    MALAYALAM='Malayalam'
1179
    MALTESE='Maltese'
1180
    MANX='Manx'
1181
    MĀORI='Māori'
1182
    MARATHI='Marathi'
1183
    MARSHALLESE='Marshallese'
1184
    MONGOLIAN='Mongolian'
1185
    NAURU='Nauru'
1186
    NAVAJO='Navajo'
1187
    NDONGA='Ndonga'
1188
    NEPALI='Nepali'
1189
    NORTH_NDEBELE='North Ndebele'
1190
    NORTHERN_SAMI='Northern Sami'
1191
    NORWEGIAN='Norwegian'
1192
    NORWEGIAN_BOKMÅL='Norwegian Bokmål'
1193
    NORWEGIAN_NYNORSK='Norwegian Nynorsk'
1194
    NUOSU='Nuosu'
1195
    OCCITAN='Occitan'
1196
    OJIBWE='Ojibwe'
1197
    OLD_CHURCH_SLAVONIC='Old Church Slavonic'
1198
    ORIYA='Oriya'
1199
    OROMO='Oromo'
1200
    OSSETIAN='Ossetian'
1201
    PĀLI='Pāli'
1202
    PANJABI='Panjabi'
1203
    PASHTO='Pashto'
1204
    PERSIAN='Persian'
1205
    POLISH='Polish'
1206
    PORTUGUESE='Portuguese'
1207
    PUNJABI='Punjabi'
1208
    QUECHUA='Quechua'
1209
    ROMANIAN='Romanian'
1210
    ROMANSH='Romansh'
1211
    RUSSIAN='Russian'
1212
    SAMOAN='Samoan'
1213
    SANGO='Sango'
1214
    SANSKRIT='Sanskrit'
1215
    SARDINIAN='Sardinian'
1216
    SERBIAN='Serbian'
1217
    SHONA='Shona'
1218
    SINDHI='Sindhi'
1219
    SINHALA='Sinhala'
1220
    SLOVAK='Slovak'
1221
    SLOVENE='Slovene'
1222
    SOMALI='Somali'
1223
    SOUTH_NDEBELE='South Ndebele'
1224
    SOUTHERN_SOTHO='Southern Sotho'
1225
    SPANISH='Spanish'
1226
    SUNDANESE='Sundanese'
1227
    SWAHILI='Swahili'
1228
    SWATI='Swati'
1229
    SWEDISH='Swedish'
1230
    TAGALOG='Tagalog'
1231
    TAHITIAN='Tahitian'
1232
    TAJIK='Tajik'
1233
    TAMIL='Tamil'
1234
    TATAR='Tatar'
1235
    TELUGU='Telugu'
1236
    THAI='Thai'
1237
    TIBETAN='Tibetan'
1238
    TIGRINYA='Tigrinya'
1239
    TONGA='Tonga'
1240
    TSONGA='Tsonga'
1241
    TSWANA='Tswana'
1242
    TURKISH='Turkish'
1243
    TURKMEN='Turkmen'
1244
    TWI='Twi'
1245
    UIGHUR='Uighur'
1246
    UKRAINIAN='Ukrainian'
1247
    URDU='Urdu'
1248
    UZBEK='Uzbek'
1249
    VENDA='Venda'
1250
    VIETNAMESE='Vietnamese'
1251
    VOLAPÜK='Volapük'
1252
    WALLOON='Walloon'
1253
    WELSH='Welsh'
1254
    WESTERN_FRISIAN='Western Frisian'
1255
    WOLOF='Wolof'
1256
    XHOSA='Xhosa'
1257
    YIDDISH='Yiddish'
1258
    YORUBA='Yoruba'
1259
    ZHUANG='Zhuang'
1260
    ZULU='Zulu'
1261
    OTHER='other'
1262
1263
1264
class PageTypeSimpleType(str, Enum):
1265
    FRONTCOVER='front-cover'
1266
    BACKCOVER='back-cover'
1267
    TITLE='title'
1268
    TABLEOFCONTENTS='table-of-contents'
1269
    INDEX='index'
1270
    CONTENT='content'
1271
    BLANK='blank'
1272
    OTHER='other'
1273
1274
1275
class ProductionSimpleType(str, Enum):
1276
    """ProductionSimpleType -- Text production type
1277
    
1278
    """
1279
    PRINTED='printed'
1280
    TYPEWRITTEN='typewritten'
1281
    HANDWRITTENCURSIVE='handwritten-cursive'
1282
    HANDWRITTENPRINTSCRIPT='handwritten-printscript'
1283
    MEDIEVALMANUSCRIPT='medieval-manuscript'
1284
    OTHER='other'
1285
1286
1287
class ReadingDirectionSimpleType(str, Enum):
1288
    LEFTTORIGHT='left-to-right'
1289
    RIGHTTOLEFT='right-to-left'
1290
    TOPTOBOTTOM='top-to-bottom'
1291
    BOTTOMTOTOP='bottom-to-top'
1292
1293
1294
class ScriptSimpleType(str, Enum):
1295
    """ScriptSimpleType -- iso15924 2016-07-14
1296
    
1297
    """
1298
    ADLM_ADLAM='Adlm - Adlam'
1299
    AFAK_AFAKA='Afak - Afaka'
1300
    AGHB_CAUCASIAN_ALBANIAN='Aghb - Caucasian Albanian'
1301
    AHOM_AHOM_TAI_AHOM='Ahom - Ahom, Tai Ahom'
1302
    ARAB_ARABIC='Arab - Arabic'
1303
    ARAN_ARABIC_NASTALIQVARIANT='Aran - Arabic (Nastaliq variant)'
1304
    ARMI_IMPERIAL_ARAMAIC='Armi - Imperial Aramaic'
1305
    ARMN_ARMENIAN='Armn - Armenian'
1306
    AVST_AVESTAN='Avst - Avestan'
1307
    BALI_BALINESE='Bali - Balinese'
1308
    BAMU_BAMUM='Bamu - Bamum'
1309
    BASS_BASSA_VAH='Bass - Bassa Vah'
1310
    BATK_BATAK='Batk - Batak'
1311
    BENG_BENGALI='Beng - Bengali'
1312
    BHKS_BHAIKSUKI='Bhks - Bhaiksuki'
1313
    BLIS_BLISSYMBOLS='Blis - Blissymbols'
1314
    BOPO_BOPOMOFO='Bopo - Bopomofo'
1315
    BRAH_BRAHMI='Brah - Brahmi'
1316
    BRAI_BRAILLE='Brai - Braille'
1317
    BUGI_BUGINESE='Bugi - Buginese'
1318
    BUHD_BUHID='Buhd - Buhid'
1319
    CAKM_CHAKMA='Cakm - Chakma'
1320
    CANS_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS='Cans - Unified Canadian Aboriginal Syllabics'
1321
    CARI_CARIAN='Cari - Carian'
1322
    CHAM_CHAM='Cham - Cham'
1323
    CHER_CHEROKEE='Cher - Cherokee'
1324
    CIRT_CIRTH='Cirt - Cirth'
1325
    COPT_COPTIC='Copt - Coptic'
1326
    CPRT_CYPRIOT='Cprt - Cypriot'
1327
    CYRL_CYRILLIC='Cyrl - Cyrillic'
1328
    CYRS_CYRILLIC_OLD_CHURCH_SLAVONICVARIANT='Cyrs - Cyrillic (Old Church Slavonic variant)'
1329
    DEVA_DEVANAGARI_NAGARI='Deva - Devanagari (Nagari)'
1330
    DSRT_DESERET_MORMON='Dsrt - Deseret (Mormon)'
1331
    DUPL_DUPLOYANSHORTHAND_DUPLOYANSTENOGRAPHY='Dupl - Duployan shorthand, Duployan stenography'
1332
    EGYD_EGYPTIANDEMOTIC='Egyd - Egyptian demotic'
1333
    EGYH_EGYPTIANHIERATIC='Egyh - Egyptian hieratic'
1334
    EGYP_EGYPTIANHIEROGLYPHS='Egyp - Egyptian hieroglyphs'
1335
    ELBA_ELBASAN='Elba - Elbasan'
1336
    ETHI_ETHIOPIC='Ethi - Ethiopic'
1337
    GEOK_KHUTSURI_ASOMTAVRULIAND_NUSKHURI='Geok - Khutsuri (Asomtavruli and Nuskhuri)'
1338
    GEOR_GEORGIAN_MKHEDRULI='Geor - Georgian (Mkhedruli)'
1339
    GLAG_GLAGOLITIC='Glag - Glagolitic'
1340
    GOTH_GOTHIC='Goth - Gothic'
1341
    GRAN_GRANTHA='Gran - Grantha'
1342
    GREK_GREEK='Grek - Greek'
1343
    GUJR_GUJARATI='Gujr - Gujarati'
1344
    GURU_GURMUKHI='Guru - Gurmukhi'
1345
    HANB_HANWITH_BOPOMOFO='Hanb - Han with Bopomofo'
1346
    HANG_HANGUL='Hang - Hangul'
1347
    HANI_HAN_HANZI_KANJI_HANJA='Hani - Han (Hanzi, Kanji, Hanja)'
1348
    HANO_HANUNOO_HANUNÓO='Hano - Hanunoo (Hanunóo)'
1349
    HANS_HAN_SIMPLIFIEDVARIANT='Hans - Han (Simplified variant)'
1350
    HANT_HAN_TRADITIONALVARIANT='Hant - Han (Traditional variant)'
1351
    HATR_HATRAN='Hatr - Hatran'
1352
    HEBR_HEBREW='Hebr - Hebrew'
1353
    HIRA_HIRAGANA='Hira - Hiragana'
1354
    HLUW_ANATOLIAN_HIEROGLYPHS='Hluw - Anatolian Hieroglyphs'
1355
    HMNG_PAHAWH_HMONG='Hmng - Pahawh Hmong'
1356
    HRKT_JAPANESESYLLABARIES='Hrkt - Japanese syllabaries'
1357
    HUNG_OLD_HUNGARIAN_HUNGARIAN_RUNIC='Hung - Old Hungarian (Hungarian Runic)'
1358
    INDS_INDUS_HARAPPAN='Inds - Indus (Harappan)'
1359
    ITAL_OLD_ITALIC_ETRUSCAN_OSCANETC='Ital - Old Italic (Etruscan, Oscan etc.)'
1360
    JAMO_JAMO='Jamo - Jamo'
1361
    JAVA_JAVANESE='Java - Javanese'
1362
    JPAN_JAPANESE='Jpan - Japanese'
1363
    JURC_JURCHEN='Jurc - Jurchen'
1364
    KALI_KAYAH_LI='Kali - Kayah Li'
1365
    KANA_KATAKANA='Kana - Katakana'
1366
    KHAR_KHAROSHTHI='Khar - Kharoshthi'
1367
    KHMR_KHMER='Khmr - Khmer'
1368
    KHOJ_KHOJKI='Khoj - Khojki'
1369
    KITL_KHITANLARGESCRIPT='Kitl - Khitan large script'
1370
    KITS_KHITANSMALLSCRIPT='Kits - Khitan small script'
1371
    KNDA_KANNADA='Knda - Kannada'
1372
    KORE_KOREANALIASFOR_HANGUL_HAN='Kore - Korean (alias for Hangul + Han)'
1373
    KPEL_KPELLE='Kpel - Kpelle'
1374
    KTHI_KAITHI='Kthi - Kaithi'
1375
    LANA_TAI_THAM_LANNA='Lana - Tai Tham (Lanna)'
1376
    LAOO_LAO='Laoo - Lao'
1377
    LATF_LATIN_FRAKTURVARIANT='Latf - Latin (Fraktur variant)'
1378
    LATG_LATIN_GAELICVARIANT='Latg - Latin (Gaelic variant)'
1379
    LATN_LATIN='Latn - Latin'
1380
    LEKE_LEKE='Leke - Leke'
1381
    LEPC_LEPCHARÓNG='Lepc - Lepcha (Róng)'
1382
    LIMB_LIMBU='Limb - Limbu'
1383
    LINA_LINEARA='Lina - Linear A'
1384
    LINB_LINEARB='Linb - Linear B'
1385
    LISU_LISU_FRASER='Lisu - Lisu (Fraser)'
1386
    LOMA_LOMA='Loma - Loma'
1387
    LYCI_LYCIAN='Lyci - Lycian'
1388
    LYDI_LYDIAN='Lydi - Lydian'
1389
    MAHJ_MAHAJANI='Mahj - Mahajani'
1390
    MAND_MANDAIC_MANDAEAN='Mand - Mandaic, Mandaean'
1391
    MANI_MANICHAEAN='Mani - Manichaean'
1392
    MARC_MARCHEN='Marc - Marchen'
1393
    MAYA_MAYANHIEROGLYPHS='Maya - Mayan hieroglyphs'
1394
    MEND_MENDE_KIKAKUI='Mend - Mende Kikakui'
1395
    MERC_MEROITIC_CURSIVE='Merc - Meroitic Cursive'
1396
    MERO_MEROITIC_HIEROGLYPHS='Mero - Meroitic Hieroglyphs'
1397
    MLYM_MALAYALAM='Mlym - Malayalam'
1398
    MODI_MODI_MOḌĪ='Modi - Modi, Moḍī'
1399
    MONG_MONGOLIAN='Mong - Mongolian'
1400
    MOON_MOON_MOONCODE_MOONSCRIPT_MOONTYPE='Moon - Moon (Moon code, Moon script, Moon type)'
1401
    MROO_MRO_MRU='Mroo - Mro, Mru'
1402
    MTEI_MEITEI_MAYEK_MEITHEI_MEETEI='Mtei - Meitei Mayek (Meithei, Meetei)'
1403
    MULT_MULTANI='Mult - Multani'
1404
    MYMR_MYANMAR_BURMESE='Mymr - Myanmar (Burmese)'
1405
    NARB_OLD_NORTH_ARABIAN_ANCIENT_NORTH_ARABIAN='Narb - Old North Arabian (Ancient North Arabian)'
1406
    NBAT_NABATAEAN='Nbat - Nabataean'
1407
    NEWA_NEWA_NEWAR_NEWARI='Newa - Newa, Newar, Newari'
1408
    NKGB_NAKHI_GEBA='Nkgb - Nakhi Geba'
1409
    NKOON_KO='Nkoo - N’Ko'
1410
    NSHUNÜSHU='Nshu - Nüshu'
1411
    OGAM_OGHAM='Ogam - Ogham'
1412
    OLCK_OL_CHIKI_OL_CEMET_OL_SANTALI='Olck - Ol Chiki (Ol Cemet’, Ol, Santali)'
1413
    ORKH_OLD_TURKIC_ORKHON_RUNIC='Orkh - Old Turkic, Orkhon Runic'
1414
    ORYA_ORIYA='Orya - Oriya'
1415
    OSGE_OSAGE='Osge - Osage'
1416
    OSMA_OSMANYA='Osma - Osmanya'
1417
    PALM_PALMYRENE='Palm - Palmyrene'
1418
    PAUC_PAU_CIN_HAU='Pauc - Pau Cin Hau'
1419
    PERM_OLD_PERMIC='Perm - Old Permic'
1420
    PHAG_PHAGSPA='Phag - Phags-pa'
1421
    PHLI_INSCRIPTIONAL_PAHLAVI='Phli - Inscriptional Pahlavi'
1422
    PHLP_PSALTER_PAHLAVI='Phlp - Psalter Pahlavi'
1423
    PHLV_BOOK_PAHLAVI='Phlv - Book Pahlavi'
1424
    PHNX_PHOENICIAN='Phnx - Phoenician'
1425
    PIQD_KLINGONKLIP_IQA_D='Piqd - Klingon (KLI pIqaD)'
1426
    PLRD_MIAO_POLLARD='Plrd - Miao (Pollard)'
1427
    PRTI_INSCRIPTIONAL_PARTHIAN='Prti - Inscriptional Parthian'
1428
    RJNG_REJANG_REDJANG_KAGANGA='Rjng - Rejang (Redjang, Kaganga)'
1429
    RORO_RONGORONGO='Roro - Rongorongo'
1430
    RUNR_RUNIC='Runr - Runic'
1431
    SAMR_SAMARITAN='Samr - Samaritan'
1432
    SARA_SARATI='Sara - Sarati'
1433
    SARB_OLD_SOUTH_ARABIAN='Sarb - Old South Arabian'
1434
    SAUR_SAURASHTRA='Saur - Saurashtra'
1435
    SGNW_SIGN_WRITING='Sgnw - SignWriting'
1436
    SHAW_SHAVIAN_SHAW='Shaw - Shavian (Shaw)'
1437
    SHRD_SHARADAŚĀRADĀ='Shrd - Sharada, Śāradā'
1438
    SIDD_SIDDHAM='Sidd - Siddham'
1439
    SIND_KHUDAWADI_SINDHI='Sind - Khudawadi, Sindhi'
1440
    SINH_SINHALA='Sinh - Sinhala'
1441
    SORA_SORA_SOMPENG='Sora - Sora Sompeng'
1442
    SUND_SUNDANESE='Sund - Sundanese'
1443
    SYLO_SYLOTI_NAGRI='Sylo - Syloti Nagri'
1444
    SYRC_SYRIAC='Syrc - Syriac'
1445
    SYRE_SYRIAC_ESTRANGELOVARIANT='Syre - Syriac (Estrangelo variant)'
1446
    SYRJ_SYRIAC_WESTERNVARIANT='Syrj - Syriac (Western variant)'
1447
    SYRN_SYRIAC_EASTERNVARIANT='Syrn - Syriac (Eastern variant)'
1448
    TAGB_TAGBANWA='Tagb - Tagbanwa'
1449
    TAKR_TAKRI='Takr - Takri'
1450
    TALE_TAI_LE='Tale - Tai Le'
1451
    TALU_NEW_TAI_LUE='Talu - New Tai Lue'
1452
    TAML_TAMIL='Taml - Tamil'
1453
    TANG_TANGUT='Tang - Tangut'
1454
    TAVT_TAI_VIET='Tavt - Tai Viet'
1455
    TELU_TELUGU='Telu - Telugu'
1456
    TENG_TENGWAR='Teng - Tengwar'
1457
    TFNG_TIFINAGH_BERBER='Tfng - Tifinagh (Berber)'
1458
    TGLG_TAGALOG_BAYBAYIN_ALIBATA='Tglg - Tagalog (Baybayin, Alibata)'
1459
    THAA_THAANA='Thaa - Thaana'
1460
    THAI_THAI='Thai - Thai'
1461
    TIBT_TIBETAN='Tibt - Tibetan'
1462
    TIRH_TIRHUTA='Tirh - Tirhuta'
1463
    UGAR_UGARITIC='Ugar - Ugaritic'
1464
    VAII_VAI='Vaii - Vai'
1465
    VISP_VISIBLE_SPEECH='Visp - Visible Speech'
1466
    WARA_WARANG_CITI_VARANG_KSHITI='Wara - Warang Citi (Varang Kshiti)'
1467
    WOLE_WOLEAI='Wole - Woleai'
1468
    XPEO_OLD_PERSIAN='Xpeo - Old Persian'
1469
    XSUX_CUNEIFORM_SUMERO_AKKADIAN='Xsux - Cuneiform, Sumero-Akkadian'
1470
    YIII_YI='Yiii - Yi'
1471
    ZINH_CODEFORINHERITEDSCRIPT='Zinh - Code for inherited script'
1472
    ZMTH_MATHEMATICALNOTATION='Zmth - Mathematical notation'
1473
    ZSYE_SYMBOLS_EMOJIVARIANT='Zsye - Symbols (Emoji variant)'
1474
    ZSYM_SYMBOLS='Zsym - Symbols'
1475
    ZXXX_CODEFORUNWRITTENDOCUMENTS='Zxxx - Code for unwritten documents'
1476
    ZYYY_CODEFORUNDETERMINEDSCRIPT='Zyyy - Code for undetermined script'
1477
    ZZZZ_CODEFORUNCODEDSCRIPT='Zzzz - Code for uncoded script'
1478
    OTHER='other'
1479
1480
1481
class TextDataTypeSimpleType(str, Enum):
1482
    XSDDECIMAL='xsd:decimal' # Examples: "123.456", "+1234.456", "-1234.456", "-.456", "-456"
1483
    XSDFLOAT='xsd:float' # Examples: "123.456", "+1234.456", "-1.2344e56", "-.45E-6", "INF", "-INF", "NaN"
1484
    XSDINTEGER='xsd:integer' # Examples: "123456", "+00000012", "-1", "-456"
1485
    XSDBOOLEAN='xsd:boolean' # Examples: "true", "false", "1", "0"
1486
    XSDDATE='xsd:date' # Examples: "2001-10-26", "2001-10-26+02:00", "2001-10-26Z", "2001-10-26+00:00", "-2001-10-26", "-20000-04-01"
1487
    XSDTIME='xsd:time' # Examples: "21:32:52", "21:32:52+02:00", "19:32:52Z", "19:32:52+00:00", "21:32:52.12679"
1488
    XSDDATE_TIME='xsd:dateTime' # Examples: "2001-10-26T21:32:52", "2001-10-26T21:32:52+02:00", "2001-10-26T19:32:52Z", "2001-10-26T19:32:52+00:00", "-2001-10-26T21:32:52", "2001-10-26T21:32:52.12679"
1489
    XSDSTRING='xsd:string' # Generic text string
1490
    OTHER='other' # An XSD type that is not listed or a custom type (use dataTypeDetails attribute).
1491
1492
1493
class TextLineOrderSimpleType(str, Enum):
1494
    TOPTOBOTTOM='top-to-bottom'
1495
    BOTTOMTOTOP='bottom-to-top'
1496
    LEFTTORIGHT='left-to-right'
1497
    RIGHTTOLEFT='right-to-left'
1498
1499
1500
class TextTypeSimpleType(str, Enum):
1501
    PARAGRAPH='paragraph'
1502
    HEADING='heading'
1503
    CAPTION='caption'
1504
    HEADER='header'
1505
    FOOTER='footer'
1506
    PAGENUMBER='page-number'
1507
    DROPCAPITAL='drop-capital'
1508
    CREDIT='credit'
1509
    FLOATING='floating'
1510
    SIGNATUREMARK='signature-mark'
1511
    CATCHWORD='catch-word'
1512
    MARGINALIA='marginalia'
1513
    FOOTNOTE='footnote'
1514
    FOOTNOTECONTINUED='footnote-continued'
1515
    ENDNOTE='endnote'
1516
    TOCENTRY='TOC-entry'
1517
    LISTLABEL='list-label'
1518
    OTHER='other'
1519
1520
1521
class UnderlineStyleSimpleType(str, Enum):
1522
    SINGLE_LINE='singleLine'
1523
    DOUBLE_LINE='doubleLine'
1524
    OTHER='other'
1525
1526
1527
class charTypeType(str, Enum):
1528
    """charTypeType --
1529
    Type of character represented by the
1530
    grapheme, group, or non-printing character element.
1531
    
1532
    """
1533
    BASE='base'
1534
    COMBINING='combining'
1535
1536
1537
class imageResolutionUnitType(str, Enum):
1538
    """imageResolutionUnitType --
1539
    Specifies the unit of the resolution information
1540
    referring to a standardised unit of measurement
1541
    (pixels per inch, pixels per centimeter or other).
1542
    
1543
    """
1544
    PPI='PPI'
1545
    PPCM='PPCM'
1546
    OTHER='other'
1547
1548
1549
class typeType(str, Enum):
1550
    """typeType --
1551
    Type of metadata (e.g. author)
1552
    
1553
    """
1554
    AUTHOR='author'
1555
    IMAGE_PROPERTIES='imageProperties'
1556
    PROCESSING_STEP='processingStep'
1557
    OTHER='other'
1558
1559
1560
class typeType1(str, Enum):
1561
    LINK='link'
1562
    JOIN='join'
1563
1564
1565
class typeType3(str, Enum):
1566
    XSDSTRING='xsd:string'
1567
    XSDINTEGER='xsd:integer'
1568
    XSDBOOLEAN='xsd:boolean'
1569
    XSDFLOAT='xsd:float'
1570
1571
1572
#
1573
# Start data representation classes
1574
#
1575
class PcGtsType(GeneratedsSuper):
1576
    __hash__ = GeneratedsSuper.__hash__
1577
    member_data_items_ = [
1578
        MemberSpec_('pcGtsId', 'string', 0, 1, {'use': 'optional', 'name': 'pcGtsId'}),
1579
        MemberSpec_('Metadata', 'MetadataType', 0, 0, {'name': 'Metadata', 'type': 'MetadataType'}, None),
1580
        MemberSpec_('Page', 'PageType', 0, 0, {'name': 'Page', 'type': 'PageType'}, None),
1581
    ]
1582
    subclass = None
1583
    superclass = None
1584
    def __init__(self, pcGtsId=None, Metadata=None, Page=None, gds_collector_=None, **kwargs_):
1585
        self.gds_collector_ = gds_collector_
1586
        self.gds_elementtree_node_ = None
1587
        self.original_tagname_ = None
1588
        self.parent_object_ = kwargs_.get('parent_object_')
1589
        self.ns_prefix_ = "pc"
1590
        self.pcGtsId = _cast(None, pcGtsId)
1591
        self.pcGtsId_nsprefix_ = "pc"
1592
        self.Metadata = Metadata
1593
        self.Metadata_nsprefix_ = "pc"
1594
        self.Page = Page
1595
        self.Page_nsprefix_ = "pc"
1596
    def factory(*args_, **kwargs_):
1597
        if CurrentSubclassModule_ is not None:
1598
            subclass = getSubclassFromModule_(
1599
                CurrentSubclassModule_, PcGtsType)
1600
            if subclass is not None:
1601
                return subclass(*args_, **kwargs_)
1602
        if PcGtsType.subclass:
1603
            return PcGtsType.subclass(*args_, **kwargs_)
1604
        else:
1605
            return PcGtsType(*args_, **kwargs_)
1606
    factory = staticmethod(factory)
1607
    def get_ns_prefix_(self):
1608
        return self.ns_prefix_
1609
    def set_ns_prefix_(self, ns_prefix):
1610
        self.ns_prefix_ = ns_prefix
1611
    def get_Metadata(self):
1612
        return self.Metadata
1613
    def set_Metadata(self, Metadata):
1614
        self.Metadata = Metadata
1615
    def get_Page(self):
1616
        return self.Page
1617
    def set_Page(self, Page):
1618
        self.Page = Page
1619
    def get_pcGtsId(self):
1620
        return self.pcGtsId
1621
    def set_pcGtsId(self, pcGtsId):
1622
        self.pcGtsId = pcGtsId
1623
    def has__content(self):
1624
        if (
1625
            self.Metadata is not None or
1626
            self.Page is not None
1627
        ):
1628
            return True
1629
        else:
1630
            return False
1631
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='PcGtsType', pretty_print=True):
1632
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('PcGtsType')
1633
        if imported_ns_def_ is not None:
1634
            namespacedef_ = imported_ns_def_
1635
        if pretty_print:
1636
            eol_ = '\n'
1637
        else:
1638
            eol_ = ''
1639
        if self.original_tagname_ is not None and name_ == 'PcGtsType':
1640
            name_ = self.original_tagname_
1641
        if UseCapturedNS_ and self.ns_prefix_:
1642
            namespaceprefix_ = self.ns_prefix_ + ':'
1643
        showIndent(outfile, level, pretty_print)
1644
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
1645
        already_processed = set()
1646
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='PcGtsType')
1647
        if self.has__content():
1648
            outfile.write('>%s' % (eol_, ))
1649
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='PcGtsType', pretty_print=pretty_print)
1650
            showIndent(outfile, level, pretty_print)
1651
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
1652
        else:
1653
            outfile.write('/>%s' % (eol_, ))
1654
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='PcGtsType'):
1655
        if self.pcGtsId is not None and 'pcGtsId' not in already_processed:
1656
            already_processed.add('pcGtsId')
1657
            outfile.write(' pcGtsId=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.pcGtsId), input_name='pcGtsId')), ))
1658
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='PcGtsType', fromsubclass_=False, pretty_print=True):
1659
        if pretty_print:
1660
            eol_ = '\n'
1661
        else:
1662
            eol_ = ''
1663
        if self.Metadata is not None:
1664
            namespaceprefix_ = self.Metadata_nsprefix_ + ':' if (UseCapturedNS_ and self.Metadata_nsprefix_) else ''
1665
            self.Metadata.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Metadata', pretty_print=pretty_print)
1666
        if self.Page is not None:
1667
            namespaceprefix_ = self.Page_nsprefix_ + ':' if (UseCapturedNS_ and self.Page_nsprefix_) else ''
1668
            self.Page.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Page', pretty_print=pretty_print)
1669
    def to_etree(self, parent_element=None, name_='PcGtsType', mapping_=None, reverse_mapping_=None, nsmap_=None):
1670
        if parent_element is None:
1671
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
1672
        else:
1673
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
1674
        if self.pcGtsId is not None:
1675
            element.set('pcGtsId', self.gds_format_string(self.pcGtsId))
1676
        if self.Metadata is not None:
1677
            Metadata_ = self.Metadata
1678
            Metadata_.to_etree(element, name_='Metadata', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
1679
        if self.Page is not None:
1680
            Page_ = self.Page
1681
            Page_.to_etree(element, name_='Page', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
1682
        if mapping_ is not None:
1683
            mapping_[id(self)] = element
1684
        if reverse_mapping_ is not None:
1685
            reverse_mapping_[element] = self
1686
        return element
1687
    def build(self, node, gds_collector_=None):
1688
        self.gds_collector_ = gds_collector_
1689
        if SaveElementTreeNode:
1690
            self.gds_elementtree_node_ = node
1691
        already_processed = set()
1692
        self.ns_prefix_ = node.prefix
1693
        self._buildAttributes(node, node.attrib, already_processed)
1694
        for child in node:
1695
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
1696
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
1697
        return self
1698
    def _buildAttributes(self, node, attrs, already_processed):
1699
        value = find_attr_value_('pcGtsId', node)
1700
        if value is not None and 'pcGtsId' not in already_processed:
1701
            already_processed.add('pcGtsId')
1702
            self.pcGtsId = value
1703
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
1704
        if nodeName_ == 'Metadata':
1705
            obj_ = MetadataType.factory(parent_object_=self)
1706
            obj_.build(child_, gds_collector_=gds_collector_)
1707
            self.Metadata = obj_
1708
            obj_.original_tagname_ = 'Metadata'
1709
        elif nodeName_ == 'Page':
1710
            obj_ = PageType.factory(parent_object_=self)
1711
            obj_.build(child_, gds_collector_=gds_collector_)
1712
            self.Page = obj_
1713
            obj_.original_tagname_ = 'Page'
1714
    def __hash__(self):
1715
        return hash(self.id)
1716
    @property
1717
    def id(self):
1718
        from ocrd_utils import make_xml_id
1719
        if hasattr(self, 'pcGtsId'):
1720
            return self.pcGtsId or ''
1721
        return make_xml_id(self.imageFilename)
1722 View Code Duplication
    def get_AllAlternativeImagePaths(self, page=True, region=True, line=True, word=True, glyph=True):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
1723
        """
1724
        Get all the ``pc:AlternativeImage/@filename`` paths referenced in the PAGE-XML document.
1725
    
1726
        Arguments:
1727
            page (boolean): Get images on ``pc:Page`` level
1728
            region (boolean): Get images on ``pc:*Region`` level
1729
            line (boolean): Get images on ``pc:TextLine`` level
1730
            word (boolean): Get images on ``pc:Word`` level
1731
            glyph (boolean): Get images on ``pc:Glyph`` level
1732
    
1733
        Returns:
1734
            a list of image filename strings
1735
        """
1736
        from .constants import NAMESPACES, PAGE_REGION_TYPES # pylint: disable=relative-beyond-top-level,import-outside-toplevel
1737
        from io import StringIO  # pylint: disable=import-outside-toplevel
1738
        ret = []
1739
        # XXX Since we're only interested in the **paths** of the images,
1740
        # export, parse and xpath are less convoluted than traversing
1741
        # the generateDS API. Quite possibly not as efficient as could be.
1742
        sio = StringIO()
1743
        self.export(
1744
                outfile=sio,
1745
                level=0,
1746
                name_='PcGts',
1747
                namespaceprefix_='pc:',
1748
                namespacedef_='xmlns:pc="%s" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="%s %s/pagecontent.xsd"' % (
1749
                    NAMESPACES['page'],
1750
                    NAMESPACES['page'],
1751
                    NAMESPACES['page']
1752
                ))
1753
        doc = parsexmlstring_(sio.getvalue())  # pylint: disable=undefined-variable
1754
        # shortcut
1755
        if page and region and line and word and glyph:
1756
            ret += doc.xpath('//page:AlternativeImage/@filename', namespaces=NAMESPACES)
1757
        else:
1758
            if page:
1759
                ret += doc.xpath('/page:PcGts/page:Page/page:AlternativeImage/@filename', namespaces=NAMESPACES)
1760
            if region:
1761
                for class_ in PAGE_REGION_TYPES:
1762
                    ret += doc.xpath('//page:%sRegion/page:AlternativeImage/@filename' % class_, namespaces=NAMESPACES)
1763
            if line:
1764
                ret += doc.xpath('//page:TextLine/page:AlternativeImage/@filename', namespaces=NAMESPACES)
1765
            if word:
1766
                ret += doc.xpath('//page:Word/page:AlternativeImage/@filename', namespaces=NAMESPACES)
1767
            if glyph:
1768
                ret += doc.xpath('//page:Glyph/page:AlternativeImage/@filename', namespaces=NAMESPACES)
1769
    
1770
        return ret
1771 View Code Duplication
    def prune_ReadingOrder(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
1772
        """
1773
        Remove any empty ReadingOrder elements
1774
        """
1775
        ro = self.get_Page().get_ReadingOrder()
1776
        if ro:
1777
            og = ro.get_OrderedGroup()
1778
            if og and (not og.get_RegionRefIndexed() and
1779
                       not og.get_OrderedGroupIndexed() and
1780
                       not og.get_UnorderedGroupIndexed()):
1781
                og = None
1782
            ug = ro.get_UnorderedGroup()
1783
            if ug and (not ug.get_RegionRef() and
1784
                       not ug.get_OrderedGroup() and
1785
                       not ug.get_UnorderedGroup()):
1786
                ug = None
1787
            if not og and not ug:
1788
                self.get_Page().set_ReadingOrder(None)
1789
# end class PcGtsType
1790
1791
1792
class MetadataType(GeneratedsSuper):
1793
    """externalRef -- External reference of any kind
1794
    Created --
1795
    The timestamp has to be in UTC (Coordinated
1796
    Universal Time) and not local time.
1797
      
1798
    * LastChange --
1799
      The timestamp has to be in UTC
1800
      (Coordinated Universal Time)
1801
      and not local time.
1802
    
1803
    """
1804
    __hash__ = GeneratedsSuper.__hash__
1805
    member_data_items_ = [
1806
        MemberSpec_('externalRef', 'string', 0, 1, {'use': 'optional', 'name': 'externalRef'}),
1807
        MemberSpec_('Creator', 'string', 0, 0, {'name': 'Creator', 'type': 'string'}, None),
1808
        MemberSpec_('Created', 'dateTime', 0, 0, {'name': 'Created', 'type': 'dateTime'}, None),
1809
        MemberSpec_('LastChange', 'dateTime', 0, 0, {'name': 'LastChange', 'type': 'dateTime'}, None),
1810
        MemberSpec_('Comments', 'string', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'Comments', 'type': 'string'}, None),
1811
        MemberSpec_('UserDefined', 'UserDefinedType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'UserDefined', 'type': 'UserDefinedType'}, None),
1812
        MemberSpec_('MetadataItem', 'MetadataItemType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'MetadataItem', 'type': 'MetadataItemType'}, None),
1813
    ]
1814
    subclass = None
1815
    superclass = None
1816
    def __init__(self, externalRef=None, Creator=None, Created=None, LastChange=None, Comments=None, UserDefined=None, MetadataItem=None, gds_collector_=None, **kwargs_):
1817
        self.gds_collector_ = gds_collector_
1818
        self.gds_elementtree_node_ = None
1819
        self.original_tagname_ = None
1820
        self.parent_object_ = kwargs_.get('parent_object_')
1821
        self.ns_prefix_ = None
1822
        self.externalRef = _cast(None, externalRef)
1823
        self.externalRef_nsprefix_ = "pc"
1824
        self.Creator = Creator
1825
        self.Creator_nsprefix_ = "pc"
1826
        if isinstance(Created, BaseStrType_):
1827
            initvalue_ = datetime_.datetime.strptime(Created, '%Y-%m-%dT%H:%M:%S')
1828
        else:
1829
            initvalue_ = Created
1830
        self.Created = initvalue_
1831
        self.Created_nsprefix_ = "pc"
1832
        if isinstance(LastChange, BaseStrType_):
1833
            initvalue_ = datetime_.datetime.strptime(LastChange, '%Y-%m-%dT%H:%M:%S')
1834
        else:
1835
            initvalue_ = LastChange
1836
        self.LastChange = initvalue_
1837
        self.LastChange_nsprefix_ = "pc"
1838
        self.Comments = Comments
1839
        self.Comments_nsprefix_ = "pc"
1840
        self.UserDefined = UserDefined
1841
        self.UserDefined_nsprefix_ = "pc"
1842
        if MetadataItem is None:
1843
            self.MetadataItem = []
1844
        else:
1845
            self.MetadataItem = MetadataItem
1846
        self.MetadataItem_nsprefix_ = "pc"
1847
    def factory(*args_, **kwargs_):
1848
        if CurrentSubclassModule_ is not None:
1849
            subclass = getSubclassFromModule_(
1850
                CurrentSubclassModule_, MetadataType)
1851
            if subclass is not None:
1852
                return subclass(*args_, **kwargs_)
1853
        if MetadataType.subclass:
1854
            return MetadataType.subclass(*args_, **kwargs_)
1855
        else:
1856
            return MetadataType(*args_, **kwargs_)
1857
    factory = staticmethod(factory)
1858
    def get_ns_prefix_(self):
1859
        return self.ns_prefix_
1860
    def set_ns_prefix_(self, ns_prefix):
1861
        self.ns_prefix_ = ns_prefix
1862
    def get_Creator(self):
1863
        return self.Creator
1864
    def set_Creator(self, Creator):
1865
        self.Creator = Creator
1866
    def get_Created(self):
1867
        return self.Created
1868
    def set_Created(self, Created):
1869
        self.Created = Created
1870
    def get_LastChange(self):
1871
        return self.LastChange
1872
    def set_LastChange(self, LastChange):
1873
        self.LastChange = LastChange
1874
    def get_Comments(self):
1875
        return self.Comments
1876
    def set_Comments(self, Comments):
1877
        self.Comments = Comments
1878
    def get_UserDefined(self):
1879
        return self.UserDefined
1880
    def set_UserDefined(self, UserDefined):
1881
        self.UserDefined = UserDefined
1882
    def get_MetadataItem(self):
1883
        return self.MetadataItem
1884
    def set_MetadataItem(self, MetadataItem):
1885
        self.MetadataItem = MetadataItem
1886
    def add_MetadataItem(self, value):
1887
        self.MetadataItem.append(value)
1888
    def insert_MetadataItem_at(self, index, value):
1889
        self.MetadataItem.insert(index, value)
1890
    def replace_MetadataItem_at(self, index, value):
1891
        self.MetadataItem[index] = value
1892
    def get_externalRef(self):
1893
        return self.externalRef
1894
    def set_externalRef(self, externalRef):
1895
        self.externalRef = externalRef
1896
    def has__content(self):
1897
        if (
1898
            self.Creator is not None or
1899
            self.Created is not None or
1900
            self.LastChange is not None or
1901
            self.Comments is not None or
1902
            self.UserDefined is not None or
1903
            self.MetadataItem
1904
        ):
1905
            return True
1906
        else:
1907
            return False
1908
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15" xmlns:None="http://www.w3.org/2001/XMLSchema" ', name_='MetadataType', pretty_print=True):
1909
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('MetadataType')
1910
        if imported_ns_def_ is not None:
1911
            namespacedef_ = imported_ns_def_
1912
        if pretty_print:
1913
            eol_ = '\n'
1914
        else:
1915
            eol_ = ''
1916
        if self.original_tagname_ is not None and name_ == 'MetadataType':
1917
            name_ = self.original_tagname_
1918
        if UseCapturedNS_ and self.ns_prefix_:
1919
            namespaceprefix_ = self.ns_prefix_ + ':'
1920
        showIndent(outfile, level, pretty_print)
1921
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
1922
        already_processed = set()
1923
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='MetadataType')
1924
        if self.has__content():
1925
            outfile.write('>%s' % (eol_, ))
1926
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='MetadataType', pretty_print=pretty_print)
1927
            showIndent(outfile, level, pretty_print)
1928
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
1929
        else:
1930
            outfile.write('/>%s' % (eol_, ))
1931
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='MetadataType'):
1932
        if self.externalRef is not None and 'externalRef' not in already_processed:
1933
            already_processed.add('externalRef')
1934
            outfile.write(' externalRef=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.externalRef), input_name='externalRef')), ))
1935
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15" xmlns:None="http://www.w3.org/2001/XMLSchema" ', name_='MetadataType', fromsubclass_=False, pretty_print=True):
1936
        if pretty_print:
1937
            eol_ = '\n'
1938
        else:
1939
            eol_ = ''
1940
        if self.Creator is not None:
1941
            namespaceprefix_ = self.Creator_nsprefix_ + ':' if (UseCapturedNS_ and self.Creator_nsprefix_) else ''
1942
            showIndent(outfile, level, pretty_print)
1943
            outfile.write('<%sCreator>%s</%sCreator>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.Creator), input_name='Creator')), namespaceprefix_ , eol_))
1944
        if self.Created is not None:
1945
            namespaceprefix_ = self.Created_nsprefix_ + ':' if (UseCapturedNS_ and self.Created_nsprefix_) else ''
1946
            showIndent(outfile, level, pretty_print)
1947
            outfile.write('<%sCreated>%s</%sCreated>%s' % (namespaceprefix_ , self.gds_format_datetime(self.Created, input_name='Created'), namespaceprefix_ , eol_))
1948
        if self.LastChange is not None:
1949
            namespaceprefix_ = self.LastChange_nsprefix_ + ':' if (UseCapturedNS_ and self.LastChange_nsprefix_) else ''
1950
            showIndent(outfile, level, pretty_print)
1951
            outfile.write('<%sLastChange>%s</%sLastChange>%s' % (namespaceprefix_ , self.gds_format_datetime(self.LastChange, input_name='LastChange'), namespaceprefix_ , eol_))
1952
        if self.Comments is not None:
1953
            namespaceprefix_ = self.Comments_nsprefix_ + ':' if (UseCapturedNS_ and self.Comments_nsprefix_) else ''
1954
            showIndent(outfile, level, pretty_print)
1955
            outfile.write('<%sComments>%s</%sComments>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.Comments), input_name='Comments')), namespaceprefix_ , eol_))
1956
        if self.UserDefined is not None:
1957
            namespaceprefix_ = self.UserDefined_nsprefix_ + ':' if (UseCapturedNS_ and self.UserDefined_nsprefix_) else ''
1958
            self.UserDefined.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UserDefined', pretty_print=pretty_print)
1959
        for MetadataItem_ in self.MetadataItem:
1960
            namespaceprefix_ = self.MetadataItem_nsprefix_ + ':' if (UseCapturedNS_ and self.MetadataItem_nsprefix_) else ''
1961
            MetadataItem_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='MetadataItem', pretty_print=pretty_print)
1962
    def to_etree(self, parent_element=None, name_='MetadataType', mapping_=None, reverse_mapping_=None, nsmap_=None):
1963
        if parent_element is None:
1964
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
1965
        else:
1966
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
1967
        if self.externalRef is not None:
1968
            element.set('externalRef', self.gds_format_string(self.externalRef))
1969
        if self.Creator is not None:
1970
            Creator_ = self.Creator
1971
            etree_.SubElement(element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}Creator').text = self.gds_format_string(Creator_)
1972
        if self.Created is not None:
1973
            Created_ = self.Created
1974
            etree_.SubElement(element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}Created').text = self.gds_format_datetime(Created_)
1975
        if self.LastChange is not None:
1976
            LastChange_ = self.LastChange
1977
            etree_.SubElement(element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}LastChange').text = self.gds_format_datetime(LastChange_)
1978
        if self.Comments is not None:
1979
            Comments_ = self.Comments
1980
            etree_.SubElement(element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}Comments').text = self.gds_format_string(Comments_)
1981
        if self.UserDefined is not None:
1982
            UserDefined_ = self.UserDefined
1983
            UserDefined_.to_etree(element, name_='UserDefined', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
1984
        for MetadataItem_ in self.MetadataItem:
1985
            MetadataItem_.to_etree(element, name_='MetadataItem', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
1986
        if mapping_ is not None:
1987
            mapping_[id(self)] = element
1988
        if reverse_mapping_ is not None:
1989
            reverse_mapping_[element] = self
1990
        return element
1991
    def build(self, node, gds_collector_=None):
1992
        self.gds_collector_ = gds_collector_
1993
        if SaveElementTreeNode:
1994
            self.gds_elementtree_node_ = node
1995
        already_processed = set()
1996
        self.ns_prefix_ = node.prefix
1997
        self._buildAttributes(node, node.attrib, already_processed)
1998
        for child in node:
1999
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
2000
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
2001
        return self
2002
    def _buildAttributes(self, node, attrs, already_processed):
2003
        value = find_attr_value_('externalRef', node)
2004
        if value is not None and 'externalRef' not in already_processed:
2005
            already_processed.add('externalRef')
2006
            self.externalRef = value
2007
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
2008
        if nodeName_ == 'Creator':
2009
            value_ = child_.text
2010
            value_ = self.gds_parse_string(value_, node, 'Creator')
2011
            value_ = self.gds_validate_string(value_, node, 'Creator')
2012
            self.Creator = value_
2013
2014
        elif nodeName_ == 'Created':
2015
            sval_ = child_.text
2016
            dval_ = self.gds_parse_datetime(sval_)
2017
            self.Created = dval_
2018
2019
        elif nodeName_ == 'LastChange':
2020
            sval_ = child_.text
2021
            dval_ = self.gds_parse_datetime(sval_)
2022
            self.LastChange = dval_
2023
2024
        elif nodeName_ == 'Comments':
2025
            value_ = child_.text
2026
            value_ = self.gds_parse_string(value_, node, 'Comments')
2027
            value_ = self.gds_validate_string(value_, node, 'Comments')
2028
            self.Comments = value_
2029
2030
        elif nodeName_ == 'UserDefined':
2031
            obj_ = UserDefinedType.factory(parent_object_=self)
2032
            obj_.build(child_, gds_collector_=gds_collector_)
2033
            self.UserDefined = obj_
2034
            obj_.original_tagname_ = 'UserDefined'
2035
        elif nodeName_ == 'MetadataItem':
2036
            obj_ = MetadataItemType.factory(parent_object_=self)
2037
            obj_.build(child_, gds_collector_=gds_collector_)
2038
            self.MetadataItem.append(obj_)
2039
            obj_.original_tagname_ = 'MetadataItem'
2040
    def __hash__(self):
2041
        return hash(self.id)
2042
# end class MetadataType
2043
2044
2045
class MetadataItemType(GeneratedsSuper):
2046
    """type --
2047
    Type of metadata (e.g. author)
2048
      
2049
    * name --
2050
      E.g. imagePhotometricInterpretation
2051
      
2052
    * value -- E.g. RGB
2053
    * Labels -- Semantic labels / tags
2054
    
2055
    """
2056
    __hash__ = GeneratedsSuper.__hash__
2057
    member_data_items_ = [
2058
        MemberSpec_('type_', 'typeType', 0, 1, {'use': 'optional', 'name': 'type_'}),
2059
        MemberSpec_('name', 'string', 0, 1, {'use': 'optional', 'name': 'name'}),
2060
        MemberSpec_('value', 'string', 0, 0, {'use': 'required', 'name': 'value'}),
2061
        MemberSpec_('date', 'dateTime', 0, 1, {'use': 'optional', 'name': 'date'}),
2062
        MemberSpec_('Labels', 'LabelsType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Labels', 'type': 'LabelsType'}, None),
2063
    ]
2064
    subclass = None
2065
    superclass = None
2066
    def __init__(self, type_=None, name=None, value=None, date=None, Labels=None, gds_collector_=None, **kwargs_):
2067
        self.gds_collector_ = gds_collector_
2068
        self.gds_elementtree_node_ = None
2069
        self.original_tagname_ = None
2070
        self.parent_object_ = kwargs_.get('parent_object_')
2071
        self.ns_prefix_ = "pc"
2072
        self.type_ = _cast(None, type_)
2073
        self.type__nsprefix_ = "pc"
2074
        self.name = _cast(None, name)
2075
        self.name_nsprefix_ = "pc"
2076
        self.value = _cast(None, value)
2077
        self.value_nsprefix_ = "pc"
2078
        if isinstance(date, BaseStrType_):
2079
            initvalue_ = datetime_.datetime.strptime(date, '%Y-%m-%dT%H:%M:%S')
2080
        else:
2081
            initvalue_ = date
2082
        self.date = initvalue_
2083
        if Labels is None:
2084
            self.Labels = []
2085
        else:
2086
            self.Labels = Labels
2087
        self.Labels_nsprefix_ = "pc"
2088
    def factory(*args_, **kwargs_):
2089
        if CurrentSubclassModule_ is not None:
2090
            subclass = getSubclassFromModule_(
2091
                CurrentSubclassModule_, MetadataItemType)
2092
            if subclass is not None:
2093
                return subclass(*args_, **kwargs_)
2094
        if MetadataItemType.subclass:
2095
            return MetadataItemType.subclass(*args_, **kwargs_)
2096
        else:
2097
            return MetadataItemType(*args_, **kwargs_)
2098
    factory = staticmethod(factory)
2099
    def get_ns_prefix_(self):
2100
        return self.ns_prefix_
2101
    def set_ns_prefix_(self, ns_prefix):
2102
        self.ns_prefix_ = ns_prefix
2103
    def get_Labels(self):
2104
        return self.Labels
2105
    def set_Labels(self, Labels):
2106
        self.Labels = Labels
2107
    def add_Labels(self, value):
2108
        self.Labels.append(value)
2109
    def insert_Labels_at(self, index, value):
2110
        self.Labels.insert(index, value)
2111
    def replace_Labels_at(self, index, value):
2112
        self.Labels[index] = value
2113
    def get_type(self):
2114
        return self.type_
2115
    def set_type(self, type_):
2116
        self.type_ = type_
2117
    def get_name(self):
2118
        return self.name
2119
    def set_name(self, name):
2120
        self.name = name
2121
    def get_value(self):
2122
        return self.value
2123
    def set_value(self, value):
2124
        self.value = value
2125
    def get_date(self):
2126
        return self.date
2127
    def set_date(self, date):
2128
        self.date = date
2129
    def validate_typeType(self, value):
2130
        # Validate type typeType, a restriction on string.
2131
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
2132
            if not isinstance(value, str):
2133
                lineno = self.gds_get_node_lineno_()
2134
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
2135
                return False
2136
            value = value
2137
            enumerations = ['author', 'imageProperties', 'processingStep', 'other']
2138
            if value not in enumerations:
2139
                lineno = self.gds_get_node_lineno_()
2140
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on typeType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
2141
                result = False
2142
    def has__content(self):
2143
        if (
2144
            self.Labels
2145
        ):
2146
            return True
2147
        else:
2148
            return False
2149
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='MetadataItemType', pretty_print=True):
2150
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('MetadataItemType')
2151
        if imported_ns_def_ is not None:
2152
            namespacedef_ = imported_ns_def_
2153
        if pretty_print:
2154
            eol_ = '\n'
2155
        else:
2156
            eol_ = ''
2157
        if self.original_tagname_ is not None and name_ == 'MetadataItemType':
2158
            name_ = self.original_tagname_
2159
        if UseCapturedNS_ and self.ns_prefix_:
2160
            namespaceprefix_ = self.ns_prefix_ + ':'
2161
        showIndent(outfile, level, pretty_print)
2162
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
2163
        already_processed = set()
2164
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='MetadataItemType')
2165
        if self.has__content():
2166
            outfile.write('>%s' % (eol_, ))
2167
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='MetadataItemType', pretty_print=pretty_print)
2168
            showIndent(outfile, level, pretty_print)
2169
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
2170
        else:
2171
            outfile.write('/>%s' % (eol_, ))
2172
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='MetadataItemType'):
2173
        if self.type_ is not None and 'type_' not in already_processed:
2174
            already_processed.add('type_')
2175
            outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), ))
2176
        if self.name is not None and 'name' not in already_processed:
2177
            already_processed.add('name')
2178
            outfile.write(' name=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.name), input_name='name')), ))
2179
        if self.value is not None and 'value' not in already_processed:
2180
            already_processed.add('value')
2181
            outfile.write(' value=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.value), input_name='value')), ))
2182
        if self.date is not None and 'date' not in already_processed:
2183
            already_processed.add('date')
2184
            outfile.write(' date="%s"' % self.gds_format_datetime(self.date, input_name='date'))
2185
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='MetadataItemType', fromsubclass_=False, pretty_print=True):
2186
        if pretty_print:
2187
            eol_ = '\n'
2188
        else:
2189
            eol_ = ''
2190
        for Labels_ in self.Labels:
2191
            namespaceprefix_ = self.Labels_nsprefix_ + ':' if (UseCapturedNS_ and self.Labels_nsprefix_) else ''
2192
            Labels_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Labels', pretty_print=pretty_print)
2193
    def to_etree(self, parent_element=None, name_='MetadataItemType', mapping_=None, reverse_mapping_=None, nsmap_=None):
2194
        if parent_element is None:
2195
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
2196
        else:
2197
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
2198
        if self.type_ is not None:
2199
            element.set('type', self.gds_format_string(self.type_))
2200
        if self.name is not None:
2201
            element.set('name', self.gds_format_string(self.name))
2202
        if self.value is not None:
2203
            element.set('value', self.gds_format_string(self.value))
2204
        if self.date is not None:
2205
            element.set('date', self.gds_format_datetime(self.date))
2206
        for Labels_ in self.Labels:
2207
            Labels_.to_etree(element, name_='Labels', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
2208
        if mapping_ is not None:
2209
            mapping_[id(self)] = element
2210
        if reverse_mapping_ is not None:
2211
            reverse_mapping_[element] = self
2212
        return element
2213
    def build(self, node, gds_collector_=None):
2214
        self.gds_collector_ = gds_collector_
2215
        if SaveElementTreeNode:
2216
            self.gds_elementtree_node_ = node
2217
        already_processed = set()
2218
        self.ns_prefix_ = node.prefix
2219
        self._buildAttributes(node, node.attrib, already_processed)
2220
        for child in node:
2221
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
2222
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
2223
        return self
2224
    def _buildAttributes(self, node, attrs, already_processed):
2225
        value = find_attr_value_('type', node)
2226
        if value is not None and 'type' not in already_processed:
2227
            already_processed.add('type')
2228
            self.type_ = value
2229
            self.validate_typeType(self.type_)    # validate type typeType
2230
        value = find_attr_value_('name', node)
2231
        if value is not None and 'name' not in already_processed:
2232
            already_processed.add('name')
2233
            self.name = value
2234
        value = find_attr_value_('value', node)
2235
        if value is not None and 'value' not in already_processed:
2236
            already_processed.add('value')
2237
            self.value = value
2238
        value = find_attr_value_('date', node)
2239
        if value is not None and 'date' not in already_processed:
2240
            already_processed.add('date')
2241
            try:
2242
                self.date = self.gds_parse_datetime(value)
2243
            except ValueError as exp:
2244
                raise ValueError('Bad date-time attribute (date): %s' % exp)
2245
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
2246
        if nodeName_ == 'Labels':
2247
            obj_ = LabelsType.factory(parent_object_=self)
2248
            obj_.build(child_, gds_collector_=gds_collector_)
2249
            self.Labels.append(obj_)
2250
            obj_.original_tagname_ = 'Labels'
2251
    def __hash__(self):
2252
        return hash(self.id)
2253
# end class MetadataItemType
2254
2255
2256
class LabelsType(GeneratedsSuper):
2257
    """externalModel --
2258
    Reference to external model / ontology / schema
2259
      
2260
    * externalId --
2261
      E.g. an RDF resource identifier
2262
      (to be used as subject or object of an RDF triple)
2263
      
2264
    * prefix --
2265
      Prefix for all labels (e.g. first part of an URI)
2266
      
2267
    * Label --
2268
      A semantic label / tag
2269
    
2270
    """
2271
    __hash__ = GeneratedsSuper.__hash__
2272
    member_data_items_ = [
2273
        MemberSpec_('externalModel', 'string', 0, 1, {'use': 'optional', 'name': 'externalModel'}),
2274
        MemberSpec_('externalId', 'string', 0, 1, {'use': 'optional', 'name': 'externalId'}),
2275
        MemberSpec_('prefix', 'string', 0, 1, {'use': 'optional', 'name': 'prefix'}),
2276
        MemberSpec_('comments', 'string', 0, 1, {'use': 'optional', 'name': 'comments'}),
2277
        MemberSpec_('Label', 'LabelType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Label', 'type': 'LabelType'}, None),
2278
    ]
2279
    subclass = None
2280
    superclass = None
2281
    def __init__(self, externalModel=None, externalId=None, prefix=None, comments=None, Label=None, gds_collector_=None, **kwargs_):
2282
        self.gds_collector_ = gds_collector_
2283
        self.gds_elementtree_node_ = None
2284
        self.original_tagname_ = None
2285
        self.parent_object_ = kwargs_.get('parent_object_')
2286
        self.ns_prefix_ = "pc"
2287
        self.externalModel = _cast(None, externalModel)
2288
        self.externalModel_nsprefix_ = "pc"
2289
        self.externalId = _cast(None, externalId)
2290
        self.externalId_nsprefix_ = "pc"
2291
        self.prefix = _cast(None, prefix)
2292
        self.prefix_nsprefix_ = "pc"
2293
        self.comments = _cast(None, comments)
2294
        self.comments_nsprefix_ = "pc"
2295
        if Label is None:
2296
            self.Label = []
2297
        else:
2298
            self.Label = Label
2299
        self.Label_nsprefix_ = "pc"
2300
    def factory(*args_, **kwargs_):
2301
        if CurrentSubclassModule_ is not None:
2302
            subclass = getSubclassFromModule_(
2303
                CurrentSubclassModule_, LabelsType)
2304
            if subclass is not None:
2305
                return subclass(*args_, **kwargs_)
2306
        if LabelsType.subclass:
2307
            return LabelsType.subclass(*args_, **kwargs_)
2308
        else:
2309
            return LabelsType(*args_, **kwargs_)
2310
    factory = staticmethod(factory)
2311
    def get_ns_prefix_(self):
2312
        return self.ns_prefix_
2313
    def set_ns_prefix_(self, ns_prefix):
2314
        self.ns_prefix_ = ns_prefix
2315
    def get_Label(self):
2316
        return self.Label
2317
    def set_Label(self, Label):
2318
        self.Label = Label
2319
    def add_Label(self, value):
2320
        self.Label.append(value)
2321
    def insert_Label_at(self, index, value):
2322
        self.Label.insert(index, value)
2323
    def replace_Label_at(self, index, value):
2324
        self.Label[index] = value
2325
    def get_externalModel(self):
2326
        return self.externalModel
2327
    def set_externalModel(self, externalModel):
2328
        self.externalModel = externalModel
2329
    def get_externalId(self):
2330
        return self.externalId
2331
    def set_externalId(self, externalId):
2332
        self.externalId = externalId
2333
    def get_prefix(self):
2334
        return self.prefix
2335
    def set_prefix(self, prefix):
2336
        self.prefix = prefix
2337
    def get_comments(self):
2338
        return self.comments
2339
    def set_comments(self, comments):
2340
        self.comments = comments
2341
    def has__content(self):
2342
        if (
2343
            self.Label
2344
        ):
2345
            return True
2346
        else:
2347
            return False
2348
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='LabelsType', pretty_print=True):
2349
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('LabelsType')
2350
        if imported_ns_def_ is not None:
2351
            namespacedef_ = imported_ns_def_
2352
        if pretty_print:
2353
            eol_ = '\n'
2354
        else:
2355
            eol_ = ''
2356
        if self.original_tagname_ is not None and name_ == 'LabelsType':
2357
            name_ = self.original_tagname_
2358
        if UseCapturedNS_ and self.ns_prefix_:
2359
            namespaceprefix_ = self.ns_prefix_ + ':'
2360
        showIndent(outfile, level, pretty_print)
2361
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
2362
        already_processed = set()
2363
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='LabelsType')
2364
        if self.has__content():
2365
            outfile.write('>%s' % (eol_, ))
2366
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='LabelsType', pretty_print=pretty_print)
2367
            showIndent(outfile, level, pretty_print)
2368
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
2369
        else:
2370
            outfile.write('/>%s' % (eol_, ))
2371 View Code Duplication
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='LabelsType'):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
2372
        if self.externalModel is not None and 'externalModel' not in already_processed:
2373
            already_processed.add('externalModel')
2374
            outfile.write(' externalModel=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.externalModel), input_name='externalModel')), ))
2375
        if self.externalId is not None and 'externalId' not in already_processed:
2376
            already_processed.add('externalId')
2377
            outfile.write(' externalId=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.externalId), input_name='externalId')), ))
2378
        if self.prefix is not None and 'prefix' not in already_processed:
2379
            already_processed.add('prefix')
2380
            outfile.write(' prefix=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.prefix), input_name='prefix')), ))
2381
        if self.comments is not None and 'comments' not in already_processed:
2382
            already_processed.add('comments')
2383
            outfile.write(' comments=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.comments), input_name='comments')), ))
2384
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='LabelsType', fromsubclass_=False, pretty_print=True):
2385
        if pretty_print:
2386
            eol_ = '\n'
2387
        else:
2388
            eol_ = ''
2389
        for Label_ in self.Label:
2390
            namespaceprefix_ = self.Label_nsprefix_ + ':' if (UseCapturedNS_ and self.Label_nsprefix_) else ''
2391
            Label_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Label', pretty_print=pretty_print)
2392
    def to_etree(self, parent_element=None, name_='LabelsType', mapping_=None, reverse_mapping_=None, nsmap_=None):
2393
        if parent_element is None:
2394
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
2395
        else:
2396
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
2397
        if self.externalModel is not None:
2398
            element.set('externalModel', self.gds_format_string(self.externalModel))
2399
        if self.externalId is not None:
2400
            element.set('externalId', self.gds_format_string(self.externalId))
2401
        if self.prefix is not None:
2402
            element.set('prefix', self.gds_format_string(self.prefix))
2403
        if self.comments is not None:
2404
            element.set('comments', self.gds_format_string(self.comments))
2405
        for Label_ in self.Label:
2406
            Label_.to_etree(element, name_='Label', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
2407
        if mapping_ is not None:
2408
            mapping_[id(self)] = element
2409
        if reverse_mapping_ is not None:
2410
            reverse_mapping_[element] = self
2411
        return element
2412
    def build(self, node, gds_collector_=None):
2413
        self.gds_collector_ = gds_collector_
2414
        if SaveElementTreeNode:
2415
            self.gds_elementtree_node_ = node
2416
        already_processed = set()
2417
        self.ns_prefix_ = node.prefix
2418
        self._buildAttributes(node, node.attrib, already_processed)
2419
        for child in node:
2420
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
2421
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
2422
        return self
2423
    def _buildAttributes(self, node, attrs, already_processed):
2424
        value = find_attr_value_('externalModel', node)
2425
        if value is not None and 'externalModel' not in already_processed:
2426
            already_processed.add('externalModel')
2427
            self.externalModel = value
2428
        value = find_attr_value_('externalId', node)
2429
        if value is not None and 'externalId' not in already_processed:
2430
            already_processed.add('externalId')
2431
            self.externalId = value
2432
        value = find_attr_value_('prefix', node)
2433
        if value is not None and 'prefix' not in already_processed:
2434
            already_processed.add('prefix')
2435
            self.prefix = value
2436
        value = find_attr_value_('comments', node)
2437
        if value is not None and 'comments' not in already_processed:
2438
            already_processed.add('comments')
2439
            self.comments = value
2440
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
2441
        if nodeName_ == 'Label':
2442
            obj_ = LabelType.factory(parent_object_=self)
2443
            obj_.build(child_, gds_collector_=gds_collector_)
2444
            self.Label.append(obj_)
2445
            obj_.original_tagname_ = 'Label'
2446
    def __hash__(self):
2447
        return hash(self.id)
2448
# end class LabelsType
2449
2450
2451
class LabelType(GeneratedsSuper):
2452
    """LabelType -- Semantic label
2453
    value --
2454
    The label / tag (e.g. 'person').
2455
    Can be an RDF resource identifier
2456
    (e.g. object of an RDF triple).
2457
      
2458
    * type --
2459
      Additional information on the label
2460
      (e.g. 'YYYY-mm-dd' for a date label).
2461
      Can be used as predicate of an RDF triple.
2462
    
2463
    """
2464
    __hash__ = GeneratedsSuper.__hash__
2465
    member_data_items_ = [
2466
        MemberSpec_('value', 'string', 0, 0, {'use': 'required', 'name': 'value'}),
2467
        MemberSpec_('type_', 'string', 0, 1, {'use': 'optional', 'name': 'type_'}),
2468
        MemberSpec_('comments', 'string', 0, 1, {'use': 'optional', 'name': 'comments'}),
2469
    ]
2470
    subclass = None
2471
    superclass = None
2472
    def __init__(self, value=None, type_=None, comments=None, gds_collector_=None, **kwargs_):
2473
        self.gds_collector_ = gds_collector_
2474
        self.gds_elementtree_node_ = None
2475
        self.original_tagname_ = None
2476
        self.parent_object_ = kwargs_.get('parent_object_')
2477
        self.ns_prefix_ = "pc"
2478
        self.value = _cast(None, value)
2479
        self.value_nsprefix_ = "pc"
2480
        self.type_ = _cast(None, type_)
2481
        self.type__nsprefix_ = "pc"
2482
        self.comments = _cast(None, comments)
2483
        self.comments_nsprefix_ = "pc"
2484
    def factory(*args_, **kwargs_):
2485
        if CurrentSubclassModule_ is not None:
2486
            subclass = getSubclassFromModule_(
2487
                CurrentSubclassModule_, LabelType)
2488
            if subclass is not None:
2489
                return subclass(*args_, **kwargs_)
2490
        if LabelType.subclass:
2491
            return LabelType.subclass(*args_, **kwargs_)
2492
        else:
2493
            return LabelType(*args_, **kwargs_)
2494
    factory = staticmethod(factory)
2495
    def get_ns_prefix_(self):
2496
        return self.ns_prefix_
2497
    def set_ns_prefix_(self, ns_prefix):
2498
        self.ns_prefix_ = ns_prefix
2499
    def get_value(self):
2500
        return self.value
2501
    def set_value(self, value):
2502
        self.value = value
2503
    def get_type(self):
2504
        return self.type_
2505
    def set_type(self, type_):
2506
        self.type_ = type_
2507
    def get_comments(self):
2508
        return self.comments
2509
    def set_comments(self, comments):
2510
        self.comments = comments
2511
    def has__content(self):
2512
        if (
2513
2514
        ):
2515
            return True
2516
        else:
2517
            return False
2518
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='LabelType', pretty_print=True):
2519
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('LabelType')
2520
        if imported_ns_def_ is not None:
2521
            namespacedef_ = imported_ns_def_
2522
        if pretty_print:
2523
            eol_ = '\n'
2524
        else:
2525
            eol_ = ''
2526
        if self.original_tagname_ is not None and name_ == 'LabelType':
2527
            name_ = self.original_tagname_
2528
        if UseCapturedNS_ and self.ns_prefix_:
2529
            namespaceprefix_ = self.ns_prefix_ + ':'
2530
        showIndent(outfile, level, pretty_print)
2531
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
2532
        already_processed = set()
2533
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='LabelType')
2534
        if self.has__content():
2535
            outfile.write('>%s' % (eol_, ))
2536
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='LabelType', pretty_print=pretty_print)
2537
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
2538
        else:
2539
            outfile.write('/>%s' % (eol_, ))
2540 View Code Duplication
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='LabelType'):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
2541
        if self.value is not None and 'value' not in already_processed:
2542
            already_processed.add('value')
2543
            outfile.write(' value=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.value), input_name='value')), ))
2544
        if self.type_ is not None and 'type_' not in already_processed:
2545
            already_processed.add('type_')
2546
            outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), ))
2547
        if self.comments is not None and 'comments' not in already_processed:
2548
            already_processed.add('comments')
2549
            outfile.write(' comments=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.comments), input_name='comments')), ))
2550
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='LabelType', fromsubclass_=False, pretty_print=True):
2551
        pass
2552 View Code Duplication
    def to_etree(self, parent_element=None, name_='LabelType', mapping_=None, reverse_mapping_=None, nsmap_=None):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
2553
        if parent_element is None:
2554
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
2555
        else:
2556
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
2557
        if self.value is not None:
2558
            element.set('value', self.gds_format_string(self.value))
2559
        if self.type_ is not None:
2560
            element.set('type', self.gds_format_string(self.type_))
2561
        if self.comments is not None:
2562
            element.set('comments', self.gds_format_string(self.comments))
2563
        if mapping_ is not None:
2564
            mapping_[id(self)] = element
2565
        if reverse_mapping_ is not None:
2566
            reverse_mapping_[element] = self
2567
        return element
2568
    def build(self, node, gds_collector_=None):
2569
        self.gds_collector_ = gds_collector_
2570
        if SaveElementTreeNode:
2571
            self.gds_elementtree_node_ = node
2572
        already_processed = set()
2573
        self.ns_prefix_ = node.prefix
2574
        self._buildAttributes(node, node.attrib, already_processed)
2575
        for child in node:
2576
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
2577
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
2578
        return self
2579
    def _buildAttributes(self, node, attrs, already_processed):
2580
        value = find_attr_value_('value', node)
2581
        if value is not None and 'value' not in already_processed:
2582
            already_processed.add('value')
2583
            self.value = value
2584
        value = find_attr_value_('type', node)
2585
        if value is not None and 'type' not in already_processed:
2586
            already_processed.add('type')
2587
            self.type_ = value
2588
        value = find_attr_value_('comments', node)
2589
        if value is not None and 'comments' not in already_processed:
2590
            already_processed.add('comments')
2591
            self.comments = value
2592
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
2593
        pass
2594
    def __hash__(self):
2595
        return hash(self.id)
2596
# end class LabelType
2597
2598
2599
class PageType(GeneratedsSuper):
2600
    """imageFilename --
2601
    Contains the image file name including the file extension.
2602
      
2603
    * imageWidth -- Specifies the width of the image.
2604
    * imageHeight -- Specifies the height of the image.
2605
    * imageXResolution -- Specifies the image resolution in width.
2606
    * imageYResolution -- Specifies the image resolution in height.
2607
    * imageResolutionUnit --
2608
      Specifies the unit of the resolution information
2609
      referring to a standardised unit of measurement
2610
      (pixels per inch, pixels per centimeter or other).
2611
      
2612
    * custom -- For generic use
2613
    * orientation --
2614
      The angle the rectangle encapsulating the page
2615
      (or its Border)	has to be rotated in clockwise direction
2616
      in order to correct the present skew
2617
      (negative values indicate anti-clockwise rotation).
2618
      (The rotated image can be further referenced
2619
      via
2620
2621
      AlternativeImage
2622
2623
      .)
2624
      Range: -179.999,180
2625
      
2626
    * type --
2627
      The type of the page within the document
2628
      (e.g. cover page).
2629
      
2630
    * primaryLanguage --
2631
      The primary language used in the page
2632
      (lower-level definitions override the page-level definition).
2633
      
2634
    * secondaryLanguage --
2635
      The secondary language used in the page
2636
      (lower-level definitions override the page-level definition).
2637
      
2638
    * primaryScript --
2639
      The primary script used in the page
2640
      (lower-level definitions override the page-level definition).
2641
      
2642
    * secondaryScript --
2643
      The secondary script used in the page
2644
      (lower-level definitions override the page-level definition).
2645
      
2646
    * readingDirection --
2647
      The direction in which text within lines
2648
      should be read (order of words and characters),
2649
      in addition to
2650
2651
      textLineOrder
2652
2653
      (lower-level definitions override the page-level definition).
2654
      
2655
    * textLineOrder --
2656
      The order of text lines within a block,
2657
      in addition to
2658
2659
      readingDirection
2660
2661
      (lower-level definitions override the page-level definition).
2662
      
2663
    * conf -- Confidence value for whole page (between 0 and 1)
2664
    * AlternativeImage --
2665
      Alternative document page images
2666
      (e.g. black-and-white).
2667
      
2668
    * ReadingOrder -- Order of blocks within the page.
2669
    * Layers --
2670
      Unassigned regions are considered to be in the
2671
      (virtual) default layer which is to be treated
2672
      as below any other layers.
2673
      
2674
    * TextStyle -- Default text style
2675
    * Labels -- Semantic labels / tags
2676
    
2677
    """
2678
    __hash__ = GeneratedsSuper.__hash__
2679
    member_data_items_ = [
2680
        MemberSpec_('imageFilename', 'string', 0, 0, {'use': 'required', 'name': 'imageFilename'}),
2681
        MemberSpec_('imageWidth', 'int', 0, 0, {'use': 'required', 'name': 'imageWidth'}),
2682
        MemberSpec_('imageHeight', 'int', 0, 0, {'use': 'required', 'name': 'imageHeight'}),
2683
        MemberSpec_('imageXResolution', 'float', 0, 1, {'use': 'optional', 'name': 'imageXResolution'}),
2684
        MemberSpec_('imageYResolution', 'float', 0, 1, {'use': 'optional', 'name': 'imageYResolution'}),
2685
        MemberSpec_('imageResolutionUnit', 'imageResolutionUnitType', 0, 1, {'use': 'optional', 'name': 'imageResolutionUnit'}),
2686
        MemberSpec_('custom', 'string', 0, 1, {'use': 'optional', 'name': 'custom'}),
2687
        MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional', 'name': 'orientation'}),
2688
        MemberSpec_('type_', 'pc:PageTypeSimpleType', 0, 1, {'use': 'optional', 'name': 'type_'}),
2689
        MemberSpec_('primaryLanguage', 'pc:LanguageSimpleType', 0, 1, {'use': 'optional', 'name': 'primaryLanguage'}),
2690
        MemberSpec_('secondaryLanguage', 'pc:LanguageSimpleType', 0, 1, {'use': 'optional', 'name': 'secondaryLanguage'}),
2691
        MemberSpec_('primaryScript', 'pc:ScriptSimpleType', 0, 1, {'use': 'optional', 'name': 'primaryScript'}),
2692
        MemberSpec_('secondaryScript', 'pc:ScriptSimpleType', 0, 1, {'use': 'optional', 'name': 'secondaryScript'}),
2693
        MemberSpec_('readingDirection', 'pc:ReadingDirectionSimpleType', 0, 1, {'use': 'optional', 'name': 'readingDirection'}),
2694
        MemberSpec_('textLineOrder', 'pc:TextLineOrderSimpleType', 0, 1, {'use': 'optional', 'name': 'textLineOrder'}),
2695
        MemberSpec_('conf', 'pc:ConfSimpleType', 0, 1, {'use': 'optional', 'name': 'conf'}),
2696
        MemberSpec_('AlternativeImage', 'AlternativeImageType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'AlternativeImage', 'type': 'AlternativeImageType'}, None),
2697
        MemberSpec_('Border', 'BorderType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'Border', 'type': 'BorderType'}, None),
2698
        MemberSpec_('PrintSpace', 'PrintSpaceType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'PrintSpace', 'type': 'PrintSpaceType'}, None),
2699
        MemberSpec_('ReadingOrder', 'ReadingOrderType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'ReadingOrder', 'type': 'ReadingOrderType'}, None),
2700
        MemberSpec_('Layers', 'LayersType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'Layers', 'type': 'LayersType'}, None),
2701
        MemberSpec_('Relations', 'RelationsType', 0, 1, {'minOccurs': '0', 'name': 'Relations', 'type': 'RelationsType'}, None),
2702
        MemberSpec_('TextStyle', 'TextStyleType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'TextStyle', 'type': 'TextStyleType'}, None),
2703
        MemberSpec_('UserDefined', 'UserDefinedType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'UserDefined', 'type': 'UserDefinedType'}, None),
2704
        MemberSpec_('Labels', 'LabelsType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Labels', 'type': 'LabelsType'}, None),
2705
        MemberSpec_('TextRegion', 'TextRegionType', 1, 1, {'name': 'TextRegion', 'type': 'TextRegionType'}, 1),
2706
        MemberSpec_('ImageRegion', 'ImageRegionType', 1, 1, {'name': 'ImageRegion', 'type': 'ImageRegionType'}, 1),
2707
        MemberSpec_('LineDrawingRegion', 'LineDrawingRegionType', 1, 1, {'name': 'LineDrawingRegion', 'type': 'LineDrawingRegionType'}, 1),
2708
        MemberSpec_('GraphicRegion', 'GraphicRegionType', 1, 1, {'name': 'GraphicRegion', 'type': 'GraphicRegionType'}, 1),
2709
        MemberSpec_('TableRegion', 'TableRegionType', 1, 1, {'name': 'TableRegion', 'type': 'TableRegionType'}, 1),
2710
        MemberSpec_('ChartRegion', 'ChartRegionType', 1, 1, {'name': 'ChartRegion', 'type': 'ChartRegionType'}, 1),
2711
        MemberSpec_('MapRegion', 'MapRegionType', 1, 1, {'name': 'MapRegion', 'type': 'MapRegionType'}, 1),
2712
        MemberSpec_('SeparatorRegion', 'SeparatorRegionType', 1, 1, {'name': 'SeparatorRegion', 'type': 'SeparatorRegionType'}, 1),
2713
        MemberSpec_('MathsRegion', 'MathsRegionType', 1, 1, {'name': 'MathsRegion', 'type': 'MathsRegionType'}, 1),
2714
        MemberSpec_('ChemRegion', 'ChemRegionType', 1, 1, {'name': 'ChemRegion', 'type': 'ChemRegionType'}, 1),
2715
        MemberSpec_('MusicRegion', 'MusicRegionType', 1, 1, {'name': 'MusicRegion', 'type': 'MusicRegionType'}, 1),
2716
        MemberSpec_('AdvertRegion', 'AdvertRegionType', 1, 1, {'name': 'AdvertRegion', 'type': 'AdvertRegionType'}, 1),
2717
        MemberSpec_('NoiseRegion', 'NoiseRegionType', 1, 1, {'name': 'NoiseRegion', 'type': 'NoiseRegionType'}, 1),
2718
        MemberSpec_('UnknownRegion', 'UnknownRegionType', 1, 1, {'name': 'UnknownRegion', 'type': 'UnknownRegionType'}, 1),
2719
        MemberSpec_('CustomRegion', 'CustomRegionType', 1, 1, {'name': 'CustomRegion', 'type': 'CustomRegionType'}, 1),
2720
    ]
2721
    subclass = None
2722
    superclass = None
2723
    def __init__(self, imageFilename=None, imageWidth=None, imageHeight=None, imageXResolution=None, imageYResolution=None, imageResolutionUnit=None, custom=None, orientation=None, type_=None, primaryLanguage=None, secondaryLanguage=None, primaryScript=None, secondaryScript=None, readingDirection=None, textLineOrder=None, conf=None, AlternativeImage=None, Border=None, PrintSpace=None, ReadingOrder=None, Layers=None, Relations=None, TextStyle=None, UserDefined=None, Labels=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, MapRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, gds_collector_=None, **kwargs_):
2724
        self.gds_collector_ = gds_collector_
2725
        self.gds_elementtree_node_ = None
2726
        self.original_tagname_ = None
2727
        self.parent_object_ = kwargs_.get('parent_object_')
2728
        self.ns_prefix_ = "pc"
2729
        self.imageFilename = _cast(None, imageFilename)
2730
        self.imageFilename_nsprefix_ = "pc"
2731
        self.imageWidth = _cast(int, imageWidth)
2732
        self.imageWidth_nsprefix_ = "pc"
2733
        self.imageHeight = _cast(int, imageHeight)
2734
        self.imageHeight_nsprefix_ = "pc"
2735
        self.imageXResolution = _cast(float, imageXResolution)
2736
        self.imageXResolution_nsprefix_ = "pc"
2737
        self.imageYResolution = _cast(float, imageYResolution)
2738
        self.imageYResolution_nsprefix_ = "pc"
2739
        self.imageResolutionUnit = _cast(None, imageResolutionUnit)
2740
        self.imageResolutionUnit_nsprefix_ = "pc"
2741
        self.custom = _cast(None, custom)
2742
        self.custom_nsprefix_ = "pc"
2743
        self.orientation = _cast(float, orientation)
2744
        self.orientation_nsprefix_ = "pc"
2745
        self.type_ = _cast(None, type_)
2746
        self.type__nsprefix_ = "pc"
2747
        self.primaryLanguage = _cast(None, primaryLanguage)
2748
        self.primaryLanguage_nsprefix_ = "pc"
2749
        self.secondaryLanguage = _cast(None, secondaryLanguage)
2750
        self.secondaryLanguage_nsprefix_ = "pc"
2751
        self.primaryScript = _cast(None, primaryScript)
2752
        self.primaryScript_nsprefix_ = "pc"
2753
        self.secondaryScript = _cast(None, secondaryScript)
2754
        self.secondaryScript_nsprefix_ = "pc"
2755
        self.readingDirection = _cast(None, readingDirection)
2756
        self.readingDirection_nsprefix_ = "pc"
2757
        self.textLineOrder = _cast(None, textLineOrder)
2758
        self.textLineOrder_nsprefix_ = "pc"
2759
        self.conf = _cast(float, conf)
2760
        self.conf_nsprefix_ = "pc"
2761
        if AlternativeImage is None:
2762
            self.AlternativeImage = []
2763
        else:
2764
            self.AlternativeImage = AlternativeImage
2765
        self.AlternativeImage_nsprefix_ = "pc"
2766
        self.Border = Border
2767
        self.Border_nsprefix_ = "pc"
2768
        self.PrintSpace = PrintSpace
2769
        self.PrintSpace_nsprefix_ = "pc"
2770
        self.ReadingOrder = ReadingOrder
2771
        self.ReadingOrder_nsprefix_ = "pc"
2772
        self.Layers = Layers
2773
        self.Layers_nsprefix_ = "pc"
2774
        self.Relations = Relations
2775
        self.Relations_nsprefix_ = "pc"
2776
        self.TextStyle = TextStyle
2777
        self.TextStyle_nsprefix_ = "pc"
2778
        self.UserDefined = UserDefined
2779
        self.UserDefined_nsprefix_ = "pc"
2780
        if Labels is None:
2781
            self.Labels = []
2782
        else:
2783
            self.Labels = Labels
2784
        self.Labels_nsprefix_ = "pc"
2785
        if TextRegion is None:
2786
            self.TextRegion = []
2787
        else:
2788
            self.TextRegion = TextRegion
2789
        self.TextRegion_nsprefix_ = "pc"
2790
        if ImageRegion is None:
2791
            self.ImageRegion = []
2792
        else:
2793
            self.ImageRegion = ImageRegion
2794
        self.ImageRegion_nsprefix_ = "pc"
2795
        if LineDrawingRegion is None:
2796
            self.LineDrawingRegion = []
2797
        else:
2798
            self.LineDrawingRegion = LineDrawingRegion
2799
        self.LineDrawingRegion_nsprefix_ = "pc"
2800
        if GraphicRegion is None:
2801
            self.GraphicRegion = []
2802
        else:
2803
            self.GraphicRegion = GraphicRegion
2804
        self.GraphicRegion_nsprefix_ = "pc"
2805
        if TableRegion is None:
2806
            self.TableRegion = []
2807
        else:
2808
            self.TableRegion = TableRegion
2809
        self.TableRegion_nsprefix_ = "pc"
2810
        if ChartRegion is None:
2811
            self.ChartRegion = []
2812
        else:
2813
            self.ChartRegion = ChartRegion
2814
        self.ChartRegion_nsprefix_ = "pc"
2815
        if MapRegion is None:
2816
            self.MapRegion = []
2817
        else:
2818
            self.MapRegion = MapRegion
2819
        self.MapRegion_nsprefix_ = "pc"
2820
        if SeparatorRegion is None:
2821
            self.SeparatorRegion = []
2822
        else:
2823
            self.SeparatorRegion = SeparatorRegion
2824
        self.SeparatorRegion_nsprefix_ = "pc"
2825
        if MathsRegion is None:
2826
            self.MathsRegion = []
2827
        else:
2828
            self.MathsRegion = MathsRegion
2829
        self.MathsRegion_nsprefix_ = "pc"
2830
        if ChemRegion is None:
2831
            self.ChemRegion = []
2832
        else:
2833
            self.ChemRegion = ChemRegion
2834
        self.ChemRegion_nsprefix_ = "pc"
2835
        if MusicRegion is None:
2836
            self.MusicRegion = []
2837
        else:
2838
            self.MusicRegion = MusicRegion
2839
        self.MusicRegion_nsprefix_ = "pc"
2840
        if AdvertRegion is None:
2841
            self.AdvertRegion = []
2842
        else:
2843
            self.AdvertRegion = AdvertRegion
2844
        self.AdvertRegion_nsprefix_ = "pc"
2845
        if NoiseRegion is None:
2846
            self.NoiseRegion = []
2847
        else:
2848
            self.NoiseRegion = NoiseRegion
2849
        self.NoiseRegion_nsprefix_ = "pc"
2850
        if UnknownRegion is None:
2851
            self.UnknownRegion = []
2852
        else:
2853
            self.UnknownRegion = UnknownRegion
2854
        self.UnknownRegion_nsprefix_ = "pc"
2855
        if CustomRegion is None:
2856
            self.CustomRegion = []
2857
        else:
2858
            self.CustomRegion = CustomRegion
2859
        self.CustomRegion_nsprefix_ = "pc"
2860
    def factory(*args_, **kwargs_):
2861
        if CurrentSubclassModule_ is not None:
2862
            subclass = getSubclassFromModule_(
2863
                CurrentSubclassModule_, PageType)
2864
            if subclass is not None:
2865
                return subclass(*args_, **kwargs_)
2866
        if PageType.subclass:
2867
            return PageType.subclass(*args_, **kwargs_)
2868
        else:
2869
            return PageType(*args_, **kwargs_)
2870
    factory = staticmethod(factory)
2871
    def get_ns_prefix_(self):
2872
        return self.ns_prefix_
2873
    def set_ns_prefix_(self, ns_prefix):
2874
        self.ns_prefix_ = ns_prefix
2875
    def get_AlternativeImage(self):
2876
        return self.AlternativeImage
2877
    def set_AlternativeImage(self, AlternativeImage):
2878
        self.AlternativeImage = AlternativeImage
2879
    def add_AlternativeImage(self, value):
2880
        self.AlternativeImage.append(value)
2881
    def insert_AlternativeImage_at(self, index, value):
2882
        self.AlternativeImage.insert(index, value)
2883
    def replace_AlternativeImage_at(self, index, value):
2884
        self.AlternativeImage[index] = value
2885
    def get_Border(self):
2886
        return self.Border
2887
    def set_Border(self, Border):
2888
        self.Border = Border
2889
    def get_PrintSpace(self):
2890
        return self.PrintSpace
2891
    def set_PrintSpace(self, PrintSpace):
2892
        self.PrintSpace = PrintSpace
2893
    def get_ReadingOrder(self):
2894
        return self.ReadingOrder
2895
    def set_ReadingOrder(self, ReadingOrder):
2896
        self.ReadingOrder = ReadingOrder
2897
    def get_Layers(self):
2898
        return self.Layers
2899
    def set_Layers(self, Layers):
2900
        self.Layers = Layers
2901
    def get_Relations(self):
2902
        return self.Relations
2903
    def set_Relations(self, Relations):
2904
        self.Relations = Relations
2905
    def get_TextStyle(self):
2906
        return self.TextStyle
2907
    def set_TextStyle(self, TextStyle):
2908
        self.TextStyle = TextStyle
2909
    def get_UserDefined(self):
2910
        return self.UserDefined
2911
    def set_UserDefined(self, UserDefined):
2912
        self.UserDefined = UserDefined
2913
    def get_Labels(self):
2914
        return self.Labels
2915
    def set_Labels(self, Labels):
2916
        self.Labels = Labels
2917
    def add_Labels(self, value):
2918
        self.Labels.append(value)
2919
    def insert_Labels_at(self, index, value):
2920
        self.Labels.insert(index, value)
2921
    def replace_Labels_at(self, index, value):
2922
        self.Labels[index] = value
2923
    def get_TextRegion(self):
2924
        return self.TextRegion
2925
    def set_TextRegion(self, TextRegion):
2926
        self.TextRegion = TextRegion
2927
    def add_TextRegion(self, value):
2928
        self.TextRegion.append(value)
2929
    def insert_TextRegion_at(self, index, value):
2930
        self.TextRegion.insert(index, value)
2931
    def replace_TextRegion_at(self, index, value):
2932
        self.TextRegion[index] = value
2933
    def get_ImageRegion(self):
2934
        return self.ImageRegion
2935
    def set_ImageRegion(self, ImageRegion):
2936
        self.ImageRegion = ImageRegion
2937
    def add_ImageRegion(self, value):
2938
        self.ImageRegion.append(value)
2939
    def insert_ImageRegion_at(self, index, value):
2940
        self.ImageRegion.insert(index, value)
2941
    def replace_ImageRegion_at(self, index, value):
2942
        self.ImageRegion[index] = value
2943
    def get_LineDrawingRegion(self):
2944
        return self.LineDrawingRegion
2945
    def set_LineDrawingRegion(self, LineDrawingRegion):
2946
        self.LineDrawingRegion = LineDrawingRegion
2947
    def add_LineDrawingRegion(self, value):
2948
        self.LineDrawingRegion.append(value)
2949
    def insert_LineDrawingRegion_at(self, index, value):
2950
        self.LineDrawingRegion.insert(index, value)
2951
    def replace_LineDrawingRegion_at(self, index, value):
2952
        self.LineDrawingRegion[index] = value
2953
    def get_GraphicRegion(self):
2954
        return self.GraphicRegion
2955
    def set_GraphicRegion(self, GraphicRegion):
2956
        self.GraphicRegion = GraphicRegion
2957
    def add_GraphicRegion(self, value):
2958
        self.GraphicRegion.append(value)
2959
    def insert_GraphicRegion_at(self, index, value):
2960
        self.GraphicRegion.insert(index, value)
2961
    def replace_GraphicRegion_at(self, index, value):
2962
        self.GraphicRegion[index] = value
2963
    def get_TableRegion(self):
2964
        return self.TableRegion
2965
    def set_TableRegion(self, TableRegion):
2966
        self.TableRegion = TableRegion
2967
    def add_TableRegion(self, value):
2968
        self.TableRegion.append(value)
2969
    def insert_TableRegion_at(self, index, value):
2970
        self.TableRegion.insert(index, value)
2971
    def replace_TableRegion_at(self, index, value):
2972
        self.TableRegion[index] = value
2973
    def get_ChartRegion(self):
2974
        return self.ChartRegion
2975
    def set_ChartRegion(self, ChartRegion):
2976
        self.ChartRegion = ChartRegion
2977
    def add_ChartRegion(self, value):
2978
        self.ChartRegion.append(value)
2979
    def insert_ChartRegion_at(self, index, value):
2980
        self.ChartRegion.insert(index, value)
2981
    def replace_ChartRegion_at(self, index, value):
2982
        self.ChartRegion[index] = value
2983
    def get_MapRegion(self):
2984
        return self.MapRegion
2985
    def set_MapRegion(self, MapRegion):
2986
        self.MapRegion = MapRegion
2987
    def add_MapRegion(self, value):
2988
        self.MapRegion.append(value)
2989
    def insert_MapRegion_at(self, index, value):
2990
        self.MapRegion.insert(index, value)
2991
    def replace_MapRegion_at(self, index, value):
2992
        self.MapRegion[index] = value
2993
    def get_SeparatorRegion(self):
2994
        return self.SeparatorRegion
2995
    def set_SeparatorRegion(self, SeparatorRegion):
2996
        self.SeparatorRegion = SeparatorRegion
2997
    def add_SeparatorRegion(self, value):
2998
        self.SeparatorRegion.append(value)
2999
    def insert_SeparatorRegion_at(self, index, value):
3000
        self.SeparatorRegion.insert(index, value)
3001
    def replace_SeparatorRegion_at(self, index, value):
3002
        self.SeparatorRegion[index] = value
3003
    def get_MathsRegion(self):
3004
        return self.MathsRegion
3005
    def set_MathsRegion(self, MathsRegion):
3006
        self.MathsRegion = MathsRegion
3007
    def add_MathsRegion(self, value):
3008
        self.MathsRegion.append(value)
3009
    def insert_MathsRegion_at(self, index, value):
3010
        self.MathsRegion.insert(index, value)
3011
    def replace_MathsRegion_at(self, index, value):
3012
        self.MathsRegion[index] = value
3013
    def get_ChemRegion(self):
3014
        return self.ChemRegion
3015
    def set_ChemRegion(self, ChemRegion):
3016
        self.ChemRegion = ChemRegion
3017
    def add_ChemRegion(self, value):
3018
        self.ChemRegion.append(value)
3019
    def insert_ChemRegion_at(self, index, value):
3020
        self.ChemRegion.insert(index, value)
3021
    def replace_ChemRegion_at(self, index, value):
3022
        self.ChemRegion[index] = value
3023
    def get_MusicRegion(self):
3024
        return self.MusicRegion
3025
    def set_MusicRegion(self, MusicRegion):
3026
        self.MusicRegion = MusicRegion
3027
    def add_MusicRegion(self, value):
3028
        self.MusicRegion.append(value)
3029
    def insert_MusicRegion_at(self, index, value):
3030
        self.MusicRegion.insert(index, value)
3031
    def replace_MusicRegion_at(self, index, value):
3032
        self.MusicRegion[index] = value
3033
    def get_AdvertRegion(self):
3034
        return self.AdvertRegion
3035
    def set_AdvertRegion(self, AdvertRegion):
3036
        self.AdvertRegion = AdvertRegion
3037
    def add_AdvertRegion(self, value):
3038
        self.AdvertRegion.append(value)
3039
    def insert_AdvertRegion_at(self, index, value):
3040
        self.AdvertRegion.insert(index, value)
3041
    def replace_AdvertRegion_at(self, index, value):
3042
        self.AdvertRegion[index] = value
3043
    def get_NoiseRegion(self):
3044
        return self.NoiseRegion
3045
    def set_NoiseRegion(self, NoiseRegion):
3046
        self.NoiseRegion = NoiseRegion
3047
    def add_NoiseRegion(self, value):
3048
        self.NoiseRegion.append(value)
3049
    def insert_NoiseRegion_at(self, index, value):
3050
        self.NoiseRegion.insert(index, value)
3051
    def replace_NoiseRegion_at(self, index, value):
3052
        self.NoiseRegion[index] = value
3053
    def get_UnknownRegion(self):
3054
        return self.UnknownRegion
3055
    def set_UnknownRegion(self, UnknownRegion):
3056
        self.UnknownRegion = UnknownRegion
3057
    def add_UnknownRegion(self, value):
3058
        self.UnknownRegion.append(value)
3059
    def insert_UnknownRegion_at(self, index, value):
3060
        self.UnknownRegion.insert(index, value)
3061
    def replace_UnknownRegion_at(self, index, value):
3062
        self.UnknownRegion[index] = value
3063
    def get_CustomRegion(self):
3064
        return self.CustomRegion
3065
    def set_CustomRegion(self, CustomRegion):
3066
        self.CustomRegion = CustomRegion
3067
    def add_CustomRegion(self, value):
3068
        self.CustomRegion.append(value)
3069
    def insert_CustomRegion_at(self, index, value):
3070
        self.CustomRegion.insert(index, value)
3071
    def replace_CustomRegion_at(self, index, value):
3072
        self.CustomRegion[index] = value
3073
    def get_imageFilename(self):
3074
        return self.imageFilename
3075
    def set_imageFilename(self, imageFilename):
3076
        self.imageFilename = imageFilename
3077
    def get_imageWidth(self):
3078
        return self.imageWidth
3079
    def set_imageWidth(self, imageWidth):
3080
        self.imageWidth = imageWidth
3081
    def get_imageHeight(self):
3082
        return self.imageHeight
3083
    def set_imageHeight(self, imageHeight):
3084
        self.imageHeight = imageHeight
3085
    def get_imageXResolution(self):
3086
        return self.imageXResolution
3087
    def set_imageXResolution(self, imageXResolution):
3088
        self.imageXResolution = imageXResolution
3089
    def get_imageYResolution(self):
3090
        return self.imageYResolution
3091
    def set_imageYResolution(self, imageYResolution):
3092
        self.imageYResolution = imageYResolution
3093
    def get_imageResolutionUnit(self):
3094
        return self.imageResolutionUnit
3095
    def set_imageResolutionUnit(self, imageResolutionUnit):
3096
        self.imageResolutionUnit = imageResolutionUnit
3097
    def get_custom(self):
3098
        return self.custom
3099
    def set_custom(self, custom):
3100
        self.custom = custom
3101
    def get_orientation(self):
3102
        return self.orientation
3103
    def set_orientation(self, orientation):
3104
        self.orientation = orientation
3105
    def get_type(self):
3106
        return self.type_
3107
    def set_type(self, type_):
3108
        self.type_ = type_
3109
    def get_primaryLanguage(self):
3110
        return self.primaryLanguage
3111
    def set_primaryLanguage(self, primaryLanguage):
3112
        self.primaryLanguage = primaryLanguage
3113
    def get_secondaryLanguage(self):
3114
        return self.secondaryLanguage
3115
    def set_secondaryLanguage(self, secondaryLanguage):
3116
        self.secondaryLanguage = secondaryLanguage
3117
    def get_primaryScript(self):
3118
        return self.primaryScript
3119
    def set_primaryScript(self, primaryScript):
3120
        self.primaryScript = primaryScript
3121
    def get_secondaryScript(self):
3122
        return self.secondaryScript
3123
    def set_secondaryScript(self, secondaryScript):
3124
        self.secondaryScript = secondaryScript
3125
    def get_readingDirection(self):
3126
        return self.readingDirection
3127
    def set_readingDirection(self, readingDirection):
3128
        self.readingDirection = readingDirection
3129
    def get_textLineOrder(self):
3130
        return self.textLineOrder
3131
    def set_textLineOrder(self, textLineOrder):
3132
        self.textLineOrder = textLineOrder
3133
    def get_conf(self):
3134
        return self.conf
3135
    def set_conf(self, conf):
3136
        self.conf = conf
3137
    def validate_imageResolutionUnitType(self, value):
3138
        # Validate type imageResolutionUnitType, a restriction on string.
3139
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
3140
            if not isinstance(value, str):
3141
                lineno = self.gds_get_node_lineno_()
3142
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
3143
                return False
3144
            value = value
3145
            enumerations = ['PPI', 'PPCM', 'other']
3146
            if value not in enumerations:
3147
                lineno = self.gds_get_node_lineno_()
3148
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on imageResolutionUnitType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
3149
                result = False
3150
    def validate_PageTypeSimpleType(self, value):
3151
        # Validate type pc:PageTypeSimpleType, a restriction on string.
3152
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
3153
            if not isinstance(value, str):
3154
                lineno = self.gds_get_node_lineno_()
3155
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
3156
                return False
3157
            value = value
3158
            enumerations = ['front-cover', 'back-cover', 'title', 'table-of-contents', 'index', 'content', 'blank', 'other']
3159
            if value not in enumerations:
3160
                lineno = self.gds_get_node_lineno_()
3161
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on PageTypeSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
3162
                result = False
3163
    def validate_LanguageSimpleType(self, value):
3164
        # Validate type pc:LanguageSimpleType, a restriction on string.
3165
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
3166
            if not isinstance(value, str):
3167
                lineno = self.gds_get_node_lineno_()
3168
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
3169
                return False
3170
            value = value
3171
            enumerations = ['Abkhaz', 'Afar', 'Afrikaans', 'Akan', 'Albanian', 'Amharic', 'Arabic', 'Aragonese', 'Armenian', 'Assamese', 'Avaric', 'Avestan', 'Aymara', 'Azerbaijani', 'Bambara', 'Bashkir', 'Basque', 'Belarusian', 'Bengali', 'Bihari', 'Bislama', 'Bosnian', 'Breton', 'Bulgarian', 'Burmese', 'Cambodian', 'Cantonese', 'Catalan', 'Chamorro', 'Chechen', 'Chichewa', 'Chinese', 'Chuvash', 'Cornish', 'Corsican', 'Cree', 'Croatian', 'Czech', 'Danish', 'Divehi', 'Dutch', 'Dzongkha', 'English', 'Esperanto', 'Estonian', 'Ewe', 'Faroese', 'Fijian', 'Finnish', 'French', 'Fula', 'Gaelic', 'Galician', 'Ganda', 'Georgian', 'German', 'Greek', 'Guaraní', 'Gujarati', 'Haitian', 'Hausa', 'Hebrew', 'Herero', 'Hindi', 'Hiri Motu', 'Hungarian', 'Icelandic', 'Ido', 'Igbo', 'Indonesian', 'Interlingua', 'Interlingue', 'Inuktitut', 'Inupiaq', 'Irish', 'Italian', 'Japanese', 'Javanese', 'Kalaallisut', 'Kannada', 'Kanuri', 'Kashmiri', 'Kazakh', 'Khmer', 'Kikuyu', 'Kinyarwanda', 'Kirundi', 'Komi', 'Kongo', 'Korean', 'Kurdish', 'Kwanyama', 'Kyrgyz', 'Lao', 'Latin', 'Latvian', 'Limburgish', 'Lingala', 'Lithuanian', 'Luba-Katanga', 'Luxembourgish', 'Macedonian', 'Malagasy', 'Malay', 'Malayalam', 'Maltese', 'Manx', 'Māori', 'Marathi', 'Marshallese', 'Mongolian', 'Nauru', 'Navajo', 'Ndonga', 'Nepali', 'North Ndebele', 'Northern Sami', 'Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk', 'Nuosu', 'Occitan', 'Ojibwe', 'Old Church Slavonic', 'Oriya', 'Oromo', 'Ossetian', 'Pāli', 'Panjabi', 'Pashto', 'Persian', 'Polish', 'Portuguese', 'Punjabi', 'Quechua', 'Romanian', 'Romansh', 'Russian', 'Samoan', 'Sango', 'Sanskrit', 'Sardinian', 'Serbian', 'Shona', 'Sindhi', 'Sinhala', 'Slovak', 'Slovene', 'Somali', 'South Ndebele', 'Southern Sotho', 'Spanish', 'Sundanese', 'Swahili', 'Swati', 'Swedish', 'Tagalog', 'Tahitian', 'Tajik', 'Tamil', 'Tatar', 'Telugu', 'Thai', 'Tibetan', 'Tigrinya', 'Tonga', 'Tsonga', 'Tswana', 'Turkish', 'Turkmen', 'Twi', 'Uighur', 'Ukrainian', 'Urdu', 'Uzbek', 'Venda', 'Vietnamese', 'Volapük', 'Walloon', 'Welsh', 'Western Frisian', 'Wolof', 'Xhosa', 'Yiddish', 'Yoruba', 'Zhuang', 'Zulu', 'other']
3172
            if value not in enumerations:
3173
                lineno = self.gds_get_node_lineno_()
3174
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on LanguageSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
3175
                result = False
3176
    def validate_ScriptSimpleType(self, value):
3177
        # Validate type pc:ScriptSimpleType, a restriction on string.
3178
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
3179
            if not isinstance(value, str):
3180
                lineno = self.gds_get_node_lineno_()
3181
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
3182
                return False
3183
            value = value
3184
            enumerations = ['Adlm - Adlam', 'Afak - Afaka', 'Aghb - Caucasian Albanian', 'Ahom - Ahom, Tai Ahom', 'Arab - Arabic', 'Aran - Arabic (Nastaliq variant)', 'Armi - Imperial Aramaic', 'Armn - Armenian', 'Avst - Avestan', 'Bali - Balinese', 'Bamu - Bamum', 'Bass - Bassa Vah', 'Batk - Batak', 'Beng - Bengali', 'Bhks - Bhaiksuki', 'Blis - Blissymbols', 'Bopo - Bopomofo', 'Brah - Brahmi', 'Brai - Braille', 'Bugi - Buginese', 'Buhd - Buhid', 'Cakm - Chakma', 'Cans - Unified Canadian Aboriginal Syllabics', 'Cari - Carian', 'Cham - Cham', 'Cher - Cherokee', 'Cirt - Cirth', 'Copt - Coptic', 'Cprt - Cypriot', 'Cyrl - Cyrillic', 'Cyrs - Cyrillic (Old Church Slavonic variant)', 'Deva - Devanagari (Nagari)', 'Dsrt - Deseret (Mormon)', 'Dupl - Duployan shorthand, Duployan stenography', 'Egyd - Egyptian demotic', 'Egyh - Egyptian hieratic', 'Egyp - Egyptian hieroglyphs', 'Elba - Elbasan', 'Ethi - Ethiopic', 'Geok - Khutsuri (Asomtavruli and Nuskhuri)', 'Geor - Georgian (Mkhedruli)', 'Glag - Glagolitic', 'Goth - Gothic', 'Gran - Grantha', 'Grek - Greek', 'Gujr - Gujarati', 'Guru - Gurmukhi', 'Hanb - Han with Bopomofo', 'Hang - Hangul', 'Hani - Han (Hanzi, Kanji, Hanja)', 'Hano - Hanunoo (Hanunóo)', 'Hans - Han (Simplified variant)', 'Hant - Han (Traditional variant)', 'Hatr - Hatran', 'Hebr - Hebrew', 'Hira - Hiragana', 'Hluw - Anatolian Hieroglyphs', 'Hmng - Pahawh Hmong', 'Hrkt - Japanese syllabaries', 'Hung - Old Hungarian (Hungarian Runic)', 'Inds - Indus (Harappan)', 'Ital - Old Italic (Etruscan, Oscan etc.)', 'Jamo - Jamo', 'Java - Javanese', 'Jpan - Japanese', 'Jurc - Jurchen', 'Kali - Kayah Li', 'Kana - Katakana', 'Khar - Kharoshthi', 'Khmr - Khmer', 'Khoj - Khojki', 'Kitl - Khitan large script', 'Kits - Khitan small script', 'Knda - Kannada', 'Kore - Korean (alias for Hangul + Han)', 'Kpel - Kpelle', 'Kthi - Kaithi', 'Lana - Tai Tham (Lanna)', 'Laoo - Lao', 'Latf - Latin (Fraktur variant)', 'Latg - Latin (Gaelic variant)', 'Latn - Latin', 'Leke - Leke', 'Lepc - Lepcha (Róng)', 'Limb - Limbu', 'Lina - Linear A', 'Linb - Linear B', 'Lisu - Lisu (Fraser)', 'Loma - Loma', 'Lyci - Lycian', 'Lydi - Lydian', 'Mahj - Mahajani', 'Mand - Mandaic, Mandaean', 'Mani - Manichaean', 'Marc - Marchen', 'Maya - Mayan hieroglyphs', 'Mend - Mende Kikakui', 'Merc - Meroitic Cursive', 'Mero - Meroitic Hieroglyphs', 'Mlym - Malayalam', 'Modi - Modi, Moḍī', 'Mong - Mongolian', 'Moon - Moon (Moon code, Moon script, Moon type)', 'Mroo - Mro, Mru', 'Mtei - Meitei Mayek (Meithei, Meetei)', 'Mult - Multani', 'Mymr - Myanmar (Burmese)', 'Narb - Old North Arabian (Ancient North Arabian)', 'Nbat - Nabataean', 'Newa - Newa, Newar, Newari', 'Nkgb - Nakhi Geba', 'Nkoo - N’Ko', 'Nshu - Nüshu', 'Ogam - Ogham', 'Olck - Ol Chiki (Ol Cemet’, Ol, Santali)', 'Orkh - Old Turkic, Orkhon Runic', 'Orya - Oriya', 'Osge - Osage', 'Osma - Osmanya', 'Palm - Palmyrene', 'Pauc - Pau Cin Hau', 'Perm - Old Permic', 'Phag - Phags-pa', 'Phli - Inscriptional Pahlavi', 'Phlp - Psalter Pahlavi', 'Phlv - Book Pahlavi', 'Phnx - Phoenician', 'Piqd - Klingon (KLI pIqaD)', 'Plrd - Miao (Pollard)', 'Prti - Inscriptional Parthian', 'Rjng - Rejang (Redjang, Kaganga)', 'Roro - Rongorongo', 'Runr - Runic', 'Samr - Samaritan', 'Sara - Sarati', 'Sarb - Old South Arabian', 'Saur - Saurashtra', 'Sgnw - SignWriting', 'Shaw - Shavian (Shaw)', 'Shrd - Sharada, Śāradā', 'Sidd - Siddham', 'Sind - Khudawadi, Sindhi', 'Sinh - Sinhala', 'Sora - Sora Sompeng', 'Sund - Sundanese', 'Sylo - Syloti Nagri', 'Syrc - Syriac', 'Syre - Syriac (Estrangelo variant)', 'Syrj - Syriac (Western variant)', 'Syrn - Syriac (Eastern variant)', 'Tagb - Tagbanwa', 'Takr - Takri', 'Tale - Tai Le', 'Talu - New Tai Lue', 'Taml - Tamil', 'Tang - Tangut', 'Tavt - Tai Viet', 'Telu - Telugu', 'Teng - Tengwar', 'Tfng - Tifinagh (Berber)', 'Tglg - Tagalog (Baybayin, Alibata)', 'Thaa - Thaana', 'Thai - Thai', 'Tibt - Tibetan', 'Tirh - Tirhuta', 'Ugar - Ugaritic', 'Vaii - Vai', 'Visp - Visible Speech', 'Wara - Warang Citi (Varang Kshiti)', 'Wole - Woleai', 'Xpeo - Old Persian', 'Xsux - Cuneiform, Sumero-Akkadian', 'Yiii - Yi', 'Zinh - Code for inherited script', 'Zmth - Mathematical notation', 'Zsye - Symbols (Emoji variant)', 'Zsym - Symbols', 'Zxxx - Code for unwritten documents', 'Zyyy - Code for undetermined script', 'Zzzz - Code for uncoded script', 'other']
3185
            if value not in enumerations:
3186
                lineno = self.gds_get_node_lineno_()
3187
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ScriptSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
3188
                result = False
3189
    def validate_ReadingDirectionSimpleType(self, value):
3190
        # Validate type pc:ReadingDirectionSimpleType, a restriction on string.
3191
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
3192
            if not isinstance(value, str):
3193
                lineno = self.gds_get_node_lineno_()
3194
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
3195
                return False
3196
            value = value
3197
            enumerations = ['left-to-right', 'right-to-left', 'top-to-bottom', 'bottom-to-top']
3198
            if value not in enumerations:
3199
                lineno = self.gds_get_node_lineno_()
3200
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ReadingDirectionSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
3201
                result = False
3202
    def validate_TextLineOrderSimpleType(self, value):
3203
        # Validate type pc:TextLineOrderSimpleType, a restriction on string.
3204
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
3205
            if not isinstance(value, str):
3206
                lineno = self.gds_get_node_lineno_()
3207
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
3208
                return False
3209
            value = value
3210
            enumerations = ['top-to-bottom', 'bottom-to-top', 'left-to-right', 'right-to-left']
3211
            if value not in enumerations:
3212
                lineno = self.gds_get_node_lineno_()
3213
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on TextLineOrderSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
3214
                result = False
3215 View Code Duplication
    def validate_ConfSimpleType(self, value):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
3216
        # Validate type pc:ConfSimpleType, a restriction on float.
3217
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
3218
            if not isinstance(value, float):
3219
                lineno = self.gds_get_node_lineno_()
3220
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (float)' % {"value": value, "lineno": lineno, })
3221
                return False
3222
            if value < 0:
3223
                lineno = self.gds_get_node_lineno_()
3224
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd minInclusive restriction on ConfSimpleType' % {"value": value, "lineno": lineno} )
3225
                result = False
3226
            if value > 1:
3227
                lineno = self.gds_get_node_lineno_()
3228
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxInclusive restriction on ConfSimpleType' % {"value": value, "lineno": lineno} )
3229
                result = False
3230
    def has__content(self):
3231
        if (
3232
            self.AlternativeImage or
3233
            self.Border is not None or
3234
            self.PrintSpace is not None or
3235
            self.ReadingOrder is not None or
3236
            self.Layers is not None or
3237
            self.Relations is not None or
3238
            self.TextStyle is not None or
3239
            self.UserDefined is not None or
3240
            self.Labels or
3241
            self.TextRegion or
3242
            self.ImageRegion or
3243
            self.LineDrawingRegion or
3244
            self.GraphicRegion or
3245
            self.TableRegion or
3246
            self.ChartRegion or
3247
            self.MapRegion or
3248
            self.SeparatorRegion or
3249
            self.MathsRegion or
3250
            self.ChemRegion or
3251
            self.MusicRegion or
3252
            self.AdvertRegion or
3253
            self.NoiseRegion or
3254
            self.UnknownRegion or
3255
            self.CustomRegion
3256
        ):
3257
            return True
3258
        else:
3259
            return False
3260
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='PageType', pretty_print=True):
3261
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('PageType')
3262
        if imported_ns_def_ is not None:
3263
            namespacedef_ = imported_ns_def_
3264
        if pretty_print:
3265
            eol_ = '\n'
3266
        else:
3267
            eol_ = ''
3268
        if self.original_tagname_ is not None and name_ == 'PageType':
3269
            name_ = self.original_tagname_
3270
        if UseCapturedNS_ and self.ns_prefix_:
3271
            namespaceprefix_ = self.ns_prefix_ + ':'
3272
        showIndent(outfile, level, pretty_print)
3273
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
3274
        already_processed = set()
3275
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='PageType')
3276
        if self.has__content():
3277
            outfile.write('>%s' % (eol_, ))
3278
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='PageType', pretty_print=pretty_print)
3279
            showIndent(outfile, level, pretty_print)
3280
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
3281
        else:
3282
            outfile.write('/>%s' % (eol_, ))
3283
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='PageType'):
3284
        if self.imageFilename is not None and 'imageFilename' not in already_processed:
3285
            already_processed.add('imageFilename')
3286
            outfile.write(' imageFilename=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.imageFilename), input_name='imageFilename')), ))
3287
        if self.imageWidth is not None and 'imageWidth' not in already_processed:
3288
            already_processed.add('imageWidth')
3289
            outfile.write(' imageWidth="%s"' % self.gds_format_integer(self.imageWidth, input_name='imageWidth'))
3290
        if self.imageHeight is not None and 'imageHeight' not in already_processed:
3291
            already_processed.add('imageHeight')
3292
            outfile.write(' imageHeight="%s"' % self.gds_format_integer(self.imageHeight, input_name='imageHeight'))
3293
        if self.imageXResolution is not None and 'imageXResolution' not in already_processed:
3294
            already_processed.add('imageXResolution')
3295
            outfile.write(' imageXResolution="%s"' % self.gds_format_float(self.imageXResolution, input_name='imageXResolution'))
3296
        if self.imageYResolution is not None and 'imageYResolution' not in already_processed:
3297
            already_processed.add('imageYResolution')
3298
            outfile.write(' imageYResolution="%s"' % self.gds_format_float(self.imageYResolution, input_name='imageYResolution'))
3299
        if self.imageResolutionUnit is not None and 'imageResolutionUnit' not in already_processed:
3300
            already_processed.add('imageResolutionUnit')
3301
            outfile.write(' imageResolutionUnit=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.imageResolutionUnit), input_name='imageResolutionUnit')), ))
3302
        if self.custom is not None and 'custom' not in already_processed:
3303
            already_processed.add('custom')
3304
            outfile.write(' custom=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.custom), input_name='custom')), ))
3305
        if self.orientation is not None and 'orientation' not in already_processed:
3306
            already_processed.add('orientation')
3307
            outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation'))
3308
        if self.type_ is not None and 'type_' not in already_processed:
3309
            already_processed.add('type_')
3310
            outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), ))
3311
        if self.primaryLanguage is not None and 'primaryLanguage' not in already_processed:
3312
            already_processed.add('primaryLanguage')
3313
            outfile.write(' primaryLanguage=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.primaryLanguage), input_name='primaryLanguage')), ))
3314
        if self.secondaryLanguage is not None and 'secondaryLanguage' not in already_processed:
3315
            already_processed.add('secondaryLanguage')
3316
            outfile.write(' secondaryLanguage=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.secondaryLanguage), input_name='secondaryLanguage')), ))
3317
        if self.primaryScript is not None and 'primaryScript' not in already_processed:
3318
            already_processed.add('primaryScript')
3319
            outfile.write(' primaryScript=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.primaryScript), input_name='primaryScript')), ))
3320
        if self.secondaryScript is not None and 'secondaryScript' not in already_processed:
3321
            already_processed.add('secondaryScript')
3322
            outfile.write(' secondaryScript=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.secondaryScript), input_name='secondaryScript')), ))
3323
        if self.readingDirection is not None and 'readingDirection' not in already_processed:
3324
            already_processed.add('readingDirection')
3325
            outfile.write(' readingDirection=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.readingDirection), input_name='readingDirection')), ))
3326
        if self.textLineOrder is not None and 'textLineOrder' not in already_processed:
3327
            already_processed.add('textLineOrder')
3328
            outfile.write(' textLineOrder=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.textLineOrder), input_name='textLineOrder')), ))
3329
        if self.conf is not None and 'conf' not in already_processed:
3330
            already_processed.add('conf')
3331
            outfile.write(' conf="%s"' % self.gds_format_float(self.conf, input_name='conf'))
3332
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='PageType', fromsubclass_=False, pretty_print=True):
3333
        if pretty_print:
3334
            eol_ = '\n'
3335
        else:
3336
            eol_ = ''
3337
        for AlternativeImage_ in self.AlternativeImage:
3338
            namespaceprefix_ = self.AlternativeImage_nsprefix_ + ':' if (UseCapturedNS_ and self.AlternativeImage_nsprefix_) else ''
3339
            AlternativeImage_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='AlternativeImage', pretty_print=pretty_print)
3340
        if self.Border is not None:
3341
            namespaceprefix_ = self.Border_nsprefix_ + ':' if (UseCapturedNS_ and self.Border_nsprefix_) else ''
3342
            self.Border.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Border', pretty_print=pretty_print)
3343
        if self.PrintSpace is not None:
3344
            namespaceprefix_ = self.PrintSpace_nsprefix_ + ':' if (UseCapturedNS_ and self.PrintSpace_nsprefix_) else ''
3345
            self.PrintSpace.export(outfile, level, namespaceprefix_, namespacedef_='', name_='PrintSpace', pretty_print=pretty_print)
3346
        if self.ReadingOrder is not None:
3347
            namespaceprefix_ = self.ReadingOrder_nsprefix_ + ':' if (UseCapturedNS_ and self.ReadingOrder_nsprefix_) else ''
3348
            self.ReadingOrder.export(outfile, level, namespaceprefix_, namespacedef_='', name_='ReadingOrder', pretty_print=pretty_print)
3349
        if self.Layers is not None:
3350
            namespaceprefix_ = self.Layers_nsprefix_ + ':' if (UseCapturedNS_ and self.Layers_nsprefix_) else ''
3351
            self.Layers.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Layers', pretty_print=pretty_print)
3352
        if self.Relations is not None:
3353
            namespaceprefix_ = self.Relations_nsprefix_ + ':' if (UseCapturedNS_ and self.Relations_nsprefix_) else ''
3354
            self.Relations.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Relations', pretty_print=pretty_print)
3355
        if self.TextStyle is not None:
3356
            namespaceprefix_ = self.TextStyle_nsprefix_ + ':' if (UseCapturedNS_ and self.TextStyle_nsprefix_) else ''
3357
            self.TextStyle.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TextStyle', pretty_print=pretty_print)
3358
        if self.UserDefined is not None:
3359
            namespaceprefix_ = self.UserDefined_nsprefix_ + ':' if (UseCapturedNS_ and self.UserDefined_nsprefix_) else ''
3360
            self.UserDefined.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UserDefined', pretty_print=pretty_print)
3361
        for Labels_ in self.Labels:
3362
            namespaceprefix_ = self.Labels_nsprefix_ + ':' if (UseCapturedNS_ and self.Labels_nsprefix_) else ''
3363
            Labels_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Labels', pretty_print=pretty_print)
3364
        for TextRegion_ in self.TextRegion:
3365
            namespaceprefix_ = self.TextRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.TextRegion_nsprefix_) else ''
3366
            TextRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TextRegion', pretty_print=pretty_print)
3367
        for ImageRegion_ in self.ImageRegion:
3368
            namespaceprefix_ = self.ImageRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.ImageRegion_nsprefix_) else ''
3369
            ImageRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='ImageRegion', pretty_print=pretty_print)
3370
        for LineDrawingRegion_ in self.LineDrawingRegion:
3371
            namespaceprefix_ = self.LineDrawingRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.LineDrawingRegion_nsprefix_) else ''
3372
            LineDrawingRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='LineDrawingRegion', pretty_print=pretty_print)
3373
        for GraphicRegion_ in self.GraphicRegion:
3374
            namespaceprefix_ = self.GraphicRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.GraphicRegion_nsprefix_) else ''
3375
            GraphicRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='GraphicRegion', pretty_print=pretty_print)
3376
        for TableRegion_ in self.TableRegion:
3377
            namespaceprefix_ = self.TableRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.TableRegion_nsprefix_) else ''
3378
            TableRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TableRegion', pretty_print=pretty_print)
3379
        for ChartRegion_ in self.ChartRegion:
3380
            namespaceprefix_ = self.ChartRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.ChartRegion_nsprefix_) else ''
3381
            ChartRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='ChartRegion', pretty_print=pretty_print)
3382
        for MapRegion_ in self.MapRegion:
3383
            namespaceprefix_ = self.MapRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.MapRegion_nsprefix_) else ''
3384
            MapRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='MapRegion', pretty_print=pretty_print)
3385
        for SeparatorRegion_ in self.SeparatorRegion:
3386
            namespaceprefix_ = self.SeparatorRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.SeparatorRegion_nsprefix_) else ''
3387
            SeparatorRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='SeparatorRegion', pretty_print=pretty_print)
3388
        for MathsRegion_ in self.MathsRegion:
3389
            namespaceprefix_ = self.MathsRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.MathsRegion_nsprefix_) else ''
3390
            MathsRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='MathsRegion', pretty_print=pretty_print)
3391
        for ChemRegion_ in self.ChemRegion:
3392
            namespaceprefix_ = self.ChemRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.ChemRegion_nsprefix_) else ''
3393
            ChemRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='ChemRegion', pretty_print=pretty_print)
3394
        for MusicRegion_ in self.MusicRegion:
3395
            namespaceprefix_ = self.MusicRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.MusicRegion_nsprefix_) else ''
3396
            MusicRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='MusicRegion', pretty_print=pretty_print)
3397
        for AdvertRegion_ in self.AdvertRegion:
3398
            namespaceprefix_ = self.AdvertRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.AdvertRegion_nsprefix_) else ''
3399
            AdvertRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='AdvertRegion', pretty_print=pretty_print)
3400
        for NoiseRegion_ in self.NoiseRegion:
3401
            namespaceprefix_ = self.NoiseRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.NoiseRegion_nsprefix_) else ''
3402
            NoiseRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='NoiseRegion', pretty_print=pretty_print)
3403
        for UnknownRegion_ in self.UnknownRegion:
3404
            namespaceprefix_ = self.UnknownRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.UnknownRegion_nsprefix_) else ''
3405
            UnknownRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UnknownRegion', pretty_print=pretty_print)
3406
        for CustomRegion_ in self.CustomRegion:
3407
            namespaceprefix_ = self.CustomRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.CustomRegion_nsprefix_) else ''
3408
            CustomRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='CustomRegion', pretty_print=pretty_print)
3409
    def to_etree(self, parent_element=None, name_='PageType', mapping_=None, reverse_mapping_=None, nsmap_=None):
3410
        if parent_element is None:
3411
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
3412
        else:
3413
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
3414
        if self.imageFilename is not None:
3415
            element.set('imageFilename', self.gds_format_string(self.imageFilename))
3416
        if self.imageWidth is not None:
3417
            element.set('imageWidth', self.gds_format_integer(self.imageWidth))
3418
        if self.imageHeight is not None:
3419
            element.set('imageHeight', self.gds_format_integer(self.imageHeight))
3420
        if self.imageXResolution is not None:
3421
            element.set('imageXResolution', self.gds_format_float(self.imageXResolution))
3422
        if self.imageYResolution is not None:
3423
            element.set('imageYResolution', self.gds_format_float(self.imageYResolution))
3424
        if self.imageResolutionUnit is not None:
3425
            element.set('imageResolutionUnit', self.gds_format_string(self.imageResolutionUnit))
3426
        if self.custom is not None:
3427
            element.set('custom', self.gds_format_string(self.custom))
3428
        if self.orientation is not None:
3429
            element.set('orientation', self.gds_format_float(self.orientation))
3430
        if self.type_ is not None:
3431
            element.set('type', self.gds_format_string(self.type_))
3432
        if self.primaryLanguage is not None:
3433
            element.set('primaryLanguage', self.gds_format_string(self.primaryLanguage))
3434
        if self.secondaryLanguage is not None:
3435
            element.set('secondaryLanguage', self.gds_format_string(self.secondaryLanguage))
3436
        if self.primaryScript is not None:
3437
            element.set('primaryScript', self.gds_format_string(self.primaryScript))
3438
        if self.secondaryScript is not None:
3439
            element.set('secondaryScript', self.gds_format_string(self.secondaryScript))
3440
        if self.readingDirection is not None:
3441
            element.set('readingDirection', self.gds_format_string(self.readingDirection))
3442
        if self.textLineOrder is not None:
3443
            element.set('textLineOrder', self.gds_format_string(self.textLineOrder))
3444
        if self.conf is not None:
3445
            element.set('conf', self.gds_format_float(self.conf))
3446
        for AlternativeImage_ in self.AlternativeImage:
3447
            AlternativeImage_.to_etree(element, name_='AlternativeImage', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3448
        if self.Border is not None:
3449
            Border_ = self.Border
3450
            Border_.to_etree(element, name_='Border', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3451
        if self.PrintSpace is not None:
3452
            PrintSpace_ = self.PrintSpace
3453
            PrintSpace_.to_etree(element, name_='PrintSpace', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3454
        if self.ReadingOrder is not None:
3455
            ReadingOrder_ = self.ReadingOrder
3456
            ReadingOrder_.to_etree(element, name_='ReadingOrder', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3457
        if self.Layers is not None:
3458
            Layers_ = self.Layers
3459
            Layers_.to_etree(element, name_='Layers', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3460
        if self.Relations is not None:
3461
            Relations_ = self.Relations
3462
            Relations_.to_etree(element, name_='Relations', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3463
        if self.TextStyle is not None:
3464
            TextStyle_ = self.TextStyle
3465
            TextStyle_.to_etree(element, name_='TextStyle', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3466
        if self.UserDefined is not None:
3467
            UserDefined_ = self.UserDefined
3468
            UserDefined_.to_etree(element, name_='UserDefined', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3469
        for Labels_ in self.Labels:
3470
            Labels_.to_etree(element, name_='Labels', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3471
        for TextRegion_ in self.TextRegion:
3472
            TextRegion_.to_etree(element, name_='TextRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3473
        for ImageRegion_ in self.ImageRegion:
3474
            ImageRegion_.to_etree(element, name_='ImageRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3475
        for LineDrawingRegion_ in self.LineDrawingRegion:
3476
            LineDrawingRegion_.to_etree(element, name_='LineDrawingRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3477
        for GraphicRegion_ in self.GraphicRegion:
3478
            GraphicRegion_.to_etree(element, name_='GraphicRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3479
        for TableRegion_ in self.TableRegion:
3480
            TableRegion_.to_etree(element, name_='TableRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3481
        for ChartRegion_ in self.ChartRegion:
3482
            ChartRegion_.to_etree(element, name_='ChartRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3483
        for MapRegion_ in self.MapRegion:
3484
            MapRegion_.to_etree(element, name_='MapRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3485
        for SeparatorRegion_ in self.SeparatorRegion:
3486
            SeparatorRegion_.to_etree(element, name_='SeparatorRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3487
        for MathsRegion_ in self.MathsRegion:
3488
            MathsRegion_.to_etree(element, name_='MathsRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3489
        for ChemRegion_ in self.ChemRegion:
3490
            ChemRegion_.to_etree(element, name_='ChemRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3491
        for MusicRegion_ in self.MusicRegion:
3492
            MusicRegion_.to_etree(element, name_='MusicRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3493
        for AdvertRegion_ in self.AdvertRegion:
3494
            AdvertRegion_.to_etree(element, name_='AdvertRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3495
        for NoiseRegion_ in self.NoiseRegion:
3496
            NoiseRegion_.to_etree(element, name_='NoiseRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3497
        for UnknownRegion_ in self.UnknownRegion:
3498
            UnknownRegion_.to_etree(element, name_='UnknownRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3499
        for CustomRegion_ in self.CustomRegion:
3500
            CustomRegion_.to_etree(element, name_='CustomRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
3501
        if mapping_ is not None:
3502
            mapping_[id(self)] = element
3503
        if reverse_mapping_ is not None:
3504
            reverse_mapping_[element] = self
3505
        return element
3506
    def build(self, node, gds_collector_=None):
3507
        self.gds_collector_ = gds_collector_
3508
        if SaveElementTreeNode:
3509
            self.gds_elementtree_node_ = node
3510
        already_processed = set()
3511
        self.ns_prefix_ = node.prefix
3512
        self._buildAttributes(node, node.attrib, already_processed)
3513
        for child in node:
3514
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
3515
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
3516
        return self
3517
    def _buildAttributes(self, node, attrs, already_processed):
3518
        value = find_attr_value_('imageFilename', node)
3519
        if value is not None and 'imageFilename' not in already_processed:
3520
            already_processed.add('imageFilename')
3521
            self.imageFilename = value
3522
        value = find_attr_value_('imageWidth', node)
3523
        if value is not None and 'imageWidth' not in already_processed:
3524
            already_processed.add('imageWidth')
3525
            self.imageWidth = self.gds_parse_integer(value, node, 'imageWidth')
3526
        value = find_attr_value_('imageHeight', node)
3527
        if value is not None and 'imageHeight' not in already_processed:
3528
            already_processed.add('imageHeight')
3529
            self.imageHeight = self.gds_parse_integer(value, node, 'imageHeight')
3530
        value = find_attr_value_('imageXResolution', node)
3531
        if value is not None and 'imageXResolution' not in already_processed:
3532
            already_processed.add('imageXResolution')
3533
            value = self.gds_parse_float(value, node, 'imageXResolution')
3534
            self.imageXResolution = value
3535
        value = find_attr_value_('imageYResolution', node)
3536
        if value is not None and 'imageYResolution' not in already_processed:
3537
            already_processed.add('imageYResolution')
3538
            value = self.gds_parse_float(value, node, 'imageYResolution')
3539
            self.imageYResolution = value
3540
        value = find_attr_value_('imageResolutionUnit', node)
3541
        if value is not None and 'imageResolutionUnit' not in already_processed:
3542
            already_processed.add('imageResolutionUnit')
3543
            self.imageResolutionUnit = value
3544
            self.validate_imageResolutionUnitType(self.imageResolutionUnit)    # validate type imageResolutionUnitType
3545
        value = find_attr_value_('custom', node)
3546
        if value is not None and 'custom' not in already_processed:
3547
            already_processed.add('custom')
3548
            self.custom = value
3549
        value = find_attr_value_('orientation', node)
3550
        if value is not None and 'orientation' not in already_processed:
3551
            already_processed.add('orientation')
3552
            value = self.gds_parse_float(value, node, 'orientation')
3553
            self.orientation = value
3554
        value = find_attr_value_('type', node)
3555
        if value is not None and 'type' not in already_processed:
3556
            already_processed.add('type')
3557
            self.type_ = value
3558
            self.validate_PageTypeSimpleType(self.type_)    # validate type PageTypeSimpleType
3559
        value = find_attr_value_('primaryLanguage', node)
3560
        if value is not None and 'primaryLanguage' not in already_processed:
3561
            already_processed.add('primaryLanguage')
3562
            self.primaryLanguage = value
3563
            self.validate_LanguageSimpleType(self.primaryLanguage)    # validate type LanguageSimpleType
3564
        value = find_attr_value_('secondaryLanguage', node)
3565
        if value is not None and 'secondaryLanguage' not in already_processed:
3566
            already_processed.add('secondaryLanguage')
3567
            self.secondaryLanguage = value
3568
            self.validate_LanguageSimpleType(self.secondaryLanguage)    # validate type LanguageSimpleType
3569
        value = find_attr_value_('primaryScript', node)
3570
        if value is not None and 'primaryScript' not in already_processed:
3571
            already_processed.add('primaryScript')
3572
            self.primaryScript = value
3573
            self.validate_ScriptSimpleType(self.primaryScript)    # validate type ScriptSimpleType
3574
        value = find_attr_value_('secondaryScript', node)
3575
        if value is not None and 'secondaryScript' not in already_processed:
3576
            already_processed.add('secondaryScript')
3577
            self.secondaryScript = value
3578
            self.validate_ScriptSimpleType(self.secondaryScript)    # validate type ScriptSimpleType
3579
        value = find_attr_value_('readingDirection', node)
3580
        if value is not None and 'readingDirection' not in already_processed:
3581
            already_processed.add('readingDirection')
3582
            self.readingDirection = value
3583
            self.validate_ReadingDirectionSimpleType(self.readingDirection)    # validate type ReadingDirectionSimpleType
3584
        value = find_attr_value_('textLineOrder', node)
3585
        if value is not None and 'textLineOrder' not in already_processed:
3586
            already_processed.add('textLineOrder')
3587
            self.textLineOrder = value
3588
            self.validate_TextLineOrderSimpleType(self.textLineOrder)    # validate type TextLineOrderSimpleType
3589
        value = find_attr_value_('conf', node)
3590
        if value is not None and 'conf' not in already_processed:
3591
            already_processed.add('conf')
3592
            value = self.gds_parse_float(value, node, 'conf')
3593
            self.conf = value
3594
            self.validate_ConfSimpleType(self.conf)    # validate type ConfSimpleType
3595
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
3596
        if nodeName_ == 'AlternativeImage':
3597
            obj_ = AlternativeImageType.factory(parent_object_=self)
3598
            obj_.build(child_, gds_collector_=gds_collector_)
3599
            self.AlternativeImage.append(obj_)
3600
            obj_.original_tagname_ = 'AlternativeImage'
3601
        elif nodeName_ == 'Border':
3602
            obj_ = BorderType.factory(parent_object_=self)
3603
            obj_.build(child_, gds_collector_=gds_collector_)
3604
            self.Border = obj_
3605
            obj_.original_tagname_ = 'Border'
3606
        elif nodeName_ == 'PrintSpace':
3607
            obj_ = PrintSpaceType.factory(parent_object_=self)
3608
            obj_.build(child_, gds_collector_=gds_collector_)
3609
            self.PrintSpace = obj_
3610
            obj_.original_tagname_ = 'PrintSpace'
3611
        elif nodeName_ == 'ReadingOrder':
3612
            obj_ = ReadingOrderType.factory(parent_object_=self)
3613
            obj_.build(child_, gds_collector_=gds_collector_)
3614
            self.ReadingOrder = obj_
3615
            obj_.original_tagname_ = 'ReadingOrder'
3616
        elif nodeName_ == 'Layers':
3617
            obj_ = LayersType.factory(parent_object_=self)
3618
            obj_.build(child_, gds_collector_=gds_collector_)
3619
            self.Layers = obj_
3620
            obj_.original_tagname_ = 'Layers'
3621
        elif nodeName_ == 'Relations':
3622
            obj_ = RelationsType.factory(parent_object_=self)
3623
            obj_.build(child_, gds_collector_=gds_collector_)
3624
            self.Relations = obj_
3625
            obj_.original_tagname_ = 'Relations'
3626
        elif nodeName_ == 'TextStyle':
3627
            obj_ = TextStyleType.factory(parent_object_=self)
3628
            obj_.build(child_, gds_collector_=gds_collector_)
3629
            self.TextStyle = obj_
3630
            obj_.original_tagname_ = 'TextStyle'
3631
        elif nodeName_ == 'UserDefined':
3632
            obj_ = UserDefinedType.factory(parent_object_=self)
3633
            obj_.build(child_, gds_collector_=gds_collector_)
3634
            self.UserDefined = obj_
3635
            obj_.original_tagname_ = 'UserDefined'
3636
        elif nodeName_ == 'Labels':
3637
            obj_ = LabelsType.factory(parent_object_=self)
3638
            obj_.build(child_, gds_collector_=gds_collector_)
3639
            self.Labels.append(obj_)
3640
            obj_.original_tagname_ = 'Labels'
3641
        elif nodeName_ == 'TextRegion':
3642
            obj_ = TextRegionType.factory(parent_object_=self)
3643
            obj_.build(child_, gds_collector_=gds_collector_)
3644
            self.TextRegion.append(obj_)
3645
            obj_.original_tagname_ = 'TextRegion'
3646
        elif nodeName_ == 'ImageRegion':
3647
            obj_ = ImageRegionType.factory(parent_object_=self)
3648
            obj_.build(child_, gds_collector_=gds_collector_)
3649
            self.ImageRegion.append(obj_)
3650
            obj_.original_tagname_ = 'ImageRegion'
3651
        elif nodeName_ == 'LineDrawingRegion':
3652
            obj_ = LineDrawingRegionType.factory(parent_object_=self)
3653
            obj_.build(child_, gds_collector_=gds_collector_)
3654
            self.LineDrawingRegion.append(obj_)
3655
            obj_.original_tagname_ = 'LineDrawingRegion'
3656
        elif nodeName_ == 'GraphicRegion':
3657
            obj_ = GraphicRegionType.factory(parent_object_=self)
3658
            obj_.build(child_, gds_collector_=gds_collector_)
3659
            self.GraphicRegion.append(obj_)
3660
            obj_.original_tagname_ = 'GraphicRegion'
3661
        elif nodeName_ == 'TableRegion':
3662
            obj_ = TableRegionType.factory(parent_object_=self)
3663
            obj_.build(child_, gds_collector_=gds_collector_)
3664
            self.TableRegion.append(obj_)
3665
            obj_.original_tagname_ = 'TableRegion'
3666
        elif nodeName_ == 'ChartRegion':
3667
            obj_ = ChartRegionType.factory(parent_object_=self)
3668
            obj_.build(child_, gds_collector_=gds_collector_)
3669
            self.ChartRegion.append(obj_)
3670
            obj_.original_tagname_ = 'ChartRegion'
3671
        elif nodeName_ == 'MapRegion':
3672
            obj_ = MapRegionType.factory(parent_object_=self)
3673
            obj_.build(child_, gds_collector_=gds_collector_)
3674
            self.MapRegion.append(obj_)
3675
            obj_.original_tagname_ = 'MapRegion'
3676
        elif nodeName_ == 'SeparatorRegion':
3677
            obj_ = SeparatorRegionType.factory(parent_object_=self)
3678
            obj_.build(child_, gds_collector_=gds_collector_)
3679
            self.SeparatorRegion.append(obj_)
3680
            obj_.original_tagname_ = 'SeparatorRegion'
3681
        elif nodeName_ == 'MathsRegion':
3682
            obj_ = MathsRegionType.factory(parent_object_=self)
3683
            obj_.build(child_, gds_collector_=gds_collector_)
3684
            self.MathsRegion.append(obj_)
3685
            obj_.original_tagname_ = 'MathsRegion'
3686
        elif nodeName_ == 'ChemRegion':
3687
            obj_ = ChemRegionType.factory(parent_object_=self)
3688
            obj_.build(child_, gds_collector_=gds_collector_)
3689
            self.ChemRegion.append(obj_)
3690
            obj_.original_tagname_ = 'ChemRegion'
3691
        elif nodeName_ == 'MusicRegion':
3692
            obj_ = MusicRegionType.factory(parent_object_=self)
3693
            obj_.build(child_, gds_collector_=gds_collector_)
3694
            self.MusicRegion.append(obj_)
3695
            obj_.original_tagname_ = 'MusicRegion'
3696
        elif nodeName_ == 'AdvertRegion':
3697
            obj_ = AdvertRegionType.factory(parent_object_=self)
3698
            obj_.build(child_, gds_collector_=gds_collector_)
3699
            self.AdvertRegion.append(obj_)
3700
            obj_.original_tagname_ = 'AdvertRegion'
3701
        elif nodeName_ == 'NoiseRegion':
3702
            obj_ = NoiseRegionType.factory(parent_object_=self)
3703
            obj_.build(child_, gds_collector_=gds_collector_)
3704
            self.NoiseRegion.append(obj_)
3705
            obj_.original_tagname_ = 'NoiseRegion'
3706
        elif nodeName_ == 'UnknownRegion':
3707
            obj_ = UnknownRegionType.factory(parent_object_=self)
3708
            obj_.build(child_, gds_collector_=gds_collector_)
3709
            self.UnknownRegion.append(obj_)
3710
            obj_.original_tagname_ = 'UnknownRegion'
3711
        elif nodeName_ == 'CustomRegion':
3712
            obj_ = CustomRegionType.factory(parent_object_=self)
3713
            obj_.build(child_, gds_collector_=gds_collector_)
3714
            self.CustomRegion.append(obj_)
3715
            obj_.original_tagname_ = 'CustomRegion'
3716
    def __hash__(self):
3717
        return hash(self.id)
3718
    @property
3719
    def id(self):
3720
        from ocrd_utils import make_xml_id
3721
        if hasattr(self, 'pcGtsId'):
3722
            return self.pcGtsId or ''
3723
        return make_xml_id(self.imageFilename)
3724
    # pylint: disable=line-too-long,invalid-name,protected-access,missing-module-docstring
3725
    def _region_class(self, x): # pylint: disable=unused-argument
3726
        return x.__class__.__name__.replace('RegionType', '')
3727
    
3728
    def _get_recursive_regions(self, regions, level, classes=None):
3729
        from .constants import PAGE_REGION_TYPES  # pylint: disable=relative-beyond-top-level,import-outside-toplevel
3730
        if level == 1:
3731
            # stop recursion, filter classes
3732
            if classes:
3733
                return [r for r in regions if self._region_class(r) in classes]
3734
            if regions and regions[0].__class__.__name__ == 'PageType':
3735
                regions = regions[1:]
3736
            return regions
3737
        # find more regions recursively
3738
        more_regions = []
3739
        for region in regions:
3740
            more_regions.append([])
3741
            for class_ in PAGE_REGION_TYPES:
3742
                if class_ == 'Map' and not isinstance(region, PageType): # pylint: disable=undefined-variable
3743
                    # 'Map' is not recursive in 2019 schema
3744
                    continue
3745
                more_regions[-1] += getattr(region, 'get_{}Region'.format(class_))()
3746
        if not any(more_regions):
3747
            return self._get_recursive_regions(regions, 1, classes)
3748
        ret = []
3749
        for r, more in zip(regions, more_regions):
3750
            ret.append(r)
3751
            ret += self._get_recursive_regions(more, level - 1 if level else 0, classes)
3752
        return self._get_recursive_regions(ret, 1, classes)
3753
    
3754
    def _get_recursive_reading_order(self, rogroup):
3755
        if isinstance(rogroup, (OrderedGroupType, OrderedGroupIndexedType)): # pylint: disable=undefined-variable
3756
            elements = rogroup.get_AllIndexed()
3757
        if isinstance(rogroup, (UnorderedGroupType, UnorderedGroupIndexedType)): # pylint: disable=undefined-variable
3758
            elements = (rogroup.get_RegionRef() + rogroup.get_OrderedGroup() + rogroup.get_UnorderedGroup())
3759
        regionrefs = list()
3760
        for elem in elements:
3761
            regionrefs.append(elem.get_regionRef())
3762
            if not isinstance(elem, (RegionRefType, RegionRefIndexedType)): # pylint: disable=undefined-variable
3763
                regionrefs.extend(self._get_recursive_reading_order(elem))
3764
        return regionrefs
3765
    
3766
    def get_AllRegions(self, classes=None, order='document', depth=0):
3767
        """
3768
        Get all the ``*Region`` elements, or only those provided by `classes`.
3769
        Return in document order, unless the top element is ``Page`` and
3770
        `order` is ``reading-order``.
3771
    
3772
        Arguments:
3773
            classes (list): Classes of regions that shall be returned, \
3774
                e.g. ``['Text', 'Image']``
3775
            order ("document"|"reading-order"|"reading-order-only"): Whether to \
3776
                return regions sorted by document order (``document``, default) or by
3777
                reading order with regions not in the reading order at the end of the
3778
                returned list (``reading-order``) or regions not in the reading order
3779
                omitted (``reading-order-only``). The latter two are only available
3780
                on page level.
3781
            depth (int): Recursive depth to look for regions at, set to `0` for \
3782
                all regions at any depth. Default: 0
3783
    
3784
        Returns:
3785
            a list of :py:class:`TextRegionType`, :py:class:`ImageRegionType`, \
3786
                :py:class:`LineDrawingRegionType`, :py:class:`GraphicRegionType`, \
3787
                :py:class:`TableRegionType`, :py:class:`ChartRegionType`, \
3788
                :py:class:`MapRegionType`, :py:class:`SeparatorRegionType`, \
3789
                :py:class:`MathsRegionType`, :py:class:`ChemRegionType`, \
3790
                :py:class:`MusicRegionType`, :py:class:`AdvertRegionType`, \
3791
                :py:class:`NoiseRegionType`, :py:class:`UnknownRegionType`, \
3792
                and/or :py:class:`CustomRegionType`
3793
    
3794
        For example, to get all text anywhere on the page in reading order, use:
3795
        ::
3796
            '\\n'.join(line.get_TextEquiv()[0].Unicode
3797
                      for region in page.get_AllRegions(classes=['Text'], depth=0, order='reading-order')
3798
                      for line in region.get_TextLine())
3799
        """
3800
        if order not in ['document', 'reading-order', 'reading-order-only']:
3801
            raise Exception("Argument 'order' must be either 'document', 'reading-order' or 'reading-order-only', not '{}'".format(order))
3802
        if depth < 0:
3803
            raise Exception("Argument 'depth' must be an integer greater-or-equal 0, not '{}'".format(depth))
3804
        ret = self._get_recursive_regions([self], depth + 1 if depth else 0, classes)
3805
        if self.__class__.__name__ == 'PageType' and order.startswith('reading-order'):
3806
            reading_order = self.get_ReadingOrder()
3807
            if reading_order:
3808
                reading_order = reading_order.get_OrderedGroup() or reading_order.get_UnorderedGroup()
3809
            if reading_order:
3810
                reading_order = self._get_recursive_reading_order(reading_order)
3811
            if reading_order:
3812
                id2region = {region.id: region for region in ret}
3813
                in_reading_order = [id2region[region_id] for region_id in reading_order if region_id in id2region]
3814
                #  print("ret: {} / in_ro: {} / not-in-ro: {}".format(
3815
                #      len(ret),
3816
                #      len([id2region[region_id] for region_id in reading_order if region_id in id2region]),
3817
                #      len([r for r in ret if r not in in_reading_order])
3818
                #      ))
3819
                if order == 'reading-order-only':
3820
                    ret = in_reading_order
3821
                else:
3822
                    ret = in_reading_order + [r for r in ret if r not in in_reading_order]
3823
        return ret
3824 View Code Duplication
    def get_AllAlternativeImages(self, page=True, region=True, line=True, word=True, glyph=True):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
3825
        """
3826
        Get all the ``pc:AlternativeImage`` in a document
3827
    
3828
        Arguments:
3829
            page (boolean): Get images on ``pc:Page`` level
3830
            region (boolean): Get images on ``pc:*Region`` level
3831
            line (boolean): Get images on ``pc:TextLine`` level
3832
            word (boolean): Get images on ``pc:Word`` level
3833
            glyph (boolean): Get images on ``pc:Glyph`` level
3834
    
3835
        Returns:
3836
            a list of :py:class:`AlternativeImageType`
3837
        """
3838
        ret = []
3839
        if page:
3840
            ret += self.get_AlternativeImage()
3841
        for this_region in self.get_AllRegions(['Text']):
3842
            if region:
3843
                ret += this_region.get_AlternativeImage()
3844
            for this_line in this_region.get_TextLine():
3845
                if line:
3846
                    ret += this_line.get_AlternativeImage()
3847
                for this_word in this_line.get_Word():
3848
                    if word:
3849
                        ret += this_word.get_AlternativeImage()
3850
                    for this_glyph in this_word.get_Glyph():
3851
                        if glyph:
3852
                            ret += this_glyph.get_AlternativeImage()
3853
        return ret
3854
    
3855 View Code Duplication
    def invalidate_AlternativeImage(self, feature_selector=None):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
3856
        """
3857
        Remove derived images from this segment (due to changed coordinates).
3858
    
3859
        If `feature_selector` is not none, remove only images with
3860
        matching ``@comments``, e.g. ``feature_selector=cropped,deskewed``.
3861
        """
3862
        existing_images = self.AlternativeImage or []
3863
        removed_images = []
3864
        if feature_selector:
3865
            new_images = []
3866
            for image in existing_images:
3867
                features = image.get_comments() or ''
3868
                if any(feature in features.split(',')
3869
                       for feature in feature_selector.split(',') if feature):
3870
                    removed_images.append(image)
3871
                else:
3872
                    new_images.append(image)
3873
            self.AlternativeImage = new_images
3874
        else:
3875
            removed_images = existing_images
3876
            self.AlternativeImage = []
3877
        if hasattr(self, 'id'):
3878
            name = self.id
3879
        elif hasattr(self, 'parent_object_') and hasattr(self.parent_object_, 'pcGtsId'):
3880
            name = self.parent_object_.pcGtsId
3881
        else:
3882
            name = ''
3883
        for image in removed_images:
3884
            self.gds_collector_.add_message('Removing AlternativeImage %s from "%s"' % (
3885
                image.get_comments() or '', name))
3886
    def set_Border(self, Border):
3887
        """
3888
        Set coordinate polygon by given :py:class:`BorderType` object.
3889
        Moreover, invalidate self's ``pc:AlternativeImage``s
3890
        (because they will have been cropped with a bbox
3891
        of the previous polygon).
3892
        """
3893
        self.invalidate_AlternativeImage(feature_selector='cropped')
3894
        self.Border = Border
3895 View Code Duplication
    def get_AllTextLines(self, region_order='document', respect_textline_order=True):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
3896
        """
3897
        Return all the TextLine in the document
3898
    
3899
        Arguments:
3900
            region_order ("document"|"reading-order"|"reading-order-only"): Whether to \
3901
                return regions sorted by document order (``document``, default) or by \
3902
                reading order with regions not in the reading order at the end of the \
3903
                returned list (``reading-order``) or regions not in the reading order \
3904
                omitted (``reading-order-only``)
3905
            respect_textline_order (boolean): Whether to respect `@textLineOrder` attribute
3906
    
3907
        Returns:
3908
            a list of :py:class:`TextLineType`
3909
        """
3910
        # TODO handle textLineOrder according to https://github.com/PRImA-Research-Lab/PAGE-XML/issues/26
3911
        ret = []
3912
        for reg in self.get_AllRegions(['Text'], order=region_order):
3913
            lines = reg.get_TextLine()
3914
            if not respect_textline_order:
3915
                ret += lines
3916
            else:
3917
                lo = reg.get_textLineOrder() or self.get_textLineOrder() or 'top-to-bottom'
3918
                ret += lines if lo in ['top-to-bottom', 'left-to-right'] else list(reversed(lines))
3919
        return ret
3920
    
3921 View Code Duplication
    def get_ReadingOrderGroups(self) -> dict:
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
3922
        """
3923
        Aggregate recursive ReadingOrder into a dictionary, mapping each regionRef
3924
        (i.e. segment `@id`) to its referring group object (i.e one of
3925
    
3926
        \b
3927
        - :py:class:`.RegionRefType`
3928
        - :py:class:`.RegionRefIndexedType`
3929
        - :py:class:`.OrderedGroupType`
3930
        - :py:class:`.OrderedGroupIndexedType`
3931
        - :py:class:`.UnoderedGroupType`
3932
        - :py:class:`.UnoderedGroupIndexedType`
3933
        """
3934
        from collections import OrderedDict as odict
3935
        def get_groupdict(group):
3936
            regionrefs = list()
3937
            if isinstance(group, (OrderedGroupType, OrderedGroupIndexedType)):
3938
                regionrefs = (group.get_RegionRefIndexed() +
3939
                              group.get_OrderedGroupIndexed() +
3940
                              group.get_UnorderedGroupIndexed())
3941
                regionrefs = sorted(regionrefs, key=lambda x: x.index)
3942
            if isinstance(group, (UnorderedGroupType, UnorderedGroupIndexedType)):
3943
                regionrefs = (group.get_RegionRef() +
3944
                              group.get_OrderedGroup() +
3945
                              group.get_UnorderedGroup())
3946
            refdict = odict()
3947
            for elem in regionrefs:
3948
                refdict[elem.get_regionRef()] = elem
3949
                if not isinstance(elem, (RegionRefType, RegionRefIndexedType)):
3950
                    refdict = odict(**refdict, **get_groupdict(elem))
3951
            return refdict
3952
        ro = self.get_ReadingOrder()
3953
        if ro is None:
3954
            return {}
3955
        return get_groupdict(ro.get_OrderedGroup() or ro.get_UnorderedGroup())
3956
    def set_orientation(self, orientation):
3957
        """
3958
        Set deskewing angle to given `orientation` number.
3959
        Moreover, invalidate self's ``pc:AlternativeImage``s
3960
        (because they will have been rotated and enlarged
3961
        with the angle of the previous value).
3962
        """
3963
        if hasattr(self, 'invalidate_AlternativeImage'):
3964
            # PageType, RegionType:
3965
            self.invalidate_AlternativeImage(feature_selector='deskewed')
3966
        self.orientation = orientation
3967
# end class PageType
3968
3969
3970
class CoordsType(GeneratedsSuper):
3971
    """points --
3972
    Polygon outline of the element as a path of points.
3973
    No points may lie outside the outline of its parent,
3974
    which in the case of Border is the bounding rectangle
3975
    of the root image. Paths are closed by convention,
3976
    i.e. the last point logically connects with the first
3977
    (and at least 3 points are required to span an area).
3978
    Paths must be planar (i.e. must not self-intersect).
3979
      
3980
    * conf -- Confidence value (between 0 and 1)
3981
    
3982
    """
3983
    __hash__ = GeneratedsSuper.__hash__
3984
    member_data_items_ = [
3985
        MemberSpec_('points', 'pc:PointsType', 0, 0, {'use': 'required', 'name': 'points'}),
3986
        MemberSpec_('conf', 'pc:ConfSimpleType', 0, 1, {'use': 'optional', 'name': 'conf'}),
3987
    ]
3988
    subclass = None
3989
    superclass = None
3990 View Code Duplication
    def __init__(self, points=None, conf=None, gds_collector_=None, **kwargs_):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
3991
        self.gds_collector_ = gds_collector_
3992
        self.gds_elementtree_node_ = None
3993
        self.original_tagname_ = None
3994
        self.parent_object_ = kwargs_.get('parent_object_')
3995
        self.ns_prefix_ = "pc"
3996
        self.points = _cast(None, points)
3997
        self.points_nsprefix_ = "pc"
3998
        self.conf = _cast(float, conf)
3999
        self.conf_nsprefix_ = "pc"
4000
    def factory(*args_, **kwargs_):
4001
        if CurrentSubclassModule_ is not None:
4002
            subclass = getSubclassFromModule_(
4003
                CurrentSubclassModule_, CoordsType)
4004
            if subclass is not None:
4005
                return subclass(*args_, **kwargs_)
4006
        if CoordsType.subclass:
4007
            return CoordsType.subclass(*args_, **kwargs_)
4008
        else:
4009
            return CoordsType(*args_, **kwargs_)
4010
    factory = staticmethod(factory)
4011
    def get_ns_prefix_(self):
4012
        return self.ns_prefix_
4013
    def set_ns_prefix_(self, ns_prefix):
4014
        self.ns_prefix_ = ns_prefix
4015
    def get_points(self):
4016
        return self.points
4017
    def set_points(self, points):
4018
        self.points = points
4019
    def get_conf(self):
4020
        return self.conf
4021
    def set_conf(self, conf):
4022
        self.conf = conf
4023 View Code Duplication
    def validate_PointsType(self, value):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
4024
        # Validate type pc:PointsType, a restriction on string.
4025
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
4026
            if not isinstance(value, str):
4027
                lineno = self.gds_get_node_lineno_()
4028
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
4029
                return False
4030
            if not self.gds_validate_simple_patterns(
4031
                    self.validate_PointsType_patterns_, value):
4032
                self.gds_collector_.add_message('Value "%s" does not match xsd pattern restrictions: %s' % (encode_str_2_3(value), self.validate_PointsType_patterns_, ))
4033
    validate_PointsType_patterns_ = [['^(([0-9]+,[0-9]+ )+([0-9]+,[0-9]+))$']]
4034 View Code Duplication
    def validate_ConfSimpleType(self, value):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
4035
        # Validate type pc:ConfSimpleType, a restriction on float.
4036
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
4037
            if not isinstance(value, float):
4038
                lineno = self.gds_get_node_lineno_()
4039
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (float)' % {"value": value, "lineno": lineno, })
4040
                return False
4041
            if value < 0:
4042
                lineno = self.gds_get_node_lineno_()
4043
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd minInclusive restriction on ConfSimpleType' % {"value": value, "lineno": lineno} )
4044
                result = False
4045
            if value > 1:
4046
                lineno = self.gds_get_node_lineno_()
4047
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxInclusive restriction on ConfSimpleType' % {"value": value, "lineno": lineno} )
4048
                result = False
4049
    def has__content(self):
4050
        if (
4051
4052
        ):
4053
            return True
4054
        else:
4055
            return False
4056
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='CoordsType', pretty_print=True):
4057
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('CoordsType')
4058
        if imported_ns_def_ is not None:
4059
            namespacedef_ = imported_ns_def_
4060
        if pretty_print:
4061
            eol_ = '\n'
4062
        else:
4063
            eol_ = ''
4064
        if self.original_tagname_ is not None and name_ == 'CoordsType':
4065
            name_ = self.original_tagname_
4066
        if UseCapturedNS_ and self.ns_prefix_:
4067
            namespaceprefix_ = self.ns_prefix_ + ':'
4068
        showIndent(outfile, level, pretty_print)
4069
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
4070
        already_processed = set()
4071
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='CoordsType')
4072
        if self.has__content():
4073
            outfile.write('>%s' % (eol_, ))
4074
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='CoordsType', pretty_print=pretty_print)
4075
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
4076
        else:
4077
            outfile.write('/>%s' % (eol_, ))
4078
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='CoordsType'):
4079
        if self.points is not None and 'points' not in already_processed:
4080
            already_processed.add('points')
4081
            outfile.write(' points=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.points), input_name='points')), ))
4082
        if self.conf is not None and 'conf' not in already_processed:
4083
            already_processed.add('conf')
4084
            outfile.write(' conf="%s"' % self.gds_format_float(self.conf, input_name='conf'))
4085
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='CoordsType', fromsubclass_=False, pretty_print=True):
4086
        pass
4087 View Code Duplication
    def to_etree(self, parent_element=None, name_='CoordsType', mapping_=None, reverse_mapping_=None, nsmap_=None):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
4088
        if parent_element is None:
4089
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
4090
        else:
4091
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
4092
        if self.points is not None:
4093
            element.set('points', self.gds_format_string(self.points))
4094
        if self.conf is not None:
4095
            element.set('conf', self.gds_format_float(self.conf))
4096
        if mapping_ is not None:
4097
            mapping_[id(self)] = element
4098
        if reverse_mapping_ is not None:
4099
            reverse_mapping_[element] = self
4100
        return element
4101
    def build(self, node, gds_collector_=None):
4102
        self.gds_collector_ = gds_collector_
4103
        if SaveElementTreeNode:
4104
            self.gds_elementtree_node_ = node
4105
        already_processed = set()
4106
        self.ns_prefix_ = node.prefix
4107
        self._buildAttributes(node, node.attrib, already_processed)
4108
        for child in node:
4109
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
4110
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
4111
        return self
4112 View Code Duplication
    def _buildAttributes(self, node, attrs, already_processed):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
4113
        value = find_attr_value_('points', node)
4114
        if value is not None and 'points' not in already_processed:
4115
            already_processed.add('points')
4116
            self.points = value
4117
            self.validate_PointsType(self.points)    # validate type PointsType
4118
        value = find_attr_value_('conf', node)
4119
        if value is not None and 'conf' not in already_processed:
4120
            already_processed.add('conf')
4121
            value = self.gds_parse_float(value, node, 'conf')
4122
            self.conf = value
4123
            self.validate_ConfSimpleType(self.conf)    # validate type ConfSimpleType
4124
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
4125
        pass
4126
    def __hash__(self):
4127
        return hash(self.id)
4128 View Code Duplication
    def set_points(self, points):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
4129
        """
4130
        Set coordinate polygon by given string.
4131
        Moreover, invalidate the parent's ``pc:AlternativeImage``s
4132
        (because they will have been cropped with a bbox
4133
        of the previous polygon).
4134
        """
4135
        if hasattr(self, 'parent_object_'):
4136
            parent = self.parent_object_
4137
            if hasattr(parent, 'invalidate_AlternativeImage'):
4138
                # RegionType, TextLineType, WordType, GlyphType:
4139
                parent.invalidate_AlternativeImage()
4140
            elif hasattr(parent, 'parent_object_') and hasattr(parent.parent_object_, 'invalidate_AlternativeImage'):
4141
                # BorderType:
4142
                parent.parent_object_.invalidate_AlternativeImage(feature_selector='cropped')
4143
        self.points = points
4144
# end class CoordsType
4145
4146
4147
class TextLineType(GeneratedsSuper):
4148
    """primaryLanguage --
4149
    Overrides primaryLanguage attribute of parent text
4150
    region
4151
      
4152
    * primaryScript --
4153
      The primary script used in the text line
4154
      
4155
    * secondaryScript --
4156
      The secondary script used in the text line
4157
      
4158
    * readingDirection --
4159
      The direction in which text within the line
4160
      should be read (order of words and characters).
4161
      
4162
    * production --
4163
      Overrides the production attribute of the parent
4164
      text region
4165
      
4166
    * custom -- For generic use
4167
    * index --
4168
      Position (order number) of this text line within the
4169
      parent text region.
4170
      
4171
    * AlternativeImage --
4172
      Alternative text line images (e.g.
4173
      black-and-white)
4174
      
4175
    * Baseline --
4176
      Multiple connected points that mark the baseline
4177
      of the glyphs
4178
      
4179
    * Labels -- Semantic labels / tags
4180
    
4181
    """
4182
    __hash__ = GeneratedsSuper.__hash__
4183
    member_data_items_ = [
4184
        MemberSpec_('id', 'string', 0, 0, {'use': 'required', 'name': 'id'}),
4185
        MemberSpec_('primaryLanguage', 'pc:LanguageSimpleType', 0, 1, {'use': 'optional', 'name': 'primaryLanguage'}),
4186
        MemberSpec_('primaryScript', 'pc:ScriptSimpleType', 0, 1, {'use': 'optional', 'name': 'primaryScript'}),
4187
        MemberSpec_('secondaryScript', 'pc:ScriptSimpleType', 0, 1, {'use': 'optional', 'name': 'secondaryScript'}),
4188
        MemberSpec_('readingDirection', 'pc:ReadingDirectionSimpleType', 0, 1, {'use': 'optional', 'name': 'readingDirection'}),
4189
        MemberSpec_('production', 'pc:ProductionSimpleType', 0, 1, {'use': 'optional', 'name': 'production'}),
4190
        MemberSpec_('custom', 'string', 0, 1, {'use': 'optional', 'name': 'custom'}),
4191
        MemberSpec_('comments', 'string', 0, 1, {'use': 'optional', 'name': 'comments'}),
4192
        MemberSpec_('index', 'int', 0, 1, {'use': 'optional', 'name': 'index'}),
4193
        MemberSpec_('AlternativeImage', 'AlternativeImageType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'AlternativeImage', 'type': 'AlternativeImageType'}, None),
4194
        MemberSpec_('Coords', 'CoordsType', 0, 0, {'name': 'Coords', 'type': 'CoordsType'}, None),
4195
        MemberSpec_('Baseline', 'BaselineType', 0, 1, {'minOccurs': '0', 'name': 'Baseline', 'type': 'BaselineType'}, None),
4196
        MemberSpec_('Word', 'WordType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Word', 'type': 'WordType'}, None),
4197
        MemberSpec_('TextEquiv', 'TextEquivType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'TextEquiv', 'type': 'TextEquivType'}, None),
4198
        MemberSpec_('TextStyle', 'TextStyleType', 0, 1, {'minOccurs': '0', 'name': 'TextStyle', 'type': 'TextStyleType'}, None),
4199
        MemberSpec_('UserDefined', 'UserDefinedType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'UserDefined', 'type': 'UserDefinedType'}, None),
4200
        MemberSpec_('Labels', 'LabelsType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Labels', 'type': 'LabelsType'}, None),
4201
    ]
4202
    subclass = None
4203
    superclass = None
4204
    def __init__(self, id=None, primaryLanguage=None, primaryScript=None, secondaryScript=None, readingDirection=None, production=None, custom=None, comments=None, index=None, AlternativeImage=None, Coords=None, Baseline=None, Word=None, TextEquiv=None, TextStyle=None, UserDefined=None, Labels=None, gds_collector_=None, **kwargs_):
4205
        self.gds_collector_ = gds_collector_
4206
        self.gds_elementtree_node_ = None
4207
        self.original_tagname_ = None
4208
        self.parent_object_ = kwargs_.get('parent_object_')
4209
        self.ns_prefix_ = "pc"
4210
        self.id = _cast(None, id)
4211
        self.id_nsprefix_ = "pc"
4212
        self.primaryLanguage = _cast(None, primaryLanguage)
4213
        self.primaryLanguage_nsprefix_ = "pc"
4214
        self.primaryScript = _cast(None, primaryScript)
4215
        self.primaryScript_nsprefix_ = "pc"
4216
        self.secondaryScript = _cast(None, secondaryScript)
4217
        self.secondaryScript_nsprefix_ = "pc"
4218
        self.readingDirection = _cast(None, readingDirection)
4219
        self.readingDirection_nsprefix_ = "pc"
4220
        self.production = _cast(None, production)
4221
        self.production_nsprefix_ = "pc"
4222
        self.custom = _cast(None, custom)
4223
        self.custom_nsprefix_ = "pc"
4224
        self.comments = _cast(None, comments)
4225
        self.comments_nsprefix_ = "pc"
4226
        self.index = _cast(int, index)
4227
        self.index_nsprefix_ = "pc"
4228
        if AlternativeImage is None:
4229
            self.AlternativeImage = []
4230
        else:
4231
            self.AlternativeImage = AlternativeImage
4232
        self.AlternativeImage_nsprefix_ = "pc"
4233
        self.Coords = Coords
4234
        self.Coords_nsprefix_ = "pc"
4235
        self.Baseline = Baseline
4236
        self.Baseline_nsprefix_ = "pc"
4237
        if Word is None:
4238
            self.Word = []
4239
        else:
4240
            self.Word = Word
4241
        self.Word_nsprefix_ = "pc"
4242
        if TextEquiv is None:
4243
            self.TextEquiv = []
4244
        else:
4245
            self.TextEquiv = TextEquiv
4246
        self.TextEquiv_nsprefix_ = "pc"
4247
        self.TextStyle = TextStyle
4248
        self.TextStyle_nsprefix_ = "pc"
4249
        self.UserDefined = UserDefined
4250
        self.UserDefined_nsprefix_ = "pc"
4251
        if Labels is None:
4252
            self.Labels = []
4253
        else:
4254
            self.Labels = Labels
4255
        self.Labels_nsprefix_ = "pc"
4256
    def factory(*args_, **kwargs_):
4257
        if CurrentSubclassModule_ is not None:
4258
            subclass = getSubclassFromModule_(
4259
                CurrentSubclassModule_, TextLineType)
4260
            if subclass is not None:
4261
                return subclass(*args_, **kwargs_)
4262
        if TextLineType.subclass:
4263
            return TextLineType.subclass(*args_, **kwargs_)
4264
        else:
4265
            return TextLineType(*args_, **kwargs_)
4266
    factory = staticmethod(factory)
4267
    def get_ns_prefix_(self):
4268
        return self.ns_prefix_
4269
    def set_ns_prefix_(self, ns_prefix):
4270
        self.ns_prefix_ = ns_prefix
4271
    def get_AlternativeImage(self):
4272
        return self.AlternativeImage
4273
    def set_AlternativeImage(self, AlternativeImage):
4274
        self.AlternativeImage = AlternativeImage
4275
    def add_AlternativeImage(self, value):
4276
        self.AlternativeImage.append(value)
4277
    def insert_AlternativeImage_at(self, index, value):
4278
        self.AlternativeImage.insert(index, value)
4279
    def replace_AlternativeImage_at(self, index, value):
4280
        self.AlternativeImage[index] = value
4281
    def get_Coords(self):
4282
        return self.Coords
4283
    def set_Coords(self, Coords):
4284
        self.Coords = Coords
4285
    def get_Baseline(self):
4286
        return self.Baseline
4287
    def set_Baseline(self, Baseline):
4288
        self.Baseline = Baseline
4289
    def get_Word(self):
4290
        return self.Word
4291
    def set_Word(self, Word):
4292
        self.Word = Word
4293
    def add_Word(self, value):
4294
        self.Word.append(value)
4295
    def insert_Word_at(self, index, value):
4296
        self.Word.insert(index, value)
4297
    def replace_Word_at(self, index, value):
4298
        self.Word[index] = value
4299
    def get_TextEquiv(self):
4300
        return self.TextEquiv
4301
    def set_TextEquiv(self, TextEquiv):
4302
        self.TextEquiv = TextEquiv
4303
    def add_TextEquiv(self, value):
4304
        self.TextEquiv.append(value)
4305
    def insert_TextEquiv_at(self, index, value):
4306
        self.TextEquiv.insert(index, value)
4307
    def replace_TextEquiv_at(self, index, value):
4308
        self.TextEquiv[index] = value
4309
    def get_TextStyle(self):
4310
        return self.TextStyle
4311
    def set_TextStyle(self, TextStyle):
4312
        self.TextStyle = TextStyle
4313
    def get_UserDefined(self):
4314
        return self.UserDefined
4315
    def set_UserDefined(self, UserDefined):
4316
        self.UserDefined = UserDefined
4317
    def get_Labels(self):
4318
        return self.Labels
4319
    def set_Labels(self, Labels):
4320
        self.Labels = Labels
4321
    def add_Labels(self, value):
4322
        self.Labels.append(value)
4323
    def insert_Labels_at(self, index, value):
4324
        self.Labels.insert(index, value)
4325
    def replace_Labels_at(self, index, value):
4326
        self.Labels[index] = value
4327
    def get_id(self):
4328
        return self.id
4329
    def set_id(self, id):
4330
        self.id = id
4331
    def get_primaryLanguage(self):
4332
        return self.primaryLanguage
4333
    def set_primaryLanguage(self, primaryLanguage):
4334
        self.primaryLanguage = primaryLanguage
4335
    def get_primaryScript(self):
4336
        return self.primaryScript
4337
    def set_primaryScript(self, primaryScript):
4338
        self.primaryScript = primaryScript
4339
    def get_secondaryScript(self):
4340
        return self.secondaryScript
4341
    def set_secondaryScript(self, secondaryScript):
4342
        self.secondaryScript = secondaryScript
4343
    def get_readingDirection(self):
4344
        return self.readingDirection
4345
    def set_readingDirection(self, readingDirection):
4346
        self.readingDirection = readingDirection
4347
    def get_production(self):
4348
        return self.production
4349
    def set_production(self, production):
4350
        self.production = production
4351
    def get_custom(self):
4352
        return self.custom
4353
    def set_custom(self, custom):
4354
        self.custom = custom
4355
    def get_comments(self):
4356
        return self.comments
4357
    def set_comments(self, comments):
4358
        self.comments = comments
4359
    def get_index(self):
4360
        return self.index
4361
    def set_index(self, index):
4362
        self.index = index
4363
    def validate_LanguageSimpleType(self, value):
4364
        # Validate type pc:LanguageSimpleType, a restriction on string.
4365
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
4366
            if not isinstance(value, str):
4367
                lineno = self.gds_get_node_lineno_()
4368
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
4369
                return False
4370
            value = value
4371
            enumerations = ['Abkhaz', 'Afar', 'Afrikaans', 'Akan', 'Albanian', 'Amharic', 'Arabic', 'Aragonese', 'Armenian', 'Assamese', 'Avaric', 'Avestan', 'Aymara', 'Azerbaijani', 'Bambara', 'Bashkir', 'Basque', 'Belarusian', 'Bengali', 'Bihari', 'Bislama', 'Bosnian', 'Breton', 'Bulgarian', 'Burmese', 'Cambodian', 'Cantonese', 'Catalan', 'Chamorro', 'Chechen', 'Chichewa', 'Chinese', 'Chuvash', 'Cornish', 'Corsican', 'Cree', 'Croatian', 'Czech', 'Danish', 'Divehi', 'Dutch', 'Dzongkha', 'English', 'Esperanto', 'Estonian', 'Ewe', 'Faroese', 'Fijian', 'Finnish', 'French', 'Fula', 'Gaelic', 'Galician', 'Ganda', 'Georgian', 'German', 'Greek', 'Guaraní', 'Gujarati', 'Haitian', 'Hausa', 'Hebrew', 'Herero', 'Hindi', 'Hiri Motu', 'Hungarian', 'Icelandic', 'Ido', 'Igbo', 'Indonesian', 'Interlingua', 'Interlingue', 'Inuktitut', 'Inupiaq', 'Irish', 'Italian', 'Japanese', 'Javanese', 'Kalaallisut', 'Kannada', 'Kanuri', 'Kashmiri', 'Kazakh', 'Khmer', 'Kikuyu', 'Kinyarwanda', 'Kirundi', 'Komi', 'Kongo', 'Korean', 'Kurdish', 'Kwanyama', 'Kyrgyz', 'Lao', 'Latin', 'Latvian', 'Limburgish', 'Lingala', 'Lithuanian', 'Luba-Katanga', 'Luxembourgish', 'Macedonian', 'Malagasy', 'Malay', 'Malayalam', 'Maltese', 'Manx', 'Māori', 'Marathi', 'Marshallese', 'Mongolian', 'Nauru', 'Navajo', 'Ndonga', 'Nepali', 'North Ndebele', 'Northern Sami', 'Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk', 'Nuosu', 'Occitan', 'Ojibwe', 'Old Church Slavonic', 'Oriya', 'Oromo', 'Ossetian', 'Pāli', 'Panjabi', 'Pashto', 'Persian', 'Polish', 'Portuguese', 'Punjabi', 'Quechua', 'Romanian', 'Romansh', 'Russian', 'Samoan', 'Sango', 'Sanskrit', 'Sardinian', 'Serbian', 'Shona', 'Sindhi', 'Sinhala', 'Slovak', 'Slovene', 'Somali', 'South Ndebele', 'Southern Sotho', 'Spanish', 'Sundanese', 'Swahili', 'Swati', 'Swedish', 'Tagalog', 'Tahitian', 'Tajik', 'Tamil', 'Tatar', 'Telugu', 'Thai', 'Tibetan', 'Tigrinya', 'Tonga', 'Tsonga', 'Tswana', 'Turkish', 'Turkmen', 'Twi', 'Uighur', 'Ukrainian', 'Urdu', 'Uzbek', 'Venda', 'Vietnamese', 'Volapük', 'Walloon', 'Welsh', 'Western Frisian', 'Wolof', 'Xhosa', 'Yiddish', 'Yoruba', 'Zhuang', 'Zulu', 'other']
4372
            if value not in enumerations:
4373
                lineno = self.gds_get_node_lineno_()
4374
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on LanguageSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
4375
                result = False
4376
    def validate_ScriptSimpleType(self, value):
4377
        # Validate type pc:ScriptSimpleType, a restriction on string.
4378
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
4379
            if not isinstance(value, str):
4380
                lineno = self.gds_get_node_lineno_()
4381
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
4382
                return False
4383
            value = value
4384
            enumerations = ['Adlm - Adlam', 'Afak - Afaka', 'Aghb - Caucasian Albanian', 'Ahom - Ahom, Tai Ahom', 'Arab - Arabic', 'Aran - Arabic (Nastaliq variant)', 'Armi - Imperial Aramaic', 'Armn - Armenian', 'Avst - Avestan', 'Bali - Balinese', 'Bamu - Bamum', 'Bass - Bassa Vah', 'Batk - Batak', 'Beng - Bengali', 'Bhks - Bhaiksuki', 'Blis - Blissymbols', 'Bopo - Bopomofo', 'Brah - Brahmi', 'Brai - Braille', 'Bugi - Buginese', 'Buhd - Buhid', 'Cakm - Chakma', 'Cans - Unified Canadian Aboriginal Syllabics', 'Cari - Carian', 'Cham - Cham', 'Cher - Cherokee', 'Cirt - Cirth', 'Copt - Coptic', 'Cprt - Cypriot', 'Cyrl - Cyrillic', 'Cyrs - Cyrillic (Old Church Slavonic variant)', 'Deva - Devanagari (Nagari)', 'Dsrt - Deseret (Mormon)', 'Dupl - Duployan shorthand, Duployan stenography', 'Egyd - Egyptian demotic', 'Egyh - Egyptian hieratic', 'Egyp - Egyptian hieroglyphs', 'Elba - Elbasan', 'Ethi - Ethiopic', 'Geok - Khutsuri (Asomtavruli and Nuskhuri)', 'Geor - Georgian (Mkhedruli)', 'Glag - Glagolitic', 'Goth - Gothic', 'Gran - Grantha', 'Grek - Greek', 'Gujr - Gujarati', 'Guru - Gurmukhi', 'Hanb - Han with Bopomofo', 'Hang - Hangul', 'Hani - Han (Hanzi, Kanji, Hanja)', 'Hano - Hanunoo (Hanunóo)', 'Hans - Han (Simplified variant)', 'Hant - Han (Traditional variant)', 'Hatr - Hatran', 'Hebr - Hebrew', 'Hira - Hiragana', 'Hluw - Anatolian Hieroglyphs', 'Hmng - Pahawh Hmong', 'Hrkt - Japanese syllabaries', 'Hung - Old Hungarian (Hungarian Runic)', 'Inds - Indus (Harappan)', 'Ital - Old Italic (Etruscan, Oscan etc.)', 'Jamo - Jamo', 'Java - Javanese', 'Jpan - Japanese', 'Jurc - Jurchen', 'Kali - Kayah Li', 'Kana - Katakana', 'Khar - Kharoshthi', 'Khmr - Khmer', 'Khoj - Khojki', 'Kitl - Khitan large script', 'Kits - Khitan small script', 'Knda - Kannada', 'Kore - Korean (alias for Hangul + Han)', 'Kpel - Kpelle', 'Kthi - Kaithi', 'Lana - Tai Tham (Lanna)', 'Laoo - Lao', 'Latf - Latin (Fraktur variant)', 'Latg - Latin (Gaelic variant)', 'Latn - Latin', 'Leke - Leke', 'Lepc - Lepcha (Róng)', 'Limb - Limbu', 'Lina - Linear A', 'Linb - Linear B', 'Lisu - Lisu (Fraser)', 'Loma - Loma', 'Lyci - Lycian', 'Lydi - Lydian', 'Mahj - Mahajani', 'Mand - Mandaic, Mandaean', 'Mani - Manichaean', 'Marc - Marchen', 'Maya - Mayan hieroglyphs', 'Mend - Mende Kikakui', 'Merc - Meroitic Cursive', 'Mero - Meroitic Hieroglyphs', 'Mlym - Malayalam', 'Modi - Modi, Moḍī', 'Mong - Mongolian', 'Moon - Moon (Moon code, Moon script, Moon type)', 'Mroo - Mro, Mru', 'Mtei - Meitei Mayek (Meithei, Meetei)', 'Mult - Multani', 'Mymr - Myanmar (Burmese)', 'Narb - Old North Arabian (Ancient North Arabian)', 'Nbat - Nabataean', 'Newa - Newa, Newar, Newari', 'Nkgb - Nakhi Geba', 'Nkoo - N’Ko', 'Nshu - Nüshu', 'Ogam - Ogham', 'Olck - Ol Chiki (Ol Cemet’, Ol, Santali)', 'Orkh - Old Turkic, Orkhon Runic', 'Orya - Oriya', 'Osge - Osage', 'Osma - Osmanya', 'Palm - Palmyrene', 'Pauc - Pau Cin Hau', 'Perm - Old Permic', 'Phag - Phags-pa', 'Phli - Inscriptional Pahlavi', 'Phlp - Psalter Pahlavi', 'Phlv - Book Pahlavi', 'Phnx - Phoenician', 'Piqd - Klingon (KLI pIqaD)', 'Plrd - Miao (Pollard)', 'Prti - Inscriptional Parthian', 'Rjng - Rejang (Redjang, Kaganga)', 'Roro - Rongorongo', 'Runr - Runic', 'Samr - Samaritan', 'Sara - Sarati', 'Sarb - Old South Arabian', 'Saur - Saurashtra', 'Sgnw - SignWriting', 'Shaw - Shavian (Shaw)', 'Shrd - Sharada, Śāradā', 'Sidd - Siddham', 'Sind - Khudawadi, Sindhi', 'Sinh - Sinhala', 'Sora - Sora Sompeng', 'Sund - Sundanese', 'Sylo - Syloti Nagri', 'Syrc - Syriac', 'Syre - Syriac (Estrangelo variant)', 'Syrj - Syriac (Western variant)', 'Syrn - Syriac (Eastern variant)', 'Tagb - Tagbanwa', 'Takr - Takri', 'Tale - Tai Le', 'Talu - New Tai Lue', 'Taml - Tamil', 'Tang - Tangut', 'Tavt - Tai Viet', 'Telu - Telugu', 'Teng - Tengwar', 'Tfng - Tifinagh (Berber)', 'Tglg - Tagalog (Baybayin, Alibata)', 'Thaa - Thaana', 'Thai - Thai', 'Tibt - Tibetan', 'Tirh - Tirhuta', 'Ugar - Ugaritic', 'Vaii - Vai', 'Visp - Visible Speech', 'Wara - Warang Citi (Varang Kshiti)', 'Wole - Woleai', 'Xpeo - Old Persian', 'Xsux - Cuneiform, Sumero-Akkadian', 'Yiii - Yi', 'Zinh - Code for inherited script', 'Zmth - Mathematical notation', 'Zsye - Symbols (Emoji variant)', 'Zsym - Symbols', 'Zxxx - Code for unwritten documents', 'Zyyy - Code for undetermined script', 'Zzzz - Code for uncoded script', 'other']
4385
            if value not in enumerations:
4386
                lineno = self.gds_get_node_lineno_()
4387
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ScriptSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
4388
                result = False
4389
    def validate_ReadingDirectionSimpleType(self, value):
4390
        # Validate type pc:ReadingDirectionSimpleType, a restriction on string.
4391
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
4392
            if not isinstance(value, str):
4393
                lineno = self.gds_get_node_lineno_()
4394
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
4395
                return False
4396
            value = value
4397
            enumerations = ['left-to-right', 'right-to-left', 'top-to-bottom', 'bottom-to-top']
4398
            if value not in enumerations:
4399
                lineno = self.gds_get_node_lineno_()
4400
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ReadingDirectionSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
4401
                result = False
4402
    def validate_ProductionSimpleType(self, value):
4403
        # Validate type pc:ProductionSimpleType, a restriction on string.
4404
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
4405
            if not isinstance(value, str):
4406
                lineno = self.gds_get_node_lineno_()
4407
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
4408
                return False
4409
            value = value
4410
            enumerations = ['printed', 'typewritten', 'handwritten-cursive', 'handwritten-printscript', 'medieval-manuscript', 'other']
4411
            if value not in enumerations:
4412
                lineno = self.gds_get_node_lineno_()
4413
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ProductionSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
4414
                result = False
4415
    def has__content(self):
4416
        if (
4417
            self.AlternativeImage or
4418
            self.Coords is not None or
4419
            self.Baseline is not None or
4420
            self.Word or
4421
            self.TextEquiv or
4422
            self.TextStyle is not None or
4423
            self.UserDefined is not None or
4424
            self.Labels
4425
        ):
4426
            return True
4427
        else:
4428
            return False
4429
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='TextLineType', pretty_print=True):
4430
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('TextLineType')
4431
        if imported_ns_def_ is not None:
4432
            namespacedef_ = imported_ns_def_
4433
        if pretty_print:
4434
            eol_ = '\n'
4435
        else:
4436
            eol_ = ''
4437
        if self.original_tagname_ is not None and name_ == 'TextLineType':
4438
            name_ = self.original_tagname_
4439
        if UseCapturedNS_ and self.ns_prefix_:
4440
            namespaceprefix_ = self.ns_prefix_ + ':'
4441
        showIndent(outfile, level, pretty_print)
4442
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
4443
        already_processed = set()
4444
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='TextLineType')
4445
        if self.has__content():
4446
            outfile.write('>%s' % (eol_, ))
4447
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='TextLineType', pretty_print=pretty_print)
4448
            showIndent(outfile, level, pretty_print)
4449
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
4450
        else:
4451
            outfile.write('/>%s' % (eol_, ))
4452
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='TextLineType'):
4453
        if self.id is not None and 'id' not in already_processed:
4454
            already_processed.add('id')
4455
            outfile.write(' id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.id), input_name='id')), ))
4456
        if self.primaryLanguage is not None and 'primaryLanguage' not in already_processed:
4457
            already_processed.add('primaryLanguage')
4458
            outfile.write(' primaryLanguage=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.primaryLanguage), input_name='primaryLanguage')), ))
4459
        if self.primaryScript is not None and 'primaryScript' not in already_processed:
4460
            already_processed.add('primaryScript')
4461
            outfile.write(' primaryScript=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.primaryScript), input_name='primaryScript')), ))
4462
        if self.secondaryScript is not None and 'secondaryScript' not in already_processed:
4463
            already_processed.add('secondaryScript')
4464
            outfile.write(' secondaryScript=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.secondaryScript), input_name='secondaryScript')), ))
4465
        if self.readingDirection is not None and 'readingDirection' not in already_processed:
4466
            already_processed.add('readingDirection')
4467
            outfile.write(' readingDirection=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.readingDirection), input_name='readingDirection')), ))
4468
        if self.production is not None and 'production' not in already_processed:
4469
            already_processed.add('production')
4470
            outfile.write(' production=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.production), input_name='production')), ))
4471
        if self.custom is not None and 'custom' not in already_processed:
4472
            already_processed.add('custom')
4473
            outfile.write(' custom=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.custom), input_name='custom')), ))
4474
        if self.comments is not None and 'comments' not in already_processed:
4475
            already_processed.add('comments')
4476
            outfile.write(' comments=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.comments), input_name='comments')), ))
4477
        if self.index is not None and 'index' not in already_processed:
4478
            already_processed.add('index')
4479
            outfile.write(' index="%s"' % self.gds_format_integer(self.index, input_name='index'))
4480
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='TextLineType', fromsubclass_=False, pretty_print=True):
4481
        if pretty_print:
4482
            eol_ = '\n'
4483
        else:
4484
            eol_ = ''
4485
        for AlternativeImage_ in self.AlternativeImage:
4486
            namespaceprefix_ = self.AlternativeImage_nsprefix_ + ':' if (UseCapturedNS_ and self.AlternativeImage_nsprefix_) else ''
4487
            AlternativeImage_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='AlternativeImage', pretty_print=pretty_print)
4488
        if self.Coords is not None:
4489
            namespaceprefix_ = self.Coords_nsprefix_ + ':' if (UseCapturedNS_ and self.Coords_nsprefix_) else ''
4490
            self.Coords.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Coords', pretty_print=pretty_print)
4491
        if self.Baseline is not None:
4492
            namespaceprefix_ = self.Baseline_nsprefix_ + ':' if (UseCapturedNS_ and self.Baseline_nsprefix_) else ''
4493
            self.Baseline.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Baseline', pretty_print=pretty_print)
4494
        for Word_ in self.Word:
4495
            namespaceprefix_ = self.Word_nsprefix_ + ':' if (UseCapturedNS_ and self.Word_nsprefix_) else ''
4496
            Word_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Word', pretty_print=pretty_print)
4497
        for TextEquiv_ in self.TextEquiv:
4498
            namespaceprefix_ = self.TextEquiv_nsprefix_ + ':' if (UseCapturedNS_ and self.TextEquiv_nsprefix_) else ''
4499
            TextEquiv_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TextEquiv', pretty_print=pretty_print)
4500
        if self.TextStyle is not None:
4501
            namespaceprefix_ = self.TextStyle_nsprefix_ + ':' if (UseCapturedNS_ and self.TextStyle_nsprefix_) else ''
4502
            self.TextStyle.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TextStyle', pretty_print=pretty_print)
4503
        if self.UserDefined is not None:
4504
            namespaceprefix_ = self.UserDefined_nsprefix_ + ':' if (UseCapturedNS_ and self.UserDefined_nsprefix_) else ''
4505
            self.UserDefined.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UserDefined', pretty_print=pretty_print)
4506
        for Labels_ in self.Labels:
4507
            namespaceprefix_ = self.Labels_nsprefix_ + ':' if (UseCapturedNS_ and self.Labels_nsprefix_) else ''
4508
            Labels_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Labels', pretty_print=pretty_print)
4509
    def to_etree(self, parent_element=None, name_='TextLineType', mapping_=None, reverse_mapping_=None, nsmap_=None):
4510
        if parent_element is None:
4511
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
4512
        else:
4513
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
4514
        if self.id is not None:
4515
            element.set('id', self.gds_format_string(self.id))
4516
        if self.primaryLanguage is not None:
4517
            element.set('primaryLanguage', self.gds_format_string(self.primaryLanguage))
4518
        if self.primaryScript is not None:
4519
            element.set('primaryScript', self.gds_format_string(self.primaryScript))
4520
        if self.secondaryScript is not None:
4521
            element.set('secondaryScript', self.gds_format_string(self.secondaryScript))
4522
        if self.readingDirection is not None:
4523
            element.set('readingDirection', self.gds_format_string(self.readingDirection))
4524
        if self.production is not None:
4525
            element.set('production', self.gds_format_string(self.production))
4526
        if self.custom is not None:
4527
            element.set('custom', self.gds_format_string(self.custom))
4528
        if self.comments is not None:
4529
            element.set('comments', self.gds_format_string(self.comments))
4530
        if self.index is not None:
4531
            element.set('index', self.gds_format_integer(self.index))
4532
        for AlternativeImage_ in self.AlternativeImage:
4533
            AlternativeImage_.to_etree(element, name_='AlternativeImage', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
4534
        if self.Coords is not None:
4535
            Coords_ = self.Coords
4536
            Coords_.to_etree(element, name_='Coords', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
4537
        if self.Baseline is not None:
4538
            Baseline_ = self.Baseline
4539
            Baseline_.to_etree(element, name_='Baseline', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
4540
        for Word_ in self.Word:
4541
            Word_.to_etree(element, name_='Word', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
4542
        for TextEquiv_ in self.TextEquiv:
4543
            TextEquiv_.to_etree(element, name_='TextEquiv', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
4544
        if self.TextStyle is not None:
4545
            TextStyle_ = self.TextStyle
4546
            TextStyle_.to_etree(element, name_='TextStyle', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
4547
        if self.UserDefined is not None:
4548
            UserDefined_ = self.UserDefined
4549
            UserDefined_.to_etree(element, name_='UserDefined', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
4550
        for Labels_ in self.Labels:
4551
            Labels_.to_etree(element, name_='Labels', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
4552
        if mapping_ is not None:
4553
            mapping_[id(self)] = element
4554
        if reverse_mapping_ is not None:
4555
            reverse_mapping_[element] = self
4556
        return element
4557
    def build(self, node, gds_collector_=None):
4558
        self.gds_collector_ = gds_collector_
4559
        if SaveElementTreeNode:
4560
            self.gds_elementtree_node_ = node
4561
        already_processed = set()
4562
        self.ns_prefix_ = node.prefix
4563
        self._buildAttributes(node, node.attrib, already_processed)
4564
        for child in node:
4565
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
4566
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
4567
        return self
4568
    def _buildAttributes(self, node, attrs, already_processed):
4569
        value = find_attr_value_('id', node)
4570
        if value is not None and 'id' not in already_processed:
4571
            already_processed.add('id')
4572
            self.id = value
4573
        value = find_attr_value_('primaryLanguage', node)
4574
        if value is not None and 'primaryLanguage' not in already_processed:
4575
            already_processed.add('primaryLanguage')
4576
            self.primaryLanguage = value
4577
            self.validate_LanguageSimpleType(self.primaryLanguage)    # validate type LanguageSimpleType
4578
        value = find_attr_value_('primaryScript', node)
4579
        if value is not None and 'primaryScript' not in already_processed:
4580
            already_processed.add('primaryScript')
4581
            self.primaryScript = value
4582
            self.validate_ScriptSimpleType(self.primaryScript)    # validate type ScriptSimpleType
4583
        value = find_attr_value_('secondaryScript', node)
4584
        if value is not None and 'secondaryScript' not in already_processed:
4585
            already_processed.add('secondaryScript')
4586
            self.secondaryScript = value
4587
            self.validate_ScriptSimpleType(self.secondaryScript)    # validate type ScriptSimpleType
4588
        value = find_attr_value_('readingDirection', node)
4589
        if value is not None and 'readingDirection' not in already_processed:
4590
            already_processed.add('readingDirection')
4591
            self.readingDirection = value
4592
            self.validate_ReadingDirectionSimpleType(self.readingDirection)    # validate type ReadingDirectionSimpleType
4593
        value = find_attr_value_('production', node)
4594
        if value is not None and 'production' not in already_processed:
4595
            already_processed.add('production')
4596
            self.production = value
4597
            self.validate_ProductionSimpleType(self.production)    # validate type ProductionSimpleType
4598
        value = find_attr_value_('custom', node)
4599
        if value is not None and 'custom' not in already_processed:
4600
            already_processed.add('custom')
4601
            self.custom = value
4602
        value = find_attr_value_('comments', node)
4603
        if value is not None and 'comments' not in already_processed:
4604
            already_processed.add('comments')
4605
            self.comments = value
4606
        value = find_attr_value_('index', node)
4607
        if value is not None and 'index' not in already_processed:
4608
            already_processed.add('index')
4609
            self.index = self.gds_parse_integer(value, node, 'index')
4610
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
4611
        if nodeName_ == 'AlternativeImage':
4612
            obj_ = AlternativeImageType.factory(parent_object_=self)
4613
            obj_.build(child_, gds_collector_=gds_collector_)
4614
            self.AlternativeImage.append(obj_)
4615
            obj_.original_tagname_ = 'AlternativeImage'
4616
        elif nodeName_ == 'Coords':
4617
            obj_ = CoordsType.factory(parent_object_=self)
4618
            obj_.build(child_, gds_collector_=gds_collector_)
4619
            self.Coords = obj_
4620
            obj_.original_tagname_ = 'Coords'
4621
        elif nodeName_ == 'Baseline':
4622
            obj_ = BaselineType.factory(parent_object_=self)
4623
            obj_.build(child_, gds_collector_=gds_collector_)
4624
            self.Baseline = obj_
4625
            obj_.original_tagname_ = 'Baseline'
4626
        elif nodeName_ == 'Word':
4627
            obj_ = WordType.factory(parent_object_=self)
4628
            obj_.build(child_, gds_collector_=gds_collector_)
4629
            self.Word.append(obj_)
4630
            obj_.original_tagname_ = 'Word'
4631
        elif nodeName_ == 'TextEquiv':
4632
            obj_ = TextEquivType.factory(parent_object_=self)
4633
            obj_.build(child_, gds_collector_=gds_collector_)
4634
            self.TextEquiv.append(obj_)
4635
            obj_.original_tagname_ = 'TextEquiv'
4636
        elif nodeName_ == 'TextStyle':
4637
            obj_ = TextStyleType.factory(parent_object_=self)
4638
            obj_.build(child_, gds_collector_=gds_collector_)
4639
            self.TextStyle = obj_
4640
            obj_.original_tagname_ = 'TextStyle'
4641
        elif nodeName_ == 'UserDefined':
4642
            obj_ = UserDefinedType.factory(parent_object_=self)
4643
            obj_.build(child_, gds_collector_=gds_collector_)
4644
            self.UserDefined = obj_
4645
            obj_.original_tagname_ = 'UserDefined'
4646
        elif nodeName_ == 'Labels':
4647
            obj_ = LabelsType.factory(parent_object_=self)
4648
            obj_.build(child_, gds_collector_=gds_collector_)
4649
            self.Labels.append(obj_)
4650
            obj_.original_tagname_ = 'Labels'
4651
    def __hash__(self):
4652
        return hash(self.id)
4653 View Code Duplication
    def invalidate_AlternativeImage(self, feature_selector=None):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
4654
        """
4655
        Remove derived images from this segment (due to changed coordinates).
4656
    
4657
        If `feature_selector` is not none, remove only images with
4658
        matching ``@comments``, e.g. ``feature_selector=cropped,deskewed``.
4659
        """
4660
        existing_images = self.AlternativeImage or []
4661
        removed_images = []
4662
        if feature_selector:
4663
            new_images = []
4664
            for image in existing_images:
4665
                features = image.get_comments() or ''
4666
                if any(feature in features.split(',')
4667
                       for feature in feature_selector.split(',') if feature):
4668
                    removed_images.append(image)
4669
                else:
4670
                    new_images.append(image)
4671
            self.AlternativeImage = new_images
4672
        else:
4673
            removed_images = existing_images
4674
            self.AlternativeImage = []
4675
        if hasattr(self, 'id'):
4676
            name = self.id
4677
        elif hasattr(self, 'parent_object_') and hasattr(self.parent_object_, 'pcGtsId'):
4678
            name = self.parent_object_.pcGtsId
4679
        else:
4680
            name = ''
4681
        for image in removed_images:
4682
            self.gds_collector_.add_message('Removing AlternativeImage %s from "%s"' % (
4683
                image.get_comments() or '', name))
4684
    def set_Coords(self, Coords):
4685
        """
4686
        Set coordinate polygon by given :py:class:`CoordsType` object.
4687
        Moreover, invalidate self's ``pc:AlternativeImage``s
4688
        (because they will have been cropped with a bbox
4689
        of the previous polygon).
4690
        """
4691
        if hasattr(self, 'invalidate_AlternativeImage'):
4692
            # RegionType, TextLineType, WordType, GlyphType:
4693
            self.invalidate_AlternativeImage()
4694
        elif hasattr(self, 'parent_object_') and hasattr(self.parent_object_, 'invalidate_AlternativeImage'):
4695
            # BorderType:
4696
            self.parent_object_.invalidate_AlternativeImage(feature_selector='cropped')
4697
        self.Coords = Coords
4698
# end class TextLineType
4699
4700
4701
class WordType(GeneratedsSuper):
4702
    """language --
4703
    Overrides primaryLanguage attribute of parent line
4704
    and/or text region
4705
      
4706
    * primaryScript --
4707
      The primary script used in the word
4708
      
4709
    * secondaryScript --
4710
      The secondary script used in the word
4711
      
4712
    * readingDirection --
4713
      The direction in which text within the word
4714
      should be read (order of characters).
4715
      
4716
    * production --
4717
      Overrides the production attribute of the parent
4718
      text line and/or text region.
4719
      
4720
    * custom -- For generic use
4721
    * AlternativeImage --
4722
      Alternative word images (e.g.
4723
      black-and-white)
4724
      
4725
    * Labels -- Semantic labels / tags
4726
    
4727
    """
4728
    __hash__ = GeneratedsSuper.__hash__
4729
    member_data_items_ = [
4730
        MemberSpec_('id', 'string', 0, 0, {'use': 'required', 'name': 'id'}),
4731
        MemberSpec_('language', 'pc:LanguageSimpleType', 0, 1, {'use': 'optional', 'name': 'language'}),
4732
        MemberSpec_('primaryScript', 'pc:ScriptSimpleType', 0, 1, {'use': 'optional', 'name': 'primaryScript'}),
4733
        MemberSpec_('secondaryScript', 'pc:ScriptSimpleType', 0, 1, {'use': 'optional', 'name': 'secondaryScript'}),
4734
        MemberSpec_('readingDirection', 'pc:ReadingDirectionSimpleType', 0, 1, {'use': 'optional', 'name': 'readingDirection'}),
4735
        MemberSpec_('production', 'pc:ProductionSimpleType', 0, 1, {'use': 'optional', 'name': 'production'}),
4736
        MemberSpec_('custom', 'string', 0, 1, {'use': 'optional', 'name': 'custom'}),
4737
        MemberSpec_('comments', 'string', 0, 1, {'use': 'optional', 'name': 'comments'}),
4738
        MemberSpec_('AlternativeImage', 'AlternativeImageType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'AlternativeImage', 'type': 'AlternativeImageType'}, None),
4739
        MemberSpec_('Coords', 'CoordsType', 0, 0, {'name': 'Coords', 'type': 'CoordsType'}, None),
4740
        MemberSpec_('Glyph', 'GlyphType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Glyph', 'type': 'GlyphType'}, None),
4741
        MemberSpec_('TextEquiv', 'TextEquivType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'TextEquiv', 'type': 'TextEquivType'}, None),
4742
        MemberSpec_('TextStyle', 'TextStyleType', 0, 1, {'minOccurs': '0', 'name': 'TextStyle', 'type': 'TextStyleType'}, None),
4743
        MemberSpec_('UserDefined', 'UserDefinedType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'UserDefined', 'type': 'UserDefinedType'}, None),
4744
        MemberSpec_('Labels', 'LabelsType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Labels', 'type': 'LabelsType'}, None),
4745
    ]
4746
    subclass = None
4747
    superclass = None
4748
    def __init__(self, id=None, language=None, primaryScript=None, secondaryScript=None, readingDirection=None, production=None, custom=None, comments=None, AlternativeImage=None, Coords=None, Glyph=None, TextEquiv=None, TextStyle=None, UserDefined=None, Labels=None, gds_collector_=None, **kwargs_):
4749
        self.gds_collector_ = gds_collector_
4750
        self.gds_elementtree_node_ = None
4751
        self.original_tagname_ = None
4752
        self.parent_object_ = kwargs_.get('parent_object_')
4753
        self.ns_prefix_ = "pc"
4754
        self.id = _cast(None, id)
4755
        self.id_nsprefix_ = "pc"
4756
        self.language = _cast(None, language)
4757
        self.language_nsprefix_ = "pc"
4758
        self.primaryScript = _cast(None, primaryScript)
4759
        self.primaryScript_nsprefix_ = "pc"
4760
        self.secondaryScript = _cast(None, secondaryScript)
4761
        self.secondaryScript_nsprefix_ = "pc"
4762
        self.readingDirection = _cast(None, readingDirection)
4763
        self.readingDirection_nsprefix_ = "pc"
4764
        self.production = _cast(None, production)
4765
        self.production_nsprefix_ = "pc"
4766
        self.custom = _cast(None, custom)
4767
        self.custom_nsprefix_ = "pc"
4768
        self.comments = _cast(None, comments)
4769
        self.comments_nsprefix_ = "pc"
4770
        if AlternativeImage is None:
4771
            self.AlternativeImage = []
4772
        else:
4773
            self.AlternativeImage = AlternativeImage
4774
        self.AlternativeImage_nsprefix_ = "pc"
4775
        self.Coords = Coords
4776
        self.Coords_nsprefix_ = "pc"
4777
        if Glyph is None:
4778
            self.Glyph = []
4779
        else:
4780
            self.Glyph = Glyph
4781
        self.Glyph_nsprefix_ = "pc"
4782
        if TextEquiv is None:
4783
            self.TextEquiv = []
4784
        else:
4785
            self.TextEquiv = TextEquiv
4786
        self.TextEquiv_nsprefix_ = "pc"
4787
        self.TextStyle = TextStyle
4788
        self.TextStyle_nsprefix_ = "pc"
4789
        self.UserDefined = UserDefined
4790
        self.UserDefined_nsprefix_ = "pc"
4791
        if Labels is None:
4792
            self.Labels = []
4793
        else:
4794
            self.Labels = Labels
4795
        self.Labels_nsprefix_ = "pc"
4796
    def factory(*args_, **kwargs_):
4797
        if CurrentSubclassModule_ is not None:
4798
            subclass = getSubclassFromModule_(
4799
                CurrentSubclassModule_, WordType)
4800
            if subclass is not None:
4801
                return subclass(*args_, **kwargs_)
4802
        if WordType.subclass:
4803
            return WordType.subclass(*args_, **kwargs_)
4804
        else:
4805
            return WordType(*args_, **kwargs_)
4806
    factory = staticmethod(factory)
4807
    def get_ns_prefix_(self):
4808
        return self.ns_prefix_
4809
    def set_ns_prefix_(self, ns_prefix):
4810
        self.ns_prefix_ = ns_prefix
4811
    def get_AlternativeImage(self):
4812
        return self.AlternativeImage
4813
    def set_AlternativeImage(self, AlternativeImage):
4814
        self.AlternativeImage = AlternativeImage
4815
    def add_AlternativeImage(self, value):
4816
        self.AlternativeImage.append(value)
4817
    def insert_AlternativeImage_at(self, index, value):
4818
        self.AlternativeImage.insert(index, value)
4819
    def replace_AlternativeImage_at(self, index, value):
4820
        self.AlternativeImage[index] = value
4821
    def get_Coords(self):
4822
        return self.Coords
4823
    def set_Coords(self, Coords):
4824
        self.Coords = Coords
4825
    def get_Glyph(self):
4826
        return self.Glyph
4827
    def set_Glyph(self, Glyph):
4828
        self.Glyph = Glyph
4829
    def add_Glyph(self, value):
4830
        self.Glyph.append(value)
4831
    def insert_Glyph_at(self, index, value):
4832
        self.Glyph.insert(index, value)
4833
    def replace_Glyph_at(self, index, value):
4834
        self.Glyph[index] = value
4835
    def get_TextEquiv(self):
4836
        return self.TextEquiv
4837
    def set_TextEquiv(self, TextEquiv):
4838
        self.TextEquiv = TextEquiv
4839
    def add_TextEquiv(self, value):
4840
        self.TextEquiv.append(value)
4841
    def insert_TextEquiv_at(self, index, value):
4842
        self.TextEquiv.insert(index, value)
4843
    def replace_TextEquiv_at(self, index, value):
4844
        self.TextEquiv[index] = value
4845
    def get_TextStyle(self):
4846
        return self.TextStyle
4847
    def set_TextStyle(self, TextStyle):
4848
        self.TextStyle = TextStyle
4849
    def get_UserDefined(self):
4850
        return self.UserDefined
4851
    def set_UserDefined(self, UserDefined):
4852
        self.UserDefined = UserDefined
4853
    def get_Labels(self):
4854
        return self.Labels
4855
    def set_Labels(self, Labels):
4856
        self.Labels = Labels
4857
    def add_Labels(self, value):
4858
        self.Labels.append(value)
4859
    def insert_Labels_at(self, index, value):
4860
        self.Labels.insert(index, value)
4861
    def replace_Labels_at(self, index, value):
4862
        self.Labels[index] = value
4863
    def get_id(self):
4864
        return self.id
4865
    def set_id(self, id):
4866
        self.id = id
4867
    def get_language(self):
4868
        return self.language
4869
    def set_language(self, language):
4870
        self.language = language
4871
    def get_primaryScript(self):
4872
        return self.primaryScript
4873
    def set_primaryScript(self, primaryScript):
4874
        self.primaryScript = primaryScript
4875
    def get_secondaryScript(self):
4876
        return self.secondaryScript
4877
    def set_secondaryScript(self, secondaryScript):
4878
        self.secondaryScript = secondaryScript
4879
    def get_readingDirection(self):
4880
        return self.readingDirection
4881
    def set_readingDirection(self, readingDirection):
4882
        self.readingDirection = readingDirection
4883
    def get_production(self):
4884
        return self.production
4885
    def set_production(self, production):
4886
        self.production = production
4887
    def get_custom(self):
4888
        return self.custom
4889
    def set_custom(self, custom):
4890
        self.custom = custom
4891
    def get_comments(self):
4892
        return self.comments
4893
    def set_comments(self, comments):
4894
        self.comments = comments
4895
    def validate_LanguageSimpleType(self, value):
4896
        # Validate type pc:LanguageSimpleType, a restriction on string.
4897
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
4898
            if not isinstance(value, str):
4899
                lineno = self.gds_get_node_lineno_()
4900
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
4901
                return False
4902
            value = value
4903
            enumerations = ['Abkhaz', 'Afar', 'Afrikaans', 'Akan', 'Albanian', 'Amharic', 'Arabic', 'Aragonese', 'Armenian', 'Assamese', 'Avaric', 'Avestan', 'Aymara', 'Azerbaijani', 'Bambara', 'Bashkir', 'Basque', 'Belarusian', 'Bengali', 'Bihari', 'Bislama', 'Bosnian', 'Breton', 'Bulgarian', 'Burmese', 'Cambodian', 'Cantonese', 'Catalan', 'Chamorro', 'Chechen', 'Chichewa', 'Chinese', 'Chuvash', 'Cornish', 'Corsican', 'Cree', 'Croatian', 'Czech', 'Danish', 'Divehi', 'Dutch', 'Dzongkha', 'English', 'Esperanto', 'Estonian', 'Ewe', 'Faroese', 'Fijian', 'Finnish', 'French', 'Fula', 'Gaelic', 'Galician', 'Ganda', 'Georgian', 'German', 'Greek', 'Guaraní', 'Gujarati', 'Haitian', 'Hausa', 'Hebrew', 'Herero', 'Hindi', 'Hiri Motu', 'Hungarian', 'Icelandic', 'Ido', 'Igbo', 'Indonesian', 'Interlingua', 'Interlingue', 'Inuktitut', 'Inupiaq', 'Irish', 'Italian', 'Japanese', 'Javanese', 'Kalaallisut', 'Kannada', 'Kanuri', 'Kashmiri', 'Kazakh', 'Khmer', 'Kikuyu', 'Kinyarwanda', 'Kirundi', 'Komi', 'Kongo', 'Korean', 'Kurdish', 'Kwanyama', 'Kyrgyz', 'Lao', 'Latin', 'Latvian', 'Limburgish', 'Lingala', 'Lithuanian', 'Luba-Katanga', 'Luxembourgish', 'Macedonian', 'Malagasy', 'Malay', 'Malayalam', 'Maltese', 'Manx', 'Māori', 'Marathi', 'Marshallese', 'Mongolian', 'Nauru', 'Navajo', 'Ndonga', 'Nepali', 'North Ndebele', 'Northern Sami', 'Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk', 'Nuosu', 'Occitan', 'Ojibwe', 'Old Church Slavonic', 'Oriya', 'Oromo', 'Ossetian', 'Pāli', 'Panjabi', 'Pashto', 'Persian', 'Polish', 'Portuguese', 'Punjabi', 'Quechua', 'Romanian', 'Romansh', 'Russian', 'Samoan', 'Sango', 'Sanskrit', 'Sardinian', 'Serbian', 'Shona', 'Sindhi', 'Sinhala', 'Slovak', 'Slovene', 'Somali', 'South Ndebele', 'Southern Sotho', 'Spanish', 'Sundanese', 'Swahili', 'Swati', 'Swedish', 'Tagalog', 'Tahitian', 'Tajik', 'Tamil', 'Tatar', 'Telugu', 'Thai', 'Tibetan', 'Tigrinya', 'Tonga', 'Tsonga', 'Tswana', 'Turkish', 'Turkmen', 'Twi', 'Uighur', 'Ukrainian', 'Urdu', 'Uzbek', 'Venda', 'Vietnamese', 'Volapük', 'Walloon', 'Welsh', 'Western Frisian', 'Wolof', 'Xhosa', 'Yiddish', 'Yoruba', 'Zhuang', 'Zulu', 'other']
4904
            if value not in enumerations:
4905
                lineno = self.gds_get_node_lineno_()
4906
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on LanguageSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
4907
                result = False
4908
    def validate_ScriptSimpleType(self, value):
4909
        # Validate type pc:ScriptSimpleType, a restriction on string.
4910
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
4911
            if not isinstance(value, str):
4912
                lineno = self.gds_get_node_lineno_()
4913
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
4914
                return False
4915
            value = value
4916
            enumerations = ['Adlm - Adlam', 'Afak - Afaka', 'Aghb - Caucasian Albanian', 'Ahom - Ahom, Tai Ahom', 'Arab - Arabic', 'Aran - Arabic (Nastaliq variant)', 'Armi - Imperial Aramaic', 'Armn - Armenian', 'Avst - Avestan', 'Bali - Balinese', 'Bamu - Bamum', 'Bass - Bassa Vah', 'Batk - Batak', 'Beng - Bengali', 'Bhks - Bhaiksuki', 'Blis - Blissymbols', 'Bopo - Bopomofo', 'Brah - Brahmi', 'Brai - Braille', 'Bugi - Buginese', 'Buhd - Buhid', 'Cakm - Chakma', 'Cans - Unified Canadian Aboriginal Syllabics', 'Cari - Carian', 'Cham - Cham', 'Cher - Cherokee', 'Cirt - Cirth', 'Copt - Coptic', 'Cprt - Cypriot', 'Cyrl - Cyrillic', 'Cyrs - Cyrillic (Old Church Slavonic variant)', 'Deva - Devanagari (Nagari)', 'Dsrt - Deseret (Mormon)', 'Dupl - Duployan shorthand, Duployan stenography', 'Egyd - Egyptian demotic', 'Egyh - Egyptian hieratic', 'Egyp - Egyptian hieroglyphs', 'Elba - Elbasan', 'Ethi - Ethiopic', 'Geok - Khutsuri (Asomtavruli and Nuskhuri)', 'Geor - Georgian (Mkhedruli)', 'Glag - Glagolitic', 'Goth - Gothic', 'Gran - Grantha', 'Grek - Greek', 'Gujr - Gujarati', 'Guru - Gurmukhi', 'Hanb - Han with Bopomofo', 'Hang - Hangul', 'Hani - Han (Hanzi, Kanji, Hanja)', 'Hano - Hanunoo (Hanunóo)', 'Hans - Han (Simplified variant)', 'Hant - Han (Traditional variant)', 'Hatr - Hatran', 'Hebr - Hebrew', 'Hira - Hiragana', 'Hluw - Anatolian Hieroglyphs', 'Hmng - Pahawh Hmong', 'Hrkt - Japanese syllabaries', 'Hung - Old Hungarian (Hungarian Runic)', 'Inds - Indus (Harappan)', 'Ital - Old Italic (Etruscan, Oscan etc.)', 'Jamo - Jamo', 'Java - Javanese', 'Jpan - Japanese', 'Jurc - Jurchen', 'Kali - Kayah Li', 'Kana - Katakana', 'Khar - Kharoshthi', 'Khmr - Khmer', 'Khoj - Khojki', 'Kitl - Khitan large script', 'Kits - Khitan small script', 'Knda - Kannada', 'Kore - Korean (alias for Hangul + Han)', 'Kpel - Kpelle', 'Kthi - Kaithi', 'Lana - Tai Tham (Lanna)', 'Laoo - Lao', 'Latf - Latin (Fraktur variant)', 'Latg - Latin (Gaelic variant)', 'Latn - Latin', 'Leke - Leke', 'Lepc - Lepcha (Róng)', 'Limb - Limbu', 'Lina - Linear A', 'Linb - Linear B', 'Lisu - Lisu (Fraser)', 'Loma - Loma', 'Lyci - Lycian', 'Lydi - Lydian', 'Mahj - Mahajani', 'Mand - Mandaic, Mandaean', 'Mani - Manichaean', 'Marc - Marchen', 'Maya - Mayan hieroglyphs', 'Mend - Mende Kikakui', 'Merc - Meroitic Cursive', 'Mero - Meroitic Hieroglyphs', 'Mlym - Malayalam', 'Modi - Modi, Moḍī', 'Mong - Mongolian', 'Moon - Moon (Moon code, Moon script, Moon type)', 'Mroo - Mro, Mru', 'Mtei - Meitei Mayek (Meithei, Meetei)', 'Mult - Multani', 'Mymr - Myanmar (Burmese)', 'Narb - Old North Arabian (Ancient North Arabian)', 'Nbat - Nabataean', 'Newa - Newa, Newar, Newari', 'Nkgb - Nakhi Geba', 'Nkoo - N’Ko', 'Nshu - Nüshu', 'Ogam - Ogham', 'Olck - Ol Chiki (Ol Cemet’, Ol, Santali)', 'Orkh - Old Turkic, Orkhon Runic', 'Orya - Oriya', 'Osge - Osage', 'Osma - Osmanya', 'Palm - Palmyrene', 'Pauc - Pau Cin Hau', 'Perm - Old Permic', 'Phag - Phags-pa', 'Phli - Inscriptional Pahlavi', 'Phlp - Psalter Pahlavi', 'Phlv - Book Pahlavi', 'Phnx - Phoenician', 'Piqd - Klingon (KLI pIqaD)', 'Plrd - Miao (Pollard)', 'Prti - Inscriptional Parthian', 'Rjng - Rejang (Redjang, Kaganga)', 'Roro - Rongorongo', 'Runr - Runic', 'Samr - Samaritan', 'Sara - Sarati', 'Sarb - Old South Arabian', 'Saur - Saurashtra', 'Sgnw - SignWriting', 'Shaw - Shavian (Shaw)', 'Shrd - Sharada, Śāradā', 'Sidd - Siddham', 'Sind - Khudawadi, Sindhi', 'Sinh - Sinhala', 'Sora - Sora Sompeng', 'Sund - Sundanese', 'Sylo - Syloti Nagri', 'Syrc - Syriac', 'Syre - Syriac (Estrangelo variant)', 'Syrj - Syriac (Western variant)', 'Syrn - Syriac (Eastern variant)', 'Tagb - Tagbanwa', 'Takr - Takri', 'Tale - Tai Le', 'Talu - New Tai Lue', 'Taml - Tamil', 'Tang - Tangut', 'Tavt - Tai Viet', 'Telu - Telugu', 'Teng - Tengwar', 'Tfng - Tifinagh (Berber)', 'Tglg - Tagalog (Baybayin, Alibata)', 'Thaa - Thaana', 'Thai - Thai', 'Tibt - Tibetan', 'Tirh - Tirhuta', 'Ugar - Ugaritic', 'Vaii - Vai', 'Visp - Visible Speech', 'Wara - Warang Citi (Varang Kshiti)', 'Wole - Woleai', 'Xpeo - Old Persian', 'Xsux - Cuneiform, Sumero-Akkadian', 'Yiii - Yi', 'Zinh - Code for inherited script', 'Zmth - Mathematical notation', 'Zsye - Symbols (Emoji variant)', 'Zsym - Symbols', 'Zxxx - Code for unwritten documents', 'Zyyy - Code for undetermined script', 'Zzzz - Code for uncoded script', 'other']
4917
            if value not in enumerations:
4918
                lineno = self.gds_get_node_lineno_()
4919
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ScriptSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
4920
                result = False
4921
    def validate_ReadingDirectionSimpleType(self, value):
4922
        # Validate type pc:ReadingDirectionSimpleType, a restriction on string.
4923
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
4924
            if not isinstance(value, str):
4925
                lineno = self.gds_get_node_lineno_()
4926
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
4927
                return False
4928
            value = value
4929
            enumerations = ['left-to-right', 'right-to-left', 'top-to-bottom', 'bottom-to-top']
4930
            if value not in enumerations:
4931
                lineno = self.gds_get_node_lineno_()
4932
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ReadingDirectionSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
4933
                result = False
4934
    def validate_ProductionSimpleType(self, value):
4935
        # Validate type pc:ProductionSimpleType, a restriction on string.
4936
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
4937
            if not isinstance(value, str):
4938
                lineno = self.gds_get_node_lineno_()
4939
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
4940
                return False
4941
            value = value
4942
            enumerations = ['printed', 'typewritten', 'handwritten-cursive', 'handwritten-printscript', 'medieval-manuscript', 'other']
4943
            if value not in enumerations:
4944
                lineno = self.gds_get_node_lineno_()
4945
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ProductionSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
4946
                result = False
4947
    def has__content(self):
4948
        if (
4949
            self.AlternativeImage or
4950
            self.Coords is not None or
4951
            self.Glyph or
4952
            self.TextEquiv or
4953
            self.TextStyle is not None or
4954
            self.UserDefined is not None or
4955
            self.Labels
4956
        ):
4957
            return True
4958
        else:
4959
            return False
4960
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='WordType', pretty_print=True):
4961
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('WordType')
4962
        if imported_ns_def_ is not None:
4963
            namespacedef_ = imported_ns_def_
4964
        if pretty_print:
4965
            eol_ = '\n'
4966
        else:
4967
            eol_ = ''
4968
        if self.original_tagname_ is not None and name_ == 'WordType':
4969
            name_ = self.original_tagname_
4970
        if UseCapturedNS_ and self.ns_prefix_:
4971
            namespaceprefix_ = self.ns_prefix_ + ':'
4972
        showIndent(outfile, level, pretty_print)
4973
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
4974
        already_processed = set()
4975
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='WordType')
4976
        if self.has__content():
4977
            outfile.write('>%s' % (eol_, ))
4978
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='WordType', pretty_print=pretty_print)
4979
            showIndent(outfile, level, pretty_print)
4980
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
4981
        else:
4982
            outfile.write('/>%s' % (eol_, ))
4983
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='WordType'):
4984
        if self.id is not None and 'id' not in already_processed:
4985
            already_processed.add('id')
4986
            outfile.write(' id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.id), input_name='id')), ))
4987
        if self.language is not None and 'language' not in already_processed:
4988
            already_processed.add('language')
4989
            outfile.write(' language=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.language), input_name='language')), ))
4990
        if self.primaryScript is not None and 'primaryScript' not in already_processed:
4991
            already_processed.add('primaryScript')
4992
            outfile.write(' primaryScript=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.primaryScript), input_name='primaryScript')), ))
4993
        if self.secondaryScript is not None and 'secondaryScript' not in already_processed:
4994
            already_processed.add('secondaryScript')
4995
            outfile.write(' secondaryScript=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.secondaryScript), input_name='secondaryScript')), ))
4996
        if self.readingDirection is not None and 'readingDirection' not in already_processed:
4997
            already_processed.add('readingDirection')
4998
            outfile.write(' readingDirection=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.readingDirection), input_name='readingDirection')), ))
4999
        if self.production is not None and 'production' not in already_processed:
5000
            already_processed.add('production')
5001
            outfile.write(' production=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.production), input_name='production')), ))
5002
        if self.custom is not None and 'custom' not in already_processed:
5003
            already_processed.add('custom')
5004
            outfile.write(' custom=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.custom), input_name='custom')), ))
5005
        if self.comments is not None and 'comments' not in already_processed:
5006
            already_processed.add('comments')
5007
            outfile.write(' comments=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.comments), input_name='comments')), ))
5008 View Code Duplication
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='WordType', fromsubclass_=False, pretty_print=True):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
5009
        if pretty_print:
5010
            eol_ = '\n'
5011
        else:
5012
            eol_ = ''
5013
        for AlternativeImage_ in self.AlternativeImage:
5014
            namespaceprefix_ = self.AlternativeImage_nsprefix_ + ':' if (UseCapturedNS_ and self.AlternativeImage_nsprefix_) else ''
5015
            AlternativeImage_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='AlternativeImage', pretty_print=pretty_print)
5016
        if self.Coords is not None:
5017
            namespaceprefix_ = self.Coords_nsprefix_ + ':' if (UseCapturedNS_ and self.Coords_nsprefix_) else ''
5018
            self.Coords.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Coords', pretty_print=pretty_print)
5019
        for Glyph_ in self.Glyph:
5020
            namespaceprefix_ = self.Glyph_nsprefix_ + ':' if (UseCapturedNS_ and self.Glyph_nsprefix_) else ''
5021
            Glyph_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Glyph', pretty_print=pretty_print)
5022
        for TextEquiv_ in self.TextEquiv:
5023
            namespaceprefix_ = self.TextEquiv_nsprefix_ + ':' if (UseCapturedNS_ and self.TextEquiv_nsprefix_) else ''
5024
            TextEquiv_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TextEquiv', pretty_print=pretty_print)
5025
        if self.TextStyle is not None:
5026
            namespaceprefix_ = self.TextStyle_nsprefix_ + ':' if (UseCapturedNS_ and self.TextStyle_nsprefix_) else ''
5027
            self.TextStyle.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TextStyle', pretty_print=pretty_print)
5028
        if self.UserDefined is not None:
5029
            namespaceprefix_ = self.UserDefined_nsprefix_ + ':' if (UseCapturedNS_ and self.UserDefined_nsprefix_) else ''
5030
            self.UserDefined.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UserDefined', pretty_print=pretty_print)
5031
        for Labels_ in self.Labels:
5032
            namespaceprefix_ = self.Labels_nsprefix_ + ':' if (UseCapturedNS_ and self.Labels_nsprefix_) else ''
5033
            Labels_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Labels', pretty_print=pretty_print)
5034
    def to_etree(self, parent_element=None, name_='WordType', mapping_=None, reverse_mapping_=None, nsmap_=None):
5035
        if parent_element is None:
5036
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
5037
        else:
5038
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
5039
        if self.id is not None:
5040
            element.set('id', self.gds_format_string(self.id))
5041
        if self.language is not None:
5042
            element.set('language', self.gds_format_string(self.language))
5043
        if self.primaryScript is not None:
5044
            element.set('primaryScript', self.gds_format_string(self.primaryScript))
5045
        if self.secondaryScript is not None:
5046
            element.set('secondaryScript', self.gds_format_string(self.secondaryScript))
5047
        if self.readingDirection is not None:
5048
            element.set('readingDirection', self.gds_format_string(self.readingDirection))
5049
        if self.production is not None:
5050
            element.set('production', self.gds_format_string(self.production))
5051
        if self.custom is not None:
5052
            element.set('custom', self.gds_format_string(self.custom))
5053
        if self.comments is not None:
5054
            element.set('comments', self.gds_format_string(self.comments))
5055
        for AlternativeImage_ in self.AlternativeImage:
5056
            AlternativeImage_.to_etree(element, name_='AlternativeImage', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
5057
        if self.Coords is not None:
5058
            Coords_ = self.Coords
5059
            Coords_.to_etree(element, name_='Coords', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
5060
        for Glyph_ in self.Glyph:
5061
            Glyph_.to_etree(element, name_='Glyph', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
5062
        for TextEquiv_ in self.TextEquiv:
5063
            TextEquiv_.to_etree(element, name_='TextEquiv', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
5064
        if self.TextStyle is not None:
5065
            TextStyle_ = self.TextStyle
5066
            TextStyle_.to_etree(element, name_='TextStyle', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
5067
        if self.UserDefined is not None:
5068
            UserDefined_ = self.UserDefined
5069
            UserDefined_.to_etree(element, name_='UserDefined', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
5070
        for Labels_ in self.Labels:
5071
            Labels_.to_etree(element, name_='Labels', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
5072
        if mapping_ is not None:
5073
            mapping_[id(self)] = element
5074
        if reverse_mapping_ is not None:
5075
            reverse_mapping_[element] = self
5076
        return element
5077
    def build(self, node, gds_collector_=None):
5078
        self.gds_collector_ = gds_collector_
5079
        if SaveElementTreeNode:
5080
            self.gds_elementtree_node_ = node
5081
        already_processed = set()
5082
        self.ns_prefix_ = node.prefix
5083
        self._buildAttributes(node, node.attrib, already_processed)
5084
        for child in node:
5085
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
5086
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
5087
        return self
5088
    def _buildAttributes(self, node, attrs, already_processed):
5089
        value = find_attr_value_('id', node)
5090
        if value is not None and 'id' not in already_processed:
5091
            already_processed.add('id')
5092
            self.id = value
5093
        value = find_attr_value_('language', node)
5094
        if value is not None and 'language' not in already_processed:
5095
            already_processed.add('language')
5096
            self.language = value
5097
            self.validate_LanguageSimpleType(self.language)    # validate type LanguageSimpleType
5098
        value = find_attr_value_('primaryScript', node)
5099
        if value is not None and 'primaryScript' not in already_processed:
5100
            already_processed.add('primaryScript')
5101
            self.primaryScript = value
5102
            self.validate_ScriptSimpleType(self.primaryScript)    # validate type ScriptSimpleType
5103
        value = find_attr_value_('secondaryScript', node)
5104
        if value is not None and 'secondaryScript' not in already_processed:
5105
            already_processed.add('secondaryScript')
5106
            self.secondaryScript = value
5107
            self.validate_ScriptSimpleType(self.secondaryScript)    # validate type ScriptSimpleType
5108
        value = find_attr_value_('readingDirection', node)
5109
        if value is not None and 'readingDirection' not in already_processed:
5110
            already_processed.add('readingDirection')
5111
            self.readingDirection = value
5112
            self.validate_ReadingDirectionSimpleType(self.readingDirection)    # validate type ReadingDirectionSimpleType
5113
        value = find_attr_value_('production', node)
5114
        if value is not None and 'production' not in already_processed:
5115
            already_processed.add('production')
5116
            self.production = value
5117
            self.validate_ProductionSimpleType(self.production)    # validate type ProductionSimpleType
5118
        value = find_attr_value_('custom', node)
5119
        if value is not None and 'custom' not in already_processed:
5120
            already_processed.add('custom')
5121
            self.custom = value
5122
        value = find_attr_value_('comments', node)
5123
        if value is not None and 'comments' not in already_processed:
5124
            already_processed.add('comments')
5125
            self.comments = value
5126 View Code Duplication
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
5127
        if nodeName_ == 'AlternativeImage':
5128
            obj_ = AlternativeImageType.factory(parent_object_=self)
5129
            obj_.build(child_, gds_collector_=gds_collector_)
5130
            self.AlternativeImage.append(obj_)
5131
            obj_.original_tagname_ = 'AlternativeImage'
5132
        elif nodeName_ == 'Coords':
5133
            obj_ = CoordsType.factory(parent_object_=self)
5134
            obj_.build(child_, gds_collector_=gds_collector_)
5135
            self.Coords = obj_
5136
            obj_.original_tagname_ = 'Coords'
5137
        elif nodeName_ == 'Glyph':
5138
            obj_ = GlyphType.factory(parent_object_=self)
5139
            obj_.build(child_, gds_collector_=gds_collector_)
5140
            self.Glyph.append(obj_)
5141
            obj_.original_tagname_ = 'Glyph'
5142
        elif nodeName_ == 'TextEquiv':
5143
            obj_ = TextEquivType.factory(parent_object_=self)
5144
            obj_.build(child_, gds_collector_=gds_collector_)
5145
            self.TextEquiv.append(obj_)
5146
            obj_.original_tagname_ = 'TextEquiv'
5147
        elif nodeName_ == 'TextStyle':
5148
            obj_ = TextStyleType.factory(parent_object_=self)
5149
            obj_.build(child_, gds_collector_=gds_collector_)
5150
            self.TextStyle = obj_
5151
            obj_.original_tagname_ = 'TextStyle'
5152
        elif nodeName_ == 'UserDefined':
5153
            obj_ = UserDefinedType.factory(parent_object_=self)
5154
            obj_.build(child_, gds_collector_=gds_collector_)
5155
            self.UserDefined = obj_
5156
            obj_.original_tagname_ = 'UserDefined'
5157
        elif nodeName_ == 'Labels':
5158
            obj_ = LabelsType.factory(parent_object_=self)
5159
            obj_.build(child_, gds_collector_=gds_collector_)
5160
            self.Labels.append(obj_)
5161
            obj_.original_tagname_ = 'Labels'
5162
    def __hash__(self):
5163
        return hash(self.id)
5164 View Code Duplication
    def invalidate_AlternativeImage(self, feature_selector=None):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
5165
        """
5166
        Remove derived images from this segment (due to changed coordinates).
5167
    
5168
        If `feature_selector` is not none, remove only images with
5169
        matching ``@comments``, e.g. ``feature_selector=cropped,deskewed``.
5170
        """
5171
        existing_images = self.AlternativeImage or []
5172
        removed_images = []
5173
        if feature_selector:
5174
            new_images = []
5175
            for image in existing_images:
5176
                features = image.get_comments() or ''
5177
                if any(feature in features.split(',')
5178
                       for feature in feature_selector.split(',') if feature):
5179
                    removed_images.append(image)
5180
                else:
5181
                    new_images.append(image)
5182
            self.AlternativeImage = new_images
5183
        else:
5184
            removed_images = existing_images
5185
            self.AlternativeImage = []
5186
        if hasattr(self, 'id'):
5187
            name = self.id
5188
        elif hasattr(self, 'parent_object_') and hasattr(self.parent_object_, 'pcGtsId'):
5189
            name = self.parent_object_.pcGtsId
5190
        else:
5191
            name = ''
5192
        for image in removed_images:
5193
            self.gds_collector_.add_message('Removing AlternativeImage %s from "%s"' % (
5194
                image.get_comments() or '', name))
5195
    def set_Coords(self, Coords):
5196
        """
5197
        Set coordinate polygon by given :py:class:`CoordsType` object.
5198
        Moreover, invalidate self's ``pc:AlternativeImage``s
5199
        (because they will have been cropped with a bbox
5200
        of the previous polygon).
5201
        """
5202
        if hasattr(self, 'invalidate_AlternativeImage'):
5203
            # RegionType, TextLineType, WordType, GlyphType:
5204
            self.invalidate_AlternativeImage()
5205
        elif hasattr(self, 'parent_object_') and hasattr(self.parent_object_, 'invalidate_AlternativeImage'):
5206
            # BorderType:
5207
            self.parent_object_.invalidate_AlternativeImage(feature_selector='cropped')
5208
        self.Coords = Coords
5209
# end class WordType
5210
5211
5212
class GlyphType(GeneratedsSuper):
5213
    """script --
5214
    The script used for the glyph
5215
      
5216
    * production --
5217
      Overrides the production attribute of the parent
5218
      word / text line / text region.
5219
      
5220
    * custom -- For generic use
5221
    * AlternativeImage --
5222
      Alternative glyph images (e.g.
5223
      black-and-white)
5224
      
5225
    * Graphemes --
5226
      Container for graphemes, grapheme groups and
5227
      non-printing characters
5228
      
5229
    * Labels -- Semantic labels / tags
5230
    
5231
    """
5232
    __hash__ = GeneratedsSuper.__hash__
5233
    member_data_items_ = [
5234
        MemberSpec_('id', 'string', 0, 0, {'use': 'required', 'name': 'id'}),
5235
        MemberSpec_('ligature', 'boolean', 0, 1, {'use': 'optional', 'name': 'ligature'}),
5236
        MemberSpec_('symbol', 'boolean', 0, 1, {'use': 'optional', 'name': 'symbol'}),
5237
        MemberSpec_('script', 'pc:ScriptSimpleType', 0, 1, {'use': 'optional', 'name': 'script'}),
5238
        MemberSpec_('production', 'pc:ProductionSimpleType', 0, 1, {'use': 'optional', 'name': 'production'}),
5239
        MemberSpec_('custom', 'string', 0, 1, {'use': 'optional', 'name': 'custom'}),
5240
        MemberSpec_('comments', 'string', 0, 1, {'use': 'optional', 'name': 'comments'}),
5241
        MemberSpec_('AlternativeImage', 'AlternativeImageType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'AlternativeImage', 'type': 'AlternativeImageType'}, None),
5242
        MemberSpec_('Coords', 'CoordsType', 0, 0, {'name': 'Coords', 'type': 'CoordsType'}, None),
5243
        MemberSpec_('Graphemes', 'GraphemesType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'Graphemes', 'type': 'GraphemesType'}, None),
5244
        MemberSpec_('TextEquiv', 'TextEquivType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'TextEquiv', 'type': 'TextEquivType'}, None),
5245
        MemberSpec_('TextStyle', 'TextStyleType', 0, 1, {'minOccurs': '0', 'name': 'TextStyle', 'type': 'TextStyleType'}, None),
5246
        MemberSpec_('UserDefined', 'UserDefinedType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'UserDefined', 'type': 'UserDefinedType'}, None),
5247
        MemberSpec_('Labels', 'LabelsType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Labels', 'type': 'LabelsType'}, None),
5248
    ]
5249
    subclass = None
5250
    superclass = None
5251
    def __init__(self, id=None, ligature=None, symbol=None, script=None, production=None, custom=None, comments=None, AlternativeImage=None, Coords=None, Graphemes=None, TextEquiv=None, TextStyle=None, UserDefined=None, Labels=None, gds_collector_=None, **kwargs_):
5252
        self.gds_collector_ = gds_collector_
5253
        self.gds_elementtree_node_ = None
5254
        self.original_tagname_ = None
5255
        self.parent_object_ = kwargs_.get('parent_object_')
5256
        self.ns_prefix_ = "pc"
5257
        self.id = _cast(None, id)
5258
        self.id_nsprefix_ = "pc"
5259
        self.ligature = _cast(bool, ligature)
5260
        self.ligature_nsprefix_ = "pc"
5261
        self.symbol = _cast(bool, symbol)
5262
        self.symbol_nsprefix_ = "pc"
5263
        self.script = _cast(None, script)
5264
        self.script_nsprefix_ = "pc"
5265
        self.production = _cast(None, production)
5266
        self.production_nsprefix_ = "pc"
5267
        self.custom = _cast(None, custom)
5268
        self.custom_nsprefix_ = "pc"
5269
        self.comments = _cast(None, comments)
5270
        self.comments_nsprefix_ = "pc"
5271
        if AlternativeImage is None:
5272
            self.AlternativeImage = []
5273
        else:
5274
            self.AlternativeImage = AlternativeImage
5275
        self.AlternativeImage_nsprefix_ = "pc"
5276
        self.Coords = Coords
5277
        self.Coords_nsprefix_ = "pc"
5278
        self.Graphemes = Graphemes
5279
        self.Graphemes_nsprefix_ = "pc"
5280
        if TextEquiv is None:
5281
            self.TextEquiv = []
5282
        else:
5283
            self.TextEquiv = TextEquiv
5284
        self.TextEquiv_nsprefix_ = "pc"
5285
        self.TextStyle = TextStyle
5286
        self.TextStyle_nsprefix_ = "pc"
5287
        self.UserDefined = UserDefined
5288
        self.UserDefined_nsprefix_ = "pc"
5289
        if Labels is None:
5290
            self.Labels = []
5291
        else:
5292
            self.Labels = Labels
5293
        self.Labels_nsprefix_ = "pc"
5294
    def factory(*args_, **kwargs_):
5295
        if CurrentSubclassModule_ is not None:
5296
            subclass = getSubclassFromModule_(
5297
                CurrentSubclassModule_, GlyphType)
5298
            if subclass is not None:
5299
                return subclass(*args_, **kwargs_)
5300
        if GlyphType.subclass:
5301
            return GlyphType.subclass(*args_, **kwargs_)
5302
        else:
5303
            return GlyphType(*args_, **kwargs_)
5304
    factory = staticmethod(factory)
5305
    def get_ns_prefix_(self):
5306
        return self.ns_prefix_
5307
    def set_ns_prefix_(self, ns_prefix):
5308
        self.ns_prefix_ = ns_prefix
5309
    def get_AlternativeImage(self):
5310
        return self.AlternativeImage
5311
    def set_AlternativeImage(self, AlternativeImage):
5312
        self.AlternativeImage = AlternativeImage
5313
    def add_AlternativeImage(self, value):
5314
        self.AlternativeImage.append(value)
5315
    def insert_AlternativeImage_at(self, index, value):
5316
        self.AlternativeImage.insert(index, value)
5317
    def replace_AlternativeImage_at(self, index, value):
5318
        self.AlternativeImage[index] = value
5319
    def get_Coords(self):
5320
        return self.Coords
5321
    def set_Coords(self, Coords):
5322
        self.Coords = Coords
5323
    def get_Graphemes(self):
5324
        return self.Graphemes
5325
    def set_Graphemes(self, Graphemes):
5326
        self.Graphemes = Graphemes
5327
    def get_TextEquiv(self):
5328
        return self.TextEquiv
5329
    def set_TextEquiv(self, TextEquiv):
5330
        self.TextEquiv = TextEquiv
5331
    def add_TextEquiv(self, value):
5332
        self.TextEquiv.append(value)
5333
    def insert_TextEquiv_at(self, index, value):
5334
        self.TextEquiv.insert(index, value)
5335
    def replace_TextEquiv_at(self, index, value):
5336
        self.TextEquiv[index] = value
5337
    def get_TextStyle(self):
5338
        return self.TextStyle
5339
    def set_TextStyle(self, TextStyle):
5340
        self.TextStyle = TextStyle
5341
    def get_UserDefined(self):
5342
        return self.UserDefined
5343
    def set_UserDefined(self, UserDefined):
5344
        self.UserDefined = UserDefined
5345
    def get_Labels(self):
5346
        return self.Labels
5347
    def set_Labels(self, Labels):
5348
        self.Labels = Labels
5349
    def add_Labels(self, value):
5350
        self.Labels.append(value)
5351
    def insert_Labels_at(self, index, value):
5352
        self.Labels.insert(index, value)
5353
    def replace_Labels_at(self, index, value):
5354
        self.Labels[index] = value
5355
    def get_id(self):
5356
        return self.id
5357
    def set_id(self, id):
5358
        self.id = id
5359
    def get_ligature(self):
5360
        return self.ligature
5361
    def set_ligature(self, ligature):
5362
        self.ligature = ligature
5363
    def get_symbol(self):
5364
        return self.symbol
5365
    def set_symbol(self, symbol):
5366
        self.symbol = symbol
5367
    def get_script(self):
5368
        return self.script
5369
    def set_script(self, script):
5370
        self.script = script
5371
    def get_production(self):
5372
        return self.production
5373
    def set_production(self, production):
5374
        self.production = production
5375
    def get_custom(self):
5376
        return self.custom
5377
    def set_custom(self, custom):
5378
        self.custom = custom
5379
    def get_comments(self):
5380
        return self.comments
5381
    def set_comments(self, comments):
5382
        self.comments = comments
5383
    def validate_ScriptSimpleType(self, value):
5384
        # Validate type pc:ScriptSimpleType, a restriction on string.
5385
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
5386
            if not isinstance(value, str):
5387
                lineno = self.gds_get_node_lineno_()
5388
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
5389
                return False
5390
            value = value
5391
            enumerations = ['Adlm - Adlam', 'Afak - Afaka', 'Aghb - Caucasian Albanian', 'Ahom - Ahom, Tai Ahom', 'Arab - Arabic', 'Aran - Arabic (Nastaliq variant)', 'Armi - Imperial Aramaic', 'Armn - Armenian', 'Avst - Avestan', 'Bali - Balinese', 'Bamu - Bamum', 'Bass - Bassa Vah', 'Batk - Batak', 'Beng - Bengali', 'Bhks - Bhaiksuki', 'Blis - Blissymbols', 'Bopo - Bopomofo', 'Brah - Brahmi', 'Brai - Braille', 'Bugi - Buginese', 'Buhd - Buhid', 'Cakm - Chakma', 'Cans - Unified Canadian Aboriginal Syllabics', 'Cari - Carian', 'Cham - Cham', 'Cher - Cherokee', 'Cirt - Cirth', 'Copt - Coptic', 'Cprt - Cypriot', 'Cyrl - Cyrillic', 'Cyrs - Cyrillic (Old Church Slavonic variant)', 'Deva - Devanagari (Nagari)', 'Dsrt - Deseret (Mormon)', 'Dupl - Duployan shorthand, Duployan stenography', 'Egyd - Egyptian demotic', 'Egyh - Egyptian hieratic', 'Egyp - Egyptian hieroglyphs', 'Elba - Elbasan', 'Ethi - Ethiopic', 'Geok - Khutsuri (Asomtavruli and Nuskhuri)', 'Geor - Georgian (Mkhedruli)', 'Glag - Glagolitic', 'Goth - Gothic', 'Gran - Grantha', 'Grek - Greek', 'Gujr - Gujarati', 'Guru - Gurmukhi', 'Hanb - Han with Bopomofo', 'Hang - Hangul', 'Hani - Han (Hanzi, Kanji, Hanja)', 'Hano - Hanunoo (Hanunóo)', 'Hans - Han (Simplified variant)', 'Hant - Han (Traditional variant)', 'Hatr - Hatran', 'Hebr - Hebrew', 'Hira - Hiragana', 'Hluw - Anatolian Hieroglyphs', 'Hmng - Pahawh Hmong', 'Hrkt - Japanese syllabaries', 'Hung - Old Hungarian (Hungarian Runic)', 'Inds - Indus (Harappan)', 'Ital - Old Italic (Etruscan, Oscan etc.)', 'Jamo - Jamo', 'Java - Javanese', 'Jpan - Japanese', 'Jurc - Jurchen', 'Kali - Kayah Li', 'Kana - Katakana', 'Khar - Kharoshthi', 'Khmr - Khmer', 'Khoj - Khojki', 'Kitl - Khitan large script', 'Kits - Khitan small script', 'Knda - Kannada', 'Kore - Korean (alias for Hangul + Han)', 'Kpel - Kpelle', 'Kthi - Kaithi', 'Lana - Tai Tham (Lanna)', 'Laoo - Lao', 'Latf - Latin (Fraktur variant)', 'Latg - Latin (Gaelic variant)', 'Latn - Latin', 'Leke - Leke', 'Lepc - Lepcha (Róng)', 'Limb - Limbu', 'Lina - Linear A', 'Linb - Linear B', 'Lisu - Lisu (Fraser)', 'Loma - Loma', 'Lyci - Lycian', 'Lydi - Lydian', 'Mahj - Mahajani', 'Mand - Mandaic, Mandaean', 'Mani - Manichaean', 'Marc - Marchen', 'Maya - Mayan hieroglyphs', 'Mend - Mende Kikakui', 'Merc - Meroitic Cursive', 'Mero - Meroitic Hieroglyphs', 'Mlym - Malayalam', 'Modi - Modi, Moḍī', 'Mong - Mongolian', 'Moon - Moon (Moon code, Moon script, Moon type)', 'Mroo - Mro, Mru', 'Mtei - Meitei Mayek (Meithei, Meetei)', 'Mult - Multani', 'Mymr - Myanmar (Burmese)', 'Narb - Old North Arabian (Ancient North Arabian)', 'Nbat - Nabataean', 'Newa - Newa, Newar, Newari', 'Nkgb - Nakhi Geba', 'Nkoo - N’Ko', 'Nshu - Nüshu', 'Ogam - Ogham', 'Olck - Ol Chiki (Ol Cemet’, Ol, Santali)', 'Orkh - Old Turkic, Orkhon Runic', 'Orya - Oriya', 'Osge - Osage', 'Osma - Osmanya', 'Palm - Palmyrene', 'Pauc - Pau Cin Hau', 'Perm - Old Permic', 'Phag - Phags-pa', 'Phli - Inscriptional Pahlavi', 'Phlp - Psalter Pahlavi', 'Phlv - Book Pahlavi', 'Phnx - Phoenician', 'Piqd - Klingon (KLI pIqaD)', 'Plrd - Miao (Pollard)', 'Prti - Inscriptional Parthian', 'Rjng - Rejang (Redjang, Kaganga)', 'Roro - Rongorongo', 'Runr - Runic', 'Samr - Samaritan', 'Sara - Sarati', 'Sarb - Old South Arabian', 'Saur - Saurashtra', 'Sgnw - SignWriting', 'Shaw - Shavian (Shaw)', 'Shrd - Sharada, Śāradā', 'Sidd - Siddham', 'Sind - Khudawadi, Sindhi', 'Sinh - Sinhala', 'Sora - Sora Sompeng', 'Sund - Sundanese', 'Sylo - Syloti Nagri', 'Syrc - Syriac', 'Syre - Syriac (Estrangelo variant)', 'Syrj - Syriac (Western variant)', 'Syrn - Syriac (Eastern variant)', 'Tagb - Tagbanwa', 'Takr - Takri', 'Tale - Tai Le', 'Talu - New Tai Lue', 'Taml - Tamil', 'Tang - Tangut', 'Tavt - Tai Viet', 'Telu - Telugu', 'Teng - Tengwar', 'Tfng - Tifinagh (Berber)', 'Tglg - Tagalog (Baybayin, Alibata)', 'Thaa - Thaana', 'Thai - Thai', 'Tibt - Tibetan', 'Tirh - Tirhuta', 'Ugar - Ugaritic', 'Vaii - Vai', 'Visp - Visible Speech', 'Wara - Warang Citi (Varang Kshiti)', 'Wole - Woleai', 'Xpeo - Old Persian', 'Xsux - Cuneiform, Sumero-Akkadian', 'Yiii - Yi', 'Zinh - Code for inherited script', 'Zmth - Mathematical notation', 'Zsye - Symbols (Emoji variant)', 'Zsym - Symbols', 'Zxxx - Code for unwritten documents', 'Zyyy - Code for undetermined script', 'Zzzz - Code for uncoded script', 'other']
5392
            if value not in enumerations:
5393
                lineno = self.gds_get_node_lineno_()
5394
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ScriptSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
5395
                result = False
5396
    def validate_ProductionSimpleType(self, value):
5397
        # Validate type pc:ProductionSimpleType, a restriction on string.
5398
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
5399
            if not isinstance(value, str):
5400
                lineno = self.gds_get_node_lineno_()
5401
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
5402
                return False
5403
            value = value
5404
            enumerations = ['printed', 'typewritten', 'handwritten-cursive', 'handwritten-printscript', 'medieval-manuscript', 'other']
5405
            if value not in enumerations:
5406
                lineno = self.gds_get_node_lineno_()
5407
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ProductionSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
5408
                result = False
5409
    def has__content(self):
5410
        if (
5411
            self.AlternativeImage or
5412
            self.Coords is not None or
5413
            self.Graphemes is not None or
5414
            self.TextEquiv or
5415
            self.TextStyle is not None or
5416
            self.UserDefined is not None or
5417
            self.Labels
5418
        ):
5419
            return True
5420
        else:
5421
            return False
5422
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GlyphType', pretty_print=True):
5423
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('GlyphType')
5424
        if imported_ns_def_ is not None:
5425
            namespacedef_ = imported_ns_def_
5426
        if pretty_print:
5427
            eol_ = '\n'
5428
        else:
5429
            eol_ = ''
5430
        if self.original_tagname_ is not None and name_ == 'GlyphType':
5431
            name_ = self.original_tagname_
5432
        if UseCapturedNS_ and self.ns_prefix_:
5433
            namespaceprefix_ = self.ns_prefix_ + ':'
5434
        showIndent(outfile, level, pretty_print)
5435
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
5436
        already_processed = set()
5437
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='GlyphType')
5438
        if self.has__content():
5439
            outfile.write('>%s' % (eol_, ))
5440
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='GlyphType', pretty_print=pretty_print)
5441
            showIndent(outfile, level, pretty_print)
5442
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
5443
        else:
5444
            outfile.write('/>%s' % (eol_, ))
5445
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='GlyphType'):
5446
        if self.id is not None and 'id' not in already_processed:
5447
            already_processed.add('id')
5448
            outfile.write(' id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.id), input_name='id')), ))
5449
        if self.ligature is not None and 'ligature' not in already_processed:
5450
            already_processed.add('ligature')
5451
            outfile.write(' ligature="%s"' % self.gds_format_boolean(self.ligature, input_name='ligature'))
5452
        if self.symbol is not None and 'symbol' not in already_processed:
5453
            already_processed.add('symbol')
5454
            outfile.write(' symbol="%s"' % self.gds_format_boolean(self.symbol, input_name='symbol'))
5455
        if self.script is not None and 'script' not in already_processed:
5456
            already_processed.add('script')
5457
            outfile.write(' script=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.script), input_name='script')), ))
5458
        if self.production is not None and 'production' not in already_processed:
5459
            already_processed.add('production')
5460
            outfile.write(' production=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.production), input_name='production')), ))
5461
        if self.custom is not None and 'custom' not in already_processed:
5462
            already_processed.add('custom')
5463
            outfile.write(' custom=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.custom), input_name='custom')), ))
5464
        if self.comments is not None and 'comments' not in already_processed:
5465
            already_processed.add('comments')
5466
            outfile.write(' comments=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.comments), input_name='comments')), ))
5467 View Code Duplication
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GlyphType', fromsubclass_=False, pretty_print=True):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
5468
        if pretty_print:
5469
            eol_ = '\n'
5470
        else:
5471
            eol_ = ''
5472
        for AlternativeImage_ in self.AlternativeImage:
5473
            namespaceprefix_ = self.AlternativeImage_nsprefix_ + ':' if (UseCapturedNS_ and self.AlternativeImage_nsprefix_) else ''
5474
            AlternativeImage_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='AlternativeImage', pretty_print=pretty_print)
5475
        if self.Coords is not None:
5476
            namespaceprefix_ = self.Coords_nsprefix_ + ':' if (UseCapturedNS_ and self.Coords_nsprefix_) else ''
5477
            self.Coords.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Coords', pretty_print=pretty_print)
5478
        if self.Graphemes is not None:
5479
            namespaceprefix_ = self.Graphemes_nsprefix_ + ':' if (UseCapturedNS_ and self.Graphemes_nsprefix_) else ''
5480
            self.Graphemes.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Graphemes', pretty_print=pretty_print)
5481
        for TextEquiv_ in self.TextEquiv:
5482
            namespaceprefix_ = self.TextEquiv_nsprefix_ + ':' if (UseCapturedNS_ and self.TextEquiv_nsprefix_) else ''
5483
            TextEquiv_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TextEquiv', pretty_print=pretty_print)
5484
        if self.TextStyle is not None:
5485
            namespaceprefix_ = self.TextStyle_nsprefix_ + ':' if (UseCapturedNS_ and self.TextStyle_nsprefix_) else ''
5486
            self.TextStyle.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TextStyle', pretty_print=pretty_print)
5487
        if self.UserDefined is not None:
5488
            namespaceprefix_ = self.UserDefined_nsprefix_ + ':' if (UseCapturedNS_ and self.UserDefined_nsprefix_) else ''
5489
            self.UserDefined.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UserDefined', pretty_print=pretty_print)
5490
        for Labels_ in self.Labels:
5491
            namespaceprefix_ = self.Labels_nsprefix_ + ':' if (UseCapturedNS_ and self.Labels_nsprefix_) else ''
5492
            Labels_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Labels', pretty_print=pretty_print)
5493
    def to_etree(self, parent_element=None, name_='GlyphType', mapping_=None, reverse_mapping_=None, nsmap_=None):
5494
        if parent_element is None:
5495
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
5496
        else:
5497
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
5498
        if self.id is not None:
5499
            element.set('id', self.gds_format_string(self.id))
5500
        if self.ligature is not None:
5501
            element.set('ligature', self.gds_format_boolean(self.ligature))
5502
        if self.symbol is not None:
5503
            element.set('symbol', self.gds_format_boolean(self.symbol))
5504
        if self.script is not None:
5505
            element.set('script', self.gds_format_string(self.script))
5506
        if self.production is not None:
5507
            element.set('production', self.gds_format_string(self.production))
5508
        if self.custom is not None:
5509
            element.set('custom', self.gds_format_string(self.custom))
5510
        if self.comments is not None:
5511
            element.set('comments', self.gds_format_string(self.comments))
5512
        for AlternativeImage_ in self.AlternativeImage:
5513
            AlternativeImage_.to_etree(element, name_='AlternativeImage', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
5514
        if self.Coords is not None:
5515
            Coords_ = self.Coords
5516
            Coords_.to_etree(element, name_='Coords', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
5517
        if self.Graphemes is not None:
5518
            Graphemes_ = self.Graphemes
5519
            Graphemes_.to_etree(element, name_='Graphemes', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
5520
        for TextEquiv_ in self.TextEquiv:
5521
            TextEquiv_.to_etree(element, name_='TextEquiv', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
5522
        if self.TextStyle is not None:
5523
            TextStyle_ = self.TextStyle
5524
            TextStyle_.to_etree(element, name_='TextStyle', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
5525
        if self.UserDefined is not None:
5526
            UserDefined_ = self.UserDefined
5527
            UserDefined_.to_etree(element, name_='UserDefined', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
5528
        for Labels_ in self.Labels:
5529
            Labels_.to_etree(element, name_='Labels', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
5530
        if mapping_ is not None:
5531
            mapping_[id(self)] = element
5532
        if reverse_mapping_ is not None:
5533
            reverse_mapping_[element] = self
5534
        return element
5535
    def build(self, node, gds_collector_=None):
5536
        self.gds_collector_ = gds_collector_
5537
        if SaveElementTreeNode:
5538
            self.gds_elementtree_node_ = node
5539
        already_processed = set()
5540
        self.ns_prefix_ = node.prefix
5541
        self._buildAttributes(node, node.attrib, already_processed)
5542
        for child in node:
5543
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
5544
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
5545
        return self
5546
    def _buildAttributes(self, node, attrs, already_processed):
5547
        value = find_attr_value_('id', node)
5548
        if value is not None and 'id' not in already_processed:
5549
            already_processed.add('id')
5550
            self.id = value
5551
        value = find_attr_value_('ligature', node)
5552
        if value is not None and 'ligature' not in already_processed:
5553
            already_processed.add('ligature')
5554
            if value in ('true', '1'):
5555
                self.ligature = True
5556
            elif value in ('false', '0'):
5557
                self.ligature = False
5558
            else:
5559
                raise_parse_error(node, 'Bad boolean attribute')
5560
        value = find_attr_value_('symbol', node)
5561
        if value is not None and 'symbol' not in already_processed:
5562
            already_processed.add('symbol')
5563
            if value in ('true', '1'):
5564
                self.symbol = True
5565
            elif value in ('false', '0'):
5566
                self.symbol = False
5567
            else:
5568
                raise_parse_error(node, 'Bad boolean attribute')
5569
        value = find_attr_value_('script', node)
5570
        if value is not None and 'script' not in already_processed:
5571
            already_processed.add('script')
5572
            self.script = value
5573
            self.validate_ScriptSimpleType(self.script)    # validate type ScriptSimpleType
5574
        value = find_attr_value_('production', node)
5575
        if value is not None and 'production' not in already_processed:
5576
            already_processed.add('production')
5577
            self.production = value
5578
            self.validate_ProductionSimpleType(self.production)    # validate type ProductionSimpleType
5579
        value = find_attr_value_('custom', node)
5580
        if value is not None and 'custom' not in already_processed:
5581
            already_processed.add('custom')
5582
            self.custom = value
5583
        value = find_attr_value_('comments', node)
5584
        if value is not None and 'comments' not in already_processed:
5585
            already_processed.add('comments')
5586
            self.comments = value
5587 View Code Duplication
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
5588
        if nodeName_ == 'AlternativeImage':
5589
            obj_ = AlternativeImageType.factory(parent_object_=self)
5590
            obj_.build(child_, gds_collector_=gds_collector_)
5591
            self.AlternativeImage.append(obj_)
5592
            obj_.original_tagname_ = 'AlternativeImage'
5593
        elif nodeName_ == 'Coords':
5594
            obj_ = CoordsType.factory(parent_object_=self)
5595
            obj_.build(child_, gds_collector_=gds_collector_)
5596
            self.Coords = obj_
5597
            obj_.original_tagname_ = 'Coords'
5598
        elif nodeName_ == 'Graphemes':
5599
            obj_ = GraphemesType.factory(parent_object_=self)
5600
            obj_.build(child_, gds_collector_=gds_collector_)
5601
            self.Graphemes = obj_
5602
            obj_.original_tagname_ = 'Graphemes'
5603
        elif nodeName_ == 'TextEquiv':
5604
            obj_ = TextEquivType.factory(parent_object_=self)
5605
            obj_.build(child_, gds_collector_=gds_collector_)
5606
            self.TextEquiv.append(obj_)
5607
            obj_.original_tagname_ = 'TextEquiv'
5608
        elif nodeName_ == 'TextStyle':
5609
            obj_ = TextStyleType.factory(parent_object_=self)
5610
            obj_.build(child_, gds_collector_=gds_collector_)
5611
            self.TextStyle = obj_
5612
            obj_.original_tagname_ = 'TextStyle'
5613
        elif nodeName_ == 'UserDefined':
5614
            obj_ = UserDefinedType.factory(parent_object_=self)
5615
            obj_.build(child_, gds_collector_=gds_collector_)
5616
            self.UserDefined = obj_
5617
            obj_.original_tagname_ = 'UserDefined'
5618
        elif nodeName_ == 'Labels':
5619
            obj_ = LabelsType.factory(parent_object_=self)
5620
            obj_.build(child_, gds_collector_=gds_collector_)
5621
            self.Labels.append(obj_)
5622
            obj_.original_tagname_ = 'Labels'
5623
    def __hash__(self):
5624
        return hash(self.id)
5625 View Code Duplication
    def invalidate_AlternativeImage(self, feature_selector=None):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
5626
        """
5627
        Remove derived images from this segment (due to changed coordinates).
5628
    
5629
        If `feature_selector` is not none, remove only images with
5630
        matching ``@comments``, e.g. ``feature_selector=cropped,deskewed``.
5631
        """
5632
        existing_images = self.AlternativeImage or []
5633
        removed_images = []
5634
        if feature_selector:
5635
            new_images = []
5636
            for image in existing_images:
5637
                features = image.get_comments() or ''
5638
                if any(feature in features.split(',')
5639
                       for feature in feature_selector.split(',') if feature):
5640
                    removed_images.append(image)
5641
                else:
5642
                    new_images.append(image)
5643
            self.AlternativeImage = new_images
5644
        else:
5645
            removed_images = existing_images
5646
            self.AlternativeImage = []
5647
        if hasattr(self, 'id'):
5648
            name = self.id
5649
        elif hasattr(self, 'parent_object_') and hasattr(self.parent_object_, 'pcGtsId'):
5650
            name = self.parent_object_.pcGtsId
5651
        else:
5652
            name = ''
5653
        for image in removed_images:
5654
            self.gds_collector_.add_message('Removing AlternativeImage %s from "%s"' % (
5655
                image.get_comments() or '', name))
5656
    def set_Coords(self, Coords):
5657
        """
5658
        Set coordinate polygon by given :py:class:`CoordsType` object.
5659
        Moreover, invalidate self's ``pc:AlternativeImage``s
5660
        (because they will have been cropped with a bbox
5661
        of the previous polygon).
5662
        """
5663
        if hasattr(self, 'invalidate_AlternativeImage'):
5664
            # RegionType, TextLineType, WordType, GlyphType:
5665
            self.invalidate_AlternativeImage()
5666
        elif hasattr(self, 'parent_object_') and hasattr(self.parent_object_, 'invalidate_AlternativeImage'):
5667
            # BorderType:
5668
            self.parent_object_.invalidate_AlternativeImage(feature_selector='cropped')
5669
        self.Coords = Coords
5670
# end class GlyphType
5671
5672
5673
class TextEquivType(GeneratedsSuper):
5674
    """index --
5675
    Used for sort order in case multiple TextEquivs are defined.
5676
    The text content with the lowest index should be interpreted
5677
    as the main text content.
5678
      
5679
    * conf -- OCR confidence value (between 0 and 1)
5680
    * dataType --
5681
      Type of text content (is it free text or a number, for instance).
5682
      This is only a descriptive attribute, the text type
5683
      is not checked during XML validation.
5684
      
5685
    * dataTypeDetails --
5686
      Refinement for dataType attribute. Can be a regular expression, for instance.
5687
      
5688
    * PlainText --
5689
      Text in a "simple" form (ASCII or extended ASCII
5690
      as mostly used for typing). I.e. no use of
5691
      special characters for ligatures (should be
5692
      stored as two separate characters) etc.
5693
      
5694
    * Unicode --
5695
      Correct encoding of the original, always using
5696
      the corresponding Unicode code point. I.e.
5697
      ligatures have to be represented as one
5698
      character etc.
5699
    
5700
    """
5701
    __hash__ = GeneratedsSuper.__hash__
5702
    member_data_items_ = [
5703
        MemberSpec_('index', 'indexType', 0, 1, {'use': 'optional', 'name': 'index'}),
5704
        MemberSpec_('conf', 'pc:ConfSimpleType', 0, 1, {'use': 'optional', 'name': 'conf'}),
5705
        MemberSpec_('dataType', 'pc:TextDataTypeSimpleType', 0, 1, {'use': 'optional', 'name': 'dataType'}),
5706
        MemberSpec_('dataTypeDetails', 'string', 0, 1, {'use': 'optional', 'name': 'dataTypeDetails'}),
5707
        MemberSpec_('comments', 'string', 0, 1, {'use': 'optional', 'name': 'comments'}),
5708
        MemberSpec_('PlainText', 'string', 0, 1, {'minOccurs': '0', 'name': 'PlainText', 'type': 'string'}, None),
5709
        MemberSpec_('Unicode', 'string', 0, 0, {'name': 'Unicode', 'type': 'string'}, None),
5710
    ]
5711
    subclass = None
5712
    superclass = None
5713
    def __init__(self, index=None, conf=None, dataType=None, dataTypeDetails=None, comments=None, PlainText=None, Unicode=None, gds_collector_=None, **kwargs_):
5714
        self.gds_collector_ = gds_collector_
5715
        self.gds_elementtree_node_ = None
5716
        self.original_tagname_ = None
5717
        self.parent_object_ = kwargs_.get('parent_object_')
5718
        self.ns_prefix_ = None
5719
        self.index = _cast(int, index)
5720
        self.index_nsprefix_ = "pc"
5721
        self.conf = _cast(float, conf)
5722
        self.conf_nsprefix_ = "pc"
5723
        self.dataType = _cast(None, dataType)
5724
        self.dataType_nsprefix_ = "pc"
5725
        self.dataTypeDetails = _cast(None, dataTypeDetails)
5726
        self.dataTypeDetails_nsprefix_ = "pc"
5727
        self.comments = _cast(None, comments)
5728
        self.comments_nsprefix_ = "pc"
5729
        self.PlainText = PlainText
5730
        self.PlainText_nsprefix_ = "pc"
5731
        self.Unicode = Unicode
5732
        self.Unicode_nsprefix_ = "pc"
5733
    def factory(*args_, **kwargs_):
5734
        if CurrentSubclassModule_ is not None:
5735
            subclass = getSubclassFromModule_(
5736
                CurrentSubclassModule_, TextEquivType)
5737
            if subclass is not None:
5738
                return subclass(*args_, **kwargs_)
5739
        if TextEquivType.subclass:
5740
            return TextEquivType.subclass(*args_, **kwargs_)
5741
        else:
5742
            return TextEquivType(*args_, **kwargs_)
5743
    factory = staticmethod(factory)
5744
    def get_ns_prefix_(self):
5745
        return self.ns_prefix_
5746
    def set_ns_prefix_(self, ns_prefix):
5747
        self.ns_prefix_ = ns_prefix
5748
    def get_PlainText(self):
5749
        return self.PlainText
5750
    def set_PlainText(self, PlainText):
5751
        self.PlainText = PlainText
5752
    def get_Unicode(self):
5753
        return self.Unicode
5754
    def set_Unicode(self, Unicode):
5755
        self.Unicode = Unicode
5756
    def get_index(self):
5757
        return self.index
5758
    def set_index(self, index):
5759
        self.index = index
5760
    def get_conf(self):
5761
        return self.conf
5762
    def set_conf(self, conf):
5763
        self.conf = conf
5764
    def get_dataType(self):
5765
        return self.dataType
5766
    def set_dataType(self, dataType):
5767
        self.dataType = dataType
5768
    def get_dataTypeDetails(self):
5769
        return self.dataTypeDetails
5770
    def set_dataTypeDetails(self, dataTypeDetails):
5771
        self.dataTypeDetails = dataTypeDetails
5772
    def get_comments(self):
5773
        return self.comments
5774
    def set_comments(self, comments):
5775
        self.comments = comments
5776 View Code Duplication
    def validate_indexType(self, value):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
5777
        # Validate type indexType, a restriction on integer.
5778
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
5779
            if not isinstance(value, int):
5780
                lineno = self.gds_get_node_lineno_()
5781
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (int)' % {"value": value, "lineno": lineno, })
5782
                return False
5783
            if value < 0:
5784
                lineno = self.gds_get_node_lineno_()
5785
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd minInclusive restriction on indexType' % {"value": value, "lineno": lineno} )
5786
                result = False
5787 View Code Duplication
    def validate_ConfSimpleType(self, value):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
5788
        # Validate type pc:ConfSimpleType, a restriction on float.
5789
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
5790
            if not isinstance(value, float):
5791
                lineno = self.gds_get_node_lineno_()
5792
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (float)' % {"value": value, "lineno": lineno, })
5793
                return False
5794
            if value < 0:
5795
                lineno = self.gds_get_node_lineno_()
5796
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd minInclusive restriction on ConfSimpleType' % {"value": value, "lineno": lineno} )
5797
                result = False
5798
            if value > 1:
5799
                lineno = self.gds_get_node_lineno_()
5800
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxInclusive restriction on ConfSimpleType' % {"value": value, "lineno": lineno} )
5801
                result = False
5802
    def validate_TextDataTypeSimpleType(self, value):
5803
        # Validate type pc:TextDataTypeSimpleType, a restriction on string.
5804
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
5805
            if not isinstance(value, str):
5806
                lineno = self.gds_get_node_lineno_()
5807
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
5808
                return False
5809
            value = value
5810
            enumerations = ['xsd:decimal', 'xsd:float', 'xsd:integer', 'xsd:boolean', 'xsd:date', 'xsd:time', 'xsd:dateTime', 'xsd:string', 'other']
5811
            if value not in enumerations:
5812
                lineno = self.gds_get_node_lineno_()
5813
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on TextDataTypeSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
5814
                result = False
5815
    def has__content(self):
5816
        if (
5817
            self.PlainText is not None or
5818
            self.Unicode is not None
5819
        ):
5820
            return True
5821
        else:
5822
            return False
5823
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15" xmlns:None="http://www.w3.org/2001/XMLSchema" ', name_='TextEquivType', pretty_print=True):
5824
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('TextEquivType')
5825
        if imported_ns_def_ is not None:
5826
            namespacedef_ = imported_ns_def_
5827
        if pretty_print:
5828
            eol_ = '\n'
5829
        else:
5830
            eol_ = ''
5831
        if self.original_tagname_ is not None and name_ == 'TextEquivType':
5832
            name_ = self.original_tagname_
5833
        if UseCapturedNS_ and self.ns_prefix_:
5834
            namespaceprefix_ = self.ns_prefix_ + ':'
5835
        showIndent(outfile, level, pretty_print)
5836
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
5837
        already_processed = set()
5838
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='TextEquivType')
5839
        if self.has__content():
5840
            outfile.write('>%s' % (eol_, ))
5841
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='TextEquivType', pretty_print=pretty_print)
5842
            showIndent(outfile, level, pretty_print)
5843
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
5844
        else:
5845
            outfile.write('/>%s' % (eol_, ))
5846
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='TextEquivType'):
5847
        if self.index is not None and 'index' not in already_processed:
5848
            already_processed.add('index')
5849
            outfile.write(' index="%s"' % self.gds_format_integer(self.index, input_name='index'))
5850
        if self.conf is not None and 'conf' not in already_processed:
5851
            already_processed.add('conf')
5852
            outfile.write(' conf="%s"' % self.gds_format_float(self.conf, input_name='conf'))
5853
        if self.dataType is not None and 'dataType' not in already_processed:
5854
            already_processed.add('dataType')
5855
            outfile.write(' dataType=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.dataType), input_name='dataType')), ))
5856
        if self.dataTypeDetails is not None and 'dataTypeDetails' not in already_processed:
5857
            already_processed.add('dataTypeDetails')
5858
            outfile.write(' dataTypeDetails=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.dataTypeDetails), input_name='dataTypeDetails')), ))
5859
        if self.comments is not None and 'comments' not in already_processed:
5860
            already_processed.add('comments')
5861
            outfile.write(' comments=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.comments), input_name='comments')), ))
5862
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15" xmlns:None="http://www.w3.org/2001/XMLSchema" ', name_='TextEquivType', fromsubclass_=False, pretty_print=True):
5863
        if pretty_print:
5864
            eol_ = '\n'
5865
        else:
5866
            eol_ = ''
5867
        if self.PlainText is not None:
5868
            namespaceprefix_ = self.PlainText_nsprefix_ + ':' if (UseCapturedNS_ and self.PlainText_nsprefix_) else ''
5869
            showIndent(outfile, level, pretty_print)
5870
            outfile.write('<%sPlainText>%s</%sPlainText>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.PlainText), input_name='PlainText')), namespaceprefix_ , eol_))
5871
        if self.Unicode is not None:
5872
            namespaceprefix_ = self.Unicode_nsprefix_ + ':' if (UseCapturedNS_ and self.Unicode_nsprefix_) else ''
5873
            showIndent(outfile, level, pretty_print)
5874
            outfile.write('<%sUnicode>%s</%sUnicode>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.Unicode), input_name='Unicode')), namespaceprefix_ , eol_))
5875
    def to_etree(self, parent_element=None, name_='TextEquivType', mapping_=None, reverse_mapping_=None, nsmap_=None):
5876
        if parent_element is None:
5877
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
5878
        else:
5879
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
5880
        if self.index is not None:
5881
            element.set('index', self.gds_format_integer(self.index))
5882
        if self.conf is not None:
5883
            element.set('conf', self.gds_format_float(self.conf))
5884
        if self.dataType is not None:
5885
            element.set('dataType', self.gds_format_string(self.dataType))
5886
        if self.dataTypeDetails is not None:
5887
            element.set('dataTypeDetails', self.gds_format_string(self.dataTypeDetails))
5888
        if self.comments is not None:
5889
            element.set('comments', self.gds_format_string(self.comments))
5890
        if self.PlainText is not None:
5891
            PlainText_ = self.PlainText
5892
            etree_.SubElement(element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}PlainText').text = self.gds_format_string(PlainText_)
5893
        if self.Unicode is not None:
5894
            Unicode_ = self.Unicode
5895
            etree_.SubElement(element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}Unicode').text = self.gds_format_string(Unicode_)
5896
        if mapping_ is not None:
5897
            mapping_[id(self)] = element
5898
        if reverse_mapping_ is not None:
5899
            reverse_mapping_[element] = self
5900
        return element
5901
    def build(self, node, gds_collector_=None):
5902
        self.gds_collector_ = gds_collector_
5903
        if SaveElementTreeNode:
5904
            self.gds_elementtree_node_ = node
5905
        already_processed = set()
5906
        self.ns_prefix_ = node.prefix
5907
        self._buildAttributes(node, node.attrib, already_processed)
5908
        for child in node:
5909
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
5910
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
5911
        return self
5912
    def _buildAttributes(self, node, attrs, already_processed):
5913
        value = find_attr_value_('index', node)
5914
        if value is not None and 'index' not in already_processed:
5915
            already_processed.add('index')
5916
            self.index = self.gds_parse_integer(value, node, 'index')
5917
            self.validate_indexType(self.index)    # validate type indexType
5918
        value = find_attr_value_('conf', node)
5919
        if value is not None and 'conf' not in already_processed:
5920
            already_processed.add('conf')
5921
            value = self.gds_parse_float(value, node, 'conf')
5922
            self.conf = value
5923
            self.validate_ConfSimpleType(self.conf)    # validate type ConfSimpleType
5924
        value = find_attr_value_('dataType', node)
5925
        if value is not None and 'dataType' not in already_processed:
5926
            already_processed.add('dataType')
5927
            self.dataType = value
5928
            self.validate_TextDataTypeSimpleType(self.dataType)    # validate type TextDataTypeSimpleType
5929
        value = find_attr_value_('dataTypeDetails', node)
5930
        if value is not None and 'dataTypeDetails' not in already_processed:
5931
            already_processed.add('dataTypeDetails')
5932
            self.dataTypeDetails = value
5933
        value = find_attr_value_('comments', node)
5934
        if value is not None and 'comments' not in already_processed:
5935
            already_processed.add('comments')
5936
            self.comments = value
5937
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
5938
        if nodeName_ == 'PlainText':
5939
            value_ = child_.text
5940
            value_ = self.gds_parse_string(value_, node, 'PlainText')
5941
            value_ = self.gds_validate_string(value_, node, 'PlainText')
5942
            self.PlainText = value_
5943
5944
        elif nodeName_ == 'Unicode':
5945
            value_ = child_.text
5946
            value_ = self.gds_parse_string(value_, node, 'Unicode')
5947
            value_ = self.gds_validate_string(value_, node, 'Unicode')
5948
            self.Unicode = value_
5949
5950
    def __hash__(self):
5951
        return hash(self.id)
5952
# end class TextEquivType
5953
5954
5955 View Code Duplication
class GridType(GeneratedsSuper):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
5956
    """GridType --
5957
    Matrix of grid points defining the table grid on the page.
5958
      
5959
    * GridPoints --
5960
      One row in the grid point matrix.
5961
      Points with x,y coordinates.
5962
      (note: for a table with n table rows there should be n+1 grid rows)
5963
    
5964
    """
5965
    __hash__ = GeneratedsSuper.__hash__
5966
    member_data_items_ = [
5967
        MemberSpec_('GridPoints', 'GridPointsType', 1, 0, {'maxOccurs': 'unbounded', 'minOccurs': '2', 'name': 'GridPoints', 'type': 'GridPointsType'}, None),
5968
    ]
5969
    subclass = None
5970
    superclass = None
5971
    def __init__(self, GridPoints=None, gds_collector_=None, **kwargs_):
5972
        self.gds_collector_ = gds_collector_
5973
        self.gds_elementtree_node_ = None
5974
        self.original_tagname_ = None
5975
        self.parent_object_ = kwargs_.get('parent_object_')
5976
        self.ns_prefix_ = "pc"
5977
        if GridPoints is None:
5978
            self.GridPoints = []
5979
        else:
5980
            self.GridPoints = GridPoints
5981
        self.GridPoints_nsprefix_ = "pc"
5982
    def factory(*args_, **kwargs_):
5983
        if CurrentSubclassModule_ is not None:
5984
            subclass = getSubclassFromModule_(
5985
                CurrentSubclassModule_, GridType)
5986
            if subclass is not None:
5987
                return subclass(*args_, **kwargs_)
5988
        if GridType.subclass:
5989
            return GridType.subclass(*args_, **kwargs_)
5990
        else:
5991
            return GridType(*args_, **kwargs_)
5992
    factory = staticmethod(factory)
5993
    def get_ns_prefix_(self):
5994
        return self.ns_prefix_
5995
    def set_ns_prefix_(self, ns_prefix):
5996
        self.ns_prefix_ = ns_prefix
5997
    def get_GridPoints(self):
5998
        return self.GridPoints
5999
    def set_GridPoints(self, GridPoints):
6000
        self.GridPoints = GridPoints
6001
    def add_GridPoints(self, value):
6002
        self.GridPoints.append(value)
6003
    def insert_GridPoints_at(self, index, value):
6004
        self.GridPoints.insert(index, value)
6005
    def replace_GridPoints_at(self, index, value):
6006
        self.GridPoints[index] = value
6007
    def has__content(self):
6008
        if (
6009
            self.GridPoints
6010
        ):
6011
            return True
6012
        else:
6013
            return False
6014
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GridType', pretty_print=True):
6015
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('GridType')
6016
        if imported_ns_def_ is not None:
6017
            namespacedef_ = imported_ns_def_
6018
        if pretty_print:
6019
            eol_ = '\n'
6020
        else:
6021
            eol_ = ''
6022
        if self.original_tagname_ is not None and name_ == 'GridType':
6023
            name_ = self.original_tagname_
6024
        if UseCapturedNS_ and self.ns_prefix_:
6025
            namespaceprefix_ = self.ns_prefix_ + ':'
6026
        showIndent(outfile, level, pretty_print)
6027
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
6028
        already_processed = set()
6029
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='GridType')
6030
        if self.has__content():
6031
            outfile.write('>%s' % (eol_, ))
6032
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='GridType', pretty_print=pretty_print)
6033
            showIndent(outfile, level, pretty_print)
6034
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
6035
        else:
6036
            outfile.write('/>%s' % (eol_, ))
6037
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='GridType'):
6038
        pass
6039
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GridType', fromsubclass_=False, pretty_print=True):
6040
        if pretty_print:
6041
            eol_ = '\n'
6042
        else:
6043
            eol_ = ''
6044
        for GridPoints_ in self.GridPoints:
6045
            namespaceprefix_ = self.GridPoints_nsprefix_ + ':' if (UseCapturedNS_ and self.GridPoints_nsprefix_) else ''
6046
            GridPoints_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='GridPoints', pretty_print=pretty_print)
6047
    def to_etree(self, parent_element=None, name_='GridType', mapping_=None, reverse_mapping_=None, nsmap_=None):
6048
        if parent_element is None:
6049
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
6050
        else:
6051
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
6052
        for GridPoints_ in self.GridPoints:
6053
            GridPoints_.to_etree(element, name_='GridPoints', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
6054
        if mapping_ is not None:
6055
            mapping_[id(self)] = element
6056
        if reverse_mapping_ is not None:
6057
            reverse_mapping_[element] = self
6058
        return element
6059
    def build(self, node, gds_collector_=None):
6060
        self.gds_collector_ = gds_collector_
6061
        if SaveElementTreeNode:
6062
            self.gds_elementtree_node_ = node
6063
        already_processed = set()
6064
        self.ns_prefix_ = node.prefix
6065
        self._buildAttributes(node, node.attrib, already_processed)
6066
        for child in node:
6067
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
6068
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
6069
        return self
6070
    def _buildAttributes(self, node, attrs, already_processed):
6071
        pass
6072
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
6073
        if nodeName_ == 'GridPoints':
6074
            obj_ = GridPointsType.factory(parent_object_=self)
6075
            obj_.build(child_, gds_collector_=gds_collector_)
6076
            self.GridPoints.append(obj_)
6077
            obj_.original_tagname_ = 'GridPoints'
6078
    def __hash__(self):
6079
        return hash(self.id)
6080
# end class GridType
6081
6082
6083
class GridPointsType(GeneratedsSuper):
6084
    """GridPointsType -- Points with x,y coordinates.
6085
    index --
6086
    The grid row index
6087
    
6088
    """
6089
    __hash__ = GeneratedsSuper.__hash__
6090
    member_data_items_ = [
6091
        MemberSpec_('index', 'int', 0, 0, {'use': 'required', 'name': 'index'}),
6092
        MemberSpec_('points', 'pc:PointsType', 0, 0, {'use': 'required', 'name': 'points'}),
6093
    ]
6094
    subclass = None
6095
    superclass = None
6096
    def __init__(self, index=None, points=None, gds_collector_=None, **kwargs_):
6097
        self.gds_collector_ = gds_collector_
6098
        self.gds_elementtree_node_ = None
6099
        self.original_tagname_ = None
6100
        self.parent_object_ = kwargs_.get('parent_object_')
6101
        self.ns_prefix_ = "pc"
6102
        self.index = _cast(int, index)
6103
        self.index_nsprefix_ = "pc"
6104
        self.points = _cast(None, points)
6105
        self.points_nsprefix_ = "pc"
6106
    def factory(*args_, **kwargs_):
6107
        if CurrentSubclassModule_ is not None:
6108
            subclass = getSubclassFromModule_(
6109
                CurrentSubclassModule_, GridPointsType)
6110
            if subclass is not None:
6111
                return subclass(*args_, **kwargs_)
6112
        if GridPointsType.subclass:
6113
            return GridPointsType.subclass(*args_, **kwargs_)
6114
        else:
6115
            return GridPointsType(*args_, **kwargs_)
6116
    factory = staticmethod(factory)
6117
    def get_ns_prefix_(self):
6118
        return self.ns_prefix_
6119
    def set_ns_prefix_(self, ns_prefix):
6120
        self.ns_prefix_ = ns_prefix
6121
    def get_index(self):
6122
        return self.index
6123
    def set_index(self, index):
6124
        self.index = index
6125
    def get_points(self):
6126
        return self.points
6127
    def set_points(self, points):
6128
        self.points = points
6129 View Code Duplication
    def validate_PointsType(self, value):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
6130
        # Validate type pc:PointsType, a restriction on string.
6131
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
6132
            if not isinstance(value, str):
6133
                lineno = self.gds_get_node_lineno_()
6134
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
6135
                return False
6136
            if not self.gds_validate_simple_patterns(
6137
                    self.validate_PointsType_patterns_, value):
6138
                self.gds_collector_.add_message('Value "%s" does not match xsd pattern restrictions: %s' % (encode_str_2_3(value), self.validate_PointsType_patterns_, ))
6139
    validate_PointsType_patterns_ = [['^(([0-9]+,[0-9]+ )+([0-9]+,[0-9]+))$']]
6140
    def has__content(self):
6141
        if (
6142
6143
        ):
6144
            return True
6145
        else:
6146
            return False
6147
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GridPointsType', pretty_print=True):
6148
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('GridPointsType')
6149
        if imported_ns_def_ is not None:
6150
            namespacedef_ = imported_ns_def_
6151
        if pretty_print:
6152
            eol_ = '\n'
6153
        else:
6154
            eol_ = ''
6155
        if self.original_tagname_ is not None and name_ == 'GridPointsType':
6156
            name_ = self.original_tagname_
6157
        if UseCapturedNS_ and self.ns_prefix_:
6158
            namespaceprefix_ = self.ns_prefix_ + ':'
6159
        showIndent(outfile, level, pretty_print)
6160
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
6161
        already_processed = set()
6162
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='GridPointsType')
6163
        if self.has__content():
6164
            outfile.write('>%s' % (eol_, ))
6165
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='GridPointsType', pretty_print=pretty_print)
6166
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
6167
        else:
6168
            outfile.write('/>%s' % (eol_, ))
6169
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='GridPointsType'):
6170
        if self.index is not None and 'index' not in already_processed:
6171
            already_processed.add('index')
6172
            outfile.write(' index="%s"' % self.gds_format_integer(self.index, input_name='index'))
6173
        if self.points is not None and 'points' not in already_processed:
6174
            already_processed.add('points')
6175
            outfile.write(' points=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.points), input_name='points')), ))
6176
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GridPointsType', fromsubclass_=False, pretty_print=True):
6177
        pass
6178 View Code Duplication
    def to_etree(self, parent_element=None, name_='GridPointsType', mapping_=None, reverse_mapping_=None, nsmap_=None):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
6179
        if parent_element is None:
6180
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
6181
        else:
6182
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
6183
        if self.index is not None:
6184
            element.set('index', self.gds_format_integer(self.index))
6185
        if self.points is not None:
6186
            element.set('points', self.gds_format_string(self.points))
6187
        if mapping_ is not None:
6188
            mapping_[id(self)] = element
6189
        if reverse_mapping_ is not None:
6190
            reverse_mapping_[element] = self
6191
        return element
6192
    def build(self, node, gds_collector_=None):
6193
        self.gds_collector_ = gds_collector_
6194
        if SaveElementTreeNode:
6195
            self.gds_elementtree_node_ = node
6196
        already_processed = set()
6197
        self.ns_prefix_ = node.prefix
6198
        self._buildAttributes(node, node.attrib, already_processed)
6199
        for child in node:
6200
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
6201
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
6202
        return self
6203
    def _buildAttributes(self, node, attrs, already_processed):
6204
        value = find_attr_value_('index', node)
6205
        if value is not None and 'index' not in already_processed:
6206
            already_processed.add('index')
6207
            self.index = self.gds_parse_integer(value, node, 'index')
6208
        value = find_attr_value_('points', node)
6209
        if value is not None and 'points' not in already_processed:
6210
            already_processed.add('points')
6211
            self.points = value
6212
            self.validate_PointsType(self.points)    # validate type PointsType
6213
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
6214
        pass
6215
    def __hash__(self):
6216
        return hash(self.id)
6217
# end class GridPointsType
6218
6219
6220 View Code Duplication
class PrintSpaceType(GeneratedsSuper):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
6221
    """PrintSpaceType --
6222
    Determines the effective area on the paper of a printed page.
6223
    Its size is equal for all pages of a book
6224
    (exceptions: titlepage, multipage pictures).
6225
    It contains all living elements (except marginals)
6226
    like body type, footnotes, headings, running titles.
6227
    It does not contain pagenumber (if not part of running title),
6228
    marginals, signature mark, preview words.
6229
    
6230
    """
6231
    __hash__ = GeneratedsSuper.__hash__
6232
    member_data_items_ = [
6233
        MemberSpec_('Coords', 'CoordsType', 0, 0, {'name': 'Coords', 'type': 'CoordsType'}, None),
6234
    ]
6235
    subclass = None
6236
    superclass = None
6237
    def __init__(self, Coords=None, gds_collector_=None, **kwargs_):
6238
        self.gds_collector_ = gds_collector_
6239
        self.gds_elementtree_node_ = None
6240
        self.original_tagname_ = None
6241
        self.parent_object_ = kwargs_.get('parent_object_')
6242
        self.ns_prefix_ = "pc"
6243
        self.Coords = Coords
6244
        self.Coords_nsprefix_ = "pc"
6245
    def factory(*args_, **kwargs_):
6246
        if CurrentSubclassModule_ is not None:
6247
            subclass = getSubclassFromModule_(
6248
                CurrentSubclassModule_, PrintSpaceType)
6249
            if subclass is not None:
6250
                return subclass(*args_, **kwargs_)
6251
        if PrintSpaceType.subclass:
6252
            return PrintSpaceType.subclass(*args_, **kwargs_)
6253
        else:
6254
            return PrintSpaceType(*args_, **kwargs_)
6255
    factory = staticmethod(factory)
6256
    def get_ns_prefix_(self):
6257
        return self.ns_prefix_
6258
    def set_ns_prefix_(self, ns_prefix):
6259
        self.ns_prefix_ = ns_prefix
6260
    def get_Coords(self):
6261
        return self.Coords
6262
    def set_Coords(self, Coords):
6263
        self.Coords = Coords
6264
    def has__content(self):
6265
        if (
6266
            self.Coords is not None
6267
        ):
6268
            return True
6269
        else:
6270
            return False
6271
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='PrintSpaceType', pretty_print=True):
6272
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('PrintSpaceType')
6273
        if imported_ns_def_ is not None:
6274
            namespacedef_ = imported_ns_def_
6275
        if pretty_print:
6276
            eol_ = '\n'
6277
        else:
6278
            eol_ = ''
6279
        if self.original_tagname_ is not None and name_ == 'PrintSpaceType':
6280
            name_ = self.original_tagname_
6281
        if UseCapturedNS_ and self.ns_prefix_:
6282
            namespaceprefix_ = self.ns_prefix_ + ':'
6283
        showIndent(outfile, level, pretty_print)
6284
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
6285
        already_processed = set()
6286
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='PrintSpaceType')
6287
        if self.has__content():
6288
            outfile.write('>%s' % (eol_, ))
6289
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='PrintSpaceType', pretty_print=pretty_print)
6290
            showIndent(outfile, level, pretty_print)
6291
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
6292
        else:
6293
            outfile.write('/>%s' % (eol_, ))
6294
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='PrintSpaceType'):
6295
        pass
6296
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='PrintSpaceType', fromsubclass_=False, pretty_print=True):
6297
        if pretty_print:
6298
            eol_ = '\n'
6299
        else:
6300
            eol_ = ''
6301
        if self.Coords is not None:
6302
            namespaceprefix_ = self.Coords_nsprefix_ + ':' if (UseCapturedNS_ and self.Coords_nsprefix_) else ''
6303
            self.Coords.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Coords', pretty_print=pretty_print)
6304
    def to_etree(self, parent_element=None, name_='PrintSpaceType', mapping_=None, reverse_mapping_=None, nsmap_=None):
6305
        if parent_element is None:
6306
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
6307
        else:
6308
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
6309
        if self.Coords is not None:
6310
            Coords_ = self.Coords
6311
            Coords_.to_etree(element, name_='Coords', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
6312
        if mapping_ is not None:
6313
            mapping_[id(self)] = element
6314
        if reverse_mapping_ is not None:
6315
            reverse_mapping_[element] = self
6316
        return element
6317
    def build(self, node, gds_collector_=None):
6318
        self.gds_collector_ = gds_collector_
6319
        if SaveElementTreeNode:
6320
            self.gds_elementtree_node_ = node
6321
        already_processed = set()
6322
        self.ns_prefix_ = node.prefix
6323
        self._buildAttributes(node, node.attrib, already_processed)
6324
        for child in node:
6325
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
6326
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
6327
        return self
6328
    def _buildAttributes(self, node, attrs, already_processed):
6329
        pass
6330
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
6331
        if nodeName_ == 'Coords':
6332
            obj_ = CoordsType.factory(parent_object_=self)
6333
            obj_.build(child_, gds_collector_=gds_collector_)
6334
            self.Coords = obj_
6335
            obj_.original_tagname_ = 'Coords'
6336
    def __hash__(self):
6337
        return hash(self.id)
6338
# end class PrintSpaceType
6339
6340
6341
class ReadingOrderType(GeneratedsSuper):
6342
    """ReadingOrderType --
6343
    Definition of the reading order within the page.
6344
    To express a reading order between elements
6345
    they have to be included in an OrderedGroup.
6346
    Groups may contain further groups.
6347
      
6348
    * conf -- Confidence value (between 0 and 1)
6349
    
6350
    """
6351
    __hash__ = GeneratedsSuper.__hash__
6352
    member_data_items_ = [
6353
        MemberSpec_('conf', 'pc:ConfSimpleType', 0, 1, {'use': 'optional', 'name': 'conf'}),
6354
        MemberSpec_('OrderedGroup', 'OrderedGroupType', 0, 0, {'name': 'OrderedGroup', 'type': 'OrderedGroupType'}, 2),
6355
        MemberSpec_('UnorderedGroup', 'UnorderedGroupType', 0, 0, {'name': 'UnorderedGroup', 'type': 'UnorderedGroupType'}, 2),
6356
    ]
6357
    subclass = None
6358
    superclass = None
6359
    def __init__(self, conf=None, OrderedGroup=None, UnorderedGroup=None, gds_collector_=None, **kwargs_):
6360
        self.gds_collector_ = gds_collector_
6361
        self.gds_elementtree_node_ = None
6362
        self.original_tagname_ = None
6363
        self.parent_object_ = kwargs_.get('parent_object_')
6364
        self.ns_prefix_ = "pc"
6365
        self.conf = _cast(float, conf)
6366
        self.conf_nsprefix_ = "pc"
6367
        self.OrderedGroup = OrderedGroup
6368
        self.OrderedGroup_nsprefix_ = "pc"
6369
        self.UnorderedGroup = UnorderedGroup
6370
        self.UnorderedGroup_nsprefix_ = "pc"
6371
    def factory(*args_, **kwargs_):
6372
        if CurrentSubclassModule_ is not None:
6373
            subclass = getSubclassFromModule_(
6374
                CurrentSubclassModule_, ReadingOrderType)
6375
            if subclass is not None:
6376
                return subclass(*args_, **kwargs_)
6377
        if ReadingOrderType.subclass:
6378
            return ReadingOrderType.subclass(*args_, **kwargs_)
6379
        else:
6380
            return ReadingOrderType(*args_, **kwargs_)
6381
    factory = staticmethod(factory)
6382
    def get_ns_prefix_(self):
6383
        return self.ns_prefix_
6384
    def set_ns_prefix_(self, ns_prefix):
6385
        self.ns_prefix_ = ns_prefix
6386
    def get_OrderedGroup(self):
6387
        return self.OrderedGroup
6388
    def set_OrderedGroup(self, OrderedGroup):
6389
        self.OrderedGroup = OrderedGroup
6390
    def get_UnorderedGroup(self):
6391
        return self.UnorderedGroup
6392
    def set_UnorderedGroup(self, UnorderedGroup):
6393
        self.UnorderedGroup = UnorderedGroup
6394
    def get_conf(self):
6395
        return self.conf
6396
    def set_conf(self, conf):
6397
        self.conf = conf
6398 View Code Duplication
    def validate_ConfSimpleType(self, value):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
6399
        # Validate type pc:ConfSimpleType, a restriction on float.
6400
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
6401
            if not isinstance(value, float):
6402
                lineno = self.gds_get_node_lineno_()
6403
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (float)' % {"value": value, "lineno": lineno, })
6404
                return False
6405
            if value < 0:
6406
                lineno = self.gds_get_node_lineno_()
6407
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd minInclusive restriction on ConfSimpleType' % {"value": value, "lineno": lineno} )
6408
                result = False
6409
            if value > 1:
6410
                lineno = self.gds_get_node_lineno_()
6411
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxInclusive restriction on ConfSimpleType' % {"value": value, "lineno": lineno} )
6412
                result = False
6413
    def has__content(self):
6414
        if (
6415
            self.OrderedGroup is not None or
6416
            self.UnorderedGroup is not None
6417
        ):
6418
            return True
6419
        else:
6420
            return False
6421
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='ReadingOrderType', pretty_print=True):
6422
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('ReadingOrderType')
6423
        if imported_ns_def_ is not None:
6424
            namespacedef_ = imported_ns_def_
6425
        if pretty_print:
6426
            eol_ = '\n'
6427
        else:
6428
            eol_ = ''
6429
        if self.original_tagname_ is not None and name_ == 'ReadingOrderType':
6430
            name_ = self.original_tagname_
6431
        if UseCapturedNS_ and self.ns_prefix_:
6432
            namespaceprefix_ = self.ns_prefix_ + ':'
6433
        showIndent(outfile, level, pretty_print)
6434
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
6435
        already_processed = set()
6436
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='ReadingOrderType')
6437
        if self.has__content():
6438
            outfile.write('>%s' % (eol_, ))
6439
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='ReadingOrderType', pretty_print=pretty_print)
6440
            showIndent(outfile, level, pretty_print)
6441
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
6442
        else:
6443
            outfile.write('/>%s' % (eol_, ))
6444
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='ReadingOrderType'):
6445
        if self.conf is not None and 'conf' not in already_processed:
6446
            already_processed.add('conf')
6447
            outfile.write(' conf="%s"' % self.gds_format_float(self.conf, input_name='conf'))
6448
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='ReadingOrderType', fromsubclass_=False, pretty_print=True):
6449
        if pretty_print:
6450
            eol_ = '\n'
6451
        else:
6452
            eol_ = ''
6453
        if self.OrderedGroup is not None:
6454
            namespaceprefix_ = self.OrderedGroup_nsprefix_ + ':' if (UseCapturedNS_ and self.OrderedGroup_nsprefix_) else ''
6455
            self.OrderedGroup.export(outfile, level, namespaceprefix_, namespacedef_='', name_='OrderedGroup', pretty_print=pretty_print)
6456
        if self.UnorderedGroup is not None:
6457
            namespaceprefix_ = self.UnorderedGroup_nsprefix_ + ':' if (UseCapturedNS_ and self.UnorderedGroup_nsprefix_) else ''
6458
            self.UnorderedGroup.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UnorderedGroup', pretty_print=pretty_print)
6459
    def to_etree(self, parent_element=None, name_='ReadingOrderType', mapping_=None, reverse_mapping_=None, nsmap_=None):
6460
        if parent_element is None:
6461
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
6462
        else:
6463
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
6464
        if self.conf is not None:
6465
            element.set('conf', self.gds_format_float(self.conf))
6466
        if self.OrderedGroup is not None:
6467
            OrderedGroup_ = self.OrderedGroup
6468
            OrderedGroup_.to_etree(element, name_='OrderedGroup', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
6469
        if self.UnorderedGroup is not None:
6470
            UnorderedGroup_ = self.UnorderedGroup
6471
            UnorderedGroup_.to_etree(element, name_='UnorderedGroup', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
6472
        if mapping_ is not None:
6473
            mapping_[id(self)] = element
6474
        if reverse_mapping_ is not None:
6475
            reverse_mapping_[element] = self
6476
        return element
6477
    def build(self, node, gds_collector_=None):
6478
        self.gds_collector_ = gds_collector_
6479
        if SaveElementTreeNode:
6480
            self.gds_elementtree_node_ = node
6481
        already_processed = set()
6482
        self.ns_prefix_ = node.prefix
6483
        self._buildAttributes(node, node.attrib, already_processed)
6484
        for child in node:
6485
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
6486
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
6487
        return self
6488
    def _buildAttributes(self, node, attrs, already_processed):
6489
        value = find_attr_value_('conf', node)
6490
        if value is not None and 'conf' not in already_processed:
6491
            already_processed.add('conf')
6492
            value = self.gds_parse_float(value, node, 'conf')
6493
            self.conf = value
6494
            self.validate_ConfSimpleType(self.conf)    # validate type ConfSimpleType
6495
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
6496
        if nodeName_ == 'OrderedGroup':
6497
            obj_ = OrderedGroupType.factory(parent_object_=self)
6498
            obj_.build(child_, gds_collector_=gds_collector_)
6499
            self.OrderedGroup = obj_
6500
            obj_.original_tagname_ = 'OrderedGroup'
6501
        elif nodeName_ == 'UnorderedGroup':
6502
            obj_ = UnorderedGroupType.factory(parent_object_=self)
6503
            obj_.build(child_, gds_collector_=gds_collector_)
6504
            self.UnorderedGroup = obj_
6505
            obj_.original_tagname_ = 'UnorderedGroup'
6506
    def __hash__(self):
6507
        return hash(self.id)
6508
# end class ReadingOrderType
6509
6510
6511
class RegionRefIndexedType(GeneratedsSuper):
6512
    """RegionRefIndexedType -- Numbered region
6513
    index -- Position (order number) of this item within the current hierarchy level.
6514
    
6515
    """
6516
    __hash__ = GeneratedsSuper.__hash__
6517
    member_data_items_ = [
6518
        MemberSpec_('index', 'int', 0, 0, {'use': 'required', 'name': 'index'}),
6519
        MemberSpec_('regionRef', 'string', 0, 0, {'use': 'required', 'name': 'regionRef'}),
6520
    ]
6521
    subclass = None
6522
    superclass = None
6523
    def __init__(self, index=None, regionRef=None, gds_collector_=None, **kwargs_):
6524
        self.gds_collector_ = gds_collector_
6525
        self.gds_elementtree_node_ = None
6526
        self.original_tagname_ = None
6527
        self.parent_object_ = kwargs_.get('parent_object_')
6528
        self.ns_prefix_ = "pc"
6529
        self.index = _cast(int, index)
6530
        self.index_nsprefix_ = "pc"
6531
        self.regionRef = _cast(None, regionRef)
6532
        self.regionRef_nsprefix_ = "pc"
6533
    def factory(*args_, **kwargs_):
6534
        if CurrentSubclassModule_ is not None:
6535
            subclass = getSubclassFromModule_(
6536
                CurrentSubclassModule_, RegionRefIndexedType)
6537
            if subclass is not None:
6538
                return subclass(*args_, **kwargs_)
6539
        if RegionRefIndexedType.subclass:
6540
            return RegionRefIndexedType.subclass(*args_, **kwargs_)
6541
        else:
6542
            return RegionRefIndexedType(*args_, **kwargs_)
6543
    factory = staticmethod(factory)
6544
    def get_ns_prefix_(self):
6545
        return self.ns_prefix_
6546
    def set_ns_prefix_(self, ns_prefix):
6547
        self.ns_prefix_ = ns_prefix
6548
    def get_index(self):
6549
        return self.index
6550
    def set_index(self, index):
6551
        self.index = index
6552
    def get_regionRef(self):
6553
        return self.regionRef
6554
    def set_regionRef(self, regionRef):
6555
        self.regionRef = regionRef
6556
    def has__content(self):
6557
        if (
6558
6559
        ):
6560
            return True
6561
        else:
6562
            return False
6563
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RegionRefIndexedType', pretty_print=True):
6564
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('RegionRefIndexedType')
6565
        if imported_ns_def_ is not None:
6566
            namespacedef_ = imported_ns_def_
6567
        if pretty_print:
6568
            eol_ = '\n'
6569
        else:
6570
            eol_ = ''
6571
        if self.original_tagname_ is not None and name_ == 'RegionRefIndexedType':
6572
            name_ = self.original_tagname_
6573
        if UseCapturedNS_ and self.ns_prefix_:
6574
            namespaceprefix_ = self.ns_prefix_ + ':'
6575
        showIndent(outfile, level, pretty_print)
6576
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
6577
        already_processed = set()
6578
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='RegionRefIndexedType')
6579
        if self.has__content():
6580
            outfile.write('>%s' % (eol_, ))
6581
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='RegionRefIndexedType', pretty_print=pretty_print)
6582
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
6583
        else:
6584
            outfile.write('/>%s' % (eol_, ))
6585
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='RegionRefIndexedType'):
6586
        if self.index is not None and 'index' not in already_processed:
6587
            already_processed.add('index')
6588
            outfile.write(' index="%s"' % self.gds_format_integer(self.index, input_name='index'))
6589
        if self.regionRef is not None and 'regionRef' not in already_processed:
6590
            already_processed.add('regionRef')
6591
            outfile.write(' regionRef=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.regionRef), input_name='regionRef')), ))
6592
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RegionRefIndexedType', fromsubclass_=False, pretty_print=True):
6593
        pass
6594 View Code Duplication
    def to_etree(self, parent_element=None, name_='RegionRefIndexedType', mapping_=None, reverse_mapping_=None, nsmap_=None):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
6595
        if parent_element is None:
6596
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
6597
        else:
6598
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
6599
        if self.index is not None:
6600
            element.set('index', self.gds_format_integer(self.index))
6601
        if self.regionRef is not None:
6602
            element.set('regionRef', self.gds_format_string(self.regionRef))
6603
        if mapping_ is not None:
6604
            mapping_[id(self)] = element
6605
        if reverse_mapping_ is not None:
6606
            reverse_mapping_[element] = self
6607
        return element
6608
    def build(self, node, gds_collector_=None):
6609
        self.gds_collector_ = gds_collector_
6610
        if SaveElementTreeNode:
6611
            self.gds_elementtree_node_ = node
6612
        already_processed = set()
6613
        self.ns_prefix_ = node.prefix
6614
        self._buildAttributes(node, node.attrib, already_processed)
6615
        for child in node:
6616
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
6617
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
6618
        return self
6619
    def _buildAttributes(self, node, attrs, already_processed):
6620
        value = find_attr_value_('index', node)
6621
        if value is not None and 'index' not in already_processed:
6622
            already_processed.add('index')
6623
            self.index = self.gds_parse_integer(value, node, 'index')
6624
        value = find_attr_value_('regionRef', node)
6625
        if value is not None and 'regionRef' not in already_processed:
6626
            already_processed.add('regionRef')
6627
            self.regionRef = value
6628
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
6629
        pass
6630
    def __hash__(self):
6631
        return hash(self.id)
6632
# end class RegionRefIndexedType
6633
6634
6635
class OrderedGroupIndexedType(GeneratedsSuper):
6636
    """OrderedGroupIndexedType --
6637
    Indexed group containing ordered elements
6638
      
6639
    * regionRef --
6640
      Optional link to a parent region of nested regions.
6641
      The parent region doubles as reading order group.
6642
      Only the nested regions should be allowed as group members.
6643
      
6644
    * index --
6645
      Position (order number) of this item within the
6646
      current hierarchy level.
6647
      
6648
    * continuation --
6649
      Is this group a continuation of another group (from
6650
      previous column or page, for example)?
6651
      
6652
    * custom -- For generic use
6653
    * Labels -- Semantic labels / tags
6654
    
6655
    """
6656
    __hash__ = GeneratedsSuper.__hash__
6657
    member_data_items_ = [
6658
        MemberSpec_('id', 'string', 0, 0, {'use': 'required', 'name': 'id'}),
6659
        MemberSpec_('regionRef', 'string', 0, 1, {'use': 'optional', 'name': 'regionRef'}),
6660
        MemberSpec_('index', 'int', 0, 0, {'use': 'required', 'name': 'index'}),
6661
        MemberSpec_('caption', 'string', 0, 1, {'use': 'optional', 'name': 'caption'}),
6662
        MemberSpec_('type_', 'pc:GroupTypeSimpleType', 0, 1, {'use': 'optional', 'name': 'type_'}),
6663
        MemberSpec_('continuation', 'boolean', 0, 1, {'use': 'optional', 'name': 'continuation'}),
6664
        MemberSpec_('custom', 'string', 0, 1, {'use': 'optional', 'name': 'custom'}),
6665
        MemberSpec_('comments', 'string', 0, 1, {'use': 'optional', 'name': 'comments'}),
6666
        MemberSpec_('UserDefined', 'UserDefinedType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'UserDefined', 'type': 'UserDefinedType'}, None),
6667
        MemberSpec_('Labels', 'LabelsType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Labels', 'type': 'LabelsType'}, None),
6668
        MemberSpec_('RegionRefIndexed', 'RegionRefIndexedType', 1, 0, {'name': 'RegionRefIndexed', 'type': 'RegionRefIndexedType'}, 3),
6669
        MemberSpec_('OrderedGroupIndexed', 'OrderedGroupIndexedType', 1, 0, {'name': 'OrderedGroupIndexed', 'type': 'OrderedGroupIndexedType'}, 3),
6670
        MemberSpec_('UnorderedGroupIndexed', 'UnorderedGroupIndexedType', 1, 0, {'name': 'UnorderedGroupIndexed', 'type': 'UnorderedGroupIndexedType'}, 3),
6671
    ]
6672
    subclass = None
6673
    superclass = None
6674 View Code Duplication
    def __init__(self, id=None, regionRef=None, index=None, caption=None, type_=None, continuation=None, custom=None, comments=None, UserDefined=None, Labels=None, RegionRefIndexed=None, OrderedGroupIndexed=None, UnorderedGroupIndexed=None, gds_collector_=None, **kwargs_):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
6675
        self.gds_collector_ = gds_collector_
6676
        self.gds_elementtree_node_ = None
6677
        self.original_tagname_ = None
6678
        self.parent_object_ = kwargs_.get('parent_object_')
6679
        self.ns_prefix_ = "pc"
6680
        self.id = _cast(None, id)
6681
        self.id_nsprefix_ = "pc"
6682
        self.regionRef = _cast(None, regionRef)
6683
        self.regionRef_nsprefix_ = "pc"
6684
        self.index = _cast(int, index)
6685
        self.index_nsprefix_ = "pc"
6686
        self.caption = _cast(None, caption)
6687
        self.caption_nsprefix_ = "pc"
6688
        self.type_ = _cast(None, type_)
6689
        self.type__nsprefix_ = "pc"
6690
        self.continuation = _cast(bool, continuation)
6691
        self.continuation_nsprefix_ = "pc"
6692
        self.custom = _cast(None, custom)
6693
        self.custom_nsprefix_ = "pc"
6694
        self.comments = _cast(None, comments)
6695
        self.comments_nsprefix_ = "pc"
6696
        self.UserDefined = UserDefined
6697
        self.UserDefined_nsprefix_ = "pc"
6698
        if Labels is None:
6699
            self.Labels = []
6700
        else:
6701
            self.Labels = Labels
6702
        self.Labels_nsprefix_ = "pc"
6703
        if RegionRefIndexed is None:
6704
            self.RegionRefIndexed = []
6705
        else:
6706
            self.RegionRefIndexed = RegionRefIndexed
6707
        self.RegionRefIndexed_nsprefix_ = "pc"
6708
        if OrderedGroupIndexed is None:
6709
            self.OrderedGroupIndexed = []
6710
        else:
6711
            self.OrderedGroupIndexed = OrderedGroupIndexed
6712
        self.OrderedGroupIndexed_nsprefix_ = "pc"
6713
        if UnorderedGroupIndexed is None:
6714
            self.UnorderedGroupIndexed = []
6715
        else:
6716
            self.UnorderedGroupIndexed = UnorderedGroupIndexed
6717
        self.UnorderedGroupIndexed_nsprefix_ = "pc"
6718
    def factory(*args_, **kwargs_):
6719
        if CurrentSubclassModule_ is not None:
6720
            subclass = getSubclassFromModule_(
6721
                CurrentSubclassModule_, OrderedGroupIndexedType)
6722
            if subclass is not None:
6723
                return subclass(*args_, **kwargs_)
6724
        if OrderedGroupIndexedType.subclass:
6725
            return OrderedGroupIndexedType.subclass(*args_, **kwargs_)
6726
        else:
6727
            return OrderedGroupIndexedType(*args_, **kwargs_)
6728
    factory = staticmethod(factory)
6729
    def get_ns_prefix_(self):
6730
        return self.ns_prefix_
6731
    def set_ns_prefix_(self, ns_prefix):
6732
        self.ns_prefix_ = ns_prefix
6733
    def get_UserDefined(self):
6734
        return self.UserDefined
6735
    def set_UserDefined(self, UserDefined):
6736
        self.UserDefined = UserDefined
6737
    def get_Labels(self):
6738
        return self.Labels
6739
    def set_Labels(self, Labels):
6740
        self.Labels = Labels
6741
    def add_Labels(self, value):
6742
        self.Labels.append(value)
6743
    def insert_Labels_at(self, index, value):
6744
        self.Labels.insert(index, value)
6745
    def replace_Labels_at(self, index, value):
6746
        self.Labels[index] = value
6747
    def get_RegionRefIndexed(self):
6748
        return self.RegionRefIndexed
6749
    def set_RegionRefIndexed(self, RegionRefIndexed):
6750
        self.RegionRefIndexed = RegionRefIndexed
6751
    def add_RegionRefIndexed(self, value):
6752
        self.RegionRefIndexed.append(value)
6753
    def insert_RegionRefIndexed_at(self, index, value):
6754
        self.RegionRefIndexed.insert(index, value)
6755
    def replace_RegionRefIndexed_at(self, index, value):
6756
        self.RegionRefIndexed[index] = value
6757
    def get_OrderedGroupIndexed(self):
6758
        return self.OrderedGroupIndexed
6759
    def set_OrderedGroupIndexed(self, OrderedGroupIndexed):
6760
        self.OrderedGroupIndexed = OrderedGroupIndexed
6761
    def add_OrderedGroupIndexed(self, value):
6762
        self.OrderedGroupIndexed.append(value)
6763
    def insert_OrderedGroupIndexed_at(self, index, value):
6764
        self.OrderedGroupIndexed.insert(index, value)
6765
    def replace_OrderedGroupIndexed_at(self, index, value):
6766
        self.OrderedGroupIndexed[index] = value
6767
    def get_UnorderedGroupIndexed(self):
6768
        return self.UnorderedGroupIndexed
6769
    def set_UnorderedGroupIndexed(self, UnorderedGroupIndexed):
6770
        self.UnorderedGroupIndexed = UnorderedGroupIndexed
6771
    def add_UnorderedGroupIndexed(self, value):
6772
        self.UnorderedGroupIndexed.append(value)
6773
    def insert_UnorderedGroupIndexed_at(self, index, value):
6774
        self.UnorderedGroupIndexed.insert(index, value)
6775
    def replace_UnorderedGroupIndexed_at(self, index, value):
6776
        self.UnorderedGroupIndexed[index] = value
6777
    def get_id(self):
6778
        return self.id
6779
    def set_id(self, id):
6780
        self.id = id
6781
    def get_regionRef(self):
6782
        return self.regionRef
6783
    def set_regionRef(self, regionRef):
6784
        self.regionRef = regionRef
6785
    def get_index(self):
6786
        return self.index
6787
    def set_index(self, index):
6788
        self.index = index
6789
    def get_caption(self):
6790
        return self.caption
6791
    def set_caption(self, caption):
6792
        self.caption = caption
6793
    def get_type(self):
6794
        return self.type_
6795
    def set_type(self, type_):
6796
        self.type_ = type_
6797
    def get_continuation(self):
6798
        return self.continuation
6799
    def set_continuation(self, continuation):
6800
        self.continuation = continuation
6801
    def get_custom(self):
6802
        return self.custom
6803
    def set_custom(self, custom):
6804
        self.custom = custom
6805
    def get_comments(self):
6806
        return self.comments
6807
    def set_comments(self, comments):
6808
        self.comments = comments
6809
    def validate_GroupTypeSimpleType(self, value):
6810
        # Validate type pc:GroupTypeSimpleType, a restriction on string.
6811
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
6812
            if not isinstance(value, str):
6813
                lineno = self.gds_get_node_lineno_()
6814
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
6815
                return False
6816
            value = value
6817
            enumerations = ['paragraph', 'list', 'list-item', 'figure', 'article', 'div', 'other']
6818
            if value not in enumerations:
6819
                lineno = self.gds_get_node_lineno_()
6820
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on GroupTypeSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
6821
                result = False
6822
    def has__content(self):
6823
        if (
6824
            self.UserDefined is not None or
6825
            self.Labels or
6826
            self.RegionRefIndexed or
6827
            self.OrderedGroupIndexed or
6828
            self.UnorderedGroupIndexed
6829
        ):
6830
            return True
6831
        else:
6832
            return False
6833
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='OrderedGroupIndexedType', pretty_print=True):
6834
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('OrderedGroupIndexedType')
6835
        if imported_ns_def_ is not None:
6836
            namespacedef_ = imported_ns_def_
6837
        if pretty_print:
6838
            eol_ = '\n'
6839
        else:
6840
            eol_ = ''
6841
        if self.original_tagname_ is not None and name_ == 'OrderedGroupIndexedType':
6842
            name_ = self.original_tagname_
6843
        if UseCapturedNS_ and self.ns_prefix_:
6844
            namespaceprefix_ = self.ns_prefix_ + ':'
6845
        showIndent(outfile, level, pretty_print)
6846
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
6847
        already_processed = set()
6848
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='OrderedGroupIndexedType')
6849
        if self.has__content():
6850
            outfile.write('>%s' % (eol_, ))
6851
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='OrderedGroupIndexedType', pretty_print=pretty_print)
6852
            showIndent(outfile, level, pretty_print)
6853
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
6854
        else:
6855
            outfile.write('/>%s' % (eol_, ))
6856 View Code Duplication
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='OrderedGroupIndexedType'):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
6857
        if self.id is not None and 'id' not in already_processed:
6858
            already_processed.add('id')
6859
            outfile.write(' id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.id), input_name='id')), ))
6860
        if self.regionRef is not None and 'regionRef' not in already_processed:
6861
            already_processed.add('regionRef')
6862
            outfile.write(' regionRef=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.regionRef), input_name='regionRef')), ))
6863
        if self.index is not None and 'index' not in already_processed:
6864
            already_processed.add('index')
6865
            outfile.write(' index="%s"' % self.gds_format_integer(self.index, input_name='index'))
6866
        if self.caption is not None and 'caption' not in already_processed:
6867
            already_processed.add('caption')
6868
            outfile.write(' caption=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.caption), input_name='caption')), ))
6869
        if self.type_ is not None and 'type_' not in already_processed:
6870
            already_processed.add('type_')
6871
            outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), ))
6872
        if self.continuation is not None and 'continuation' not in already_processed:
6873
            already_processed.add('continuation')
6874
            outfile.write(' continuation="%s"' % self.gds_format_boolean(self.continuation, input_name='continuation'))
6875
        if self.custom is not None and 'custom' not in already_processed:
6876
            already_processed.add('custom')
6877
            outfile.write(' custom=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.custom), input_name='custom')), ))
6878
        if self.comments is not None and 'comments' not in already_processed:
6879
            already_processed.add('comments')
6880
            outfile.write(' comments=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.comments), input_name='comments')), ))
6881 View Code Duplication
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='OrderedGroupIndexedType', fromsubclass_=False, pretty_print=True):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
6882
        if pretty_print:
6883
            eol_ = '\n'
6884
        else:
6885
            eol_ = ''
6886
        if self.UserDefined is not None:
6887
            namespaceprefix_ = self.UserDefined_nsprefix_ + ':' if (UseCapturedNS_ and self.UserDefined_nsprefix_) else ''
6888
            self.UserDefined.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UserDefined', pretty_print=pretty_print)
6889
        for Labels_ in self.Labels:
6890
            namespaceprefix_ = self.Labels_nsprefix_ + ':' if (UseCapturedNS_ and self.Labels_nsprefix_) else ''
6891
            Labels_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Labels', pretty_print=pretty_print)
6892
        for RegionRefIndexed_ in self.RegionRefIndexed:
6893
            namespaceprefix_ = self.RegionRefIndexed_nsprefix_ + ':' if (UseCapturedNS_ and self.RegionRefIndexed_nsprefix_) else ''
6894
            RegionRefIndexed_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='RegionRefIndexed', pretty_print=pretty_print)
6895
        for OrderedGroupIndexed_ in self.OrderedGroupIndexed:
6896
            namespaceprefix_ = self.OrderedGroupIndexed_nsprefix_ + ':' if (UseCapturedNS_ and self.OrderedGroupIndexed_nsprefix_) else ''
6897
            OrderedGroupIndexed_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='OrderedGroupIndexed', pretty_print=pretty_print)
6898
        for UnorderedGroupIndexed_ in self.UnorderedGroupIndexed:
6899
            namespaceprefix_ = self.UnorderedGroupIndexed_nsprefix_ + ':' if (UseCapturedNS_ and self.UnorderedGroupIndexed_nsprefix_) else ''
6900
            UnorderedGroupIndexed_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UnorderedGroupIndexed', pretty_print=pretty_print)
6901 View Code Duplication
    def to_etree(self, parent_element=None, name_='OrderedGroupIndexedType', mapping_=None, reverse_mapping_=None, nsmap_=None):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
6902
        if parent_element is None:
6903
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
6904
        else:
6905
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
6906
        if self.id is not None:
6907
            element.set('id', self.gds_format_string(self.id))
6908
        if self.regionRef is not None:
6909
            element.set('regionRef', self.gds_format_string(self.regionRef))
6910
        if self.index is not None:
6911
            element.set('index', self.gds_format_integer(self.index))
6912
        if self.caption is not None:
6913
            element.set('caption', self.gds_format_string(self.caption))
6914
        if self.type_ is not None:
6915
            element.set('type', self.gds_format_string(self.type_))
6916
        if self.continuation is not None:
6917
            element.set('continuation', self.gds_format_boolean(self.continuation))
6918
        if self.custom is not None:
6919
            element.set('custom', self.gds_format_string(self.custom))
6920
        if self.comments is not None:
6921
            element.set('comments', self.gds_format_string(self.comments))
6922
        if self.UserDefined is not None:
6923
            UserDefined_ = self.UserDefined
6924
            UserDefined_.to_etree(element, name_='UserDefined', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
6925
        for Labels_ in self.Labels:
6926
            Labels_.to_etree(element, name_='Labels', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
6927
        for RegionRefIndexed_ in self.RegionRefIndexed:
6928
            RegionRefIndexed_.to_etree(element, name_='RegionRefIndexed', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
6929
        for OrderedGroupIndexed_ in self.OrderedGroupIndexed:
6930
            OrderedGroupIndexed_.to_etree(element, name_='OrderedGroupIndexed', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
6931
        for UnorderedGroupIndexed_ in self.UnorderedGroupIndexed:
6932
            UnorderedGroupIndexed_.to_etree(element, name_='UnorderedGroupIndexed', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
6933
        if mapping_ is not None:
6934
            mapping_[id(self)] = element
6935
        if reverse_mapping_ is not None:
6936
            reverse_mapping_[element] = self
6937
        return element
6938
    def build(self, node, gds_collector_=None):
6939
        self.gds_collector_ = gds_collector_
6940
        if SaveElementTreeNode:
6941
            self.gds_elementtree_node_ = node
6942
        already_processed = set()
6943
        self.ns_prefix_ = node.prefix
6944
        self._buildAttributes(node, node.attrib, already_processed)
6945
        for child in node:
6946
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
6947
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
6948
        return self
6949 View Code Duplication
    def _buildAttributes(self, node, attrs, already_processed):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
6950
        value = find_attr_value_('id', node)
6951
        if value is not None and 'id' not in already_processed:
6952
            already_processed.add('id')
6953
            self.id = value
6954
        value = find_attr_value_('regionRef', node)
6955
        if value is not None and 'regionRef' not in already_processed:
6956
            already_processed.add('regionRef')
6957
            self.regionRef = value
6958
        value = find_attr_value_('index', node)
6959
        if value is not None and 'index' not in already_processed:
6960
            already_processed.add('index')
6961
            self.index = self.gds_parse_integer(value, node, 'index')
6962
        value = find_attr_value_('caption', node)
6963
        if value is not None and 'caption' not in already_processed:
6964
            already_processed.add('caption')
6965
            self.caption = value
6966
        value = find_attr_value_('type', node)
6967
        if value is not None and 'type' not in already_processed:
6968
            already_processed.add('type')
6969
            self.type_ = value
6970
            self.validate_GroupTypeSimpleType(self.type_)    # validate type GroupTypeSimpleType
6971
        value = find_attr_value_('continuation', node)
6972
        if value is not None and 'continuation' not in already_processed:
6973
            already_processed.add('continuation')
6974
            if value in ('true', '1'):
6975
                self.continuation = True
6976
            elif value in ('false', '0'):
6977
                self.continuation = False
6978
            else:
6979
                raise_parse_error(node, 'Bad boolean attribute')
6980
        value = find_attr_value_('custom', node)
6981
        if value is not None and 'custom' not in already_processed:
6982
            already_processed.add('custom')
6983
            self.custom = value
6984
        value = find_attr_value_('comments', node)
6985
        if value is not None and 'comments' not in already_processed:
6986
            already_processed.add('comments')
6987
            self.comments = value
6988 View Code Duplication
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
6989
        if nodeName_ == 'UserDefined':
6990
            obj_ = UserDefinedType.factory(parent_object_=self)
6991
            obj_.build(child_, gds_collector_=gds_collector_)
6992
            self.UserDefined = obj_
6993
            obj_.original_tagname_ = 'UserDefined'
6994
        elif nodeName_ == 'Labels':
6995
            obj_ = LabelsType.factory(parent_object_=self)
6996
            obj_.build(child_, gds_collector_=gds_collector_)
6997
            self.Labels.append(obj_)
6998
            obj_.original_tagname_ = 'Labels'
6999
        elif nodeName_ == 'RegionRefIndexed':
7000
            obj_ = RegionRefIndexedType.factory(parent_object_=self)
7001
            obj_.build(child_, gds_collector_=gds_collector_)
7002
            self.RegionRefIndexed.append(obj_)
7003
            obj_.original_tagname_ = 'RegionRefIndexed'
7004
        elif nodeName_ == 'OrderedGroupIndexed':
7005
            obj_ = OrderedGroupIndexedType.factory(parent_object_=self)
7006
            obj_.build(child_, gds_collector_=gds_collector_)
7007
            self.OrderedGroupIndexed.append(obj_)
7008
            obj_.original_tagname_ = 'OrderedGroupIndexed'
7009
        elif nodeName_ == 'UnorderedGroupIndexed':
7010
            obj_ = UnorderedGroupIndexedType.factory(parent_object_=self)
7011
            obj_.build(child_, gds_collector_=gds_collector_)
7012
            self.UnorderedGroupIndexed.append(obj_)
7013
            obj_.original_tagname_ = 'UnorderedGroupIndexed'
7014
    def __hash__(self):
7015
        return hash(self.id)
7016
    # pylint: disable=invalid-name,missing-module-docstring,line-too-long
7017 View Code Duplication
    def get_AllIndexed(self, classes=None, index_sort=True):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7018
        """
7019
        Get all indexed children sorted by their ``@index``.
7020
    
7021
        Arguments:
7022
            classes (list): Type of children (sans ``Indexed``) to return. \
7023
                Default: ``['RegionRef', 'OrderedGroup', 'UnorderedGroup']``
7024
            index_sort (boolean): Whether to sort by ``@index``
7025
    
7026
        Returns:
7027
            a list of :py:class:`RegionRefIndexedType`, \
7028
                :py:class:`OrderedGroupIndexedType`, and \
7029
                :py:class:`UnorderedGroupIndexedType`
7030
        """
7031
        if not classes:
7032
            classes = ['RegionRef', 'OrderedGroup', 'UnorderedGroup']
7033
        ret = []
7034
        for class_ in classes:
7035
            ret += getattr(self, 'get_{}Indexed'.format(class_))()
7036
        if index_sort:
7037
            return sorted(ret, key=lambda x: x.index)
7038
        return ret
7039
    def clear_AllIndexed(self):
7040
        ret = self.get_AllIndexed()
7041
        self.set_RegionRefIndexed([])
7042
        self.set_OrderedGroupIndexed([])
7043
        self.set_UnorderedGroupIndexed([])
7044
        return ret
7045
    
7046
    # pylint: disable=line-too-long,invalid-name,missing-module-docstring
7047 View Code Duplication
    def extend_AllIndexed(self, elements, validate_continuity=False):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7048
        """
7049
        Add all elements in list `elements`, respecting ``@index`` order.
7050
        With `validate_continuity`, check that all new elements come after all old elements
7051
        (or raise an exception). 
7052
        Otherwise, ensure this condition silently (by increasing ``@index`` accordingly).
7053
        """
7054
        if not isinstance(elements, list):
7055
            elements = [elements]
7056
        siblings = self.get_AllIndexed()
7057
        highest_sibling_index = siblings[-1].index if siblings else -1
7058
        if validate_continuity:
7059
            elements = sorted(elements, key=lambda x: x.index)
7060
            lowest_element_index = elements[0].index
7061
            if lowest_element_index <= highest_sibling_index:
7062
                raise Exception("@index already used: {}".format(lowest_element_index))
7063
        else:
7064
            for element in elements:
7065
                highest_sibling_index += 1
7066
                element.index = highest_sibling_index
7067
        for element in elements:
7068
            if isinstance(element, RegionRefIndexedType): # pylint: disable=undefined-variable
7069
                self.add_RegionRefIndexed(element)
7070
            elif isinstance(element, OrderedGroupIndexedType): # pylint: disable=undefined-variable
7071
                self.add_OrderedGroupIndexed(element)
7072
            elif isinstance(element, UnorderedGroupIndexedType): # pylint: disable=undefined-variable
7073
                self.add_UnorderedGroupIndexed(element)
7074
        return self.get_AllIndexed()
7075
    # pylint: disable=line-too-long,invalid-name,missing-module-docstring
7076 View Code Duplication
    def sort_AllIndexed(self, validate_uniqueness=True):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7077
        """
7078
        Sort all indexed children in-place.
7079
        """
7080
        elements = self.get_AllIndexed(index_sort=True)
7081
        self.clear_AllIndexed()
7082
        for element in elements:
7083
            if isinstance(element, RegionRefIndexedType): # pylint: disable=undefined-variable
7084
                self.add_RegionRefIndexed(element)
7085
            elif isinstance(element, OrderedGroupIndexedType): # pylint: disable=undefined-variable
7086
                self.add_OrderedGroupIndexed(element)
7087
            elif isinstance(element, UnorderedGroupIndexedType): # pylint: disable=undefined-variable
7088
                self.add_UnorderedGroupIndexed(element)
7089
        return self.get_AllIndexed()
7090
    
7091
    # pylint: disable=line-too-long,invalid-name,missing-module-docstring,missing-function-docstring
7092 View Code Duplication
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='OrderedGroupType', fromsubclass_=False, pretty_print=True): # pylint: disable=unused-argument,too-many-arguments
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7093
        if pretty_print:
7094
            eol_ = '\n'
7095
        else:
7096
            eol_ = ''
7097
        if self.UserDefined is not None:
7098
            namespaceprefix_ = self.UserDefined_nsprefix_ + ':' if (UseCapturedNS_ and self.UserDefined_nsprefix_) else ''
7099
            self.UserDefined.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UserDefined', pretty_print=pretty_print)
7100
        for Labels_ in self.Labels:
7101
            namespaceprefix_ = self.Labels_nsprefix_ + ':' if (UseCapturedNS_ and self.Labels_nsprefix_) else ''
7102
            Labels_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Labels', pretty_print=pretty_print)
7103
        cleaned = []
7104
        def replaceWithRRI(group):
7105
            rri = RegionRefIndexedType.factory(parent_object_=self) # pylint: disable=undefined-variable
7106
            rri.index = group.index
7107
            rri.regionRef = group.regionRef
7108
            cleaned.append(rri)
7109
        # remove empty groups and replace with RegionRefIndexedType
7110
        for entry in self.get_AllIndexed():
7111
            # pylint: disable=undefined-variable
7112
            if isinstance(entry, (OrderedGroupIndexedType)) and not entry.get_AllIndexed():
7113
                replaceWithRRI(entry)
7114
            elif isinstance(entry, UnorderedGroupIndexedType) and not entry.get_UnorderedGroupChildren():
7115
                replaceWithRRI(entry)
7116
            else:
7117
                cleaned.append(entry)
7118
        for entry in cleaned:
7119
            entry.export(outfile, level, namespaceprefix_, namespacedef_='', name_=entry.__class__.__name__[:-4], pretty_print=pretty_print)
7120
# end class OrderedGroupIndexedType
7121
7122
7123
class UnorderedGroupIndexedType(GeneratedsSuper):
7124
    """UnorderedGroupIndexedType --
7125
    Indexed group containing unordered elements
7126
      
7127
    * regionRef --
7128
      Optional link to a parent region of nested regions.
7129
      The parent region doubles as reading order group.
7130
      Only the nested regions should be allowed as group members.
7131
      
7132
    * index --
7133
      Position (order number) of this item within the
7134
      current hierarchy level.
7135
      
7136
    * continuation --
7137
      Is this group a continuation of another group
7138
      (from previous column or page, for example)?
7139
      
7140
    * custom -- For generic use
7141
    * Labels -- Semantic labels / tags
7142
    
7143
    """
7144
    __hash__ = GeneratedsSuper.__hash__
7145
    member_data_items_ = [
7146
        MemberSpec_('id', 'string', 0, 0, {'use': 'required', 'name': 'id'}),
7147
        MemberSpec_('regionRef', 'string', 0, 1, {'use': 'optional', 'name': 'regionRef'}),
7148
        MemberSpec_('index', 'int', 0, 0, {'use': 'required', 'name': 'index'}),
7149
        MemberSpec_('caption', 'string', 0, 1, {'use': 'optional', 'name': 'caption'}),
7150
        MemberSpec_('type_', 'pc:GroupTypeSimpleType', 0, 1, {'use': 'optional', 'name': 'type_'}),
7151
        MemberSpec_('continuation', 'boolean', 0, 1, {'use': 'optional', 'name': 'continuation'}),
7152
        MemberSpec_('custom', 'string', 0, 1, {'use': 'optional', 'name': 'custom'}),
7153
        MemberSpec_('comments', 'string', 0, 1, {'use': 'optional', 'name': 'comments'}),
7154
        MemberSpec_('UserDefined', 'UserDefinedType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'UserDefined', 'type': 'UserDefinedType'}, None),
7155
        MemberSpec_('Labels', 'LabelsType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Labels', 'type': 'LabelsType'}, None),
7156
        MemberSpec_('RegionRef', 'RegionRefType', 1, 0, {'name': 'RegionRef', 'type': 'RegionRefType'}, 4),
7157
        MemberSpec_('OrderedGroup', 'OrderedGroupType', 1, 0, {'name': 'OrderedGroup', 'type': 'OrderedGroupType'}, 4),
7158
        MemberSpec_('UnorderedGroup', 'UnorderedGroupType', 1, 0, {'name': 'UnorderedGroup', 'type': 'UnorderedGroupType'}, 4),
7159
    ]
7160
    subclass = None
7161
    superclass = None
7162
    def __init__(self, id=None, regionRef=None, index=None, caption=None, type_=None, continuation=None, custom=None, comments=None, UserDefined=None, Labels=None, RegionRef=None, OrderedGroup=None, UnorderedGroup=None, gds_collector_=None, **kwargs_):
7163
        self.gds_collector_ = gds_collector_
7164
        self.gds_elementtree_node_ = None
7165
        self.original_tagname_ = None
7166
        self.parent_object_ = kwargs_.get('parent_object_')
7167
        self.ns_prefix_ = "pc"
7168
        self.id = _cast(None, id)
7169
        self.id_nsprefix_ = "pc"
7170
        self.regionRef = _cast(None, regionRef)
7171
        self.regionRef_nsprefix_ = "pc"
7172
        self.index = _cast(int, index)
7173
        self.index_nsprefix_ = "pc"
7174
        self.caption = _cast(None, caption)
7175
        self.caption_nsprefix_ = "pc"
7176
        self.type_ = _cast(None, type_)
7177
        self.type__nsprefix_ = "pc"
7178
        self.continuation = _cast(bool, continuation)
7179
        self.continuation_nsprefix_ = "pc"
7180
        self.custom = _cast(None, custom)
7181
        self.custom_nsprefix_ = "pc"
7182
        self.comments = _cast(None, comments)
7183
        self.comments_nsprefix_ = "pc"
7184
        self.UserDefined = UserDefined
7185
        self.UserDefined_nsprefix_ = "pc"
7186
        if Labels is None:
7187
            self.Labels = []
7188
        else:
7189
            self.Labels = Labels
7190
        self.Labels_nsprefix_ = "pc"
7191
        if RegionRef is None:
7192
            self.RegionRef = []
7193
        else:
7194
            self.RegionRef = RegionRef
7195
        self.RegionRef_nsprefix_ = "pc"
7196
        if OrderedGroup is None:
7197
            self.OrderedGroup = []
7198
        else:
7199
            self.OrderedGroup = OrderedGroup
7200
        self.OrderedGroup_nsprefix_ = "pc"
7201
        if UnorderedGroup is None:
7202
            self.UnorderedGroup = []
7203
        else:
7204
            self.UnorderedGroup = UnorderedGroup
7205
        self.UnorderedGroup_nsprefix_ = "pc"
7206
    def factory(*args_, **kwargs_):
7207
        if CurrentSubclassModule_ is not None:
7208
            subclass = getSubclassFromModule_(
7209
                CurrentSubclassModule_, UnorderedGroupIndexedType)
7210
            if subclass is not None:
7211
                return subclass(*args_, **kwargs_)
7212
        if UnorderedGroupIndexedType.subclass:
7213
            return UnorderedGroupIndexedType.subclass(*args_, **kwargs_)
7214
        else:
7215
            return UnorderedGroupIndexedType(*args_, **kwargs_)
7216
    factory = staticmethod(factory)
7217
    def get_ns_prefix_(self):
7218
        return self.ns_prefix_
7219
    def set_ns_prefix_(self, ns_prefix):
7220
        self.ns_prefix_ = ns_prefix
7221
    def get_UserDefined(self):
7222
        return self.UserDefined
7223
    def set_UserDefined(self, UserDefined):
7224
        self.UserDefined = UserDefined
7225
    def get_Labels(self):
7226
        return self.Labels
7227
    def set_Labels(self, Labels):
7228
        self.Labels = Labels
7229
    def add_Labels(self, value):
7230
        self.Labels.append(value)
7231
    def insert_Labels_at(self, index, value):
7232
        self.Labels.insert(index, value)
7233
    def replace_Labels_at(self, index, value):
7234
        self.Labels[index] = value
7235
    def get_RegionRef(self):
7236
        return self.RegionRef
7237
    def set_RegionRef(self, RegionRef):
7238
        self.RegionRef = RegionRef
7239
    def add_RegionRef(self, value):
7240
        self.RegionRef.append(value)
7241
    def insert_RegionRef_at(self, index, value):
7242
        self.RegionRef.insert(index, value)
7243
    def replace_RegionRef_at(self, index, value):
7244
        self.RegionRef[index] = value
7245
    def get_OrderedGroup(self):
7246
        return self.OrderedGroup
7247
    def set_OrderedGroup(self, OrderedGroup):
7248
        self.OrderedGroup = OrderedGroup
7249
    def add_OrderedGroup(self, value):
7250
        self.OrderedGroup.append(value)
7251
    def insert_OrderedGroup_at(self, index, value):
7252
        self.OrderedGroup.insert(index, value)
7253
    def replace_OrderedGroup_at(self, index, value):
7254
        self.OrderedGroup[index] = value
7255
    def get_UnorderedGroup(self):
7256
        return self.UnorderedGroup
7257
    def set_UnorderedGroup(self, UnorderedGroup):
7258
        self.UnorderedGroup = UnorderedGroup
7259
    def add_UnorderedGroup(self, value):
7260
        self.UnorderedGroup.append(value)
7261
    def insert_UnorderedGroup_at(self, index, value):
7262
        self.UnorderedGroup.insert(index, value)
7263
    def replace_UnorderedGroup_at(self, index, value):
7264
        self.UnorderedGroup[index] = value
7265
    def get_id(self):
7266
        return self.id
7267
    def set_id(self, id):
7268
        self.id = id
7269
    def get_regionRef(self):
7270
        return self.regionRef
7271
    def set_regionRef(self, regionRef):
7272
        self.regionRef = regionRef
7273
    def get_index(self):
7274
        return self.index
7275
    def set_index(self, index):
7276
        self.index = index
7277
    def get_caption(self):
7278
        return self.caption
7279
    def set_caption(self, caption):
7280
        self.caption = caption
7281
    def get_type(self):
7282
        return self.type_
7283
    def set_type(self, type_):
7284
        self.type_ = type_
7285
    def get_continuation(self):
7286
        return self.continuation
7287
    def set_continuation(self, continuation):
7288
        self.continuation = continuation
7289
    def get_custom(self):
7290
        return self.custom
7291
    def set_custom(self, custom):
7292
        self.custom = custom
7293
    def get_comments(self):
7294
        return self.comments
7295
    def set_comments(self, comments):
7296
        self.comments = comments
7297
    def validate_GroupTypeSimpleType(self, value):
7298
        # Validate type pc:GroupTypeSimpleType, a restriction on string.
7299
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
7300
            if not isinstance(value, str):
7301
                lineno = self.gds_get_node_lineno_()
7302
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
7303
                return False
7304
            value = value
7305
            enumerations = ['paragraph', 'list', 'list-item', 'figure', 'article', 'div', 'other']
7306
            if value not in enumerations:
7307
                lineno = self.gds_get_node_lineno_()
7308
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on GroupTypeSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
7309
                result = False
7310
    def has__content(self):
7311
        if (
7312
            self.UserDefined is not None or
7313
            self.Labels or
7314
            self.RegionRef or
7315
            self.OrderedGroup or
7316
            self.UnorderedGroup
7317
        ):
7318
            return True
7319
        else:
7320
            return False
7321
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='UnorderedGroupIndexedType', pretty_print=True):
7322
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('UnorderedGroupIndexedType')
7323
        if imported_ns_def_ is not None:
7324
            namespacedef_ = imported_ns_def_
7325
        if pretty_print:
7326
            eol_ = '\n'
7327
        else:
7328
            eol_ = ''
7329
        if self.original_tagname_ is not None and name_ == 'UnorderedGroupIndexedType':
7330
            name_ = self.original_tagname_
7331
        if UseCapturedNS_ and self.ns_prefix_:
7332
            namespaceprefix_ = self.ns_prefix_ + ':'
7333
        showIndent(outfile, level, pretty_print)
7334
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
7335
        already_processed = set()
7336
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='UnorderedGroupIndexedType')
7337
        if self.has__content():
7338
            outfile.write('>%s' % (eol_, ))
7339
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='UnorderedGroupIndexedType', pretty_print=pretty_print)
7340
            showIndent(outfile, level, pretty_print)
7341
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
7342
        else:
7343
            outfile.write('/>%s' % (eol_, ))
7344 View Code Duplication
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='UnorderedGroupIndexedType'):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7345
        if self.id is not None and 'id' not in already_processed:
7346
            already_processed.add('id')
7347
            outfile.write(' id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.id), input_name='id')), ))
7348
        if self.regionRef is not None and 'regionRef' not in already_processed:
7349
            already_processed.add('regionRef')
7350
            outfile.write(' regionRef=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.regionRef), input_name='regionRef')), ))
7351
        if self.index is not None and 'index' not in already_processed:
7352
            already_processed.add('index')
7353
            outfile.write(' index="%s"' % self.gds_format_integer(self.index, input_name='index'))
7354
        if self.caption is not None and 'caption' not in already_processed:
7355
            already_processed.add('caption')
7356
            outfile.write(' caption=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.caption), input_name='caption')), ))
7357
        if self.type_ is not None and 'type_' not in already_processed:
7358
            already_processed.add('type_')
7359
            outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), ))
7360
        if self.continuation is not None and 'continuation' not in already_processed:
7361
            already_processed.add('continuation')
7362
            outfile.write(' continuation="%s"' % self.gds_format_boolean(self.continuation, input_name='continuation'))
7363
        if self.custom is not None and 'custom' not in already_processed:
7364
            already_processed.add('custom')
7365
            outfile.write(' custom=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.custom), input_name='custom')), ))
7366
        if self.comments is not None and 'comments' not in already_processed:
7367
            already_processed.add('comments')
7368
            outfile.write(' comments=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.comments), input_name='comments')), ))
7369 View Code Duplication
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='UnorderedGroupIndexedType', fromsubclass_=False, pretty_print=True):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7370
        if pretty_print:
7371
            eol_ = '\n'
7372
        else:
7373
            eol_ = ''
7374
        if self.UserDefined is not None:
7375
            namespaceprefix_ = self.UserDefined_nsprefix_ + ':' if (UseCapturedNS_ and self.UserDefined_nsprefix_) else ''
7376
            self.UserDefined.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UserDefined', pretty_print=pretty_print)
7377
        for Labels_ in self.Labels:
7378
            namespaceprefix_ = self.Labels_nsprefix_ + ':' if (UseCapturedNS_ and self.Labels_nsprefix_) else ''
7379
            Labels_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Labels', pretty_print=pretty_print)
7380
        for RegionRef_ in self.RegionRef:
7381
            namespaceprefix_ = self.RegionRef_nsprefix_ + ':' if (UseCapturedNS_ and self.RegionRef_nsprefix_) else ''
7382
            RegionRef_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='RegionRef', pretty_print=pretty_print)
7383
        for OrderedGroup_ in self.OrderedGroup:
7384
            namespaceprefix_ = self.OrderedGroup_nsprefix_ + ':' if (UseCapturedNS_ and self.OrderedGroup_nsprefix_) else ''
7385
            OrderedGroup_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='OrderedGroup', pretty_print=pretty_print)
7386
        for UnorderedGroup_ in self.UnorderedGroup:
7387
            namespaceprefix_ = self.UnorderedGroup_nsprefix_ + ':' if (UseCapturedNS_ and self.UnorderedGroup_nsprefix_) else ''
7388
            UnorderedGroup_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UnorderedGroup', pretty_print=pretty_print)
7389 View Code Duplication
    def to_etree(self, parent_element=None, name_='UnorderedGroupIndexedType', mapping_=None, reverse_mapping_=None, nsmap_=None):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7390
        if parent_element is None:
7391
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
7392
        else:
7393
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
7394
        if self.id is not None:
7395
            element.set('id', self.gds_format_string(self.id))
7396
        if self.regionRef is not None:
7397
            element.set('regionRef', self.gds_format_string(self.regionRef))
7398
        if self.index is not None:
7399
            element.set('index', self.gds_format_integer(self.index))
7400
        if self.caption is not None:
7401
            element.set('caption', self.gds_format_string(self.caption))
7402
        if self.type_ is not None:
7403
            element.set('type', self.gds_format_string(self.type_))
7404
        if self.continuation is not None:
7405
            element.set('continuation', self.gds_format_boolean(self.continuation))
7406
        if self.custom is not None:
7407
            element.set('custom', self.gds_format_string(self.custom))
7408
        if self.comments is not None:
7409
            element.set('comments', self.gds_format_string(self.comments))
7410
        if self.UserDefined is not None:
7411
            UserDefined_ = self.UserDefined
7412
            UserDefined_.to_etree(element, name_='UserDefined', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
7413
        for Labels_ in self.Labels:
7414
            Labels_.to_etree(element, name_='Labels', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
7415
        for RegionRef_ in self.RegionRef:
7416
            RegionRef_.to_etree(element, name_='RegionRef', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
7417
        for OrderedGroup_ in self.OrderedGroup:
7418
            OrderedGroup_.to_etree(element, name_='OrderedGroup', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
7419
        for UnorderedGroup_ in self.UnorderedGroup:
7420
            UnorderedGroup_.to_etree(element, name_='UnorderedGroup', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
7421
        if mapping_ is not None:
7422
            mapping_[id(self)] = element
7423
        if reverse_mapping_ is not None:
7424
            reverse_mapping_[element] = self
7425
        return element
7426
    def build(self, node, gds_collector_=None):
7427
        self.gds_collector_ = gds_collector_
7428
        if SaveElementTreeNode:
7429
            self.gds_elementtree_node_ = node
7430
        already_processed = set()
7431
        self.ns_prefix_ = node.prefix
7432
        self._buildAttributes(node, node.attrib, already_processed)
7433
        for child in node:
7434
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
7435
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
7436
        return self
7437 View Code Duplication
    def _buildAttributes(self, node, attrs, already_processed):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7438
        value = find_attr_value_('id', node)
7439
        if value is not None and 'id' not in already_processed:
7440
            already_processed.add('id')
7441
            self.id = value
7442
        value = find_attr_value_('regionRef', node)
7443
        if value is not None and 'regionRef' not in already_processed:
7444
            already_processed.add('regionRef')
7445
            self.regionRef = value
7446
        value = find_attr_value_('index', node)
7447
        if value is not None and 'index' not in already_processed:
7448
            already_processed.add('index')
7449
            self.index = self.gds_parse_integer(value, node, 'index')
7450
        value = find_attr_value_('caption', node)
7451
        if value is not None and 'caption' not in already_processed:
7452
            already_processed.add('caption')
7453
            self.caption = value
7454
        value = find_attr_value_('type', node)
7455
        if value is not None and 'type' not in already_processed:
7456
            already_processed.add('type')
7457
            self.type_ = value
7458
            self.validate_GroupTypeSimpleType(self.type_)    # validate type GroupTypeSimpleType
7459
        value = find_attr_value_('continuation', node)
7460
        if value is not None and 'continuation' not in already_processed:
7461
            already_processed.add('continuation')
7462
            if value in ('true', '1'):
7463
                self.continuation = True
7464
            elif value in ('false', '0'):
7465
                self.continuation = False
7466
            else:
7467
                raise_parse_error(node, 'Bad boolean attribute')
7468
        value = find_attr_value_('custom', node)
7469
        if value is not None and 'custom' not in already_processed:
7470
            already_processed.add('custom')
7471
            self.custom = value
7472
        value = find_attr_value_('comments', node)
7473
        if value is not None and 'comments' not in already_processed:
7474
            already_processed.add('comments')
7475
            self.comments = value
7476 View Code Duplication
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7477
        if nodeName_ == 'UserDefined':
7478
            obj_ = UserDefinedType.factory(parent_object_=self)
7479
            obj_.build(child_, gds_collector_=gds_collector_)
7480
            self.UserDefined = obj_
7481
            obj_.original_tagname_ = 'UserDefined'
7482
        elif nodeName_ == 'Labels':
7483
            obj_ = LabelsType.factory(parent_object_=self)
7484
            obj_.build(child_, gds_collector_=gds_collector_)
7485
            self.Labels.append(obj_)
7486
            obj_.original_tagname_ = 'Labels'
7487
        elif nodeName_ == 'RegionRef':
7488
            obj_ = RegionRefType.factory(parent_object_=self)
7489
            obj_.build(child_, gds_collector_=gds_collector_)
7490
            self.RegionRef.append(obj_)
7491
            obj_.original_tagname_ = 'RegionRef'
7492
        elif nodeName_ == 'OrderedGroup':
7493
            obj_ = OrderedGroupType.factory(parent_object_=self)
7494
            obj_.build(child_, gds_collector_=gds_collector_)
7495
            self.OrderedGroup.append(obj_)
7496
            obj_.original_tagname_ = 'OrderedGroup'
7497
        elif nodeName_ == 'UnorderedGroup':
7498
            obj_ = UnorderedGroupType.factory(parent_object_=self)
7499
            obj_.build(child_, gds_collector_=gds_collector_)
7500
            self.UnorderedGroup.append(obj_)
7501
            obj_.original_tagname_ = 'UnorderedGroup'
7502
    def __hash__(self):
7503
        return hash(self.id)
7504
    def get_UnorderedGroupChildren(self):
7505
        """
7506
        List all non-metadata children of an :py:class:`UnorderedGroupType`
7507
        """
7508
        # TODO: should not change order
7509
        return self.get_RegionRef() + self.get_OrderedGroup() + self.get_UnorderedGroup()
7510
    
7511
# end class UnorderedGroupIndexedType
7512
7513
7514
class RegionRefType(GeneratedsSuper):
7515
    __hash__ = GeneratedsSuper.__hash__
7516
    member_data_items_ = [
7517
        MemberSpec_('regionRef', 'string', 0, 0, {'use': 'required', 'name': 'regionRef'}),
7518
    ]
7519
    subclass = None
7520
    superclass = None
7521
    def __init__(self, regionRef=None, gds_collector_=None, **kwargs_):
7522
        self.gds_collector_ = gds_collector_
7523
        self.gds_elementtree_node_ = None
7524
        self.original_tagname_ = None
7525
        self.parent_object_ = kwargs_.get('parent_object_')
7526
        self.ns_prefix_ = "pc"
7527
        self.regionRef = _cast(None, regionRef)
7528
        self.regionRef_nsprefix_ = "pc"
7529
    def factory(*args_, **kwargs_):
7530
        if CurrentSubclassModule_ is not None:
7531
            subclass = getSubclassFromModule_(
7532
                CurrentSubclassModule_, RegionRefType)
7533
            if subclass is not None:
7534
                return subclass(*args_, **kwargs_)
7535
        if RegionRefType.subclass:
7536
            return RegionRefType.subclass(*args_, **kwargs_)
7537
        else:
7538
            return RegionRefType(*args_, **kwargs_)
7539
    factory = staticmethod(factory)
7540
    def get_ns_prefix_(self):
7541
        return self.ns_prefix_
7542
    def set_ns_prefix_(self, ns_prefix):
7543
        self.ns_prefix_ = ns_prefix
7544
    def get_regionRef(self):
7545
        return self.regionRef
7546
    def set_regionRef(self, regionRef):
7547
        self.regionRef = regionRef
7548
    def has__content(self):
7549
        if (
7550
7551
        ):
7552
            return True
7553
        else:
7554
            return False
7555
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RegionRefType', pretty_print=True):
7556
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('RegionRefType')
7557
        if imported_ns_def_ is not None:
7558
            namespacedef_ = imported_ns_def_
7559
        if pretty_print:
7560
            eol_ = '\n'
7561
        else:
7562
            eol_ = ''
7563
        if self.original_tagname_ is not None and name_ == 'RegionRefType':
7564
            name_ = self.original_tagname_
7565
        if UseCapturedNS_ and self.ns_prefix_:
7566
            namespaceprefix_ = self.ns_prefix_ + ':'
7567
        showIndent(outfile, level, pretty_print)
7568
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
7569
        already_processed = set()
7570
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='RegionRefType')
7571
        if self.has__content():
7572
            outfile.write('>%s' % (eol_, ))
7573
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='RegionRefType', pretty_print=pretty_print)
7574
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
7575
        else:
7576
            outfile.write('/>%s' % (eol_, ))
7577
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='RegionRefType'):
7578
        if self.regionRef is not None and 'regionRef' not in already_processed:
7579
            already_processed.add('regionRef')
7580
            outfile.write(' regionRef=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.regionRef), input_name='regionRef')), ))
7581
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RegionRefType', fromsubclass_=False, pretty_print=True):
7582
        pass
7583
    def to_etree(self, parent_element=None, name_='RegionRefType', mapping_=None, reverse_mapping_=None, nsmap_=None):
7584
        if parent_element is None:
7585
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
7586
        else:
7587
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
7588
        if self.regionRef is not None:
7589
            element.set('regionRef', self.gds_format_string(self.regionRef))
7590
        if mapping_ is not None:
7591
            mapping_[id(self)] = element
7592
        if reverse_mapping_ is not None:
7593
            reverse_mapping_[element] = self
7594
        return element
7595
    def build(self, node, gds_collector_=None):
7596
        self.gds_collector_ = gds_collector_
7597
        if SaveElementTreeNode:
7598
            self.gds_elementtree_node_ = node
7599
        already_processed = set()
7600
        self.ns_prefix_ = node.prefix
7601
        self._buildAttributes(node, node.attrib, already_processed)
7602
        for child in node:
7603
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
7604
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
7605
        return self
7606
    def _buildAttributes(self, node, attrs, already_processed):
7607
        value = find_attr_value_('regionRef', node)
7608
        if value is not None and 'regionRef' not in already_processed:
7609
            already_processed.add('regionRef')
7610
            self.regionRef = value
7611
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
7612
        pass
7613
    def __hash__(self):
7614
        return hash(self.id)
7615
# end class RegionRefType
7616
7617
7618
class OrderedGroupType(GeneratedsSuper):
7619
    """OrderedGroupType --
7620
    Numbered group (contains ordered elements)
7621
      
7622
    * regionRef --
7623
      Optional link to a parent region of nested regions.
7624
      The parent region doubles as reading order group.
7625
      Only the nested regions should be allowed as group members.
7626
      
7627
    * continuation --
7628
      Is this group a continuation of another group
7629
      (from previous column or page, for example)?
7630
      
7631
    * custom -- For generic use
7632
    * Labels -- Semantic labels / tags
7633
    
7634
    """
7635
    __hash__ = GeneratedsSuper.__hash__
7636
    member_data_items_ = [
7637
        MemberSpec_('id', 'string', 0, 0, {'use': 'required', 'name': 'id'}),
7638
        MemberSpec_('regionRef', 'string', 0, 1, {'use': 'optional', 'name': 'regionRef'}),
7639
        MemberSpec_('caption', 'string', 0, 1, {'use': 'optional', 'name': 'caption'}),
7640
        MemberSpec_('type_', 'pc:GroupTypeSimpleType', 0, 1, {'use': 'optional', 'name': 'type_'}),
7641
        MemberSpec_('continuation', 'boolean', 0, 1, {'use': 'optional', 'name': 'continuation'}),
7642
        MemberSpec_('custom', 'string', 0, 1, {'use': 'optional', 'name': 'custom'}),
7643
        MemberSpec_('comments', 'string', 0, 1, {'use': 'optional', 'name': 'comments'}),
7644
        MemberSpec_('UserDefined', 'UserDefinedType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'UserDefined', 'type': 'UserDefinedType'}, None),
7645
        MemberSpec_('Labels', 'LabelsType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Labels', 'type': 'LabelsType'}, None),
7646
        MemberSpec_('RegionRefIndexed', 'RegionRefIndexedType', 1, 0, {'name': 'RegionRefIndexed', 'type': 'RegionRefIndexedType'}, 5),
7647
        MemberSpec_('OrderedGroupIndexed', 'OrderedGroupIndexedType', 1, 0, {'name': 'OrderedGroupIndexed', 'type': 'OrderedGroupIndexedType'}, 5),
7648
        MemberSpec_('UnorderedGroupIndexed', 'UnorderedGroupIndexedType', 1, 0, {'name': 'UnorderedGroupIndexed', 'type': 'UnorderedGroupIndexedType'}, 5),
7649
    ]
7650
    subclass = None
7651
    superclass = None
7652 View Code Duplication
    def __init__(self, id=None, regionRef=None, caption=None, type_=None, continuation=None, custom=None, comments=None, UserDefined=None, Labels=None, RegionRefIndexed=None, OrderedGroupIndexed=None, UnorderedGroupIndexed=None, gds_collector_=None, **kwargs_):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7653
        self.gds_collector_ = gds_collector_
7654
        self.gds_elementtree_node_ = None
7655
        self.original_tagname_ = None
7656
        self.parent_object_ = kwargs_.get('parent_object_')
7657
        self.ns_prefix_ = "pc"
7658
        self.id = _cast(None, id)
7659
        self.id_nsprefix_ = "pc"
7660
        self.regionRef = _cast(None, regionRef)
7661
        self.regionRef_nsprefix_ = "pc"
7662
        self.caption = _cast(None, caption)
7663
        self.caption_nsprefix_ = "pc"
7664
        self.type_ = _cast(None, type_)
7665
        self.type__nsprefix_ = "pc"
7666
        self.continuation = _cast(bool, continuation)
7667
        self.continuation_nsprefix_ = "pc"
7668
        self.custom = _cast(None, custom)
7669
        self.custom_nsprefix_ = "pc"
7670
        self.comments = _cast(None, comments)
7671
        self.comments_nsprefix_ = "pc"
7672
        self.UserDefined = UserDefined
7673
        self.UserDefined_nsprefix_ = "pc"
7674
        if Labels is None:
7675
            self.Labels = []
7676
        else:
7677
            self.Labels = Labels
7678
        self.Labels_nsprefix_ = "pc"
7679
        if RegionRefIndexed is None:
7680
            self.RegionRefIndexed = []
7681
        else:
7682
            self.RegionRefIndexed = RegionRefIndexed
7683
        self.RegionRefIndexed_nsprefix_ = "pc"
7684
        if OrderedGroupIndexed is None:
7685
            self.OrderedGroupIndexed = []
7686
        else:
7687
            self.OrderedGroupIndexed = OrderedGroupIndexed
7688
        self.OrderedGroupIndexed_nsprefix_ = "pc"
7689
        if UnorderedGroupIndexed is None:
7690
            self.UnorderedGroupIndexed = []
7691
        else:
7692
            self.UnorderedGroupIndexed = UnorderedGroupIndexed
7693
        self.UnorderedGroupIndexed_nsprefix_ = "pc"
7694
    def factory(*args_, **kwargs_):
7695
        if CurrentSubclassModule_ is not None:
7696
            subclass = getSubclassFromModule_(
7697
                CurrentSubclassModule_, OrderedGroupType)
7698
            if subclass is not None:
7699
                return subclass(*args_, **kwargs_)
7700
        if OrderedGroupType.subclass:
7701
            return OrderedGroupType.subclass(*args_, **kwargs_)
7702
        else:
7703
            return OrderedGroupType(*args_, **kwargs_)
7704
    factory = staticmethod(factory)
7705
    def get_ns_prefix_(self):
7706
        return self.ns_prefix_
7707
    def set_ns_prefix_(self, ns_prefix):
7708
        self.ns_prefix_ = ns_prefix
7709
    def get_UserDefined(self):
7710
        return self.UserDefined
7711
    def set_UserDefined(self, UserDefined):
7712
        self.UserDefined = UserDefined
7713
    def get_Labels(self):
7714
        return self.Labels
7715
    def set_Labels(self, Labels):
7716
        self.Labels = Labels
7717
    def add_Labels(self, value):
7718
        self.Labels.append(value)
7719
    def insert_Labels_at(self, index, value):
7720
        self.Labels.insert(index, value)
7721
    def replace_Labels_at(self, index, value):
7722
        self.Labels[index] = value
7723
    def get_RegionRefIndexed(self):
7724
        return self.RegionRefIndexed
7725
    def set_RegionRefIndexed(self, RegionRefIndexed):
7726
        self.RegionRefIndexed = RegionRefIndexed
7727
    def add_RegionRefIndexed(self, value):
7728
        self.RegionRefIndexed.append(value)
7729
    def insert_RegionRefIndexed_at(self, index, value):
7730
        self.RegionRefIndexed.insert(index, value)
7731
    def replace_RegionRefIndexed_at(self, index, value):
7732
        self.RegionRefIndexed[index] = value
7733
    def get_OrderedGroupIndexed(self):
7734
        return self.OrderedGroupIndexed
7735
    def set_OrderedGroupIndexed(self, OrderedGroupIndexed):
7736
        self.OrderedGroupIndexed = OrderedGroupIndexed
7737
    def add_OrderedGroupIndexed(self, value):
7738
        self.OrderedGroupIndexed.append(value)
7739
    def insert_OrderedGroupIndexed_at(self, index, value):
7740
        self.OrderedGroupIndexed.insert(index, value)
7741
    def replace_OrderedGroupIndexed_at(self, index, value):
7742
        self.OrderedGroupIndexed[index] = value
7743
    def get_UnorderedGroupIndexed(self):
7744
        return self.UnorderedGroupIndexed
7745
    def set_UnorderedGroupIndexed(self, UnorderedGroupIndexed):
7746
        self.UnorderedGroupIndexed = UnorderedGroupIndexed
7747
    def add_UnorderedGroupIndexed(self, value):
7748
        self.UnorderedGroupIndexed.append(value)
7749
    def insert_UnorderedGroupIndexed_at(self, index, value):
7750
        self.UnorderedGroupIndexed.insert(index, value)
7751
    def replace_UnorderedGroupIndexed_at(self, index, value):
7752
        self.UnorderedGroupIndexed[index] = value
7753
    def get_id(self):
7754
        return self.id
7755
    def set_id(self, id):
7756
        self.id = id
7757
    def get_regionRef(self):
7758
        return self.regionRef
7759
    def set_regionRef(self, regionRef):
7760
        self.regionRef = regionRef
7761
    def get_caption(self):
7762
        return self.caption
7763
    def set_caption(self, caption):
7764
        self.caption = caption
7765
    def get_type(self):
7766
        return self.type_
7767
    def set_type(self, type_):
7768
        self.type_ = type_
7769
    def get_continuation(self):
7770
        return self.continuation
7771
    def set_continuation(self, continuation):
7772
        self.continuation = continuation
7773
    def get_custom(self):
7774
        return self.custom
7775
    def set_custom(self, custom):
7776
        self.custom = custom
7777
    def get_comments(self):
7778
        return self.comments
7779
    def set_comments(self, comments):
7780
        self.comments = comments
7781
    def validate_GroupTypeSimpleType(self, value):
7782
        # Validate type pc:GroupTypeSimpleType, a restriction on string.
7783
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
7784
            if not isinstance(value, str):
7785
                lineno = self.gds_get_node_lineno_()
7786
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
7787
                return False
7788
            value = value
7789
            enumerations = ['paragraph', 'list', 'list-item', 'figure', 'article', 'div', 'other']
7790
            if value not in enumerations:
7791
                lineno = self.gds_get_node_lineno_()
7792
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on GroupTypeSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
7793
                result = False
7794
    def has__content(self):
7795
        if (
7796
            self.UserDefined is not None or
7797
            self.Labels or
7798
            self.RegionRefIndexed or
7799
            self.OrderedGroupIndexed or
7800
            self.UnorderedGroupIndexed
7801
        ):
7802
            return True
7803
        else:
7804
            return False
7805
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='OrderedGroupType', pretty_print=True):
7806
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('OrderedGroupType')
7807
        if imported_ns_def_ is not None:
7808
            namespacedef_ = imported_ns_def_
7809
        if pretty_print:
7810
            eol_ = '\n'
7811
        else:
7812
            eol_ = ''
7813
        if self.original_tagname_ is not None and name_ == 'OrderedGroupType':
7814
            name_ = self.original_tagname_
7815
        if UseCapturedNS_ and self.ns_prefix_:
7816
            namespaceprefix_ = self.ns_prefix_ + ':'
7817
        showIndent(outfile, level, pretty_print)
7818
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
7819
        already_processed = set()
7820
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='OrderedGroupType')
7821
        if self.has__content():
7822
            outfile.write('>%s' % (eol_, ))
7823
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='OrderedGroupType', pretty_print=pretty_print)
7824
            showIndent(outfile, level, pretty_print)
7825
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
7826
        else:
7827
            outfile.write('/>%s' % (eol_, ))
7828 View Code Duplication
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='OrderedGroupType'):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7829
        if self.id is not None and 'id' not in already_processed:
7830
            already_processed.add('id')
7831
            outfile.write(' id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.id), input_name='id')), ))
7832
        if self.regionRef is not None and 'regionRef' not in already_processed:
7833
            already_processed.add('regionRef')
7834
            outfile.write(' regionRef=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.regionRef), input_name='regionRef')), ))
7835
        if self.caption is not None and 'caption' not in already_processed:
7836
            already_processed.add('caption')
7837
            outfile.write(' caption=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.caption), input_name='caption')), ))
7838
        if self.type_ is not None and 'type_' not in already_processed:
7839
            already_processed.add('type_')
7840
            outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), ))
7841
        if self.continuation is not None and 'continuation' not in already_processed:
7842
            already_processed.add('continuation')
7843
            outfile.write(' continuation="%s"' % self.gds_format_boolean(self.continuation, input_name='continuation'))
7844
        if self.custom is not None and 'custom' not in already_processed:
7845
            already_processed.add('custom')
7846
            outfile.write(' custom=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.custom), input_name='custom')), ))
7847
        if self.comments is not None and 'comments' not in already_processed:
7848
            already_processed.add('comments')
7849
            outfile.write(' comments=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.comments), input_name='comments')), ))
7850 View Code Duplication
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='OrderedGroupType', fromsubclass_=False, pretty_print=True):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7851
        if pretty_print:
7852
            eol_ = '\n'
7853
        else:
7854
            eol_ = ''
7855
        if self.UserDefined is not None:
7856
            namespaceprefix_ = self.UserDefined_nsprefix_ + ':' if (UseCapturedNS_ and self.UserDefined_nsprefix_) else ''
7857
            self.UserDefined.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UserDefined', pretty_print=pretty_print)
7858
        for Labels_ in self.Labels:
7859
            namespaceprefix_ = self.Labels_nsprefix_ + ':' if (UseCapturedNS_ and self.Labels_nsprefix_) else ''
7860
            Labels_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Labels', pretty_print=pretty_print)
7861
        for RegionRefIndexed_ in self.RegionRefIndexed:
7862
            namespaceprefix_ = self.RegionRefIndexed_nsprefix_ + ':' if (UseCapturedNS_ and self.RegionRefIndexed_nsprefix_) else ''
7863
            RegionRefIndexed_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='RegionRefIndexed', pretty_print=pretty_print)
7864
        for OrderedGroupIndexed_ in self.OrderedGroupIndexed:
7865
            namespaceprefix_ = self.OrderedGroupIndexed_nsprefix_ + ':' if (UseCapturedNS_ and self.OrderedGroupIndexed_nsprefix_) else ''
7866
            OrderedGroupIndexed_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='OrderedGroupIndexed', pretty_print=pretty_print)
7867
        for UnorderedGroupIndexed_ in self.UnorderedGroupIndexed:
7868
            namespaceprefix_ = self.UnorderedGroupIndexed_nsprefix_ + ':' if (UseCapturedNS_ and self.UnorderedGroupIndexed_nsprefix_) else ''
7869
            UnorderedGroupIndexed_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UnorderedGroupIndexed', pretty_print=pretty_print)
7870
    def to_etree(self, parent_element=None, name_='OrderedGroupType', mapping_=None, reverse_mapping_=None, nsmap_=None):
7871
        if parent_element is None:
7872
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
7873
        else:
7874
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
7875
        if self.id is not None:
7876
            element.set('id', self.gds_format_string(self.id))
7877
        if self.regionRef is not None:
7878
            element.set('regionRef', self.gds_format_string(self.regionRef))
7879
        if self.caption is not None:
7880
            element.set('caption', self.gds_format_string(self.caption))
7881
        if self.type_ is not None:
7882
            element.set('type', self.gds_format_string(self.type_))
7883
        if self.continuation is not None:
7884
            element.set('continuation', self.gds_format_boolean(self.continuation))
7885
        if self.custom is not None:
7886
            element.set('custom', self.gds_format_string(self.custom))
7887
        if self.comments is not None:
7888
            element.set('comments', self.gds_format_string(self.comments))
7889
        if self.UserDefined is not None:
7890
            UserDefined_ = self.UserDefined
7891
            UserDefined_.to_etree(element, name_='UserDefined', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
7892
        for Labels_ in self.Labels:
7893
            Labels_.to_etree(element, name_='Labels', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
7894
        for RegionRefIndexed_ in self.RegionRefIndexed:
7895
            RegionRefIndexed_.to_etree(element, name_='RegionRefIndexed', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
7896
        for OrderedGroupIndexed_ in self.OrderedGroupIndexed:
7897
            OrderedGroupIndexed_.to_etree(element, name_='OrderedGroupIndexed', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
7898
        for UnorderedGroupIndexed_ in self.UnorderedGroupIndexed:
7899
            UnorderedGroupIndexed_.to_etree(element, name_='UnorderedGroupIndexed', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
7900
        if mapping_ is not None:
7901
            mapping_[id(self)] = element
7902
        if reverse_mapping_ is not None:
7903
            reverse_mapping_[element] = self
7904
        return element
7905
    def build(self, node, gds_collector_=None):
7906
        self.gds_collector_ = gds_collector_
7907
        if SaveElementTreeNode:
7908
            self.gds_elementtree_node_ = node
7909
        already_processed = set()
7910
        self.ns_prefix_ = node.prefix
7911
        self._buildAttributes(node, node.attrib, already_processed)
7912
        for child in node:
7913
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
7914
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
7915
        return self
7916 View Code Duplication
    def _buildAttributes(self, node, attrs, already_processed):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7917
        value = find_attr_value_('id', node)
7918
        if value is not None and 'id' not in already_processed:
7919
            already_processed.add('id')
7920
            self.id = value
7921
        value = find_attr_value_('regionRef', node)
7922
        if value is not None and 'regionRef' not in already_processed:
7923
            already_processed.add('regionRef')
7924
            self.regionRef = value
7925
        value = find_attr_value_('caption', node)
7926
        if value is not None and 'caption' not in already_processed:
7927
            already_processed.add('caption')
7928
            self.caption = value
7929
        value = find_attr_value_('type', node)
7930
        if value is not None and 'type' not in already_processed:
7931
            already_processed.add('type')
7932
            self.type_ = value
7933
            self.validate_GroupTypeSimpleType(self.type_)    # validate type GroupTypeSimpleType
7934
        value = find_attr_value_('continuation', node)
7935
        if value is not None and 'continuation' not in already_processed:
7936
            already_processed.add('continuation')
7937
            if value in ('true', '1'):
7938
                self.continuation = True
7939
            elif value in ('false', '0'):
7940
                self.continuation = False
7941
            else:
7942
                raise_parse_error(node, 'Bad boolean attribute')
7943
        value = find_attr_value_('custom', node)
7944
        if value is not None and 'custom' not in already_processed:
7945
            already_processed.add('custom')
7946
            self.custom = value
7947
        value = find_attr_value_('comments', node)
7948
        if value is not None and 'comments' not in already_processed:
7949
            already_processed.add('comments')
7950
            self.comments = value
7951 View Code Duplication
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7952
        if nodeName_ == 'UserDefined':
7953
            obj_ = UserDefinedType.factory(parent_object_=self)
7954
            obj_.build(child_, gds_collector_=gds_collector_)
7955
            self.UserDefined = obj_
7956
            obj_.original_tagname_ = 'UserDefined'
7957
        elif nodeName_ == 'Labels':
7958
            obj_ = LabelsType.factory(parent_object_=self)
7959
            obj_.build(child_, gds_collector_=gds_collector_)
7960
            self.Labels.append(obj_)
7961
            obj_.original_tagname_ = 'Labels'
7962
        elif nodeName_ == 'RegionRefIndexed':
7963
            obj_ = RegionRefIndexedType.factory(parent_object_=self)
7964
            obj_.build(child_, gds_collector_=gds_collector_)
7965
            self.RegionRefIndexed.append(obj_)
7966
            obj_.original_tagname_ = 'RegionRefIndexed'
7967
        elif nodeName_ == 'OrderedGroupIndexed':
7968
            obj_ = OrderedGroupIndexedType.factory(parent_object_=self)
7969
            obj_.build(child_, gds_collector_=gds_collector_)
7970
            self.OrderedGroupIndexed.append(obj_)
7971
            obj_.original_tagname_ = 'OrderedGroupIndexed'
7972
        elif nodeName_ == 'UnorderedGroupIndexed':
7973
            obj_ = UnorderedGroupIndexedType.factory(parent_object_=self)
7974
            obj_.build(child_, gds_collector_=gds_collector_)
7975
            self.UnorderedGroupIndexed.append(obj_)
7976
            obj_.original_tagname_ = 'UnorderedGroupIndexed'
7977
    def __hash__(self):
7978
        return hash(self.id)
7979
    # pylint: disable=invalid-name,missing-module-docstring,line-too-long
7980 View Code Duplication
    def get_AllIndexed(self, classes=None, index_sort=True):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7981
        """
7982
        Get all indexed children sorted by their ``@index``.
7983
    
7984
        Arguments:
7985
            classes (list): Type of children (sans ``Indexed``) to return. \
7986
                Default: ``['RegionRef', 'OrderedGroup', 'UnorderedGroup']``
7987
            index_sort (boolean): Whether to sort by ``@index``
7988
    
7989
        Returns:
7990
            a list of :py:class:`RegionRefIndexedType`, \
7991
                :py:class:`OrderedGroupIndexedType`, and \
7992
                :py:class:`UnorderedGroupIndexedType`
7993
        """
7994
        if not classes:
7995
            classes = ['RegionRef', 'OrderedGroup', 'UnorderedGroup']
7996
        ret = []
7997
        for class_ in classes:
7998
            ret += getattr(self, 'get_{}Indexed'.format(class_))()
7999
        if index_sort:
8000
            return sorted(ret, key=lambda x: x.index)
8001
        return ret
8002
    def clear_AllIndexed(self):
8003
        ret = self.get_AllIndexed()
8004
        self.set_RegionRefIndexed([])
8005
        self.set_OrderedGroupIndexed([])
8006
        self.set_UnorderedGroupIndexed([])
8007
        return ret
8008
    
8009
    # pylint: disable=line-too-long,invalid-name,missing-module-docstring
8010 View Code Duplication
    def extend_AllIndexed(self, elements, validate_continuity=False):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8011
        """
8012
        Add all elements in list `elements`, respecting ``@index`` order.
8013
        With `validate_continuity`, check that all new elements come after all old elements
8014
        (or raise an exception). 
8015
        Otherwise, ensure this condition silently (by increasing ``@index`` accordingly).
8016
        """
8017
        if not isinstance(elements, list):
8018
            elements = [elements]
8019
        siblings = self.get_AllIndexed()
8020
        highest_sibling_index = siblings[-1].index if siblings else -1
8021
        if validate_continuity:
8022
            elements = sorted(elements, key=lambda x: x.index)
8023
            lowest_element_index = elements[0].index
8024
            if lowest_element_index <= highest_sibling_index:
8025
                raise Exception("@index already used: {}".format(lowest_element_index))
8026
        else:
8027
            for element in elements:
8028
                highest_sibling_index += 1
8029
                element.index = highest_sibling_index
8030
        for element in elements:
8031
            if isinstance(element, RegionRefIndexedType): # pylint: disable=undefined-variable
8032
                self.add_RegionRefIndexed(element)
8033
            elif isinstance(element, OrderedGroupIndexedType): # pylint: disable=undefined-variable
8034
                self.add_OrderedGroupIndexed(element)
8035
            elif isinstance(element, UnorderedGroupIndexedType): # pylint: disable=undefined-variable
8036
                self.add_UnorderedGroupIndexed(element)
8037
        return self.get_AllIndexed()
8038
    # pylint: disable=line-too-long,invalid-name,missing-module-docstring
8039 View Code Duplication
    def sort_AllIndexed(self, validate_uniqueness=True):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8040
        """
8041
        Sort all indexed children in-place.
8042
        """
8043
        elements = self.get_AllIndexed(index_sort=True)
8044
        self.clear_AllIndexed()
8045
        for element in elements:
8046
            if isinstance(element, RegionRefIndexedType): # pylint: disable=undefined-variable
8047
                self.add_RegionRefIndexed(element)
8048
            elif isinstance(element, OrderedGroupIndexedType): # pylint: disable=undefined-variable
8049
                self.add_OrderedGroupIndexed(element)
8050
            elif isinstance(element, UnorderedGroupIndexedType): # pylint: disable=undefined-variable
8051
                self.add_UnorderedGroupIndexed(element)
8052
        return self.get_AllIndexed()
8053
    
8054
    # pylint: disable=line-too-long,invalid-name,missing-module-docstring,missing-function-docstring
8055 View Code Duplication
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='OrderedGroupType', fromsubclass_=False, pretty_print=True): # pylint: disable=unused-argument,too-many-arguments
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8056
        if pretty_print:
8057
            eol_ = '\n'
8058
        else:
8059
            eol_ = ''
8060
        if self.UserDefined is not None:
8061
            namespaceprefix_ = self.UserDefined_nsprefix_ + ':' if (UseCapturedNS_ and self.UserDefined_nsprefix_) else ''
8062
            self.UserDefined.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UserDefined', pretty_print=pretty_print)
8063
        for Labels_ in self.Labels:
8064
            namespaceprefix_ = self.Labels_nsprefix_ + ':' if (UseCapturedNS_ and self.Labels_nsprefix_) else ''
8065
            Labels_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Labels', pretty_print=pretty_print)
8066
        cleaned = []
8067
        def replaceWithRRI(group):
8068
            rri = RegionRefIndexedType.factory(parent_object_=self) # pylint: disable=undefined-variable
8069
            rri.index = group.index
8070
            rri.regionRef = group.regionRef
8071
            cleaned.append(rri)
8072
        # remove empty groups and replace with RegionRefIndexedType
8073
        for entry in self.get_AllIndexed():
8074
            # pylint: disable=undefined-variable
8075
            if isinstance(entry, (OrderedGroupIndexedType)) and not entry.get_AllIndexed():
8076
                replaceWithRRI(entry)
8077
            elif isinstance(entry, UnorderedGroupIndexedType) and not entry.get_UnorderedGroupChildren():
8078
                replaceWithRRI(entry)
8079
            else:
8080
                cleaned.append(entry)
8081
        for entry in cleaned:
8082
            entry.export(outfile, level, namespaceprefix_, namespacedef_='', name_=entry.__class__.__name__[:-4], pretty_print=pretty_print)
8083
# end class OrderedGroupType
8084
8085
8086
class UnorderedGroupType(GeneratedsSuper):
8087
    """UnorderedGroupType --
8088
    Numbered group (contains unordered elements)
8089
      
8090
    * regionRef --
8091
      Optional link to a parent region of nested regions.
8092
      The parent region doubles as reading order group.
8093
      Only the nested regions should be allowed as group members.
8094
      
8095
    * continuation --
8096
      Is this group a continuation of another group
8097
      (from previous column or page, for example)?
8098
      
8099
    * custom -- For generic use
8100
    * Labels -- Semantic labels / tags
8101
    
8102
    """
8103
    __hash__ = GeneratedsSuper.__hash__
8104
    member_data_items_ = [
8105
        MemberSpec_('id', 'string', 0, 0, {'use': 'required', 'name': 'id'}),
8106
        MemberSpec_('regionRef', 'string', 0, 1, {'use': 'optional', 'name': 'regionRef'}),
8107
        MemberSpec_('caption', 'string', 0, 1, {'use': 'optional', 'name': 'caption'}),
8108
        MemberSpec_('type_', 'pc:GroupTypeSimpleType', 0, 1, {'use': 'optional', 'name': 'type_'}),
8109
        MemberSpec_('continuation', 'boolean', 0, 1, {'use': 'optional', 'name': 'continuation'}),
8110
        MemberSpec_('custom', 'string', 0, 1, {'use': 'optional', 'name': 'custom'}),
8111
        MemberSpec_('comments', 'string', 0, 1, {'use': 'optional', 'name': 'comments'}),
8112
        MemberSpec_('UserDefined', 'UserDefinedType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'UserDefined', 'type': 'UserDefinedType'}, None),
8113
        MemberSpec_('Labels', 'LabelsType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Labels', 'type': 'LabelsType'}, None),
8114
        MemberSpec_('RegionRef', 'RegionRefType', 1, 0, {'name': 'RegionRef', 'type': 'RegionRefType'}, 6),
8115
        MemberSpec_('OrderedGroup', 'OrderedGroupType', 1, 0, {'name': 'OrderedGroup', 'type': 'OrderedGroupType'}, 6),
8116
        MemberSpec_('UnorderedGroup', 'UnorderedGroupType', 1, 0, {'name': 'UnorderedGroup', 'type': 'UnorderedGroupType'}, 6),
8117
    ]
8118
    subclass = None
8119
    superclass = None
8120 View Code Duplication
    def __init__(self, id=None, regionRef=None, caption=None, type_=None, continuation=None, custom=None, comments=None, UserDefined=None, Labels=None, RegionRef=None, OrderedGroup=None, UnorderedGroup=None, gds_collector_=None, **kwargs_):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8121
        self.gds_collector_ = gds_collector_
8122
        self.gds_elementtree_node_ = None
8123
        self.original_tagname_ = None
8124
        self.parent_object_ = kwargs_.get('parent_object_')
8125
        self.ns_prefix_ = "pc"
8126
        self.id = _cast(None, id)
8127
        self.id_nsprefix_ = "pc"
8128
        self.regionRef = _cast(None, regionRef)
8129
        self.regionRef_nsprefix_ = "pc"
8130
        self.caption = _cast(None, caption)
8131
        self.caption_nsprefix_ = "pc"
8132
        self.type_ = _cast(None, type_)
8133
        self.type__nsprefix_ = "pc"
8134
        self.continuation = _cast(bool, continuation)
8135
        self.continuation_nsprefix_ = "pc"
8136
        self.custom = _cast(None, custom)
8137
        self.custom_nsprefix_ = "pc"
8138
        self.comments = _cast(None, comments)
8139
        self.comments_nsprefix_ = "pc"
8140
        self.UserDefined = UserDefined
8141
        self.UserDefined_nsprefix_ = "pc"
8142
        if Labels is None:
8143
            self.Labels = []
8144
        else:
8145
            self.Labels = Labels
8146
        self.Labels_nsprefix_ = "pc"
8147
        if RegionRef is None:
8148
            self.RegionRef = []
8149
        else:
8150
            self.RegionRef = RegionRef
8151
        self.RegionRef_nsprefix_ = "pc"
8152
        if OrderedGroup is None:
8153
            self.OrderedGroup = []
8154
        else:
8155
            self.OrderedGroup = OrderedGroup
8156
        self.OrderedGroup_nsprefix_ = "pc"
8157
        if UnorderedGroup is None:
8158
            self.UnorderedGroup = []
8159
        else:
8160
            self.UnorderedGroup = UnorderedGroup
8161
        self.UnorderedGroup_nsprefix_ = "pc"
8162
    def factory(*args_, **kwargs_):
8163
        if CurrentSubclassModule_ is not None:
8164
            subclass = getSubclassFromModule_(
8165
                CurrentSubclassModule_, UnorderedGroupType)
8166
            if subclass is not None:
8167
                return subclass(*args_, **kwargs_)
8168
        if UnorderedGroupType.subclass:
8169
            return UnorderedGroupType.subclass(*args_, **kwargs_)
8170
        else:
8171
            return UnorderedGroupType(*args_, **kwargs_)
8172
    factory = staticmethod(factory)
8173
    def get_ns_prefix_(self):
8174
        return self.ns_prefix_
8175
    def set_ns_prefix_(self, ns_prefix):
8176
        self.ns_prefix_ = ns_prefix
8177
    def get_UserDefined(self):
8178
        return self.UserDefined
8179
    def set_UserDefined(self, UserDefined):
8180
        self.UserDefined = UserDefined
8181
    def get_Labels(self):
8182
        return self.Labels
8183
    def set_Labels(self, Labels):
8184
        self.Labels = Labels
8185
    def add_Labels(self, value):
8186
        self.Labels.append(value)
8187
    def insert_Labels_at(self, index, value):
8188
        self.Labels.insert(index, value)
8189
    def replace_Labels_at(self, index, value):
8190
        self.Labels[index] = value
8191
    def get_RegionRef(self):
8192
        return self.RegionRef
8193
    def set_RegionRef(self, RegionRef):
8194
        self.RegionRef = RegionRef
8195
    def add_RegionRef(self, value):
8196
        self.RegionRef.append(value)
8197
    def insert_RegionRef_at(self, index, value):
8198
        self.RegionRef.insert(index, value)
8199
    def replace_RegionRef_at(self, index, value):
8200
        self.RegionRef[index] = value
8201
    def get_OrderedGroup(self):
8202
        return self.OrderedGroup
8203
    def set_OrderedGroup(self, OrderedGroup):
8204
        self.OrderedGroup = OrderedGroup
8205
    def add_OrderedGroup(self, value):
8206
        self.OrderedGroup.append(value)
8207
    def insert_OrderedGroup_at(self, index, value):
8208
        self.OrderedGroup.insert(index, value)
8209
    def replace_OrderedGroup_at(self, index, value):
8210
        self.OrderedGroup[index] = value
8211
    def get_UnorderedGroup(self):
8212
        return self.UnorderedGroup
8213
    def set_UnorderedGroup(self, UnorderedGroup):
8214
        self.UnorderedGroup = UnorderedGroup
8215
    def add_UnorderedGroup(self, value):
8216
        self.UnorderedGroup.append(value)
8217
    def insert_UnorderedGroup_at(self, index, value):
8218
        self.UnorderedGroup.insert(index, value)
8219
    def replace_UnorderedGroup_at(self, index, value):
8220
        self.UnorderedGroup[index] = value
8221
    def get_id(self):
8222
        return self.id
8223
    def set_id(self, id):
8224
        self.id = id
8225
    def get_regionRef(self):
8226
        return self.regionRef
8227
    def set_regionRef(self, regionRef):
8228
        self.regionRef = regionRef
8229
    def get_caption(self):
8230
        return self.caption
8231
    def set_caption(self, caption):
8232
        self.caption = caption
8233
    def get_type(self):
8234
        return self.type_
8235
    def set_type(self, type_):
8236
        self.type_ = type_
8237
    def get_continuation(self):
8238
        return self.continuation
8239
    def set_continuation(self, continuation):
8240
        self.continuation = continuation
8241
    def get_custom(self):
8242
        return self.custom
8243
    def set_custom(self, custom):
8244
        self.custom = custom
8245
    def get_comments(self):
8246
        return self.comments
8247
    def set_comments(self, comments):
8248
        self.comments = comments
8249
    def validate_GroupTypeSimpleType(self, value):
8250
        # Validate type pc:GroupTypeSimpleType, a restriction on string.
8251
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
8252
            if not isinstance(value, str):
8253
                lineno = self.gds_get_node_lineno_()
8254
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
8255
                return False
8256
            value = value
8257
            enumerations = ['paragraph', 'list', 'list-item', 'figure', 'article', 'div', 'other']
8258
            if value not in enumerations:
8259
                lineno = self.gds_get_node_lineno_()
8260
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on GroupTypeSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
8261
                result = False
8262
    def has__content(self):
8263
        if (
8264
            self.UserDefined is not None or
8265
            self.Labels or
8266
            self.RegionRef or
8267
            self.OrderedGroup or
8268
            self.UnorderedGroup
8269
        ):
8270
            return True
8271
        else:
8272
            return False
8273
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='UnorderedGroupType', pretty_print=True):
8274
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('UnorderedGroupType')
8275
        if imported_ns_def_ is not None:
8276
            namespacedef_ = imported_ns_def_
8277
        if pretty_print:
8278
            eol_ = '\n'
8279
        else:
8280
            eol_ = ''
8281
        if self.original_tagname_ is not None and name_ == 'UnorderedGroupType':
8282
            name_ = self.original_tagname_
8283
        if UseCapturedNS_ and self.ns_prefix_:
8284
            namespaceprefix_ = self.ns_prefix_ + ':'
8285
        showIndent(outfile, level, pretty_print)
8286
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
8287
        already_processed = set()
8288
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='UnorderedGroupType')
8289
        if self.has__content():
8290
            outfile.write('>%s' % (eol_, ))
8291
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='UnorderedGroupType', pretty_print=pretty_print)
8292
            showIndent(outfile, level, pretty_print)
8293
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
8294
        else:
8295
            outfile.write('/>%s' % (eol_, ))
8296 View Code Duplication
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='UnorderedGroupType'):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8297
        if self.id is not None and 'id' not in already_processed:
8298
            already_processed.add('id')
8299
            outfile.write(' id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.id), input_name='id')), ))
8300
        if self.regionRef is not None and 'regionRef' not in already_processed:
8301
            already_processed.add('regionRef')
8302
            outfile.write(' regionRef=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.regionRef), input_name='regionRef')), ))
8303
        if self.caption is not None and 'caption' not in already_processed:
8304
            already_processed.add('caption')
8305
            outfile.write(' caption=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.caption), input_name='caption')), ))
8306
        if self.type_ is not None and 'type_' not in already_processed:
8307
            already_processed.add('type_')
8308
            outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), ))
8309
        if self.continuation is not None and 'continuation' not in already_processed:
8310
            already_processed.add('continuation')
8311
            outfile.write(' continuation="%s"' % self.gds_format_boolean(self.continuation, input_name='continuation'))
8312
        if self.custom is not None and 'custom' not in already_processed:
8313
            already_processed.add('custom')
8314
            outfile.write(' custom=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.custom), input_name='custom')), ))
8315
        if self.comments is not None and 'comments' not in already_processed:
8316
            already_processed.add('comments')
8317
            outfile.write(' comments=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.comments), input_name='comments')), ))
8318 View Code Duplication
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='UnorderedGroupType', fromsubclass_=False, pretty_print=True):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8319
        if pretty_print:
8320
            eol_ = '\n'
8321
        else:
8322
            eol_ = ''
8323
        if self.UserDefined is not None:
8324
            namespaceprefix_ = self.UserDefined_nsprefix_ + ':' if (UseCapturedNS_ and self.UserDefined_nsprefix_) else ''
8325
            self.UserDefined.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UserDefined', pretty_print=pretty_print)
8326
        for Labels_ in self.Labels:
8327
            namespaceprefix_ = self.Labels_nsprefix_ + ':' if (UseCapturedNS_ and self.Labels_nsprefix_) else ''
8328
            Labels_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Labels', pretty_print=pretty_print)
8329
        for RegionRef_ in self.RegionRef:
8330
            namespaceprefix_ = self.RegionRef_nsprefix_ + ':' if (UseCapturedNS_ and self.RegionRef_nsprefix_) else ''
8331
            RegionRef_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='RegionRef', pretty_print=pretty_print)
8332
        for OrderedGroup_ in self.OrderedGroup:
8333
            namespaceprefix_ = self.OrderedGroup_nsprefix_ + ':' if (UseCapturedNS_ and self.OrderedGroup_nsprefix_) else ''
8334
            OrderedGroup_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='OrderedGroup', pretty_print=pretty_print)
8335
        for UnorderedGroup_ in self.UnorderedGroup:
8336
            namespaceprefix_ = self.UnorderedGroup_nsprefix_ + ':' if (UseCapturedNS_ and self.UnorderedGroup_nsprefix_) else ''
8337
            UnorderedGroup_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UnorderedGroup', pretty_print=pretty_print)
8338
    def to_etree(self, parent_element=None, name_='UnorderedGroupType', mapping_=None, reverse_mapping_=None, nsmap_=None):
8339
        if parent_element is None:
8340
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
8341
        else:
8342
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
8343
        if self.id is not None:
8344
            element.set('id', self.gds_format_string(self.id))
8345
        if self.regionRef is not None:
8346
            element.set('regionRef', self.gds_format_string(self.regionRef))
8347
        if self.caption is not None:
8348
            element.set('caption', self.gds_format_string(self.caption))
8349
        if self.type_ is not None:
8350
            element.set('type', self.gds_format_string(self.type_))
8351
        if self.continuation is not None:
8352
            element.set('continuation', self.gds_format_boolean(self.continuation))
8353
        if self.custom is not None:
8354
            element.set('custom', self.gds_format_string(self.custom))
8355
        if self.comments is not None:
8356
            element.set('comments', self.gds_format_string(self.comments))
8357
        if self.UserDefined is not None:
8358
            UserDefined_ = self.UserDefined
8359
            UserDefined_.to_etree(element, name_='UserDefined', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
8360
        for Labels_ in self.Labels:
8361
            Labels_.to_etree(element, name_='Labels', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
8362
        for RegionRef_ in self.RegionRef:
8363
            RegionRef_.to_etree(element, name_='RegionRef', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
8364
        for OrderedGroup_ in self.OrderedGroup:
8365
            OrderedGroup_.to_etree(element, name_='OrderedGroup', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
8366
        for UnorderedGroup_ in self.UnorderedGroup:
8367
            UnorderedGroup_.to_etree(element, name_='UnorderedGroup', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
8368
        if mapping_ is not None:
8369
            mapping_[id(self)] = element
8370
        if reverse_mapping_ is not None:
8371
            reverse_mapping_[element] = self
8372
        return element
8373
    def build(self, node, gds_collector_=None):
8374
        self.gds_collector_ = gds_collector_
8375
        if SaveElementTreeNode:
8376
            self.gds_elementtree_node_ = node
8377
        already_processed = set()
8378
        self.ns_prefix_ = node.prefix
8379
        self._buildAttributes(node, node.attrib, already_processed)
8380
        for child in node:
8381
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
8382
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
8383
        return self
8384 View Code Duplication
    def _buildAttributes(self, node, attrs, already_processed):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8385
        value = find_attr_value_('id', node)
8386
        if value is not None and 'id' not in already_processed:
8387
            already_processed.add('id')
8388
            self.id = value
8389
        value = find_attr_value_('regionRef', node)
8390
        if value is not None and 'regionRef' not in already_processed:
8391
            already_processed.add('regionRef')
8392
            self.regionRef = value
8393
        value = find_attr_value_('caption', node)
8394
        if value is not None and 'caption' not in already_processed:
8395
            already_processed.add('caption')
8396
            self.caption = value
8397
        value = find_attr_value_('type', node)
8398
        if value is not None and 'type' not in already_processed:
8399
            already_processed.add('type')
8400
            self.type_ = value
8401
            self.validate_GroupTypeSimpleType(self.type_)    # validate type GroupTypeSimpleType
8402
        value = find_attr_value_('continuation', node)
8403
        if value is not None and 'continuation' not in already_processed:
8404
            already_processed.add('continuation')
8405
            if value in ('true', '1'):
8406
                self.continuation = True
8407
            elif value in ('false', '0'):
8408
                self.continuation = False
8409
            else:
8410
                raise_parse_error(node, 'Bad boolean attribute')
8411
        value = find_attr_value_('custom', node)
8412
        if value is not None and 'custom' not in already_processed:
8413
            already_processed.add('custom')
8414
            self.custom = value
8415
        value = find_attr_value_('comments', node)
8416
        if value is not None and 'comments' not in already_processed:
8417
            already_processed.add('comments')
8418
            self.comments = value
8419 View Code Duplication
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8420
        if nodeName_ == 'UserDefined':
8421
            obj_ = UserDefinedType.factory(parent_object_=self)
8422
            obj_.build(child_, gds_collector_=gds_collector_)
8423
            self.UserDefined = obj_
8424
            obj_.original_tagname_ = 'UserDefined'
8425
        elif nodeName_ == 'Labels':
8426
            obj_ = LabelsType.factory(parent_object_=self)
8427
            obj_.build(child_, gds_collector_=gds_collector_)
8428
            self.Labels.append(obj_)
8429
            obj_.original_tagname_ = 'Labels'
8430
        elif nodeName_ == 'RegionRef':
8431
            obj_ = RegionRefType.factory(parent_object_=self)
8432
            obj_.build(child_, gds_collector_=gds_collector_)
8433
            self.RegionRef.append(obj_)
8434
            obj_.original_tagname_ = 'RegionRef'
8435
        elif nodeName_ == 'OrderedGroup':
8436
            obj_ = OrderedGroupType.factory(parent_object_=self)
8437
            obj_.build(child_, gds_collector_=gds_collector_)
8438
            self.OrderedGroup.append(obj_)
8439
            obj_.original_tagname_ = 'OrderedGroup'
8440
        elif nodeName_ == 'UnorderedGroup':
8441
            obj_ = UnorderedGroupType.factory(parent_object_=self)
8442
            obj_.build(child_, gds_collector_=gds_collector_)
8443
            self.UnorderedGroup.append(obj_)
8444
            obj_.original_tagname_ = 'UnorderedGroup'
8445
    def __hash__(self):
8446
        return hash(self.id)
8447
    def get_UnorderedGroupChildren(self):
8448
        """
8449
        List all non-metadata children of an :py:class:`UnorderedGroupType`
8450
        """
8451
        # TODO: should not change order
8452
        return self.get_RegionRef() + self.get_OrderedGroup() + self.get_UnorderedGroup()
8453
    
8454
# end class UnorderedGroupType
8455
8456
8457
class BorderType(GeneratedsSuper):
8458
    """BorderType --
8459
    Border of the actual page (if the scanned image
8460
    contains parts not belonging to the page).
8461
    
8462
    """
8463
    __hash__ = GeneratedsSuper.__hash__
8464
    member_data_items_ = [
8465
        MemberSpec_('Coords', 'CoordsType', 0, 0, {'name': 'Coords', 'type': 'CoordsType'}, None),
8466
    ]
8467
    subclass = None
8468
    superclass = None
8469
    def __init__(self, Coords=None, gds_collector_=None, **kwargs_):
8470
        self.gds_collector_ = gds_collector_
8471
        self.gds_elementtree_node_ = None
8472
        self.original_tagname_ = None
8473
        self.parent_object_ = kwargs_.get('parent_object_')
8474
        self.ns_prefix_ = "pc"
8475
        self.Coords = Coords
8476
        self.Coords_nsprefix_ = "pc"
8477
    def factory(*args_, **kwargs_):
8478
        if CurrentSubclassModule_ is not None:
8479
            subclass = getSubclassFromModule_(
8480
                CurrentSubclassModule_, BorderType)
8481
            if subclass is not None:
8482
                return subclass(*args_, **kwargs_)
8483
        if BorderType.subclass:
8484
            return BorderType.subclass(*args_, **kwargs_)
8485
        else:
8486
            return BorderType(*args_, **kwargs_)
8487
    factory = staticmethod(factory)
8488
    def get_ns_prefix_(self):
8489
        return self.ns_prefix_
8490
    def set_ns_prefix_(self, ns_prefix):
8491
        self.ns_prefix_ = ns_prefix
8492
    def get_Coords(self):
8493
        return self.Coords
8494
    def set_Coords(self, Coords):
8495
        self.Coords = Coords
8496
    def has__content(self):
8497
        if (
8498
            self.Coords is not None
8499
        ):
8500
            return True
8501
        else:
8502
            return False
8503
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='BorderType', pretty_print=True):
8504
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('BorderType')
8505
        if imported_ns_def_ is not None:
8506
            namespacedef_ = imported_ns_def_
8507
        if pretty_print:
8508
            eol_ = '\n'
8509
        else:
8510
            eol_ = ''
8511
        if self.original_tagname_ is not None and name_ == 'BorderType':
8512
            name_ = self.original_tagname_
8513
        if UseCapturedNS_ and self.ns_prefix_:
8514
            namespaceprefix_ = self.ns_prefix_ + ':'
8515
        showIndent(outfile, level, pretty_print)
8516
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
8517
        already_processed = set()
8518
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='BorderType')
8519
        if self.has__content():
8520
            outfile.write('>%s' % (eol_, ))
8521
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='BorderType', pretty_print=pretty_print)
8522
            showIndent(outfile, level, pretty_print)
8523
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
8524
        else:
8525
            outfile.write('/>%s' % (eol_, ))
8526
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='BorderType'):
8527
        pass
8528
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='BorderType', fromsubclass_=False, pretty_print=True):
8529
        if pretty_print:
8530
            eol_ = '\n'
8531
        else:
8532
            eol_ = ''
8533
        if self.Coords is not None:
8534
            namespaceprefix_ = self.Coords_nsprefix_ + ':' if (UseCapturedNS_ and self.Coords_nsprefix_) else ''
8535
            self.Coords.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Coords', pretty_print=pretty_print)
8536
    def to_etree(self, parent_element=None, name_='BorderType', mapping_=None, reverse_mapping_=None, nsmap_=None):
8537
        if parent_element is None:
8538
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
8539
        else:
8540
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
8541
        if self.Coords is not None:
8542
            Coords_ = self.Coords
8543
            Coords_.to_etree(element, name_='Coords', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
8544
        if mapping_ is not None:
8545
            mapping_[id(self)] = element
8546
        if reverse_mapping_ is not None:
8547
            reverse_mapping_[element] = self
8548
        return element
8549
    def build(self, node, gds_collector_=None):
8550
        self.gds_collector_ = gds_collector_
8551
        if SaveElementTreeNode:
8552
            self.gds_elementtree_node_ = node
8553
        already_processed = set()
8554
        self.ns_prefix_ = node.prefix
8555
        self._buildAttributes(node, node.attrib, already_processed)
8556
        for child in node:
8557
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
8558
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
8559
        return self
8560
    def _buildAttributes(self, node, attrs, already_processed):
8561
        pass
8562
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
8563
        if nodeName_ == 'Coords':
8564
            obj_ = CoordsType.factory(parent_object_=self)
8565
            obj_.build(child_, gds_collector_=gds_collector_)
8566
            self.Coords = obj_
8567
            obj_.original_tagname_ = 'Coords'
8568
    def __hash__(self):
8569
        return hash(self.id)
8570
    def set_Coords(self, Coords):
8571
        """
8572
        Set coordinate polygon by given :py:class:`CoordsType` object.
8573
        Moreover, invalidate self's ``pc:AlternativeImage``s
8574
        (because they will have been cropped with a bbox
8575
        of the previous polygon).
8576
        """
8577
        if hasattr(self, 'invalidate_AlternativeImage'):
8578
            # RegionType, TextLineType, WordType, GlyphType:
8579
            self.invalidate_AlternativeImage()
8580
        elif hasattr(self, 'parent_object_') and hasattr(self.parent_object_, 'invalidate_AlternativeImage'):
8581
            # BorderType:
8582
            self.parent_object_.invalidate_AlternativeImage(feature_selector='cropped')
8583
        self.Coords = Coords
8584
# end class BorderType
8585
8586
8587 View Code Duplication
class LayersType(GeneratedsSuper):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8588
    """LayersType --
8589
    Can be used to express the z-index of overlapping
8590
    regions. An element with a greater z-index is always in
8591
    front of another element with lower z-index.
8592
    
8593
    """
8594
    __hash__ = GeneratedsSuper.__hash__
8595
    member_data_items_ = [
8596
        MemberSpec_('Layer', 'LayerType', 1, 0, {'maxOccurs': 'unbounded', 'minOccurs': '1', 'name': 'Layer', 'type': 'LayerType'}, None),
8597
    ]
8598
    subclass = None
8599
    superclass = None
8600
    def __init__(self, Layer=None, gds_collector_=None, **kwargs_):
8601
        self.gds_collector_ = gds_collector_
8602
        self.gds_elementtree_node_ = None
8603
        self.original_tagname_ = None
8604
        self.parent_object_ = kwargs_.get('parent_object_')
8605
        self.ns_prefix_ = "pc"
8606
        if Layer is None:
8607
            self.Layer = []
8608
        else:
8609
            self.Layer = Layer
8610
        self.Layer_nsprefix_ = "pc"
8611
    def factory(*args_, **kwargs_):
8612
        if CurrentSubclassModule_ is not None:
8613
            subclass = getSubclassFromModule_(
8614
                CurrentSubclassModule_, LayersType)
8615
            if subclass is not None:
8616
                return subclass(*args_, **kwargs_)
8617
        if LayersType.subclass:
8618
            return LayersType.subclass(*args_, **kwargs_)
8619
        else:
8620
            return LayersType(*args_, **kwargs_)
8621
    factory = staticmethod(factory)
8622
    def get_ns_prefix_(self):
8623
        return self.ns_prefix_
8624
    def set_ns_prefix_(self, ns_prefix):
8625
        self.ns_prefix_ = ns_prefix
8626
    def get_Layer(self):
8627
        return self.Layer
8628
    def set_Layer(self, Layer):
8629
        self.Layer = Layer
8630
    def add_Layer(self, value):
8631
        self.Layer.append(value)
8632
    def insert_Layer_at(self, index, value):
8633
        self.Layer.insert(index, value)
8634
    def replace_Layer_at(self, index, value):
8635
        self.Layer[index] = value
8636
    def has__content(self):
8637
        if (
8638
            self.Layer
8639
        ):
8640
            return True
8641
        else:
8642
            return False
8643
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='LayersType', pretty_print=True):
8644
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('LayersType')
8645
        if imported_ns_def_ is not None:
8646
            namespacedef_ = imported_ns_def_
8647
        if pretty_print:
8648
            eol_ = '\n'
8649
        else:
8650
            eol_ = ''
8651
        if self.original_tagname_ is not None and name_ == 'LayersType':
8652
            name_ = self.original_tagname_
8653
        if UseCapturedNS_ and self.ns_prefix_:
8654
            namespaceprefix_ = self.ns_prefix_ + ':'
8655
        showIndent(outfile, level, pretty_print)
8656
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
8657
        already_processed = set()
8658
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='LayersType')
8659
        if self.has__content():
8660
            outfile.write('>%s' % (eol_, ))
8661
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='LayersType', pretty_print=pretty_print)
8662
            showIndent(outfile, level, pretty_print)
8663
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
8664
        else:
8665
            outfile.write('/>%s' % (eol_, ))
8666
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='LayersType'):
8667
        pass
8668
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='LayersType', fromsubclass_=False, pretty_print=True):
8669
        if pretty_print:
8670
            eol_ = '\n'
8671
        else:
8672
            eol_ = ''
8673
        for Layer_ in self.Layer:
8674
            namespaceprefix_ = self.Layer_nsprefix_ + ':' if (UseCapturedNS_ and self.Layer_nsprefix_) else ''
8675
            Layer_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Layer', pretty_print=pretty_print)
8676
    def to_etree(self, parent_element=None, name_='LayersType', mapping_=None, reverse_mapping_=None, nsmap_=None):
8677
        if parent_element is None:
8678
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
8679
        else:
8680
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
8681
        for Layer_ in self.Layer:
8682
            Layer_.to_etree(element, name_='Layer', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
8683
        if mapping_ is not None:
8684
            mapping_[id(self)] = element
8685
        if reverse_mapping_ is not None:
8686
            reverse_mapping_[element] = self
8687
        return element
8688
    def build(self, node, gds_collector_=None):
8689
        self.gds_collector_ = gds_collector_
8690
        if SaveElementTreeNode:
8691
            self.gds_elementtree_node_ = node
8692
        already_processed = set()
8693
        self.ns_prefix_ = node.prefix
8694
        self._buildAttributes(node, node.attrib, already_processed)
8695
        for child in node:
8696
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
8697
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
8698
        return self
8699
    def _buildAttributes(self, node, attrs, already_processed):
8700
        pass
8701
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
8702
        if nodeName_ == 'Layer':
8703
            obj_ = LayerType.factory(parent_object_=self)
8704
            obj_.build(child_, gds_collector_=gds_collector_)
8705
            self.Layer.append(obj_)
8706
            obj_.original_tagname_ = 'Layer'
8707
    def __hash__(self):
8708
        return hash(self.id)
8709
# end class LayersType
8710
8711
8712
class LayerType(GeneratedsSuper):
8713
    __hash__ = GeneratedsSuper.__hash__
8714
    member_data_items_ = [
8715
        MemberSpec_('id', 'string', 0, 0, {'use': 'required', 'name': 'id'}),
8716
        MemberSpec_('zIndex', 'int', 0, 0, {'use': 'required', 'name': 'zIndex'}),
8717
        MemberSpec_('caption', 'string', 0, 1, {'use': 'optional', 'name': 'caption'}),
8718
        MemberSpec_('RegionRef', 'RegionRefType', 1, 0, {'maxOccurs': 'unbounded', 'minOccurs': '1', 'name': 'RegionRef', 'type': 'RegionRefType'}, None),
8719
    ]
8720
    subclass = None
8721
    superclass = None
8722
    def __init__(self, id=None, zIndex=None, caption=None, RegionRef=None, gds_collector_=None, **kwargs_):
8723
        self.gds_collector_ = gds_collector_
8724
        self.gds_elementtree_node_ = None
8725
        self.original_tagname_ = None
8726
        self.parent_object_ = kwargs_.get('parent_object_')
8727
        self.ns_prefix_ = "pc"
8728
        self.id = _cast(None, id)
8729
        self.id_nsprefix_ = "pc"
8730
        self.zIndex = _cast(int, zIndex)
8731
        self.zIndex_nsprefix_ = "pc"
8732
        self.caption = _cast(None, caption)
8733
        self.caption_nsprefix_ = "pc"
8734
        if RegionRef is None:
8735
            self.RegionRef = []
8736
        else:
8737
            self.RegionRef = RegionRef
8738
        self.RegionRef_nsprefix_ = "pc"
8739
    def factory(*args_, **kwargs_):
8740
        if CurrentSubclassModule_ is not None:
8741
            subclass = getSubclassFromModule_(
8742
                CurrentSubclassModule_, LayerType)
8743
            if subclass is not None:
8744
                return subclass(*args_, **kwargs_)
8745
        if LayerType.subclass:
8746
            return LayerType.subclass(*args_, **kwargs_)
8747
        else:
8748
            return LayerType(*args_, **kwargs_)
8749
    factory = staticmethod(factory)
8750
    def get_ns_prefix_(self):
8751
        return self.ns_prefix_
8752
    def set_ns_prefix_(self, ns_prefix):
8753
        self.ns_prefix_ = ns_prefix
8754
    def get_RegionRef(self):
8755
        return self.RegionRef
8756
    def set_RegionRef(self, RegionRef):
8757
        self.RegionRef = RegionRef
8758
    def add_RegionRef(self, value):
8759
        self.RegionRef.append(value)
8760
    def insert_RegionRef_at(self, index, value):
8761
        self.RegionRef.insert(index, value)
8762
    def replace_RegionRef_at(self, index, value):
8763
        self.RegionRef[index] = value
8764
    def get_id(self):
8765
        return self.id
8766
    def set_id(self, id):
8767
        self.id = id
8768
    def get_zIndex(self):
8769
        return self.zIndex
8770
    def set_zIndex(self, zIndex):
8771
        self.zIndex = zIndex
8772
    def get_caption(self):
8773
        return self.caption
8774
    def set_caption(self, caption):
8775
        self.caption = caption
8776
    def has__content(self):
8777
        if (
8778
            self.RegionRef
8779
        ):
8780
            return True
8781
        else:
8782
            return False
8783
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='LayerType', pretty_print=True):
8784
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('LayerType')
8785
        if imported_ns_def_ is not None:
8786
            namespacedef_ = imported_ns_def_
8787
        if pretty_print:
8788
            eol_ = '\n'
8789
        else:
8790
            eol_ = ''
8791
        if self.original_tagname_ is not None and name_ == 'LayerType':
8792
            name_ = self.original_tagname_
8793
        if UseCapturedNS_ and self.ns_prefix_:
8794
            namespaceprefix_ = self.ns_prefix_ + ':'
8795
        showIndent(outfile, level, pretty_print)
8796
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
8797
        already_processed = set()
8798
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='LayerType')
8799
        if self.has__content():
8800
            outfile.write('>%s' % (eol_, ))
8801
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='LayerType', pretty_print=pretty_print)
8802
            showIndent(outfile, level, pretty_print)
8803
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
8804
        else:
8805
            outfile.write('/>%s' % (eol_, ))
8806
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='LayerType'):
8807
        if self.id is not None and 'id' not in already_processed:
8808
            already_processed.add('id')
8809
            outfile.write(' id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.id), input_name='id')), ))
8810
        if self.zIndex is not None and 'zIndex' not in already_processed:
8811
            already_processed.add('zIndex')
8812
            outfile.write(' zIndex="%s"' % self.gds_format_integer(self.zIndex, input_name='zIndex'))
8813
        if self.caption is not None and 'caption' not in already_processed:
8814
            already_processed.add('caption')
8815
            outfile.write(' caption=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.caption), input_name='caption')), ))
8816
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='LayerType', fromsubclass_=False, pretty_print=True):
8817
        if pretty_print:
8818
            eol_ = '\n'
8819
        else:
8820
            eol_ = ''
8821
        for RegionRef_ in self.RegionRef:
8822
            namespaceprefix_ = self.RegionRef_nsprefix_ + ':' if (UseCapturedNS_ and self.RegionRef_nsprefix_) else ''
8823
            RegionRef_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='RegionRef', pretty_print=pretty_print)
8824
    def to_etree(self, parent_element=None, name_='LayerType', mapping_=None, reverse_mapping_=None, nsmap_=None):
8825
        if parent_element is None:
8826
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
8827
        else:
8828
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
8829
        if self.id is not None:
8830
            element.set('id', self.gds_format_string(self.id))
8831
        if self.zIndex is not None:
8832
            element.set('zIndex', self.gds_format_integer(self.zIndex))
8833
        if self.caption is not None:
8834
            element.set('caption', self.gds_format_string(self.caption))
8835
        for RegionRef_ in self.RegionRef:
8836
            RegionRef_.to_etree(element, name_='RegionRef', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
8837
        if mapping_ is not None:
8838
            mapping_[id(self)] = element
8839
        if reverse_mapping_ is not None:
8840
            reverse_mapping_[element] = self
8841
        return element
8842
    def build(self, node, gds_collector_=None):
8843
        self.gds_collector_ = gds_collector_
8844
        if SaveElementTreeNode:
8845
            self.gds_elementtree_node_ = node
8846
        already_processed = set()
8847
        self.ns_prefix_ = node.prefix
8848
        self._buildAttributes(node, node.attrib, already_processed)
8849
        for child in node:
8850
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
8851
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
8852
        return self
8853
    def _buildAttributes(self, node, attrs, already_processed):
8854
        value = find_attr_value_('id', node)
8855
        if value is not None and 'id' not in already_processed:
8856
            already_processed.add('id')
8857
            self.id = value
8858
        value = find_attr_value_('zIndex', node)
8859
        if value is not None and 'zIndex' not in already_processed:
8860
            already_processed.add('zIndex')
8861
            self.zIndex = self.gds_parse_integer(value, node, 'zIndex')
8862
        value = find_attr_value_('caption', node)
8863
        if value is not None and 'caption' not in already_processed:
8864
            already_processed.add('caption')
8865
            self.caption = value
8866
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
8867
        if nodeName_ == 'RegionRef':
8868
            obj_ = RegionRefType.factory(parent_object_=self)
8869
            obj_.build(child_, gds_collector_=gds_collector_)
8870
            self.RegionRef.append(obj_)
8871
            obj_.original_tagname_ = 'RegionRef'
8872
    def __hash__(self):
8873
        return hash(self.id)
8874
# end class LayerType
8875
8876
8877
class BaselineType(GeneratedsSuper):
8878
    """conf -- Confidence value (between 0 and 1)
8879
    
8880
    """
8881
    __hash__ = GeneratedsSuper.__hash__
8882
    member_data_items_ = [
8883
        MemberSpec_('points', 'pc:PointsType', 0, 0, {'use': 'required', 'name': 'points'}),
8884
        MemberSpec_('conf', 'pc:ConfSimpleType', 0, 1, {'use': 'optional', 'name': 'conf'}),
8885
    ]
8886
    subclass = None
8887
    superclass = None
8888 View Code Duplication
    def __init__(self, points=None, conf=None, gds_collector_=None, **kwargs_):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8889
        self.gds_collector_ = gds_collector_
8890
        self.gds_elementtree_node_ = None
8891
        self.original_tagname_ = None
8892
        self.parent_object_ = kwargs_.get('parent_object_')
8893
        self.ns_prefix_ = "pc"
8894
        self.points = _cast(None, points)
8895
        self.points_nsprefix_ = "pc"
8896
        self.conf = _cast(float, conf)
8897
        self.conf_nsprefix_ = "pc"
8898
    def factory(*args_, **kwargs_):
8899
        if CurrentSubclassModule_ is not None:
8900
            subclass = getSubclassFromModule_(
8901
                CurrentSubclassModule_, BaselineType)
8902
            if subclass is not None:
8903
                return subclass(*args_, **kwargs_)
8904
        if BaselineType.subclass:
8905
            return BaselineType.subclass(*args_, **kwargs_)
8906
        else:
8907
            return BaselineType(*args_, **kwargs_)
8908
    factory = staticmethod(factory)
8909
    def get_ns_prefix_(self):
8910
        return self.ns_prefix_
8911
    def set_ns_prefix_(self, ns_prefix):
8912
        self.ns_prefix_ = ns_prefix
8913
    def get_points(self):
8914
        return self.points
8915
    def set_points(self, points):
8916
        self.points = points
8917
    def get_conf(self):
8918
        return self.conf
8919
    def set_conf(self, conf):
8920
        self.conf = conf
8921 View Code Duplication
    def validate_PointsType(self, value):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8922
        # Validate type pc:PointsType, a restriction on string.
8923
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
8924
            if not isinstance(value, str):
8925
                lineno = self.gds_get_node_lineno_()
8926
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
8927
                return False
8928
            if not self.gds_validate_simple_patterns(
8929
                    self.validate_PointsType_patterns_, value):
8930
                self.gds_collector_.add_message('Value "%s" does not match xsd pattern restrictions: %s' % (encode_str_2_3(value), self.validate_PointsType_patterns_, ))
8931
    validate_PointsType_patterns_ = [['^(([0-9]+,[0-9]+ )+([0-9]+,[0-9]+))$']]
8932 View Code Duplication
    def validate_ConfSimpleType(self, value):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8933
        # Validate type pc:ConfSimpleType, a restriction on float.
8934
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
8935
            if not isinstance(value, float):
8936
                lineno = self.gds_get_node_lineno_()
8937
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (float)' % {"value": value, "lineno": lineno, })
8938
                return False
8939
            if value < 0:
8940
                lineno = self.gds_get_node_lineno_()
8941
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd minInclusive restriction on ConfSimpleType' % {"value": value, "lineno": lineno} )
8942
                result = False
8943
            if value > 1:
8944
                lineno = self.gds_get_node_lineno_()
8945
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxInclusive restriction on ConfSimpleType' % {"value": value, "lineno": lineno} )
8946
                result = False
8947
    def has__content(self):
8948
        if (
8949
8950
        ):
8951
            return True
8952
        else:
8953
            return False
8954
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='BaselineType', pretty_print=True):
8955
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('BaselineType')
8956
        if imported_ns_def_ is not None:
8957
            namespacedef_ = imported_ns_def_
8958
        if pretty_print:
8959
            eol_ = '\n'
8960
        else:
8961
            eol_ = ''
8962
        if self.original_tagname_ is not None and name_ == 'BaselineType':
8963
            name_ = self.original_tagname_
8964
        if UseCapturedNS_ and self.ns_prefix_:
8965
            namespaceprefix_ = self.ns_prefix_ + ':'
8966
        showIndent(outfile, level, pretty_print)
8967
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
8968
        already_processed = set()
8969
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='BaselineType')
8970
        if self.has__content():
8971
            outfile.write('>%s' % (eol_, ))
8972
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='BaselineType', pretty_print=pretty_print)
8973
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
8974
        else:
8975
            outfile.write('/>%s' % (eol_, ))
8976
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='BaselineType'):
8977
        if self.points is not None and 'points' not in already_processed:
8978
            already_processed.add('points')
8979
            outfile.write(' points=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.points), input_name='points')), ))
8980
        if self.conf is not None and 'conf' not in already_processed:
8981
            already_processed.add('conf')
8982
            outfile.write(' conf="%s"' % self.gds_format_float(self.conf, input_name='conf'))
8983
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='BaselineType', fromsubclass_=False, pretty_print=True):
8984
        pass
8985 View Code Duplication
    def to_etree(self, parent_element=None, name_='BaselineType', mapping_=None, reverse_mapping_=None, nsmap_=None):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8986
        if parent_element is None:
8987
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
8988
        else:
8989
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
8990
        if self.points is not None:
8991
            element.set('points', self.gds_format_string(self.points))
8992
        if self.conf is not None:
8993
            element.set('conf', self.gds_format_float(self.conf))
8994
        if mapping_ is not None:
8995
            mapping_[id(self)] = element
8996
        if reverse_mapping_ is not None:
8997
            reverse_mapping_[element] = self
8998
        return element
8999
    def build(self, node, gds_collector_=None):
9000
        self.gds_collector_ = gds_collector_
9001
        if SaveElementTreeNode:
9002
            self.gds_elementtree_node_ = node
9003
        already_processed = set()
9004
        self.ns_prefix_ = node.prefix
9005
        self._buildAttributes(node, node.attrib, already_processed)
9006
        for child in node:
9007
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
9008
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
9009
        return self
9010 View Code Duplication
    def _buildAttributes(self, node, attrs, already_processed):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
9011
        value = find_attr_value_('points', node)
9012
        if value is not None and 'points' not in already_processed:
9013
            already_processed.add('points')
9014
            self.points = value
9015
            self.validate_PointsType(self.points)    # validate type PointsType
9016
        value = find_attr_value_('conf', node)
9017
        if value is not None and 'conf' not in already_processed:
9018
            already_processed.add('conf')
9019
            value = self.gds_parse_float(value, node, 'conf')
9020
            self.conf = value
9021
            self.validate_ConfSimpleType(self.conf)    # validate type ConfSimpleType
9022
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
9023
        pass
9024
    def __hash__(self):
9025
        return hash(self.id)
9026
# end class BaselineType
9027
9028
9029 View Code Duplication
class RelationsType(GeneratedsSuper):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
9030
    """RelationsType --
9031
    Container for one-to-one relations between layout
9032
    objects (for example: DropCap - paragraph, caption -
9033
    image).
9034
    
9035
    """
9036
    __hash__ = GeneratedsSuper.__hash__
9037
    member_data_items_ = [
9038
        MemberSpec_('Relation', 'RelationType', 1, 0, {'maxOccurs': 'unbounded', 'minOccurs': '1', 'name': 'Relation', 'type': 'RelationType'}, None),
9039
    ]
9040
    subclass = None
9041
    superclass = None
9042
    def __init__(self, Relation=None, gds_collector_=None, **kwargs_):
9043
        self.gds_collector_ = gds_collector_
9044
        self.gds_elementtree_node_ = None
9045
        self.original_tagname_ = None
9046
        self.parent_object_ = kwargs_.get('parent_object_')
9047
        self.ns_prefix_ = "pc"
9048
        if Relation is None:
9049
            self.Relation = []
9050
        else:
9051
            self.Relation = Relation
9052
        self.Relation_nsprefix_ = "pc"
9053
    def factory(*args_, **kwargs_):
9054
        if CurrentSubclassModule_ is not None:
9055
            subclass = getSubclassFromModule_(
9056
                CurrentSubclassModule_, RelationsType)
9057
            if subclass is not None:
9058
                return subclass(*args_, **kwargs_)
9059
        if RelationsType.subclass:
9060
            return RelationsType.subclass(*args_, **kwargs_)
9061
        else:
9062
            return RelationsType(*args_, **kwargs_)
9063
    factory = staticmethod(factory)
9064
    def get_ns_prefix_(self):
9065
        return self.ns_prefix_
9066
    def set_ns_prefix_(self, ns_prefix):
9067
        self.ns_prefix_ = ns_prefix
9068
    def get_Relation(self):
9069
        return self.Relation
9070
    def set_Relation(self, Relation):
9071
        self.Relation = Relation
9072
    def add_Relation(self, value):
9073
        self.Relation.append(value)
9074
    def insert_Relation_at(self, index, value):
9075
        self.Relation.insert(index, value)
9076
    def replace_Relation_at(self, index, value):
9077
        self.Relation[index] = value
9078
    def has__content(self):
9079
        if (
9080
            self.Relation
9081
        ):
9082
            return True
9083
        else:
9084
            return False
9085
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RelationsType', pretty_print=True):
9086
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('RelationsType')
9087
        if imported_ns_def_ is not None:
9088
            namespacedef_ = imported_ns_def_
9089
        if pretty_print:
9090
            eol_ = '\n'
9091
        else:
9092
            eol_ = ''
9093
        if self.original_tagname_ is not None and name_ == 'RelationsType':
9094
            name_ = self.original_tagname_
9095
        if UseCapturedNS_ and self.ns_prefix_:
9096
            namespaceprefix_ = self.ns_prefix_ + ':'
9097
        showIndent(outfile, level, pretty_print)
9098
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
9099
        already_processed = set()
9100
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='RelationsType')
9101
        if self.has__content():
9102
            outfile.write('>%s' % (eol_, ))
9103
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='RelationsType', pretty_print=pretty_print)
9104
            showIndent(outfile, level, pretty_print)
9105
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
9106
        else:
9107
            outfile.write('/>%s' % (eol_, ))
9108
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='RelationsType'):
9109
        pass
9110
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RelationsType', fromsubclass_=False, pretty_print=True):
9111
        if pretty_print:
9112
            eol_ = '\n'
9113
        else:
9114
            eol_ = ''
9115
        for Relation_ in self.Relation:
9116
            namespaceprefix_ = self.Relation_nsprefix_ + ':' if (UseCapturedNS_ and self.Relation_nsprefix_) else ''
9117
            Relation_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Relation', pretty_print=pretty_print)
9118
    def to_etree(self, parent_element=None, name_='RelationsType', mapping_=None, reverse_mapping_=None, nsmap_=None):
9119
        if parent_element is None:
9120
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
9121
        else:
9122
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
9123
        for Relation_ in self.Relation:
9124
            Relation_.to_etree(element, name_='Relation', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
9125
        if mapping_ is not None:
9126
            mapping_[id(self)] = element
9127
        if reverse_mapping_ is not None:
9128
            reverse_mapping_[element] = self
9129
        return element
9130
    def build(self, node, gds_collector_=None):
9131
        self.gds_collector_ = gds_collector_
9132
        if SaveElementTreeNode:
9133
            self.gds_elementtree_node_ = node
9134
        already_processed = set()
9135
        self.ns_prefix_ = node.prefix
9136
        self._buildAttributes(node, node.attrib, already_processed)
9137
        for child in node:
9138
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
9139
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
9140
        return self
9141
    def _buildAttributes(self, node, attrs, already_processed):
9142
        pass
9143
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
9144
        if nodeName_ == 'Relation':
9145
            obj_ = RelationType.factory(parent_object_=self)
9146
            obj_.build(child_, gds_collector_=gds_collector_)
9147
            self.Relation.append(obj_)
9148
            obj_.original_tagname_ = 'Relation'
9149
    def __hash__(self):
9150
        return hash(self.id)
9151
# end class RelationsType
9152
9153
9154
class RelationType(GeneratedsSuper):
9155
    """RelationType --
9156
    One-to-one relation between to layout object. Use 'link'
9157
    for loose relations and 'join' for strong relations
9158
    (where something is fragmented for instance).
9159
    Examples for 'link': caption - image floating -
9160
    paragraph paragraph - paragraph (when a paragraph is
9161
    split across columns and the last word of the first
9162
    paragraph DOES NOT continue in the second paragraph)
9163
    drop-cap - paragraph (when the drop-cap is a whole word)
9164
    Examples for 'join': word - word (separated word at the
9165
    end of a line) drop-cap - paragraph (when the drop-cap
9166
    is not a whole word) paragraph - paragraph (when a
9167
    pragraph is split across columns and the last word of
9168
    the first paragraph DOES continue in the second
9169
    paragraph)
9170
      
9171
    * custom -- For generic use
9172
    * Labels -- Semantic labels / tags
9173
    
9174
    """
9175
    __hash__ = GeneratedsSuper.__hash__
9176
    member_data_items_ = [
9177
        MemberSpec_('id', 'string', 0, 0, {'use': 'required', 'name': 'id'}),
9178
        MemberSpec_('type_', 'typeType1', 0, 1, {'use': 'optional', 'name': 'type_'}),
9179
        MemberSpec_('custom', 'string', 0, 1, {'use': 'optional', 'name': 'custom'}),
9180
        MemberSpec_('comments', 'string', 0, 1, {'use': 'optional', 'name': 'comments'}),
9181
        MemberSpec_('Labels', 'LabelsType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Labels', 'type': 'LabelsType'}, None),
9182
        MemberSpec_('SourceRegionRef', 'RegionRefType', 0, 0, {'maxOccurs': '1', 'minOccurs': '1', 'name': 'SourceRegionRef', 'type': 'RegionRefType'}, None),
9183
        MemberSpec_('TargetRegionRef', 'RegionRefType', 0, 0, {'maxOccurs': '1', 'minOccurs': '1', 'name': 'TargetRegionRef', 'type': 'RegionRefType'}, None),
9184
    ]
9185
    subclass = None
9186
    superclass = None
9187
    def __init__(self, id=None, type_=None, custom=None, comments=None, Labels=None, SourceRegionRef=None, TargetRegionRef=None, gds_collector_=None, **kwargs_):
9188
        self.gds_collector_ = gds_collector_
9189
        self.gds_elementtree_node_ = None
9190
        self.original_tagname_ = None
9191
        self.parent_object_ = kwargs_.get('parent_object_')
9192
        self.ns_prefix_ = "pc"
9193
        self.id = _cast(None, id)
9194
        self.id_nsprefix_ = "pc"
9195
        self.type_ = _cast(None, type_)
9196
        self.type__nsprefix_ = "pc"
9197
        self.custom = _cast(None, custom)
9198
        self.custom_nsprefix_ = "pc"
9199
        self.comments = _cast(None, comments)
9200
        self.comments_nsprefix_ = "pc"
9201
        if Labels is None:
9202
            self.Labels = []
9203
        else:
9204
            self.Labels = Labels
9205
        self.Labels_nsprefix_ = "pc"
9206
        self.SourceRegionRef = SourceRegionRef
9207
        self.SourceRegionRef_nsprefix_ = "pc"
9208
        self.TargetRegionRef = TargetRegionRef
9209
        self.TargetRegionRef_nsprefix_ = "pc"
9210
    def factory(*args_, **kwargs_):
9211
        if CurrentSubclassModule_ is not None:
9212
            subclass = getSubclassFromModule_(
9213
                CurrentSubclassModule_, RelationType)
9214
            if subclass is not None:
9215
                return subclass(*args_, **kwargs_)
9216
        if RelationType.subclass:
9217
            return RelationType.subclass(*args_, **kwargs_)
9218
        else:
9219
            return RelationType(*args_, **kwargs_)
9220
    factory = staticmethod(factory)
9221
    def get_ns_prefix_(self):
9222
        return self.ns_prefix_
9223
    def set_ns_prefix_(self, ns_prefix):
9224
        self.ns_prefix_ = ns_prefix
9225
    def get_Labels(self):
9226
        return self.Labels
9227
    def set_Labels(self, Labels):
9228
        self.Labels = Labels
9229
    def add_Labels(self, value):
9230
        self.Labels.append(value)
9231
    def insert_Labels_at(self, index, value):
9232
        self.Labels.insert(index, value)
9233
    def replace_Labels_at(self, index, value):
9234
        self.Labels[index] = value
9235
    def get_SourceRegionRef(self):
9236
        return self.SourceRegionRef
9237
    def set_SourceRegionRef(self, SourceRegionRef):
9238
        self.SourceRegionRef = SourceRegionRef
9239
    def get_TargetRegionRef(self):
9240
        return self.TargetRegionRef
9241
    def set_TargetRegionRef(self, TargetRegionRef):
9242
        self.TargetRegionRef = TargetRegionRef
9243
    def get_id(self):
9244
        return self.id
9245
    def set_id(self, id):
9246
        self.id = id
9247
    def get_type(self):
9248
        return self.type_
9249
    def set_type(self, type_):
9250
        self.type_ = type_
9251
    def get_custom(self):
9252
        return self.custom
9253
    def set_custom(self, custom):
9254
        self.custom = custom
9255
    def get_comments(self):
9256
        return self.comments
9257
    def set_comments(self, comments):
9258
        self.comments = comments
9259
    def validate_typeType1(self, value):
9260
        # Validate type typeType1, a restriction on string.
9261
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
9262
            if not isinstance(value, str):
9263
                lineno = self.gds_get_node_lineno_()
9264
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
9265
                return False
9266
            value = value
9267
            enumerations = ['link', 'join']
9268
            if value not in enumerations:
9269
                lineno = self.gds_get_node_lineno_()
9270
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on typeType1' % {"value" : encode_str_2_3(value), "lineno": lineno} )
9271
                result = False
9272
    def has__content(self):
9273
        if (
9274
            self.Labels or
9275
            self.SourceRegionRef is not None or
9276
            self.TargetRegionRef is not None
9277
        ):
9278
            return True
9279
        else:
9280
            return False
9281
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RelationType', pretty_print=True):
9282
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('RelationType')
9283
        if imported_ns_def_ is not None:
9284
            namespacedef_ = imported_ns_def_
9285
        if pretty_print:
9286
            eol_ = '\n'
9287
        else:
9288
            eol_ = ''
9289
        if self.original_tagname_ is not None and name_ == 'RelationType':
9290
            name_ = self.original_tagname_
9291
        if UseCapturedNS_ and self.ns_prefix_:
9292
            namespaceprefix_ = self.ns_prefix_ + ':'
9293
        showIndent(outfile, level, pretty_print)
9294
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
9295
        already_processed = set()
9296
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='RelationType')
9297
        if self.has__content():
9298
            outfile.write('>%s' % (eol_, ))
9299
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='RelationType', pretty_print=pretty_print)
9300
            showIndent(outfile, level, pretty_print)
9301
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
9302
        else:
9303
            outfile.write('/>%s' % (eol_, ))
9304 View Code Duplication
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='RelationType'):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
9305
        if self.id is not None and 'id' not in already_processed:
9306
            already_processed.add('id')
9307
            outfile.write(' id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.id), input_name='id')), ))
9308
        if self.type_ is not None and 'type_' not in already_processed:
9309
            already_processed.add('type_')
9310
            outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), ))
9311
        if self.custom is not None and 'custom' not in already_processed:
9312
            already_processed.add('custom')
9313
            outfile.write(' custom=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.custom), input_name='custom')), ))
9314
        if self.comments is not None and 'comments' not in already_processed:
9315
            already_processed.add('comments')
9316
            outfile.write(' comments=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.comments), input_name='comments')), ))
9317
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RelationType', fromsubclass_=False, pretty_print=True):
9318
        if pretty_print:
9319
            eol_ = '\n'
9320
        else:
9321
            eol_ = ''
9322
        for Labels_ in self.Labels:
9323
            namespaceprefix_ = self.Labels_nsprefix_ + ':' if (UseCapturedNS_ and self.Labels_nsprefix_) else ''
9324
            Labels_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Labels', pretty_print=pretty_print)
9325
        if self.SourceRegionRef is not None:
9326
            namespaceprefix_ = self.SourceRegionRef_nsprefix_ + ':' if (UseCapturedNS_ and self.SourceRegionRef_nsprefix_) else ''
9327
            self.SourceRegionRef.export(outfile, level, namespaceprefix_, namespacedef_='', name_='SourceRegionRef', pretty_print=pretty_print)
9328
        if self.TargetRegionRef is not None:
9329
            namespaceprefix_ = self.TargetRegionRef_nsprefix_ + ':' if (UseCapturedNS_ and self.TargetRegionRef_nsprefix_) else ''
9330
            self.TargetRegionRef.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TargetRegionRef', pretty_print=pretty_print)
9331
    def to_etree(self, parent_element=None, name_='RelationType', mapping_=None, reverse_mapping_=None, nsmap_=None):
9332
        if parent_element is None:
9333
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
9334
        else:
9335
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
9336
        if self.id is not None:
9337
            element.set('id', self.gds_format_string(self.id))
9338
        if self.type_ is not None:
9339
            element.set('type', self.gds_format_string(self.type_))
9340
        if self.custom is not None:
9341
            element.set('custom', self.gds_format_string(self.custom))
9342
        if self.comments is not None:
9343
            element.set('comments', self.gds_format_string(self.comments))
9344
        for Labels_ in self.Labels:
9345
            Labels_.to_etree(element, name_='Labels', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
9346
        if self.SourceRegionRef is not None:
9347
            SourceRegionRef_ = self.SourceRegionRef
9348
            SourceRegionRef_.to_etree(element, name_='SourceRegionRef', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
9349
        if self.TargetRegionRef is not None:
9350
            TargetRegionRef_ = self.TargetRegionRef
9351
            TargetRegionRef_.to_etree(element, name_='TargetRegionRef', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
9352
        if mapping_ is not None:
9353
            mapping_[id(self)] = element
9354
        if reverse_mapping_ is not None:
9355
            reverse_mapping_[element] = self
9356
        return element
9357
    def build(self, node, gds_collector_=None):
9358
        self.gds_collector_ = gds_collector_
9359
        if SaveElementTreeNode:
9360
            self.gds_elementtree_node_ = node
9361
        already_processed = set()
9362
        self.ns_prefix_ = node.prefix
9363
        self._buildAttributes(node, node.attrib, already_processed)
9364
        for child in node:
9365
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
9366
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
9367
        return self
9368
    def _buildAttributes(self, node, attrs, already_processed):
9369
        value = find_attr_value_('id', node)
9370
        if value is not None and 'id' not in already_processed:
9371
            already_processed.add('id')
9372
            self.id = value
9373
        value = find_attr_value_('type', node)
9374
        if value is not None and 'type' not in already_processed:
9375
            already_processed.add('type')
9376
            self.type_ = value
9377
            self.validate_typeType1(self.type_)    # validate type typeType1
9378
        value = find_attr_value_('custom', node)
9379
        if value is not None and 'custom' not in already_processed:
9380
            already_processed.add('custom')
9381
            self.custom = value
9382
        value = find_attr_value_('comments', node)
9383
        if value is not None and 'comments' not in already_processed:
9384
            already_processed.add('comments')
9385
            self.comments = value
9386
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
9387
        if nodeName_ == 'Labels':
9388
            obj_ = LabelsType.factory(parent_object_=self)
9389
            obj_.build(child_, gds_collector_=gds_collector_)
9390
            self.Labels.append(obj_)
9391
            obj_.original_tagname_ = 'Labels'
9392
        elif nodeName_ == 'SourceRegionRef':
9393
            obj_ = RegionRefType.factory(parent_object_=self)
9394
            obj_.build(child_, gds_collector_=gds_collector_)
9395
            self.SourceRegionRef = obj_
9396
            obj_.original_tagname_ = 'SourceRegionRef'
9397
        elif nodeName_ == 'TargetRegionRef':
9398
            obj_ = RegionRefType.factory(parent_object_=self)
9399
            obj_.build(child_, gds_collector_=gds_collector_)
9400
            self.TargetRegionRef = obj_
9401
            obj_.original_tagname_ = 'TargetRegionRef'
9402
    def __hash__(self):
9403
        return hash(self.id)
9404
# end class RelationType
9405
9406
9407
class TextStyleType(GeneratedsSuper):
9408
    """TextStyleType --
9409
    Monospace (fixed-pitch, non-proportional) or
9410
    proportional font.
9411
      
9412
    * fontFamily --
9413
      For instance: Arial, Times New Roman.
9414
      Add more information if necessary
9415
      (e.g. blackletter, antiqua).
9416
      
9417
    * serif --
9418
      Serif or sans-serif typeface.
9419
      
9420
    * fontSize --
9421
      The size of the characters in points.
9422
      
9423
    * xHeight --
9424
      The x-height or corpus size refers to the distance
9425
      between the baseline and the mean line of
9426
      lower-case letters in a typeface.
9427
      The unit is assumed to be pixels.
9428
      
9429
    * kerning --
9430
      The degree of space (in points) between
9431
      the characters in a string of text.
9432
      
9433
    * textColourRgb --
9434
      Text colour in RGB encoded format
9435
      (red value) + (256 x green value) + (65536 x blue value).
9436
      
9437
    * bgColour -- Background colour
9438
    * bgColourRgb --
9439
      Background colour in RGB encoded format
9440
      (red value) + (256 x green value) + (65536 x blue value).
9441
      
9442
    * reverseVideo --
9443
      Specifies whether the colour of the text appears
9444
      reversed against a background colour.
9445
      
9446
    * underlineStyle -- Line style details if "underlined" is TRUE
9447
    
9448
    """
9449
    __hash__ = GeneratedsSuper.__hash__
9450
    member_data_items_ = [
9451
        MemberSpec_('fontFamily', 'string', 0, 1, {'use': 'optional', 'name': 'fontFamily'}),
9452
        MemberSpec_('serif', 'boolean', 0, 1, {'use': 'optional', 'name': 'serif'}),
9453
        MemberSpec_('monospace', 'boolean', 0, 1, {'use': 'optional', 'name': 'monospace'}),
9454
        MemberSpec_('fontSize', 'float', 0, 1, {'use': 'optional', 'name': 'fontSize'}),
9455
        MemberSpec_('xHeight', 'integer', 0, 1, {'use': 'optional', 'name': 'xHeight'}),
9456
        MemberSpec_('kerning', 'int', 0, 1, {'use': 'optional', 'name': 'kerning'}),
9457
        MemberSpec_('textColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional', 'name': 'textColour'}),
9458
        MemberSpec_('textColourRgb', 'integer', 0, 1, {'use': 'optional', 'name': 'textColourRgb'}),
9459
        MemberSpec_('bgColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional', 'name': 'bgColour'}),
9460
        MemberSpec_('bgColourRgb', 'integer', 0, 1, {'use': 'optional', 'name': 'bgColourRgb'}),
9461
        MemberSpec_('reverseVideo', 'boolean', 0, 1, {'use': 'optional', 'name': 'reverseVideo'}),
9462
        MemberSpec_('bold', 'boolean', 0, 1, {'use': 'optional', 'name': 'bold'}),
9463
        MemberSpec_('italic', 'boolean', 0, 1, {'use': 'optional', 'name': 'italic'}),
9464
        MemberSpec_('underlined', 'boolean', 0, 1, {'use': 'optional', 'name': 'underlined'}),
9465
        MemberSpec_('underlineStyle', 'pc:UnderlineStyleSimpleType', 0, 1, {'use': 'optional', 'name': 'underlineStyle'}),
9466
        MemberSpec_('subscript', 'boolean', 0, 1, {'use': 'optional', 'name': 'subscript'}),
9467
        MemberSpec_('superscript', 'boolean', 0, 1, {'use': 'optional', 'name': 'superscript'}),
9468
        MemberSpec_('strikethrough', 'boolean', 0, 1, {'use': 'optional', 'name': 'strikethrough'}),
9469
        MemberSpec_('smallCaps', 'boolean', 0, 1, {'use': 'optional', 'name': 'smallCaps'}),
9470
        MemberSpec_('letterSpaced', 'boolean', 0, 1, {'use': 'optional', 'name': 'letterSpaced'}),
9471
    ]
9472
    subclass = None
9473
    superclass = None
9474
    def __init__(self, fontFamily=None, serif=None, monospace=None, fontSize=None, xHeight=None, kerning=None, textColour=None, textColourRgb=None, bgColour=None, bgColourRgb=None, reverseVideo=None, bold=None, italic=None, underlined=None, underlineStyle=None, subscript=None, superscript=None, strikethrough=None, smallCaps=None, letterSpaced=None, gds_collector_=None, **kwargs_):
9475
        self.gds_collector_ = gds_collector_
9476
        self.gds_elementtree_node_ = None
9477
        self.original_tagname_ = None
9478
        self.parent_object_ = kwargs_.get('parent_object_')
9479
        self.ns_prefix_ = "pc"
9480
        self.fontFamily = _cast(None, fontFamily)
9481
        self.fontFamily_nsprefix_ = "pc"
9482
        self.serif = _cast(bool, serif)
9483
        self.serif_nsprefix_ = "pc"
9484
        self.monospace = _cast(bool, monospace)
9485
        self.monospace_nsprefix_ = "pc"
9486
        self.fontSize = _cast(float, fontSize)
9487
        self.fontSize_nsprefix_ = "pc"
9488
        self.xHeight = _cast(int, xHeight)
9489
        self.xHeight_nsprefix_ = "pc"
9490
        self.kerning = _cast(int, kerning)
9491
        self.kerning_nsprefix_ = "pc"
9492
        self.textColour = _cast(None, textColour)
9493
        self.textColour_nsprefix_ = "pc"
9494
        self.textColourRgb = _cast(int, textColourRgb)
9495
        self.textColourRgb_nsprefix_ = "pc"
9496
        self.bgColour = _cast(None, bgColour)
9497
        self.bgColour_nsprefix_ = "pc"
9498
        self.bgColourRgb = _cast(int, bgColourRgb)
9499
        self.bgColourRgb_nsprefix_ = "pc"
9500
        self.reverseVideo = _cast(bool, reverseVideo)
9501
        self.reverseVideo_nsprefix_ = "pc"
9502
        self.bold = _cast(bool, bold)
9503
        self.bold_nsprefix_ = "pc"
9504
        self.italic = _cast(bool, italic)
9505
        self.italic_nsprefix_ = "pc"
9506
        self.underlined = _cast(bool, underlined)
9507
        self.underlined_nsprefix_ = "pc"
9508
        self.underlineStyle = _cast(None, underlineStyle)
9509
        self.underlineStyle_nsprefix_ = "pc"
9510
        self.subscript = _cast(bool, subscript)
9511
        self.subscript_nsprefix_ = "pc"
9512
        self.superscript = _cast(bool, superscript)
9513
        self.superscript_nsprefix_ = "pc"
9514
        self.strikethrough = _cast(bool, strikethrough)
9515
        self.strikethrough_nsprefix_ = "pc"
9516
        self.smallCaps = _cast(bool, smallCaps)
9517
        self.smallCaps_nsprefix_ = "pc"
9518
        self.letterSpaced = _cast(bool, letterSpaced)
9519
        self.letterSpaced_nsprefix_ = "pc"
9520
    def factory(*args_, **kwargs_):
9521
        if CurrentSubclassModule_ is not None:
9522
            subclass = getSubclassFromModule_(
9523
                CurrentSubclassModule_, TextStyleType)
9524
            if subclass is not None:
9525
                return subclass(*args_, **kwargs_)
9526
        if TextStyleType.subclass:
9527
            return TextStyleType.subclass(*args_, **kwargs_)
9528
        else:
9529
            return TextStyleType(*args_, **kwargs_)
9530
    factory = staticmethod(factory)
9531
    def get_ns_prefix_(self):
9532
        return self.ns_prefix_
9533
    def set_ns_prefix_(self, ns_prefix):
9534
        self.ns_prefix_ = ns_prefix
9535
    def get_fontFamily(self):
9536
        return self.fontFamily
9537
    def set_fontFamily(self, fontFamily):
9538
        self.fontFamily = fontFamily
9539
    def get_serif(self):
9540
        return self.serif
9541
    def set_serif(self, serif):
9542
        self.serif = serif
9543
    def get_monospace(self):
9544
        return self.monospace
9545
    def set_monospace(self, monospace):
9546
        self.monospace = monospace
9547
    def get_fontSize(self):
9548
        return self.fontSize
9549
    def set_fontSize(self, fontSize):
9550
        self.fontSize = fontSize
9551
    def get_xHeight(self):
9552
        return self.xHeight
9553
    def set_xHeight(self, xHeight):
9554
        self.xHeight = xHeight
9555
    def get_kerning(self):
9556
        return self.kerning
9557
    def set_kerning(self, kerning):
9558
        self.kerning = kerning
9559
    def get_textColour(self):
9560
        return self.textColour
9561
    def set_textColour(self, textColour):
9562
        self.textColour = textColour
9563
    def get_textColourRgb(self):
9564
        return self.textColourRgb
9565
    def set_textColourRgb(self, textColourRgb):
9566
        self.textColourRgb = textColourRgb
9567
    def get_bgColour(self):
9568
        return self.bgColour
9569
    def set_bgColour(self, bgColour):
9570
        self.bgColour = bgColour
9571
    def get_bgColourRgb(self):
9572
        return self.bgColourRgb
9573
    def set_bgColourRgb(self, bgColourRgb):
9574
        self.bgColourRgb = bgColourRgb
9575
    def get_reverseVideo(self):
9576
        return self.reverseVideo
9577
    def set_reverseVideo(self, reverseVideo):
9578
        self.reverseVideo = reverseVideo
9579
    def get_bold(self):
9580
        return self.bold
9581
    def set_bold(self, bold):
9582
        self.bold = bold
9583
    def get_italic(self):
9584
        return self.italic
9585
    def set_italic(self, italic):
9586
        self.italic = italic
9587
    def get_underlined(self):
9588
        return self.underlined
9589
    def set_underlined(self, underlined):
9590
        self.underlined = underlined
9591
    def get_underlineStyle(self):
9592
        return self.underlineStyle
9593
    def set_underlineStyle(self, underlineStyle):
9594
        self.underlineStyle = underlineStyle
9595
    def get_subscript(self):
9596
        return self.subscript
9597
    def set_subscript(self, subscript):
9598
        self.subscript = subscript
9599
    def get_superscript(self):
9600
        return self.superscript
9601
    def set_superscript(self, superscript):
9602
        self.superscript = superscript
9603
    def get_strikethrough(self):
9604
        return self.strikethrough
9605
    def set_strikethrough(self, strikethrough):
9606
        self.strikethrough = strikethrough
9607
    def get_smallCaps(self):
9608
        return self.smallCaps
9609
    def set_smallCaps(self, smallCaps):
9610
        self.smallCaps = smallCaps
9611
    def get_letterSpaced(self):
9612
        return self.letterSpaced
9613
    def set_letterSpaced(self, letterSpaced):
9614
        self.letterSpaced = letterSpaced
9615
    def validate_ColourSimpleType(self, value):
9616
        # Validate type pc:ColourSimpleType, a restriction on string.
9617
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
9618
            if not isinstance(value, str):
9619
                lineno = self.gds_get_node_lineno_()
9620
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
9621
                return False
9622
            value = value
9623
            enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other']
9624
            if value not in enumerations:
9625
                lineno = self.gds_get_node_lineno_()
9626
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ColourSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
9627
                result = False
9628
    def validate_UnderlineStyleSimpleType(self, value):
9629
        # Validate type pc:UnderlineStyleSimpleType, a restriction on string.
9630
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
9631
            if not isinstance(value, str):
9632
                lineno = self.gds_get_node_lineno_()
9633
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
9634
                return False
9635
            value = value
9636
            enumerations = ['singleLine', 'doubleLine', 'other']
9637
            if value not in enumerations:
9638
                lineno = self.gds_get_node_lineno_()
9639
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on UnderlineStyleSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
9640
                result = False
9641
    def has__content(self):
9642
        if (
9643
9644
        ):
9645
            return True
9646
        else:
9647
            return False
9648
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='TextStyleType', pretty_print=True):
9649
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('TextStyleType')
9650
        if imported_ns_def_ is not None:
9651
            namespacedef_ = imported_ns_def_
9652
        if pretty_print:
9653
            eol_ = '\n'
9654
        else:
9655
            eol_ = ''
9656
        if self.original_tagname_ is not None and name_ == 'TextStyleType':
9657
            name_ = self.original_tagname_
9658
        if UseCapturedNS_ and self.ns_prefix_:
9659
            namespaceprefix_ = self.ns_prefix_ + ':'
9660
        showIndent(outfile, level, pretty_print)
9661
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
9662
        already_processed = set()
9663
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='TextStyleType')
9664
        if self.has__content():
9665
            outfile.write('>%s' % (eol_, ))
9666
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='TextStyleType', pretty_print=pretty_print)
9667
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
9668
        else:
9669
            outfile.write('/>%s' % (eol_, ))
9670
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='TextStyleType'):
9671
        if self.fontFamily is not None and 'fontFamily' not in already_processed:
9672
            already_processed.add('fontFamily')
9673
            outfile.write(' fontFamily=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.fontFamily), input_name='fontFamily')), ))
9674
        if self.serif is not None and 'serif' not in already_processed:
9675
            already_processed.add('serif')
9676
            outfile.write(' serif="%s"' % self.gds_format_boolean(self.serif, input_name='serif'))
9677
        if self.monospace is not None and 'monospace' not in already_processed:
9678
            already_processed.add('monospace')
9679
            outfile.write(' monospace="%s"' % self.gds_format_boolean(self.monospace, input_name='monospace'))
9680
        if self.fontSize is not None and 'fontSize' not in already_processed:
9681
            already_processed.add('fontSize')
9682
            outfile.write(' fontSize="%s"' % self.gds_format_float(self.fontSize, input_name='fontSize'))
9683
        if self.xHeight is not None and 'xHeight' not in already_processed:
9684
            already_processed.add('xHeight')
9685
            outfile.write(' xHeight="%s"' % self.gds_format_integer(self.xHeight, input_name='xHeight'))
9686
        if self.kerning is not None and 'kerning' not in already_processed:
9687
            already_processed.add('kerning')
9688
            outfile.write(' kerning="%s"' % self.gds_format_integer(self.kerning, input_name='kerning'))
9689
        if self.textColour is not None and 'textColour' not in already_processed:
9690
            already_processed.add('textColour')
9691
            outfile.write(' textColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.textColour), input_name='textColour')), ))
9692
        if self.textColourRgb is not None and 'textColourRgb' not in already_processed:
9693
            already_processed.add('textColourRgb')
9694
            outfile.write(' textColourRgb="%s"' % self.gds_format_integer(self.textColourRgb, input_name='textColourRgb'))
9695
        if self.bgColour is not None and 'bgColour' not in already_processed:
9696
            already_processed.add('bgColour')
9697
            outfile.write(' bgColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.bgColour), input_name='bgColour')), ))
9698
        if self.bgColourRgb is not None and 'bgColourRgb' not in already_processed:
9699
            already_processed.add('bgColourRgb')
9700
            outfile.write(' bgColourRgb="%s"' % self.gds_format_integer(self.bgColourRgb, input_name='bgColourRgb'))
9701
        if self.reverseVideo is not None and 'reverseVideo' not in already_processed:
9702
            already_processed.add('reverseVideo')
9703
            outfile.write(' reverseVideo="%s"' % self.gds_format_boolean(self.reverseVideo, input_name='reverseVideo'))
9704
        if self.bold is not None and 'bold' not in already_processed:
9705
            already_processed.add('bold')
9706
            outfile.write(' bold="%s"' % self.gds_format_boolean(self.bold, input_name='bold'))
9707
        if self.italic is not None and 'italic' not in already_processed:
9708
            already_processed.add('italic')
9709
            outfile.write(' italic="%s"' % self.gds_format_boolean(self.italic, input_name='italic'))
9710
        if self.underlined is not None and 'underlined' not in already_processed:
9711
            already_processed.add('underlined')
9712
            outfile.write(' underlined="%s"' % self.gds_format_boolean(self.underlined, input_name='underlined'))
9713
        if self.underlineStyle is not None and 'underlineStyle' not in already_processed:
9714
            already_processed.add('underlineStyle')
9715
            outfile.write(' underlineStyle=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.underlineStyle), input_name='underlineStyle')), ))
9716
        if self.subscript is not None and 'subscript' not in already_processed:
9717
            already_processed.add('subscript')
9718
            outfile.write(' subscript="%s"' % self.gds_format_boolean(self.subscript, input_name='subscript'))
9719
        if self.superscript is not None and 'superscript' not in already_processed:
9720
            already_processed.add('superscript')
9721
            outfile.write(' superscript="%s"' % self.gds_format_boolean(self.superscript, input_name='superscript'))
9722
        if self.strikethrough is not None and 'strikethrough' not in already_processed:
9723
            already_processed.add('strikethrough')
9724
            outfile.write(' strikethrough="%s"' % self.gds_format_boolean(self.strikethrough, input_name='strikethrough'))
9725
        if self.smallCaps is not None and 'smallCaps' not in already_processed:
9726
            already_processed.add('smallCaps')
9727
            outfile.write(' smallCaps="%s"' % self.gds_format_boolean(self.smallCaps, input_name='smallCaps'))
9728
        if self.letterSpaced is not None and 'letterSpaced' not in already_processed:
9729
            already_processed.add('letterSpaced')
9730
            outfile.write(' letterSpaced="%s"' % self.gds_format_boolean(self.letterSpaced, input_name='letterSpaced'))
9731
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='TextStyleType', fromsubclass_=False, pretty_print=True):
9732
        pass
9733
    def to_etree(self, parent_element=None, name_='TextStyleType', mapping_=None, reverse_mapping_=None, nsmap_=None):
9734
        if parent_element is None:
9735
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
9736
        else:
9737
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
9738
        if self.fontFamily is not None:
9739
            element.set('fontFamily', self.gds_format_string(self.fontFamily))
9740
        if self.serif is not None:
9741
            element.set('serif', self.gds_format_boolean(self.serif))
9742
        if self.monospace is not None:
9743
            element.set('monospace', self.gds_format_boolean(self.monospace))
9744
        if self.fontSize is not None:
9745
            element.set('fontSize', self.gds_format_float(self.fontSize))
9746
        if self.xHeight is not None:
9747
            element.set('xHeight', self.gds_format_integer(self.xHeight))
9748
        if self.kerning is not None:
9749
            element.set('kerning', self.gds_format_integer(self.kerning))
9750
        if self.textColour is not None:
9751
            element.set('textColour', self.gds_format_string(self.textColour))
9752
        if self.textColourRgb is not None:
9753
            element.set('textColourRgb', self.gds_format_integer(self.textColourRgb))
9754
        if self.bgColour is not None:
9755
            element.set('bgColour', self.gds_format_string(self.bgColour))
9756
        if self.bgColourRgb is not None:
9757
            element.set('bgColourRgb', self.gds_format_integer(self.bgColourRgb))
9758
        if self.reverseVideo is not None:
9759
            element.set('reverseVideo', self.gds_format_boolean(self.reverseVideo))
9760
        if self.bold is not None:
9761
            element.set('bold', self.gds_format_boolean(self.bold))
9762
        if self.italic is not None:
9763
            element.set('italic', self.gds_format_boolean(self.italic))
9764
        if self.underlined is not None:
9765
            element.set('underlined', self.gds_format_boolean(self.underlined))
9766
        if self.underlineStyle is not None:
9767
            element.set('underlineStyle', self.gds_format_string(self.underlineStyle))
9768
        if self.subscript is not None:
9769
            element.set('subscript', self.gds_format_boolean(self.subscript))
9770
        if self.superscript is not None:
9771
            element.set('superscript', self.gds_format_boolean(self.superscript))
9772
        if self.strikethrough is not None:
9773
            element.set('strikethrough', self.gds_format_boolean(self.strikethrough))
9774
        if self.smallCaps is not None:
9775
            element.set('smallCaps', self.gds_format_boolean(self.smallCaps))
9776
        if self.letterSpaced is not None:
9777
            element.set('letterSpaced', self.gds_format_boolean(self.letterSpaced))
9778
        if mapping_ is not None:
9779
            mapping_[id(self)] = element
9780
        if reverse_mapping_ is not None:
9781
            reverse_mapping_[element] = self
9782
        return element
9783
    def build(self, node, gds_collector_=None):
9784
        self.gds_collector_ = gds_collector_
9785
        if SaveElementTreeNode:
9786
            self.gds_elementtree_node_ = node
9787
        already_processed = set()
9788
        self.ns_prefix_ = node.prefix
9789
        self._buildAttributes(node, node.attrib, already_processed)
9790
        for child in node:
9791
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
9792
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
9793
        return self
9794
    def _buildAttributes(self, node, attrs, already_processed):
9795
        value = find_attr_value_('fontFamily', node)
9796
        if value is not None and 'fontFamily' not in already_processed:
9797
            already_processed.add('fontFamily')
9798
            self.fontFamily = value
9799
        value = find_attr_value_('serif', node)
9800
        if value is not None and 'serif' not in already_processed:
9801
            already_processed.add('serif')
9802
            if value in ('true', '1'):
9803
                self.serif = True
9804
            elif value in ('false', '0'):
9805
                self.serif = False
9806
            else:
9807
                raise_parse_error(node, 'Bad boolean attribute')
9808
        value = find_attr_value_('monospace', node)
9809
        if value is not None and 'monospace' not in already_processed:
9810
            already_processed.add('monospace')
9811
            if value in ('true', '1'):
9812
                self.monospace = True
9813
            elif value in ('false', '0'):
9814
                self.monospace = False
9815
            else:
9816
                raise_parse_error(node, 'Bad boolean attribute')
9817
        value = find_attr_value_('fontSize', node)
9818
        if value is not None and 'fontSize' not in already_processed:
9819
            already_processed.add('fontSize')
9820
            value = self.gds_parse_float(value, node, 'fontSize')
9821
            self.fontSize = value
9822
        value = find_attr_value_('xHeight', node)
9823
        if value is not None and 'xHeight' not in already_processed:
9824
            already_processed.add('xHeight')
9825
            self.xHeight = self.gds_parse_integer(value, node, 'xHeight')
9826
        value = find_attr_value_('kerning', node)
9827
        if value is not None and 'kerning' not in already_processed:
9828
            already_processed.add('kerning')
9829
            self.kerning = self.gds_parse_integer(value, node, 'kerning')
9830
        value = find_attr_value_('textColour', node)
9831
        if value is not None and 'textColour' not in already_processed:
9832
            already_processed.add('textColour')
9833
            self.textColour = value
9834
            self.validate_ColourSimpleType(self.textColour)    # validate type ColourSimpleType
9835
        value = find_attr_value_('textColourRgb', node)
9836
        if value is not None and 'textColourRgb' not in already_processed:
9837
            already_processed.add('textColourRgb')
9838
            self.textColourRgb = self.gds_parse_integer(value, node, 'textColourRgb')
9839
        value = find_attr_value_('bgColour', node)
9840
        if value is not None and 'bgColour' not in already_processed:
9841
            already_processed.add('bgColour')
9842
            self.bgColour = value
9843
            self.validate_ColourSimpleType(self.bgColour)    # validate type ColourSimpleType
9844
        value = find_attr_value_('bgColourRgb', node)
9845
        if value is not None and 'bgColourRgb' not in already_processed:
9846
            already_processed.add('bgColourRgb')
9847
            self.bgColourRgb = self.gds_parse_integer(value, node, 'bgColourRgb')
9848
        value = find_attr_value_('reverseVideo', node)
9849
        if value is not None and 'reverseVideo' not in already_processed:
9850
            already_processed.add('reverseVideo')
9851
            if value in ('true', '1'):
9852
                self.reverseVideo = True
9853
            elif value in ('false', '0'):
9854
                self.reverseVideo = False
9855
            else:
9856
                raise_parse_error(node, 'Bad boolean attribute')
9857
        value = find_attr_value_('bold', node)
9858
        if value is not None and 'bold' not in already_processed:
9859
            already_processed.add('bold')
9860
            if value in ('true', '1'):
9861
                self.bold = True
9862
            elif value in ('false', '0'):
9863
                self.bold = False
9864
            else:
9865
                raise_parse_error(node, 'Bad boolean attribute')
9866
        value = find_attr_value_('italic', node)
9867
        if value is not None and 'italic' not in already_processed:
9868
            already_processed.add('italic')
9869
            if value in ('true', '1'):
9870
                self.italic = True
9871
            elif value in ('false', '0'):
9872
                self.italic = False
9873
            else:
9874
                raise_parse_error(node, 'Bad boolean attribute')
9875
        value = find_attr_value_('underlined', node)
9876
        if value is not None and 'underlined' not in already_processed:
9877
            already_processed.add('underlined')
9878
            if value in ('true', '1'):
9879
                self.underlined = True
9880
            elif value in ('false', '0'):
9881
                self.underlined = False
9882
            else:
9883
                raise_parse_error(node, 'Bad boolean attribute')
9884
        value = find_attr_value_('underlineStyle', node)
9885
        if value is not None and 'underlineStyle' not in already_processed:
9886
            already_processed.add('underlineStyle')
9887
            self.underlineStyle = value
9888
            self.validate_UnderlineStyleSimpleType(self.underlineStyle)    # validate type UnderlineStyleSimpleType
9889
        value = find_attr_value_('subscript', node)
9890
        if value is not None and 'subscript' not in already_processed:
9891
            already_processed.add('subscript')
9892
            if value in ('true', '1'):
9893
                self.subscript = True
9894
            elif value in ('false', '0'):
9895
                self.subscript = False
9896
            else:
9897
                raise_parse_error(node, 'Bad boolean attribute')
9898
        value = find_attr_value_('superscript', node)
9899
        if value is not None and 'superscript' not in already_processed:
9900
            already_processed.add('superscript')
9901
            if value in ('true', '1'):
9902
                self.superscript = True
9903
            elif value in ('false', '0'):
9904
                self.superscript = False
9905
            else:
9906
                raise_parse_error(node, 'Bad boolean attribute')
9907
        value = find_attr_value_('strikethrough', node)
9908
        if value is not None and 'strikethrough' not in already_processed:
9909
            already_processed.add('strikethrough')
9910
            if value in ('true', '1'):
9911
                self.strikethrough = True
9912
            elif value in ('false', '0'):
9913
                self.strikethrough = False
9914
            else:
9915
                raise_parse_error(node, 'Bad boolean attribute')
9916
        value = find_attr_value_('smallCaps', node)
9917
        if value is not None and 'smallCaps' not in already_processed:
9918
            already_processed.add('smallCaps')
9919
            if value in ('true', '1'):
9920
                self.smallCaps = True
9921
            elif value in ('false', '0'):
9922
                self.smallCaps = False
9923
            else:
9924
                raise_parse_error(node, 'Bad boolean attribute')
9925
        value = find_attr_value_('letterSpaced', node)
9926
        if value is not None and 'letterSpaced' not in already_processed:
9927
            already_processed.add('letterSpaced')
9928
            if value in ('true', '1'):
9929
                self.letterSpaced = True
9930
            elif value in ('false', '0'):
9931
                self.letterSpaced = False
9932
            else:
9933
                raise_parse_error(node, 'Bad boolean attribute')
9934
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
9935
        pass
9936
    def __hash__(self):
9937
        return hash(self.id)
9938
# end class TextStyleType
9939
9940
9941
class RegionType(GeneratedsSuper):
9942
    """custom -- For generic use
9943
    continuation --
9944
    Is this region a continuation of another region
9945
    (in previous column or page, for example)?
9946
      
9947
    * AlternativeImage --
9948
      Alternative region images
9949
      (e.g. black-and-white).
9950
      
9951
    * Labels -- Semantic labels / tags
9952
    * Roles --
9953
      Roles the region takes
9954
      (e.g. in context of a parent region).
9955
    
9956
    """
9957
    __hash__ = GeneratedsSuper.__hash__
9958
    member_data_items_ = [
9959
        MemberSpec_('id', 'string', 0, 0, {'use': 'required', 'name': 'id'}),
9960
        MemberSpec_('custom', 'string', 0, 1, {'use': 'optional', 'name': 'custom'}),
9961
        MemberSpec_('comments', 'string', 0, 1, {'use': 'optional', 'name': 'comments'}),
9962
        MemberSpec_('continuation', 'boolean', 0, 1, {'use': 'optional', 'name': 'continuation'}),
9963
        MemberSpec_('AlternativeImage', 'AlternativeImageType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'AlternativeImage', 'type': 'AlternativeImageType'}, None),
9964
        MemberSpec_('Coords', 'CoordsType', 0, 0, {'name': 'Coords', 'type': 'CoordsType'}, None),
9965
        MemberSpec_('UserDefined', 'UserDefinedType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'UserDefined', 'type': 'UserDefinedType'}, None),
9966
        MemberSpec_('Labels', 'LabelsType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'Labels', 'type': 'LabelsType'}, None),
9967
        MemberSpec_('Roles', 'RolesType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'Roles', 'type': 'RolesType'}, None),
9968
        MemberSpec_('TextRegion', 'TextRegionType', 1, 1, {'name': 'TextRegion', 'type': 'TextRegionType'}, 7),
9969
        MemberSpec_('ImageRegion', 'ImageRegionType', 1, 1, {'name': 'ImageRegion', 'type': 'ImageRegionType'}, 7),
9970
        MemberSpec_('LineDrawingRegion', 'LineDrawingRegionType', 1, 1, {'name': 'LineDrawingRegion', 'type': 'LineDrawingRegionType'}, 7),
9971
        MemberSpec_('GraphicRegion', 'GraphicRegionType', 1, 1, {'name': 'GraphicRegion', 'type': 'GraphicRegionType'}, 7),
9972
        MemberSpec_('TableRegion', 'TableRegionType', 1, 1, {'name': 'TableRegion', 'type': 'TableRegionType'}, 7),
9973
        MemberSpec_('ChartRegion', 'ChartRegionType', 1, 1, {'name': 'ChartRegion', 'type': 'ChartRegionType'}, 7),
9974
        MemberSpec_('SeparatorRegion', 'SeparatorRegionType', 1, 1, {'name': 'SeparatorRegion', 'type': 'SeparatorRegionType'}, 7),
9975
        MemberSpec_('MathsRegion', 'MathsRegionType', 1, 1, {'name': 'MathsRegion', 'type': 'MathsRegionType'}, 7),
9976
        MemberSpec_('ChemRegion', 'ChemRegionType', 1, 1, {'name': 'ChemRegion', 'type': 'ChemRegionType'}, 7),
9977
        MemberSpec_('MusicRegion', 'MusicRegionType', 1, 1, {'name': 'MusicRegion', 'type': 'MusicRegionType'}, 7),
9978
        MemberSpec_('AdvertRegion', 'AdvertRegionType', 1, 1, {'name': 'AdvertRegion', 'type': 'AdvertRegionType'}, 7),
9979
        MemberSpec_('NoiseRegion', 'NoiseRegionType', 1, 1, {'name': 'NoiseRegion', 'type': 'NoiseRegionType'}, 7),
9980
        MemberSpec_('UnknownRegion', 'UnknownRegionType', 1, 1, {'name': 'UnknownRegion', 'type': 'UnknownRegionType'}, 7),
9981
        MemberSpec_('CustomRegion', 'CustomRegionType', 1, 1, {'name': 'CustomRegion', 'type': 'CustomRegionType'}, 7),
9982
    ]
9983
    subclass = None
9984
    superclass = None
9985
    def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, extensiontype_=None, gds_collector_=None, **kwargs_):
9986
        self.gds_collector_ = gds_collector_
9987
        self.gds_elementtree_node_ = None
9988
        self.original_tagname_ = None
9989
        self.parent_object_ = kwargs_.get('parent_object_')
9990
        self.ns_prefix_ = "pc"
9991
        self.id = _cast(None, id)
9992
        self.id_nsprefix_ = "pc"
9993
        self.custom = _cast(None, custom)
9994
        self.custom_nsprefix_ = "pc"
9995
        self.comments = _cast(None, comments)
9996
        self.comments_nsprefix_ = "pc"
9997
        self.continuation = _cast(bool, continuation)
9998
        self.continuation_nsprefix_ = "pc"
9999
        if AlternativeImage is None:
10000
            self.AlternativeImage = []
10001
        else:
10002
            self.AlternativeImage = AlternativeImage
10003
        self.AlternativeImage_nsprefix_ = "pc"
10004
        self.Coords = Coords
10005
        self.Coords_nsprefix_ = "pc"
10006
        self.UserDefined = UserDefined
10007
        self.UserDefined_nsprefix_ = "pc"
10008
        if Labels is None:
10009
            self.Labels = []
10010
        else:
10011
            self.Labels = Labels
10012
        self.Labels_nsprefix_ = "pc"
10013
        self.Roles = Roles
10014
        self.Roles_nsprefix_ = "pc"
10015
        if TextRegion is None:
10016
            self.TextRegion = []
10017
        else:
10018
            self.TextRegion = TextRegion
10019
        self.TextRegion_nsprefix_ = "pc"
10020
        if ImageRegion is None:
10021
            self.ImageRegion = []
10022
        else:
10023
            self.ImageRegion = ImageRegion
10024
        self.ImageRegion_nsprefix_ = "pc"
10025
        if LineDrawingRegion is None:
10026
            self.LineDrawingRegion = []
10027
        else:
10028
            self.LineDrawingRegion = LineDrawingRegion
10029
        self.LineDrawingRegion_nsprefix_ = "pc"
10030
        if GraphicRegion is None:
10031
            self.GraphicRegion = []
10032
        else:
10033
            self.GraphicRegion = GraphicRegion
10034
        self.GraphicRegion_nsprefix_ = "pc"
10035
        if TableRegion is None:
10036
            self.TableRegion = []
10037
        else:
10038
            self.TableRegion = TableRegion
10039
        self.TableRegion_nsprefix_ = "pc"
10040
        if ChartRegion is None:
10041
            self.ChartRegion = []
10042
        else:
10043
            self.ChartRegion = ChartRegion
10044
        self.ChartRegion_nsprefix_ = "pc"
10045
        if SeparatorRegion is None:
10046
            self.SeparatorRegion = []
10047
        else:
10048
            self.SeparatorRegion = SeparatorRegion
10049
        self.SeparatorRegion_nsprefix_ = "pc"
10050
        if MathsRegion is None:
10051
            self.MathsRegion = []
10052
        else:
10053
            self.MathsRegion = MathsRegion
10054
        self.MathsRegion_nsprefix_ = "pc"
10055
        if ChemRegion is None:
10056
            self.ChemRegion = []
10057
        else:
10058
            self.ChemRegion = ChemRegion
10059
        self.ChemRegion_nsprefix_ = "pc"
10060
        if MusicRegion is None:
10061
            self.MusicRegion = []
10062
        else:
10063
            self.MusicRegion = MusicRegion
10064
        self.MusicRegion_nsprefix_ = "pc"
10065
        if AdvertRegion is None:
10066
            self.AdvertRegion = []
10067
        else:
10068
            self.AdvertRegion = AdvertRegion
10069
        self.AdvertRegion_nsprefix_ = "pc"
10070
        if NoiseRegion is None:
10071
            self.NoiseRegion = []
10072
        else:
10073
            self.NoiseRegion = NoiseRegion
10074
        self.NoiseRegion_nsprefix_ = "pc"
10075
        if UnknownRegion is None:
10076
            self.UnknownRegion = []
10077
        else:
10078
            self.UnknownRegion = UnknownRegion
10079
        self.UnknownRegion_nsprefix_ = "pc"
10080
        if CustomRegion is None:
10081
            self.CustomRegion = []
10082
        else:
10083
            self.CustomRegion = CustomRegion
10084
        self.CustomRegion_nsprefix_ = "pc"
10085
        self.extensiontype_ = extensiontype_
10086
    def factory(*args_, **kwargs_):
10087
        if CurrentSubclassModule_ is not None:
10088
            subclass = getSubclassFromModule_(
10089
                CurrentSubclassModule_, RegionType)
10090
            if subclass is not None:
10091
                return subclass(*args_, **kwargs_)
10092
        if RegionType.subclass:
10093
            return RegionType.subclass(*args_, **kwargs_)
10094
        else:
10095
            return RegionType(*args_, **kwargs_)
10096
    factory = staticmethod(factory)
10097
    def get_ns_prefix_(self):
10098
        return self.ns_prefix_
10099
    def set_ns_prefix_(self, ns_prefix):
10100
        self.ns_prefix_ = ns_prefix
10101
    def get_AlternativeImage(self):
10102
        return self.AlternativeImage
10103
    def set_AlternativeImage(self, AlternativeImage):
10104
        self.AlternativeImage = AlternativeImage
10105
    def add_AlternativeImage(self, value):
10106
        self.AlternativeImage.append(value)
10107
    def insert_AlternativeImage_at(self, index, value):
10108
        self.AlternativeImage.insert(index, value)
10109
    def replace_AlternativeImage_at(self, index, value):
10110
        self.AlternativeImage[index] = value
10111
    def get_Coords(self):
10112
        return self.Coords
10113
    def set_Coords(self, Coords):
10114
        self.Coords = Coords
10115
    def get_UserDefined(self):
10116
        return self.UserDefined
10117
    def set_UserDefined(self, UserDefined):
10118
        self.UserDefined = UserDefined
10119
    def get_Labels(self):
10120
        return self.Labels
10121
    def set_Labels(self, Labels):
10122
        self.Labels = Labels
10123
    def add_Labels(self, value):
10124
        self.Labels.append(value)
10125
    def insert_Labels_at(self, index, value):
10126
        self.Labels.insert(index, value)
10127
    def replace_Labels_at(self, index, value):
10128
        self.Labels[index] = value
10129
    def get_Roles(self):
10130
        return self.Roles
10131
    def set_Roles(self, Roles):
10132
        self.Roles = Roles
10133
    def get_TextRegion(self):
10134
        return self.TextRegion
10135
    def set_TextRegion(self, TextRegion):
10136
        self.TextRegion = TextRegion
10137
    def add_TextRegion(self, value):
10138
        self.TextRegion.append(value)
10139
    def insert_TextRegion_at(self, index, value):
10140
        self.TextRegion.insert(index, value)
10141
    def replace_TextRegion_at(self, index, value):
10142
        self.TextRegion[index] = value
10143
    def get_ImageRegion(self):
10144
        return self.ImageRegion
10145
    def set_ImageRegion(self, ImageRegion):
10146
        self.ImageRegion = ImageRegion
10147
    def add_ImageRegion(self, value):
10148
        self.ImageRegion.append(value)
10149
    def insert_ImageRegion_at(self, index, value):
10150
        self.ImageRegion.insert(index, value)
10151
    def replace_ImageRegion_at(self, index, value):
10152
        self.ImageRegion[index] = value
10153
    def get_LineDrawingRegion(self):
10154
        return self.LineDrawingRegion
10155
    def set_LineDrawingRegion(self, LineDrawingRegion):
10156
        self.LineDrawingRegion = LineDrawingRegion
10157
    def add_LineDrawingRegion(self, value):
10158
        self.LineDrawingRegion.append(value)
10159
    def insert_LineDrawingRegion_at(self, index, value):
10160
        self.LineDrawingRegion.insert(index, value)
10161
    def replace_LineDrawingRegion_at(self, index, value):
10162
        self.LineDrawingRegion[index] = value
10163
    def get_GraphicRegion(self):
10164
        return self.GraphicRegion
10165
    def set_GraphicRegion(self, GraphicRegion):
10166
        self.GraphicRegion = GraphicRegion
10167
    def add_GraphicRegion(self, value):
10168
        self.GraphicRegion.append(value)
10169
    def insert_GraphicRegion_at(self, index, value):
10170
        self.GraphicRegion.insert(index, value)
10171
    def replace_GraphicRegion_at(self, index, value):
10172
        self.GraphicRegion[index] = value
10173
    def get_TableRegion(self):
10174
        return self.TableRegion
10175
    def set_TableRegion(self, TableRegion):
10176
        self.TableRegion = TableRegion
10177
    def add_TableRegion(self, value):
10178
        self.TableRegion.append(value)
10179
    def insert_TableRegion_at(self, index, value):
10180
        self.TableRegion.insert(index, value)
10181
    def replace_TableRegion_at(self, index, value):
10182
        self.TableRegion[index] = value
10183
    def get_ChartRegion(self):
10184
        return self.ChartRegion
10185
    def set_ChartRegion(self, ChartRegion):
10186
        self.ChartRegion = ChartRegion
10187
    def add_ChartRegion(self, value):
10188
        self.ChartRegion.append(value)
10189
    def insert_ChartRegion_at(self, index, value):
10190
        self.ChartRegion.insert(index, value)
10191
    def replace_ChartRegion_at(self, index, value):
10192
        self.ChartRegion[index] = value
10193
    def get_SeparatorRegion(self):
10194
        return self.SeparatorRegion
10195
    def set_SeparatorRegion(self, SeparatorRegion):
10196
        self.SeparatorRegion = SeparatorRegion
10197
    def add_SeparatorRegion(self, value):
10198
        self.SeparatorRegion.append(value)
10199
    def insert_SeparatorRegion_at(self, index, value):
10200
        self.SeparatorRegion.insert(index, value)
10201
    def replace_SeparatorRegion_at(self, index, value):
10202
        self.SeparatorRegion[index] = value
10203
    def get_MathsRegion(self):
10204
        return self.MathsRegion
10205
    def set_MathsRegion(self, MathsRegion):
10206
        self.MathsRegion = MathsRegion
10207
    def add_MathsRegion(self, value):
10208
        self.MathsRegion.append(value)
10209
    def insert_MathsRegion_at(self, index, value):
10210
        self.MathsRegion.insert(index, value)
10211
    def replace_MathsRegion_at(self, index, value):
10212
        self.MathsRegion[index] = value
10213
    def get_ChemRegion(self):
10214
        return self.ChemRegion
10215
    def set_ChemRegion(self, ChemRegion):
10216
        self.ChemRegion = ChemRegion
10217
    def add_ChemRegion(self, value):
10218
        self.ChemRegion.append(value)
10219
    def insert_ChemRegion_at(self, index, value):
10220
        self.ChemRegion.insert(index, value)
10221
    def replace_ChemRegion_at(self, index, value):
10222
        self.ChemRegion[index] = value
10223
    def get_MusicRegion(self):
10224
        return self.MusicRegion
10225
    def set_MusicRegion(self, MusicRegion):
10226
        self.MusicRegion = MusicRegion
10227
    def add_MusicRegion(self, value):
10228
        self.MusicRegion.append(value)
10229
    def insert_MusicRegion_at(self, index, value):
10230
        self.MusicRegion.insert(index, value)
10231
    def replace_MusicRegion_at(self, index, value):
10232
        self.MusicRegion[index] = value
10233
    def get_AdvertRegion(self):
10234
        return self.AdvertRegion
10235
    def set_AdvertRegion(self, AdvertRegion):
10236
        self.AdvertRegion = AdvertRegion
10237
    def add_AdvertRegion(self, value):
10238
        self.AdvertRegion.append(value)
10239
    def insert_AdvertRegion_at(self, index, value):
10240
        self.AdvertRegion.insert(index, value)
10241
    def replace_AdvertRegion_at(self, index, value):
10242
        self.AdvertRegion[index] = value
10243
    def get_NoiseRegion(self):
10244
        return self.NoiseRegion
10245
    def set_NoiseRegion(self, NoiseRegion):
10246
        self.NoiseRegion = NoiseRegion
10247
    def add_NoiseRegion(self, value):
10248
        self.NoiseRegion.append(value)
10249
    def insert_NoiseRegion_at(self, index, value):
10250
        self.NoiseRegion.insert(index, value)
10251
    def replace_NoiseRegion_at(self, index, value):
10252
        self.NoiseRegion[index] = value
10253
    def get_UnknownRegion(self):
10254
        return self.UnknownRegion
10255
    def set_UnknownRegion(self, UnknownRegion):
10256
        self.UnknownRegion = UnknownRegion
10257
    def add_UnknownRegion(self, value):
10258
        self.UnknownRegion.append(value)
10259
    def insert_UnknownRegion_at(self, index, value):
10260
        self.UnknownRegion.insert(index, value)
10261
    def replace_UnknownRegion_at(self, index, value):
10262
        self.UnknownRegion[index] = value
10263
    def get_CustomRegion(self):
10264
        return self.CustomRegion
10265
    def set_CustomRegion(self, CustomRegion):
10266
        self.CustomRegion = CustomRegion
10267
    def add_CustomRegion(self, value):
10268
        self.CustomRegion.append(value)
10269
    def insert_CustomRegion_at(self, index, value):
10270
        self.CustomRegion.insert(index, value)
10271
    def replace_CustomRegion_at(self, index, value):
10272
        self.CustomRegion[index] = value
10273
    def get_id(self):
10274
        return self.id
10275
    def set_id(self, id):
10276
        self.id = id
10277
    def get_custom(self):
10278
        return self.custom
10279
    def set_custom(self, custom):
10280
        self.custom = custom
10281
    def get_comments(self):
10282
        return self.comments
10283
    def set_comments(self, comments):
10284
        self.comments = comments
10285
    def get_continuation(self):
10286
        return self.continuation
10287
    def set_continuation(self, continuation):
10288
        self.continuation = continuation
10289
    def get_extensiontype_(self): return self.extensiontype_
10290
    def set_extensiontype_(self, extensiontype_): self.extensiontype_ = extensiontype_
10291
    def has__content(self):
10292
        if (
10293
            self.AlternativeImage or
10294
            self.Coords is not None or
10295
            self.UserDefined is not None or
10296
            self.Labels or
10297
            self.Roles is not None or
10298
            self.TextRegion or
10299
            self.ImageRegion or
10300
            self.LineDrawingRegion or
10301
            self.GraphicRegion or
10302
            self.TableRegion or
10303
            self.ChartRegion or
10304
            self.SeparatorRegion or
10305
            self.MathsRegion or
10306
            self.ChemRegion or
10307
            self.MusicRegion or
10308
            self.AdvertRegion or
10309
            self.NoiseRegion or
10310
            self.UnknownRegion or
10311
            self.CustomRegion
10312
        ):
10313
            return True
10314
        else:
10315
            return False
10316
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RegionType', pretty_print=True):
10317
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('RegionType')
10318
        if imported_ns_def_ is not None:
10319
            namespacedef_ = imported_ns_def_
10320
        if pretty_print:
10321
            eol_ = '\n'
10322
        else:
10323
            eol_ = ''
10324
        if self.original_tagname_ is not None and name_ == 'RegionType':
10325
            name_ = self.original_tagname_
10326
        if UseCapturedNS_ and self.ns_prefix_:
10327
            namespaceprefix_ = self.ns_prefix_ + ':'
10328
        showIndent(outfile, level, pretty_print)
10329
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
10330
        already_processed = set()
10331
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='RegionType')
10332
        if self.has__content():
10333
            outfile.write('>%s' % (eol_, ))
10334
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='RegionType', pretty_print=pretty_print)
10335
            showIndent(outfile, level, pretty_print)
10336
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
10337
        else:
10338
            outfile.write('/>%s' % (eol_, ))
10339
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='RegionType'):
10340
        if self.id is not None and 'id' not in already_processed:
10341
            already_processed.add('id')
10342
            outfile.write(' id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.id), input_name='id')), ))
10343
        if self.custom is not None and 'custom' not in already_processed:
10344
            already_processed.add('custom')
10345
            outfile.write(' custom=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.custom), input_name='custom')), ))
10346
        if self.comments is not None and 'comments' not in already_processed:
10347
            already_processed.add('comments')
10348
            outfile.write(' comments=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.comments), input_name='comments')), ))
10349
        if self.continuation is not None and 'continuation' not in already_processed:
10350
            already_processed.add('continuation')
10351
            outfile.write(' continuation="%s"' % self.gds_format_boolean(self.continuation, input_name='continuation'))
10352
        if self.extensiontype_ is not None and 'xsi:type' not in already_processed:
10353
            already_processed.add('xsi:type')
10354
            outfile.write(' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"')
10355
            if ":" not in self.extensiontype_:
10356
                imported_ns_type_prefix_ = GenerateDSNamespaceTypePrefixes_.get(self.extensiontype_, '')
10357
                outfile.write(' xsi:type="%s%s"' % (imported_ns_type_prefix_, self.extensiontype_))
10358
            else:
10359
                outfile.write(' xsi:type="%s"' % self.extensiontype_)
10360
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RegionType', fromsubclass_=False, pretty_print=True):
10361
        if pretty_print:
10362
            eol_ = '\n'
10363
        else:
10364
            eol_ = ''
10365
        for AlternativeImage_ in self.AlternativeImage:
10366
            namespaceprefix_ = self.AlternativeImage_nsprefix_ + ':' if (UseCapturedNS_ and self.AlternativeImage_nsprefix_) else ''
10367
            AlternativeImage_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='AlternativeImage', pretty_print=pretty_print)
10368
        if self.Coords is not None:
10369
            namespaceprefix_ = self.Coords_nsprefix_ + ':' if (UseCapturedNS_ and self.Coords_nsprefix_) else ''
10370
            self.Coords.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Coords', pretty_print=pretty_print)
10371
        if self.UserDefined is not None:
10372
            namespaceprefix_ = self.UserDefined_nsprefix_ + ':' if (UseCapturedNS_ and self.UserDefined_nsprefix_) else ''
10373
            self.UserDefined.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UserDefined', pretty_print=pretty_print)
10374
        for Labels_ in self.Labels:
10375
            namespaceprefix_ = self.Labels_nsprefix_ + ':' if (UseCapturedNS_ and self.Labels_nsprefix_) else ''
10376
            Labels_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Labels', pretty_print=pretty_print)
10377
        if self.Roles is not None:
10378
            namespaceprefix_ = self.Roles_nsprefix_ + ':' if (UseCapturedNS_ and self.Roles_nsprefix_) else ''
10379
            self.Roles.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Roles', pretty_print=pretty_print)
10380
        for TextRegion_ in self.TextRegion:
10381
            namespaceprefix_ = self.TextRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.TextRegion_nsprefix_) else ''
10382
            TextRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TextRegion', pretty_print=pretty_print)
10383
        for ImageRegion_ in self.ImageRegion:
10384
            namespaceprefix_ = self.ImageRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.ImageRegion_nsprefix_) else ''
10385
            ImageRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='ImageRegion', pretty_print=pretty_print)
10386
        for LineDrawingRegion_ in self.LineDrawingRegion:
10387
            namespaceprefix_ = self.LineDrawingRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.LineDrawingRegion_nsprefix_) else ''
10388
            LineDrawingRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='LineDrawingRegion', pretty_print=pretty_print)
10389
        for GraphicRegion_ in self.GraphicRegion:
10390
            namespaceprefix_ = self.GraphicRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.GraphicRegion_nsprefix_) else ''
10391
            GraphicRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='GraphicRegion', pretty_print=pretty_print)
10392
        for TableRegion_ in self.TableRegion:
10393
            namespaceprefix_ = self.TableRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.TableRegion_nsprefix_) else ''
10394
            TableRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TableRegion', pretty_print=pretty_print)
10395
        for ChartRegion_ in self.ChartRegion:
10396
            namespaceprefix_ = self.ChartRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.ChartRegion_nsprefix_) else ''
10397
            ChartRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='ChartRegion', pretty_print=pretty_print)
10398
        for SeparatorRegion_ in self.SeparatorRegion:
10399
            namespaceprefix_ = self.SeparatorRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.SeparatorRegion_nsprefix_) else ''
10400
            SeparatorRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='SeparatorRegion', pretty_print=pretty_print)
10401
        for MathsRegion_ in self.MathsRegion:
10402
            namespaceprefix_ = self.MathsRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.MathsRegion_nsprefix_) else ''
10403
            MathsRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='MathsRegion', pretty_print=pretty_print)
10404
        for ChemRegion_ in self.ChemRegion:
10405
            namespaceprefix_ = self.ChemRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.ChemRegion_nsprefix_) else ''
10406
            ChemRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='ChemRegion', pretty_print=pretty_print)
10407
        for MusicRegion_ in self.MusicRegion:
10408
            namespaceprefix_ = self.MusicRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.MusicRegion_nsprefix_) else ''
10409
            MusicRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='MusicRegion', pretty_print=pretty_print)
10410
        for AdvertRegion_ in self.AdvertRegion:
10411
            namespaceprefix_ = self.AdvertRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.AdvertRegion_nsprefix_) else ''
10412
            AdvertRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='AdvertRegion', pretty_print=pretty_print)
10413
        for NoiseRegion_ in self.NoiseRegion:
10414
            namespaceprefix_ = self.NoiseRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.NoiseRegion_nsprefix_) else ''
10415
            NoiseRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='NoiseRegion', pretty_print=pretty_print)
10416
        for UnknownRegion_ in self.UnknownRegion:
10417
            namespaceprefix_ = self.UnknownRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.UnknownRegion_nsprefix_) else ''
10418
            UnknownRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UnknownRegion', pretty_print=pretty_print)
10419
        for CustomRegion_ in self.CustomRegion:
10420
            namespaceprefix_ = self.CustomRegion_nsprefix_ + ':' if (UseCapturedNS_ and self.CustomRegion_nsprefix_) else ''
10421
            CustomRegion_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='CustomRegion', pretty_print=pretty_print)
10422
    def to_etree(self, parent_element=None, name_='RegionType', mapping_=None, reverse_mapping_=None, nsmap_=None):
10423
        if parent_element is None:
10424
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
10425
        else:
10426
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
10427
        if self.extensiontype_ is not None:
10428
            element.set('{http://www.w3.org/2001/XMLSchema-instance}type', self.extensiontype_)
10429
        if self.id is not None:
10430
            element.set('id', self.gds_format_string(self.id))
10431
        if self.custom is not None:
10432
            element.set('custom', self.gds_format_string(self.custom))
10433
        if self.comments is not None:
10434
            element.set('comments', self.gds_format_string(self.comments))
10435
        if self.continuation is not None:
10436
            element.set('continuation', self.gds_format_boolean(self.continuation))
10437
        for AlternativeImage_ in self.AlternativeImage:
10438
            AlternativeImage_.to_etree(element, name_='AlternativeImage', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10439
        if self.Coords is not None:
10440
            Coords_ = self.Coords
10441
            Coords_.to_etree(element, name_='Coords', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10442
        if self.UserDefined is not None:
10443
            UserDefined_ = self.UserDefined
10444
            UserDefined_.to_etree(element, name_='UserDefined', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10445
        for Labels_ in self.Labels:
10446
            Labels_.to_etree(element, name_='Labels', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10447
        if self.Roles is not None:
10448
            Roles_ = self.Roles
10449
            Roles_.to_etree(element, name_='Roles', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10450
        for TextRegion_ in self.TextRegion:
10451
            TextRegion_.to_etree(element, name_='TextRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10452
        for ImageRegion_ in self.ImageRegion:
10453
            ImageRegion_.to_etree(element, name_='ImageRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10454
        for LineDrawingRegion_ in self.LineDrawingRegion:
10455
            LineDrawingRegion_.to_etree(element, name_='LineDrawingRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10456
        for GraphicRegion_ in self.GraphicRegion:
10457
            GraphicRegion_.to_etree(element, name_='GraphicRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10458
        for TableRegion_ in self.TableRegion:
10459
            TableRegion_.to_etree(element, name_='TableRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10460
        for ChartRegion_ in self.ChartRegion:
10461
            ChartRegion_.to_etree(element, name_='ChartRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10462
        for SeparatorRegion_ in self.SeparatorRegion:
10463
            SeparatorRegion_.to_etree(element, name_='SeparatorRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10464
        for MathsRegion_ in self.MathsRegion:
10465
            MathsRegion_.to_etree(element, name_='MathsRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10466
        for ChemRegion_ in self.ChemRegion:
10467
            ChemRegion_.to_etree(element, name_='ChemRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10468
        for MusicRegion_ in self.MusicRegion:
10469
            MusicRegion_.to_etree(element, name_='MusicRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10470
        for AdvertRegion_ in self.AdvertRegion:
10471
            AdvertRegion_.to_etree(element, name_='AdvertRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10472
        for NoiseRegion_ in self.NoiseRegion:
10473
            NoiseRegion_.to_etree(element, name_='NoiseRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10474
        for UnknownRegion_ in self.UnknownRegion:
10475
            UnknownRegion_.to_etree(element, name_='UnknownRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10476
        for CustomRegion_ in self.CustomRegion:
10477
            CustomRegion_.to_etree(element, name_='CustomRegion', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10478
        if mapping_ is not None:
10479
            mapping_[id(self)] = element
10480
        if reverse_mapping_ is not None:
10481
            reverse_mapping_[element] = self
10482
        return element
10483
    def build(self, node, gds_collector_=None):
10484
        self.gds_collector_ = gds_collector_
10485
        if SaveElementTreeNode:
10486
            self.gds_elementtree_node_ = node
10487
        already_processed = set()
10488
        self.ns_prefix_ = node.prefix
10489
        self._buildAttributes(node, node.attrib, already_processed)
10490
        for child in node:
10491
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
10492
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
10493
        return self
10494
    def _buildAttributes(self, node, attrs, already_processed):
10495
        value = find_attr_value_('id', node)
10496
        if value is not None and 'id' not in already_processed:
10497
            already_processed.add('id')
10498
            self.id = value
10499
        value = find_attr_value_('custom', node)
10500
        if value is not None and 'custom' not in already_processed:
10501
            already_processed.add('custom')
10502
            self.custom = value
10503
        value = find_attr_value_('comments', node)
10504
        if value is not None and 'comments' not in already_processed:
10505
            already_processed.add('comments')
10506
            self.comments = value
10507
        value = find_attr_value_('continuation', node)
10508
        if value is not None and 'continuation' not in already_processed:
10509
            already_processed.add('continuation')
10510
            if value in ('true', '1'):
10511
                self.continuation = True
10512
            elif value in ('false', '0'):
10513
                self.continuation = False
10514
            else:
10515
                raise_parse_error(node, 'Bad boolean attribute')
10516
        value = find_attr_value_('xsi:type', node)
10517
        if value is not None and 'xsi:type' not in already_processed:
10518
            already_processed.add('xsi:type')
10519
            self.extensiontype_ = value
10520
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
10521
        if nodeName_ == 'AlternativeImage':
10522
            obj_ = AlternativeImageType.factory(parent_object_=self)
10523
            obj_.build(child_, gds_collector_=gds_collector_)
10524
            self.AlternativeImage.append(obj_)
10525
            obj_.original_tagname_ = 'AlternativeImage'
10526
        elif nodeName_ == 'Coords':
10527
            obj_ = CoordsType.factory(parent_object_=self)
10528
            obj_.build(child_, gds_collector_=gds_collector_)
10529
            self.Coords = obj_
10530
            obj_.original_tagname_ = 'Coords'
10531
        elif nodeName_ == 'UserDefined':
10532
            obj_ = UserDefinedType.factory(parent_object_=self)
10533
            obj_.build(child_, gds_collector_=gds_collector_)
10534
            self.UserDefined = obj_
10535
            obj_.original_tagname_ = 'UserDefined'
10536
        elif nodeName_ == 'Labels':
10537
            obj_ = LabelsType.factory(parent_object_=self)
10538
            obj_.build(child_, gds_collector_=gds_collector_)
10539
            self.Labels.append(obj_)
10540
            obj_.original_tagname_ = 'Labels'
10541
        elif nodeName_ == 'Roles':
10542
            obj_ = RolesType.factory(parent_object_=self)
10543
            obj_.build(child_, gds_collector_=gds_collector_)
10544
            self.Roles = obj_
10545
            obj_.original_tagname_ = 'Roles'
10546
        elif nodeName_ == 'TextRegion':
10547
            obj_ = TextRegionType.factory(parent_object_=self)
10548
            obj_.build(child_, gds_collector_=gds_collector_)
10549
            self.TextRegion.append(obj_)
10550
            obj_.original_tagname_ = 'TextRegion'
10551
        elif nodeName_ == 'ImageRegion':
10552
            obj_ = ImageRegionType.factory(parent_object_=self)
10553
            obj_.build(child_, gds_collector_=gds_collector_)
10554
            self.ImageRegion.append(obj_)
10555
            obj_.original_tagname_ = 'ImageRegion'
10556
        elif nodeName_ == 'LineDrawingRegion':
10557
            obj_ = LineDrawingRegionType.factory(parent_object_=self)
10558
            obj_.build(child_, gds_collector_=gds_collector_)
10559
            self.LineDrawingRegion.append(obj_)
10560
            obj_.original_tagname_ = 'LineDrawingRegion'
10561
        elif nodeName_ == 'GraphicRegion':
10562
            obj_ = GraphicRegionType.factory(parent_object_=self)
10563
            obj_.build(child_, gds_collector_=gds_collector_)
10564
            self.GraphicRegion.append(obj_)
10565
            obj_.original_tagname_ = 'GraphicRegion'
10566
        elif nodeName_ == 'TableRegion':
10567
            obj_ = TableRegionType.factory(parent_object_=self)
10568
            obj_.build(child_, gds_collector_=gds_collector_)
10569
            self.TableRegion.append(obj_)
10570
            obj_.original_tagname_ = 'TableRegion'
10571
        elif nodeName_ == 'ChartRegion':
10572
            obj_ = ChartRegionType.factory(parent_object_=self)
10573
            obj_.build(child_, gds_collector_=gds_collector_)
10574
            self.ChartRegion.append(obj_)
10575
            obj_.original_tagname_ = 'ChartRegion'
10576
        elif nodeName_ == 'SeparatorRegion':
10577
            obj_ = SeparatorRegionType.factory(parent_object_=self)
10578
            obj_.build(child_, gds_collector_=gds_collector_)
10579
            self.SeparatorRegion.append(obj_)
10580
            obj_.original_tagname_ = 'SeparatorRegion'
10581
        elif nodeName_ == 'MathsRegion':
10582
            obj_ = MathsRegionType.factory(parent_object_=self)
10583
            obj_.build(child_, gds_collector_=gds_collector_)
10584
            self.MathsRegion.append(obj_)
10585
            obj_.original_tagname_ = 'MathsRegion'
10586
        elif nodeName_ == 'ChemRegion':
10587
            obj_ = ChemRegionType.factory(parent_object_=self)
10588
            obj_.build(child_, gds_collector_=gds_collector_)
10589
            self.ChemRegion.append(obj_)
10590
            obj_.original_tagname_ = 'ChemRegion'
10591
        elif nodeName_ == 'MusicRegion':
10592
            obj_ = MusicRegionType.factory(parent_object_=self)
10593
            obj_.build(child_, gds_collector_=gds_collector_)
10594
            self.MusicRegion.append(obj_)
10595
            obj_.original_tagname_ = 'MusicRegion'
10596
        elif nodeName_ == 'AdvertRegion':
10597
            obj_ = AdvertRegionType.factory(parent_object_=self)
10598
            obj_.build(child_, gds_collector_=gds_collector_)
10599
            self.AdvertRegion.append(obj_)
10600
            obj_.original_tagname_ = 'AdvertRegion'
10601
        elif nodeName_ == 'NoiseRegion':
10602
            obj_ = NoiseRegionType.factory(parent_object_=self)
10603
            obj_.build(child_, gds_collector_=gds_collector_)
10604
            self.NoiseRegion.append(obj_)
10605
            obj_.original_tagname_ = 'NoiseRegion'
10606
        elif nodeName_ == 'UnknownRegion':
10607
            obj_ = UnknownRegionType.factory(parent_object_=self)
10608
            obj_.build(child_, gds_collector_=gds_collector_)
10609
            self.UnknownRegion.append(obj_)
10610
            obj_.original_tagname_ = 'UnknownRegion'
10611
        elif nodeName_ == 'CustomRegion':
10612
            obj_ = CustomRegionType.factory(parent_object_=self)
10613
            obj_.build(child_, gds_collector_=gds_collector_)
10614
            self.CustomRegion.append(obj_)
10615
            obj_.original_tagname_ = 'CustomRegion'
10616
    def __hash__(self):
10617
        return hash(self.id)
10618 View Code Duplication
    def invalidate_AlternativeImage(self, feature_selector=None):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
10619
        """
10620
        Remove derived images from this segment (due to changed coordinates).
10621
    
10622
        If `feature_selector` is not none, remove only images with
10623
        matching ``@comments``, e.g. ``feature_selector=cropped,deskewed``.
10624
        """
10625
        existing_images = self.AlternativeImage or []
10626
        removed_images = []
10627
        if feature_selector:
10628
            new_images = []
10629
            for image in existing_images:
10630
                features = image.get_comments() or ''
10631
                if any(feature in features.split(',')
10632
                       for feature in feature_selector.split(',') if feature):
10633
                    removed_images.append(image)
10634
                else:
10635
                    new_images.append(image)
10636
            self.AlternativeImage = new_images
10637
        else:
10638
            removed_images = existing_images
10639
            self.AlternativeImage = []
10640
        if hasattr(self, 'id'):
10641
            name = self.id
10642
        elif hasattr(self, 'parent_object_') and hasattr(self.parent_object_, 'pcGtsId'):
10643
            name = self.parent_object_.pcGtsId
10644
        else:
10645
            name = ''
10646
        for image in removed_images:
10647
            self.gds_collector_.add_message('Removing AlternativeImage %s from "%s"' % (
10648
                image.get_comments() or '', name))
10649
    def set_Coords(self, Coords):
10650
        """
10651
        Set coordinate polygon by given :py:class:`CoordsType` object.
10652
        Moreover, invalidate self's ``pc:AlternativeImage``s
10653
        (because they will have been cropped with a bbox
10654
        of the previous polygon).
10655
        """
10656
        if hasattr(self, 'invalidate_AlternativeImage'):
10657
            # RegionType, TextLineType, WordType, GlyphType:
10658
            self.invalidate_AlternativeImage()
10659
        elif hasattr(self, 'parent_object_') and hasattr(self.parent_object_, 'invalidate_AlternativeImage'):
10660
            # BorderType:
10661
            self.parent_object_.invalidate_AlternativeImage(feature_selector='cropped')
10662
        self.Coords = Coords
10663
# end class RegionType
10664
10665
10666
class AlternativeImageType(GeneratedsSuper):
10667
    """conf -- Confidence value (between 0 and 1)
10668
    
10669
    """
10670
    __hash__ = GeneratedsSuper.__hash__
10671
    member_data_items_ = [
10672
        MemberSpec_('filename', 'string', 0, 0, {'use': 'required', 'name': 'filename'}),
10673
        MemberSpec_('comments', 'string', 0, 1, {'use': 'optional', 'name': 'comments'}),
10674
        MemberSpec_('conf', 'pc:ConfSimpleType', 0, 1, {'use': 'optional', 'name': 'conf'}),
10675
    ]
10676
    subclass = None
10677
    superclass = None
10678
    def __init__(self, filename=None, comments=None, conf=None, gds_collector_=None, **kwargs_):
10679
        self.gds_collector_ = gds_collector_
10680
        self.gds_elementtree_node_ = None
10681
        self.original_tagname_ = None
10682
        self.parent_object_ = kwargs_.get('parent_object_')
10683
        self.ns_prefix_ = "pc"
10684
        self.filename = _cast(None, filename)
10685
        self.filename_nsprefix_ = "pc"
10686
        self.comments = _cast(None, comments)
10687
        self.comments_nsprefix_ = "pc"
10688
        self.conf = _cast(float, conf)
10689
        self.conf_nsprefix_ = "pc"
10690
    def factory(*args_, **kwargs_):
10691
        if CurrentSubclassModule_ is not None:
10692
            subclass = getSubclassFromModule_(
10693
                CurrentSubclassModule_, AlternativeImageType)
10694
            if subclass is not None:
10695
                return subclass(*args_, **kwargs_)
10696
        if AlternativeImageType.subclass:
10697
            return AlternativeImageType.subclass(*args_, **kwargs_)
10698
        else:
10699
            return AlternativeImageType(*args_, **kwargs_)
10700
    factory = staticmethod(factory)
10701
    def get_ns_prefix_(self):
10702
        return self.ns_prefix_
10703
    def set_ns_prefix_(self, ns_prefix):
10704
        self.ns_prefix_ = ns_prefix
10705
    def get_filename(self):
10706
        return self.filename
10707
    def set_filename(self, filename):
10708
        self.filename = filename
10709
    def get_comments(self):
10710
        return self.comments
10711
    def set_comments(self, comments):
10712
        self.comments = comments
10713
    def get_conf(self):
10714
        return self.conf
10715
    def set_conf(self, conf):
10716
        self.conf = conf
10717 View Code Duplication
    def validate_ConfSimpleType(self, value):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
10718
        # Validate type pc:ConfSimpleType, a restriction on float.
10719
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
10720
            if not isinstance(value, float):
10721
                lineno = self.gds_get_node_lineno_()
10722
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (float)' % {"value": value, "lineno": lineno, })
10723
                return False
10724
            if value < 0:
10725
                lineno = self.gds_get_node_lineno_()
10726
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd minInclusive restriction on ConfSimpleType' % {"value": value, "lineno": lineno} )
10727
                result = False
10728
            if value > 1:
10729
                lineno = self.gds_get_node_lineno_()
10730
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxInclusive restriction on ConfSimpleType' % {"value": value, "lineno": lineno} )
10731
                result = False
10732
    def has__content(self):
10733
        if (
10734
10735
        ):
10736
            return True
10737
        else:
10738
            return False
10739
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='AlternativeImageType', pretty_print=True):
10740
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('AlternativeImageType')
10741
        if imported_ns_def_ is not None:
10742
            namespacedef_ = imported_ns_def_
10743
        if pretty_print:
10744
            eol_ = '\n'
10745
        else:
10746
            eol_ = ''
10747
        if self.original_tagname_ is not None and name_ == 'AlternativeImageType':
10748
            name_ = self.original_tagname_
10749
        if UseCapturedNS_ and self.ns_prefix_:
10750
            namespaceprefix_ = self.ns_prefix_ + ':'
10751
        showIndent(outfile, level, pretty_print)
10752
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
10753
        already_processed = set()
10754
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='AlternativeImageType')
10755
        if self.has__content():
10756
            outfile.write('>%s' % (eol_, ))
10757
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='AlternativeImageType', pretty_print=pretty_print)
10758
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
10759
        else:
10760
            outfile.write('/>%s' % (eol_, ))
10761 View Code Duplication
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='AlternativeImageType'):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
10762
        if self.filename is not None and 'filename' not in already_processed:
10763
            already_processed.add('filename')
10764
            outfile.write(' filename=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.filename), input_name='filename')), ))
10765
        if self.comments is not None and 'comments' not in already_processed:
10766
            already_processed.add('comments')
10767
            outfile.write(' comments=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.comments), input_name='comments')), ))
10768
        if self.conf is not None and 'conf' not in already_processed:
10769
            already_processed.add('conf')
10770
            outfile.write(' conf="%s"' % self.gds_format_float(self.conf, input_name='conf'))
10771
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='AlternativeImageType', fromsubclass_=False, pretty_print=True):
10772
        pass
10773 View Code Duplication
    def to_etree(self, parent_element=None, name_='AlternativeImageType', mapping_=None, reverse_mapping_=None, nsmap_=None):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
10774
        if parent_element is None:
10775
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
10776
        else:
10777
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
10778
        if self.filename is not None:
10779
            element.set('filename', self.gds_format_string(self.filename))
10780
        if self.comments is not None:
10781
            element.set('comments', self.gds_format_string(self.comments))
10782
        if self.conf is not None:
10783
            element.set('conf', self.gds_format_float(self.conf))
10784
        if mapping_ is not None:
10785
            mapping_[id(self)] = element
10786
        if reverse_mapping_ is not None:
10787
            reverse_mapping_[element] = self
10788
        return element
10789
    def build(self, node, gds_collector_=None):
10790
        self.gds_collector_ = gds_collector_
10791
        if SaveElementTreeNode:
10792
            self.gds_elementtree_node_ = node
10793
        already_processed = set()
10794
        self.ns_prefix_ = node.prefix
10795
        self._buildAttributes(node, node.attrib, already_processed)
10796
        for child in node:
10797
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
10798
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
10799
        return self
10800
    def _buildAttributes(self, node, attrs, already_processed):
10801
        value = find_attr_value_('filename', node)
10802
        if value is not None and 'filename' not in already_processed:
10803
            already_processed.add('filename')
10804
            self.filename = value
10805
        value = find_attr_value_('comments', node)
10806
        if value is not None and 'comments' not in already_processed:
10807
            already_processed.add('comments')
10808
            self.comments = value
10809
        value = find_attr_value_('conf', node)
10810
        if value is not None and 'conf' not in already_processed:
10811
            already_processed.add('conf')
10812
            value = self.gds_parse_float(value, node, 'conf')
10813
            self.conf = value
10814
            self.validate_ConfSimpleType(self.conf)    # validate type ConfSimpleType
10815
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
10816
        pass
10817
    def __hash__(self):
10818
        return hash(self.id)
10819
# end class AlternativeImageType
10820
10821
10822
class GraphemesType(GeneratedsSuper):
10823
    """GraphemesType --
10824
    Container for graphemes, grapheme groups and
10825
    non-printing characters.
10826
    
10827
    """
10828
    __hash__ = GeneratedsSuper.__hash__
10829
    member_data_items_ = [
10830
        MemberSpec_('Grapheme', 'GraphemeType', 1, 0, {'name': 'Grapheme', 'type': 'GraphemeType'}, 8),
10831
        MemberSpec_('NonPrintingChar', 'NonPrintingCharType', 1, 0, {'name': 'NonPrintingChar', 'type': 'NonPrintingCharType'}, 8),
10832
        MemberSpec_('GraphemeGroup', 'GraphemeGroupType', 1, 0, {'name': 'GraphemeGroup', 'type': 'GraphemeGroupType'}, 8),
10833
    ]
10834
    subclass = None
10835
    superclass = None
10836
    def __init__(self, Grapheme=None, NonPrintingChar=None, GraphemeGroup=None, gds_collector_=None, **kwargs_):
10837
        self.gds_collector_ = gds_collector_
10838
        self.gds_elementtree_node_ = None
10839
        self.original_tagname_ = None
10840
        self.parent_object_ = kwargs_.get('parent_object_')
10841
        self.ns_prefix_ = "pc"
10842
        if Grapheme is None:
10843
            self.Grapheme = []
10844
        else:
10845
            self.Grapheme = Grapheme
10846
        self.Grapheme_nsprefix_ = "pc"
10847
        if NonPrintingChar is None:
10848
            self.NonPrintingChar = []
10849
        else:
10850
            self.NonPrintingChar = NonPrintingChar
10851
        self.NonPrintingChar_nsprefix_ = "pc"
10852
        if GraphemeGroup is None:
10853
            self.GraphemeGroup = []
10854
        else:
10855
            self.GraphemeGroup = GraphemeGroup
10856
        self.GraphemeGroup_nsprefix_ = "pc"
10857
    def factory(*args_, **kwargs_):
10858
        if CurrentSubclassModule_ is not None:
10859
            subclass = getSubclassFromModule_(
10860
                CurrentSubclassModule_, GraphemesType)
10861
            if subclass is not None:
10862
                return subclass(*args_, **kwargs_)
10863
        if GraphemesType.subclass:
10864
            return GraphemesType.subclass(*args_, **kwargs_)
10865
        else:
10866
            return GraphemesType(*args_, **kwargs_)
10867
    factory = staticmethod(factory)
10868
    def get_ns_prefix_(self):
10869
        return self.ns_prefix_
10870
    def set_ns_prefix_(self, ns_prefix):
10871
        self.ns_prefix_ = ns_prefix
10872
    def get_Grapheme(self):
10873
        return self.Grapheme
10874
    def set_Grapheme(self, Grapheme):
10875
        self.Grapheme = Grapheme
10876
    def add_Grapheme(self, value):
10877
        self.Grapheme.append(value)
10878
    def insert_Grapheme_at(self, index, value):
10879
        self.Grapheme.insert(index, value)
10880
    def replace_Grapheme_at(self, index, value):
10881
        self.Grapheme[index] = value
10882
    def get_NonPrintingChar(self):
10883
        return self.NonPrintingChar
10884
    def set_NonPrintingChar(self, NonPrintingChar):
10885
        self.NonPrintingChar = NonPrintingChar
10886
    def add_NonPrintingChar(self, value):
10887
        self.NonPrintingChar.append(value)
10888
    def insert_NonPrintingChar_at(self, index, value):
10889
        self.NonPrintingChar.insert(index, value)
10890
    def replace_NonPrintingChar_at(self, index, value):
10891
        self.NonPrintingChar[index] = value
10892
    def get_GraphemeGroup(self):
10893
        return self.GraphemeGroup
10894
    def set_GraphemeGroup(self, GraphemeGroup):
10895
        self.GraphemeGroup = GraphemeGroup
10896
    def add_GraphemeGroup(self, value):
10897
        self.GraphemeGroup.append(value)
10898
    def insert_GraphemeGroup_at(self, index, value):
10899
        self.GraphemeGroup.insert(index, value)
10900
    def replace_GraphemeGroup_at(self, index, value):
10901
        self.GraphemeGroup[index] = value
10902
    def has__content(self):
10903
        if (
10904
            self.Grapheme or
10905
            self.NonPrintingChar or
10906
            self.GraphemeGroup
10907
        ):
10908
            return True
10909
        else:
10910
            return False
10911
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GraphemesType', pretty_print=True):
10912
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('GraphemesType')
10913
        if imported_ns_def_ is not None:
10914
            namespacedef_ = imported_ns_def_
10915
        if pretty_print:
10916
            eol_ = '\n'
10917
        else:
10918
            eol_ = ''
10919
        if self.original_tagname_ is not None and name_ == 'GraphemesType':
10920
            name_ = self.original_tagname_
10921
        if UseCapturedNS_ and self.ns_prefix_:
10922
            namespaceprefix_ = self.ns_prefix_ + ':'
10923
        showIndent(outfile, level, pretty_print)
10924
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
10925
        already_processed = set()
10926
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='GraphemesType')
10927
        if self.has__content():
10928
            outfile.write('>%s' % (eol_, ))
10929
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='GraphemesType', pretty_print=pretty_print)
10930
            showIndent(outfile, level, pretty_print)
10931
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
10932
        else:
10933
            outfile.write('/>%s' % (eol_, ))
10934
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='GraphemesType'):
10935
        pass
10936
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GraphemesType', fromsubclass_=False, pretty_print=True):
10937
        if pretty_print:
10938
            eol_ = '\n'
10939
        else:
10940
            eol_ = ''
10941
        for Grapheme_ in self.Grapheme:
10942
            namespaceprefix_ = self.Grapheme_nsprefix_ + ':' if (UseCapturedNS_ and self.Grapheme_nsprefix_) else ''
10943
            Grapheme_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Grapheme', pretty_print=pretty_print)
10944
        for NonPrintingChar_ in self.NonPrintingChar:
10945
            namespaceprefix_ = self.NonPrintingChar_nsprefix_ + ':' if (UseCapturedNS_ and self.NonPrintingChar_nsprefix_) else ''
10946
            NonPrintingChar_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='NonPrintingChar', pretty_print=pretty_print)
10947
        for GraphemeGroup_ in self.GraphemeGroup:
10948
            namespaceprefix_ = self.GraphemeGroup_nsprefix_ + ':' if (UseCapturedNS_ and self.GraphemeGroup_nsprefix_) else ''
10949
            GraphemeGroup_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='GraphemeGroup', pretty_print=pretty_print)
10950
    def to_etree(self, parent_element=None, name_='GraphemesType', mapping_=None, reverse_mapping_=None, nsmap_=None):
10951
        if parent_element is None:
10952
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
10953
        else:
10954
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
10955
        for Grapheme_ in self.Grapheme:
10956
            Grapheme_.to_etree(element, name_='Grapheme', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10957
        for NonPrintingChar_ in self.NonPrintingChar:
10958
            NonPrintingChar_.to_etree(element, name_='NonPrintingChar', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10959
        for GraphemeGroup_ in self.GraphemeGroup:
10960
            GraphemeGroup_.to_etree(element, name_='GraphemeGroup', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
10961
        if mapping_ is not None:
10962
            mapping_[id(self)] = element
10963
        if reverse_mapping_ is not None:
10964
            reverse_mapping_[element] = self
10965
        return element
10966
    def build(self, node, gds_collector_=None):
10967
        self.gds_collector_ = gds_collector_
10968
        if SaveElementTreeNode:
10969
            self.gds_elementtree_node_ = node
10970
        already_processed = set()
10971
        self.ns_prefix_ = node.prefix
10972
        self._buildAttributes(node, node.attrib, already_processed)
10973
        for child in node:
10974
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
10975
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
10976
        return self
10977
    def _buildAttributes(self, node, attrs, already_processed):
10978
        pass
10979
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
10980
        if nodeName_ == 'Grapheme':
10981
            obj_ = GraphemeType.factory(parent_object_=self)
10982
            obj_.build(child_, gds_collector_=gds_collector_)
10983
            self.Grapheme.append(obj_)
10984
            obj_.original_tagname_ = 'Grapheme'
10985
        elif nodeName_ == 'NonPrintingChar':
10986
            obj_ = NonPrintingCharType.factory(parent_object_=self)
10987
            obj_.build(child_, gds_collector_=gds_collector_)
10988
            self.NonPrintingChar.append(obj_)
10989
            obj_.original_tagname_ = 'NonPrintingChar'
10990
        elif nodeName_ == 'GraphemeGroup':
10991
            obj_ = GraphemeGroupType.factory(parent_object_=self)
10992
            obj_.build(child_, gds_collector_=gds_collector_)
10993
            self.GraphemeGroup.append(obj_)
10994
            obj_.original_tagname_ = 'GraphemeGroup'
10995
    def __hash__(self):
10996
        return hash(self.id)
10997
# end class GraphemesType
10998
10999
11000
class GraphemeBaseType(GeneratedsSuper):
11001
    """GraphemeBaseType --
11002
    Base type for graphemes, grapheme groups and non-printing characters.
11003
      
11004
    * index --
11005
      Order index of grapheme, group, or non-printing character
11006
      within the parent container (graphemes or glyph or grapheme group).
11007
      
11008
    * charType --
11009
      Type of character represented by the
11010
      grapheme, group, or non-printing character element.
11011
      
11012
    * custom -- For generic use
11013
    * comments -- For generic use
11014
    
11015
    """
11016
    __hash__ = GeneratedsSuper.__hash__
11017
    member_data_items_ = [
11018
        MemberSpec_('id', 'string', 0, 0, {'use': 'required', 'name': 'id'}),
11019
        MemberSpec_('index', 'indexType2', 0, 0, {'use': 'required', 'name': 'index'}),
11020
        MemberSpec_('ligature', 'boolean', 0, 1, {'use': 'optional', 'name': 'ligature'}),
11021
        MemberSpec_('charType', 'charTypeType', 0, 1, {'use': 'optional', 'name': 'charType'}),
11022
        MemberSpec_('custom', 'string', 0, 1, {'use': 'optional', 'name': 'custom'}),
11023
        MemberSpec_('comments', 'string', 0, 1, {'use': 'optional', 'name': 'comments'}),
11024
        MemberSpec_('TextEquiv', 'TextEquivType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'TextEquiv', 'type': 'TextEquivType'}, None),
11025
    ]
11026
    subclass = None
11027
    superclass = None
11028
    def __init__(self, id=None, index=None, ligature=None, charType=None, custom=None, comments=None, TextEquiv=None, extensiontype_=None, gds_collector_=None, **kwargs_):
11029
        self.gds_collector_ = gds_collector_
11030
        self.gds_elementtree_node_ = None
11031
        self.original_tagname_ = None
11032
        self.parent_object_ = kwargs_.get('parent_object_')
11033
        self.ns_prefix_ = "pc"
11034
        self.id = _cast(None, id)
11035
        self.id_nsprefix_ = "pc"
11036
        self.index = _cast(int, index)
11037
        self.index_nsprefix_ = "pc"
11038
        self.ligature = _cast(bool, ligature)
11039
        self.ligature_nsprefix_ = "pc"
11040
        self.charType = _cast(None, charType)
11041
        self.charType_nsprefix_ = "pc"
11042
        self.custom = _cast(None, custom)
11043
        self.custom_nsprefix_ = "pc"
11044
        self.comments = _cast(None, comments)
11045
        self.comments_nsprefix_ = "pc"
11046
        if TextEquiv is None:
11047
            self.TextEquiv = []
11048
        else:
11049
            self.TextEquiv = TextEquiv
11050
        self.TextEquiv_nsprefix_ = "pc"
11051
        self.extensiontype_ = extensiontype_
11052
    def factory(*args_, **kwargs_):
11053
        if CurrentSubclassModule_ is not None:
11054
            subclass = getSubclassFromModule_(
11055
                CurrentSubclassModule_, GraphemeBaseType)
11056
            if subclass is not None:
11057
                return subclass(*args_, **kwargs_)
11058
        if GraphemeBaseType.subclass:
11059
            return GraphemeBaseType.subclass(*args_, **kwargs_)
11060
        else:
11061
            return GraphemeBaseType(*args_, **kwargs_)
11062
    factory = staticmethod(factory)
11063
    def get_ns_prefix_(self):
11064
        return self.ns_prefix_
11065
    def set_ns_prefix_(self, ns_prefix):
11066
        self.ns_prefix_ = ns_prefix
11067
    def get_TextEquiv(self):
11068
        return self.TextEquiv
11069
    def set_TextEquiv(self, TextEquiv):
11070
        self.TextEquiv = TextEquiv
11071
    def add_TextEquiv(self, value):
11072
        self.TextEquiv.append(value)
11073
    def insert_TextEquiv_at(self, index, value):
11074
        self.TextEquiv.insert(index, value)
11075
    def replace_TextEquiv_at(self, index, value):
11076
        self.TextEquiv[index] = value
11077
    def get_id(self):
11078
        return self.id
11079
    def set_id(self, id):
11080
        self.id = id
11081
    def get_index(self):
11082
        return self.index
11083
    def set_index(self, index):
11084
        self.index = index
11085
    def get_ligature(self):
11086
        return self.ligature
11087
    def set_ligature(self, ligature):
11088
        self.ligature = ligature
11089
    def get_charType(self):
11090
        return self.charType
11091
    def set_charType(self, charType):
11092
        self.charType = charType
11093
    def get_custom(self):
11094
        return self.custom
11095
    def set_custom(self, custom):
11096
        self.custom = custom
11097
    def get_comments(self):
11098
        return self.comments
11099
    def set_comments(self, comments):
11100
        self.comments = comments
11101
    def get_extensiontype_(self): return self.extensiontype_
11102
    def set_extensiontype_(self, extensiontype_): self.extensiontype_ = extensiontype_
11103 View Code Duplication
    def validate_indexType2(self, value):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
11104
        # Validate type indexType2, a restriction on int.
11105
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
11106
            if not isinstance(value, int):
11107
                lineno = self.gds_get_node_lineno_()
11108
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (int)' % {"value": value, "lineno": lineno, })
11109
                return False
11110
            if value < 0:
11111
                lineno = self.gds_get_node_lineno_()
11112
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd minInclusive restriction on indexType2' % {"value": value, "lineno": lineno} )
11113
                result = False
11114
    def validate_charTypeType(self, value):
11115
        # Validate type charTypeType, a restriction on string.
11116
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
11117
            if not isinstance(value, str):
11118
                lineno = self.gds_get_node_lineno_()
11119
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
11120
                return False
11121
            value = value
11122
            enumerations = ['base', 'combining']
11123
            if value not in enumerations:
11124
                lineno = self.gds_get_node_lineno_()
11125
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on charTypeType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
11126
                result = False
11127
    def has__content(self):
11128
        if (
11129
            self.TextEquiv
11130
        ):
11131
            return True
11132
        else:
11133
            return False
11134
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GraphemeBaseType', pretty_print=True):
11135
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('GraphemeBaseType')
11136
        if imported_ns_def_ is not None:
11137
            namespacedef_ = imported_ns_def_
11138
        if pretty_print:
11139
            eol_ = '\n'
11140
        else:
11141
            eol_ = ''
11142
        if self.original_tagname_ is not None and name_ == 'GraphemeBaseType':
11143
            name_ = self.original_tagname_
11144
        if UseCapturedNS_ and self.ns_prefix_:
11145
            namespaceprefix_ = self.ns_prefix_ + ':'
11146
        showIndent(outfile, level, pretty_print)
11147
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
11148
        already_processed = set()
11149
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='GraphemeBaseType')
11150
        if self.has__content():
11151
            outfile.write('>%s' % (eol_, ))
11152
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='GraphemeBaseType', pretty_print=pretty_print)
11153
            showIndent(outfile, level, pretty_print)
11154
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
11155
        else:
11156
            outfile.write('/>%s' % (eol_, ))
11157
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='GraphemeBaseType'):
11158
        if self.id is not None and 'id' not in already_processed:
11159
            already_processed.add('id')
11160
            outfile.write(' id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.id), input_name='id')), ))
11161
        if self.index is not None and 'index' not in already_processed:
11162
            already_processed.add('index')
11163
            outfile.write(' index="%s"' % self.gds_format_integer(self.index, input_name='index'))
11164
        if self.ligature is not None and 'ligature' not in already_processed:
11165
            already_processed.add('ligature')
11166
            outfile.write(' ligature="%s"' % self.gds_format_boolean(self.ligature, input_name='ligature'))
11167
        if self.charType is not None and 'charType' not in already_processed:
11168
            already_processed.add('charType')
11169
            outfile.write(' charType=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.charType), input_name='charType')), ))
11170
        if self.custom is not None and 'custom' not in already_processed:
11171
            already_processed.add('custom')
11172
            outfile.write(' custom=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.custom), input_name='custom')), ))
11173
        if self.comments is not None and 'comments' not in already_processed:
11174
            already_processed.add('comments')
11175
            outfile.write(' comments=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.comments), input_name='comments')), ))
11176
        if self.extensiontype_ is not None and 'xsi:type' not in already_processed:
11177
            already_processed.add('xsi:type')
11178
            outfile.write(' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"')
11179
            if ":" not in self.extensiontype_:
11180
                imported_ns_type_prefix_ = GenerateDSNamespaceTypePrefixes_.get(self.extensiontype_, '')
11181
                outfile.write(' xsi:type="%s%s"' % (imported_ns_type_prefix_, self.extensiontype_))
11182
            else:
11183
                outfile.write(' xsi:type="%s"' % self.extensiontype_)
11184
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GraphemeBaseType', fromsubclass_=False, pretty_print=True):
11185
        if pretty_print:
11186
            eol_ = '\n'
11187
        else:
11188
            eol_ = ''
11189
        for TextEquiv_ in self.TextEquiv:
11190
            namespaceprefix_ = self.TextEquiv_nsprefix_ + ':' if (UseCapturedNS_ and self.TextEquiv_nsprefix_) else ''
11191
            TextEquiv_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TextEquiv', pretty_print=pretty_print)
11192
    def to_etree(self, parent_element=None, name_='GraphemeBaseType', mapping_=None, reverse_mapping_=None, nsmap_=None):
11193
        if parent_element is None:
11194
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
11195
        else:
11196
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
11197
        if self.extensiontype_ is not None:
11198
            element.set('{http://www.w3.org/2001/XMLSchema-instance}type', self.extensiontype_)
11199
        if self.id is not None:
11200
            element.set('id', self.gds_format_string(self.id))
11201
        if self.index is not None:
11202
            element.set('index', self.gds_format_integer(self.index))
11203
        if self.ligature is not None:
11204
            element.set('ligature', self.gds_format_boolean(self.ligature))
11205
        if self.charType is not None:
11206
            element.set('charType', self.gds_format_string(self.charType))
11207
        if self.custom is not None:
11208
            element.set('custom', self.gds_format_string(self.custom))
11209
        if self.comments is not None:
11210
            element.set('comments', self.gds_format_string(self.comments))
11211
        for TextEquiv_ in self.TextEquiv:
11212
            TextEquiv_.to_etree(element, name_='TextEquiv', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
11213
        if mapping_ is not None:
11214
            mapping_[id(self)] = element
11215
        if reverse_mapping_ is not None:
11216
            reverse_mapping_[element] = self
11217
        return element
11218
    def build(self, node, gds_collector_=None):
11219
        self.gds_collector_ = gds_collector_
11220
        if SaveElementTreeNode:
11221
            self.gds_elementtree_node_ = node
11222
        already_processed = set()
11223
        self.ns_prefix_ = node.prefix
11224
        self._buildAttributes(node, node.attrib, already_processed)
11225
        for child in node:
11226
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
11227
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
11228
        return self
11229
    def _buildAttributes(self, node, attrs, already_processed):
11230
        value = find_attr_value_('id', node)
11231
        if value is not None and 'id' not in already_processed:
11232
            already_processed.add('id')
11233
            self.id = value
11234
        value = find_attr_value_('index', node)
11235
        if value is not None and 'index' not in already_processed:
11236
            already_processed.add('index')
11237
            self.index = self.gds_parse_integer(value, node, 'index')
11238
            self.validate_indexType2(self.index)    # validate type indexType2
11239
        value = find_attr_value_('ligature', node)
11240
        if value is not None and 'ligature' not in already_processed:
11241
            already_processed.add('ligature')
11242
            if value in ('true', '1'):
11243
                self.ligature = True
11244
            elif value in ('false', '0'):
11245
                self.ligature = False
11246
            else:
11247
                raise_parse_error(node, 'Bad boolean attribute')
11248
        value = find_attr_value_('charType', node)
11249
        if value is not None and 'charType' not in already_processed:
11250
            already_processed.add('charType')
11251
            self.charType = value
11252
            self.validate_charTypeType(self.charType)    # validate type charTypeType
11253
        value = find_attr_value_('custom', node)
11254
        if value is not None and 'custom' not in already_processed:
11255
            already_processed.add('custom')
11256
            self.custom = value
11257
        value = find_attr_value_('comments', node)
11258
        if value is not None and 'comments' not in already_processed:
11259
            already_processed.add('comments')
11260
            self.comments = value
11261
        value = find_attr_value_('xsi:type', node)
11262
        if value is not None and 'xsi:type' not in already_processed:
11263
            already_processed.add('xsi:type')
11264
            self.extensiontype_ = value
11265
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
11266
        if nodeName_ == 'TextEquiv':
11267
            obj_ = TextEquivType.factory(parent_object_=self)
11268
            obj_.build(child_, gds_collector_=gds_collector_)
11269
            self.TextEquiv.append(obj_)
11270
            obj_.original_tagname_ = 'TextEquiv'
11271
    def __hash__(self):
11272
        return hash(self.id)
11273
# end class GraphemeBaseType
11274
11275
11276
class GraphemeType(GraphemeBaseType):
11277
    """GraphemeType --
11278
    Represents a sub-element of a glyph.
11279
    Smallest graphical unit that can be
11280
    assigned a Unicode code point.
11281
    
11282
    """
11283
    __hash__ = GeneratedsSuper.__hash__
11284
    member_data_items_ = [
11285
        MemberSpec_('Coords', 'CoordsType', 0, 0, {'name': 'Coords', 'type': 'CoordsType'}, None),
11286
    ]
11287
    subclass = None
11288
    superclass = GraphemeBaseType
11289
    def __init__(self, id=None, index=None, ligature=None, charType=None, custom=None, comments=None, TextEquiv=None, Coords=None, gds_collector_=None, **kwargs_):
11290
        self.gds_collector_ = gds_collector_
11291
        self.gds_elementtree_node_ = None
11292
        self.original_tagname_ = None
11293
        self.parent_object_ = kwargs_.get('parent_object_')
11294
        self.ns_prefix_ = "pc"
11295
        super(globals().get("GraphemeType"), self).__init__(id, index, ligature, charType, custom, comments, TextEquiv,  **kwargs_)
11296
        self.Coords = Coords
11297
        self.Coords_nsprefix_ = "pc"
11298
    def factory(*args_, **kwargs_):
11299
        if CurrentSubclassModule_ is not None:
11300
            subclass = getSubclassFromModule_(
11301
                CurrentSubclassModule_, GraphemeType)
11302
            if subclass is not None:
11303
                return subclass(*args_, **kwargs_)
11304
        if GraphemeType.subclass:
11305
            return GraphemeType.subclass(*args_, **kwargs_)
11306
        else:
11307
            return GraphemeType(*args_, **kwargs_)
11308
    factory = staticmethod(factory)
11309
    def get_ns_prefix_(self):
11310
        return self.ns_prefix_
11311
    def set_ns_prefix_(self, ns_prefix):
11312
        self.ns_prefix_ = ns_prefix
11313
    def get_Coords(self):
11314
        return self.Coords
11315
    def set_Coords(self, Coords):
11316
        self.Coords = Coords
11317
    def has__content(self):
11318
        if (
11319
            self.Coords is not None or
11320
            super(GraphemeType, self).has__content()
11321
        ):
11322
            return True
11323
        else:
11324
            return False
11325
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GraphemeType', pretty_print=True):
11326
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('GraphemeType')
11327
        if imported_ns_def_ is not None:
11328
            namespacedef_ = imported_ns_def_
11329
        if pretty_print:
11330
            eol_ = '\n'
11331
        else:
11332
            eol_ = ''
11333
        if self.original_tagname_ is not None and name_ == 'GraphemeType':
11334
            name_ = self.original_tagname_
11335
        if UseCapturedNS_ and self.ns_prefix_:
11336
            namespaceprefix_ = self.ns_prefix_ + ':'
11337
        showIndent(outfile, level, pretty_print)
11338
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
11339
        already_processed = set()
11340
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='GraphemeType')
11341
        if self.has__content():
11342
            outfile.write('>%s' % (eol_, ))
11343
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='GraphemeType', pretty_print=pretty_print)
11344
            showIndent(outfile, level, pretty_print)
11345
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
11346
        else:
11347
            outfile.write('/>%s' % (eol_, ))
11348
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='GraphemeType'):
11349
        super(GraphemeType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='GraphemeType')
11350
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GraphemeType', fromsubclass_=False, pretty_print=True):
11351
        super(GraphemeType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print)
11352
        if pretty_print:
11353
            eol_ = '\n'
11354
        else:
11355
            eol_ = ''
11356
        if self.Coords is not None:
11357
            namespaceprefix_ = self.Coords_nsprefix_ + ':' if (UseCapturedNS_ and self.Coords_nsprefix_) else ''
11358
            self.Coords.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Coords', pretty_print=pretty_print)
11359
    def to_etree(self, parent_element=None, name_='GraphemeType', mapping_=None, reverse_mapping_=None, nsmap_=None):
11360
        element = super(GraphemeType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_)
11361
        if self.Coords is not None:
11362
            Coords_ = self.Coords
11363
            Coords_.to_etree(element, name_='Coords', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
11364
        if mapping_ is not None:
11365
            mapping_[id(self)] = element
11366
        if reverse_mapping_ is not None:
11367
            reverse_mapping_[element] = self
11368
        return element
11369
    def build(self, node, gds_collector_=None):
11370
        self.gds_collector_ = gds_collector_
11371
        if SaveElementTreeNode:
11372
            self.gds_elementtree_node_ = node
11373
        already_processed = set()
11374
        self.ns_prefix_ = node.prefix
11375
        self._buildAttributes(node, node.attrib, already_processed)
11376
        for child in node:
11377
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
11378
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
11379
        return self
11380
    def _buildAttributes(self, node, attrs, already_processed):
11381
        super(GraphemeType, self)._buildAttributes(node, attrs, already_processed)
11382
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
11383
        if nodeName_ == 'Coords':
11384
            obj_ = CoordsType.factory(parent_object_=self)
11385
            obj_.build(child_, gds_collector_=gds_collector_)
11386
            self.Coords = obj_
11387
            obj_.original_tagname_ = 'Coords'
11388
        super(GraphemeType, self)._buildChildren(child_, node, nodeName_, True)
11389
    def __hash__(self):
11390
        return hash(self.id)
11391
# end class GraphemeType
11392
11393
11394
class NonPrintingCharType(GraphemeBaseType):
11395
    """NonPrintingCharType --
11396
    A glyph component without visual representation
11397
    but with Unicode code point.
11398
    Non-visual / non-printing / control character.
11399
    Part of grapheme container (of glyph) or grapheme sub group.
11400
    
11401
    """
11402
    __hash__ = GeneratedsSuper.__hash__
11403
    member_data_items_ = [
11404
    ]
11405
    subclass = None
11406
    superclass = GraphemeBaseType
11407
    def __init__(self, id=None, index=None, ligature=None, charType=None, custom=None, comments=None, TextEquiv=None, gds_collector_=None, **kwargs_):
11408
        self.gds_collector_ = gds_collector_
11409
        self.gds_elementtree_node_ = None
11410
        self.original_tagname_ = None
11411
        self.parent_object_ = kwargs_.get('parent_object_')
11412
        self.ns_prefix_ = "pc"
11413
        super(globals().get("NonPrintingCharType"), self).__init__(id, index, ligature, charType, custom, comments, TextEquiv,  **kwargs_)
11414
    def factory(*args_, **kwargs_):
11415
        if CurrentSubclassModule_ is not None:
11416
            subclass = getSubclassFromModule_(
11417
                CurrentSubclassModule_, NonPrintingCharType)
11418
            if subclass is not None:
11419
                return subclass(*args_, **kwargs_)
11420
        if NonPrintingCharType.subclass:
11421
            return NonPrintingCharType.subclass(*args_, **kwargs_)
11422
        else:
11423
            return NonPrintingCharType(*args_, **kwargs_)
11424
    factory = staticmethod(factory)
11425
    def get_ns_prefix_(self):
11426
        return self.ns_prefix_
11427
    def set_ns_prefix_(self, ns_prefix):
11428
        self.ns_prefix_ = ns_prefix
11429
    def has__content(self):
11430
        if (
11431
            super(NonPrintingCharType, self).has__content()
11432
        ):
11433
            return True
11434
        else:
11435
            return False
11436
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='NonPrintingCharType', pretty_print=True):
11437
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('NonPrintingCharType')
11438
        if imported_ns_def_ is not None:
11439
            namespacedef_ = imported_ns_def_
11440
        if pretty_print:
11441
            eol_ = '\n'
11442
        else:
11443
            eol_ = ''
11444
        if self.original_tagname_ is not None and name_ == 'NonPrintingCharType':
11445
            name_ = self.original_tagname_
11446
        if UseCapturedNS_ and self.ns_prefix_:
11447
            namespaceprefix_ = self.ns_prefix_ + ':'
11448
        showIndent(outfile, level, pretty_print)
11449
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
11450
        already_processed = set()
11451
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='NonPrintingCharType')
11452
        if self.has__content():
11453
            outfile.write('>%s' % (eol_, ))
11454
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='NonPrintingCharType', pretty_print=pretty_print)
11455
            showIndent(outfile, level, pretty_print)
11456
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
11457
        else:
11458
            outfile.write('/>%s' % (eol_, ))
11459
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='NonPrintingCharType'):
11460
        super(NonPrintingCharType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='NonPrintingCharType')
11461
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='NonPrintingCharType', fromsubclass_=False, pretty_print=True):
11462
        super(NonPrintingCharType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print)
11463
    def to_etree(self, parent_element=None, name_='NonPrintingCharType', mapping_=None, reverse_mapping_=None, nsmap_=None):
11464
        element = super(NonPrintingCharType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_)
11465
        if mapping_ is not None:
11466
            mapping_[id(self)] = element
11467
        if reverse_mapping_ is not None:
11468
            reverse_mapping_[element] = self
11469
        return element
11470
    def build(self, node, gds_collector_=None):
11471
        self.gds_collector_ = gds_collector_
11472
        if SaveElementTreeNode:
11473
            self.gds_elementtree_node_ = node
11474
        already_processed = set()
11475
        self.ns_prefix_ = node.prefix
11476
        self._buildAttributes(node, node.attrib, already_processed)
11477
        for child in node:
11478
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
11479
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
11480
        return self
11481
    def _buildAttributes(self, node, attrs, already_processed):
11482
        super(NonPrintingCharType, self)._buildAttributes(node, attrs, already_processed)
11483
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
11484
        super(NonPrintingCharType, self)._buildChildren(child_, node, nodeName_, True)
11485
        pass
11486
    def __hash__(self):
11487
        return hash(self.id)
11488
# end class NonPrintingCharType
11489
11490
11491
class GraphemeGroupType(GraphemeBaseType):
11492
    __hash__ = GeneratedsSuper.__hash__
11493
    member_data_items_ = [
11494
        MemberSpec_('Grapheme', 'GraphemeType', 1, 1, {'name': 'Grapheme', 'type': 'GraphemeType'}, 9),
11495
        MemberSpec_('NonPrintingChar', 'NonPrintingCharType', 1, 1, {'name': 'NonPrintingChar', 'type': 'NonPrintingCharType'}, 9),
11496
    ]
11497
    subclass = None
11498
    superclass = GraphemeBaseType
11499
    def __init__(self, id=None, index=None, ligature=None, charType=None, custom=None, comments=None, TextEquiv=None, Grapheme=None, NonPrintingChar=None, gds_collector_=None, **kwargs_):
11500
        self.gds_collector_ = gds_collector_
11501
        self.gds_elementtree_node_ = None
11502
        self.original_tagname_ = None
11503
        self.parent_object_ = kwargs_.get('parent_object_')
11504
        self.ns_prefix_ = "pc"
11505
        super(globals().get("GraphemeGroupType"), self).__init__(id, index, ligature, charType, custom, comments, TextEquiv,  **kwargs_)
11506
        if Grapheme is None:
11507
            self.Grapheme = []
11508
        else:
11509
            self.Grapheme = Grapheme
11510
        self.Grapheme_nsprefix_ = "pc"
11511
        if NonPrintingChar is None:
11512
            self.NonPrintingChar = []
11513
        else:
11514
            self.NonPrintingChar = NonPrintingChar
11515
        self.NonPrintingChar_nsprefix_ = "pc"
11516
    def factory(*args_, **kwargs_):
11517
        if CurrentSubclassModule_ is not None:
11518
            subclass = getSubclassFromModule_(
11519
                CurrentSubclassModule_, GraphemeGroupType)
11520
            if subclass is not None:
11521
                return subclass(*args_, **kwargs_)
11522
        if GraphemeGroupType.subclass:
11523
            return GraphemeGroupType.subclass(*args_, **kwargs_)
11524
        else:
11525
            return GraphemeGroupType(*args_, **kwargs_)
11526
    factory = staticmethod(factory)
11527
    def get_ns_prefix_(self):
11528
        return self.ns_prefix_
11529
    def set_ns_prefix_(self, ns_prefix):
11530
        self.ns_prefix_ = ns_prefix
11531
    def get_Grapheme(self):
11532
        return self.Grapheme
11533
    def set_Grapheme(self, Grapheme):
11534
        self.Grapheme = Grapheme
11535
    def add_Grapheme(self, value):
11536
        self.Grapheme.append(value)
11537
    def insert_Grapheme_at(self, index, value):
11538
        self.Grapheme.insert(index, value)
11539
    def replace_Grapheme_at(self, index, value):
11540
        self.Grapheme[index] = value
11541
    def get_NonPrintingChar(self):
11542
        return self.NonPrintingChar
11543
    def set_NonPrintingChar(self, NonPrintingChar):
11544
        self.NonPrintingChar = NonPrintingChar
11545
    def add_NonPrintingChar(self, value):
11546
        self.NonPrintingChar.append(value)
11547
    def insert_NonPrintingChar_at(self, index, value):
11548
        self.NonPrintingChar.insert(index, value)
11549
    def replace_NonPrintingChar_at(self, index, value):
11550
        self.NonPrintingChar[index] = value
11551
    def has__content(self):
11552
        if (
11553
            self.Grapheme or
11554
            self.NonPrintingChar or
11555
            super(GraphemeGroupType, self).has__content()
11556
        ):
11557
            return True
11558
        else:
11559
            return False
11560
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GraphemeGroupType', pretty_print=True):
11561
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('GraphemeGroupType')
11562
        if imported_ns_def_ is not None:
11563
            namespacedef_ = imported_ns_def_
11564
        if pretty_print:
11565
            eol_ = '\n'
11566
        else:
11567
            eol_ = ''
11568
        if self.original_tagname_ is not None and name_ == 'GraphemeGroupType':
11569
            name_ = self.original_tagname_
11570
        if UseCapturedNS_ and self.ns_prefix_:
11571
            namespaceprefix_ = self.ns_prefix_ + ':'
11572
        showIndent(outfile, level, pretty_print)
11573
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
11574
        already_processed = set()
11575
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='GraphemeGroupType')
11576
        if self.has__content():
11577
            outfile.write('>%s' % (eol_, ))
11578
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='GraphemeGroupType', pretty_print=pretty_print)
11579
            showIndent(outfile, level, pretty_print)
11580
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
11581
        else:
11582
            outfile.write('/>%s' % (eol_, ))
11583
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='GraphemeGroupType'):
11584
        super(GraphemeGroupType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='GraphemeGroupType')
11585
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GraphemeGroupType', fromsubclass_=False, pretty_print=True):
11586
        super(GraphemeGroupType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print)
11587
        if pretty_print:
11588
            eol_ = '\n'
11589
        else:
11590
            eol_ = ''
11591
        for Grapheme_ in self.Grapheme:
11592
            namespaceprefix_ = self.Grapheme_nsprefix_ + ':' if (UseCapturedNS_ and self.Grapheme_nsprefix_) else ''
11593
            Grapheme_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Grapheme', pretty_print=pretty_print)
11594
        for NonPrintingChar_ in self.NonPrintingChar:
11595
            namespaceprefix_ = self.NonPrintingChar_nsprefix_ + ':' if (UseCapturedNS_ and self.NonPrintingChar_nsprefix_) else ''
11596
            NonPrintingChar_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='NonPrintingChar', pretty_print=pretty_print)
11597
    def to_etree(self, parent_element=None, name_='GraphemeGroupType', mapping_=None, reverse_mapping_=None, nsmap_=None):
11598
        element = super(GraphemeGroupType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_)
11599
        for Grapheme_ in self.Grapheme:
11600
            Grapheme_.to_etree(element, name_='Grapheme', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
11601
        for NonPrintingChar_ in self.NonPrintingChar:
11602
            NonPrintingChar_.to_etree(element, name_='NonPrintingChar', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
11603
        if mapping_ is not None:
11604
            mapping_[id(self)] = element
11605
        if reverse_mapping_ is not None:
11606
            reverse_mapping_[element] = self
11607
        return element
11608
    def build(self, node, gds_collector_=None):
11609
        self.gds_collector_ = gds_collector_
11610
        if SaveElementTreeNode:
11611
            self.gds_elementtree_node_ = node
11612
        already_processed = set()
11613
        self.ns_prefix_ = node.prefix
11614
        self._buildAttributes(node, node.attrib, already_processed)
11615
        for child in node:
11616
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
11617
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
11618
        return self
11619
    def _buildAttributes(self, node, attrs, already_processed):
11620
        super(GraphemeGroupType, self)._buildAttributes(node, attrs, already_processed)
11621
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
11622
        if nodeName_ == 'Grapheme':
11623
            obj_ = GraphemeType.factory(parent_object_=self)
11624
            obj_.build(child_, gds_collector_=gds_collector_)
11625
            self.Grapheme.append(obj_)
11626
            obj_.original_tagname_ = 'Grapheme'
11627
        elif nodeName_ == 'NonPrintingChar':
11628
            obj_ = NonPrintingCharType.factory(parent_object_=self)
11629
            obj_.build(child_, gds_collector_=gds_collector_)
11630
            self.NonPrintingChar.append(obj_)
11631
            obj_.original_tagname_ = 'NonPrintingChar'
11632
        super(GraphemeGroupType, self)._buildChildren(child_, node, nodeName_, True)
11633
    def __hash__(self):
11634
        return hash(self.id)
11635
# end class GraphemeGroupType
11636
11637
11638 View Code Duplication
class UserDefinedType(GeneratedsSuper):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
11639
    """UserDefinedType -- Container for user-defined attributes
11640
    
11641
    """
11642
    __hash__ = GeneratedsSuper.__hash__
11643
    member_data_items_ = [
11644
        MemberSpec_('UserAttribute', 'UserAttributeType', 1, 0, {'maxOccurs': 'unbounded', 'minOccurs': '1', 'name': 'UserAttribute', 'type': 'UserAttributeType'}, None),
11645
    ]
11646
    subclass = None
11647
    superclass = None
11648
    def __init__(self, UserAttribute=None, gds_collector_=None, **kwargs_):
11649
        self.gds_collector_ = gds_collector_
11650
        self.gds_elementtree_node_ = None
11651
        self.original_tagname_ = None
11652
        self.parent_object_ = kwargs_.get('parent_object_')
11653
        self.ns_prefix_ = "pc"
11654
        if UserAttribute is None:
11655
            self.UserAttribute = []
11656
        else:
11657
            self.UserAttribute = UserAttribute
11658
        self.UserAttribute_nsprefix_ = "pc"
11659
    def factory(*args_, **kwargs_):
11660
        if CurrentSubclassModule_ is not None:
11661
            subclass = getSubclassFromModule_(
11662
                CurrentSubclassModule_, UserDefinedType)
11663
            if subclass is not None:
11664
                return subclass(*args_, **kwargs_)
11665
        if UserDefinedType.subclass:
11666
            return UserDefinedType.subclass(*args_, **kwargs_)
11667
        else:
11668
            return UserDefinedType(*args_, **kwargs_)
11669
    factory = staticmethod(factory)
11670
    def get_ns_prefix_(self):
11671
        return self.ns_prefix_
11672
    def set_ns_prefix_(self, ns_prefix):
11673
        self.ns_prefix_ = ns_prefix
11674
    def get_UserAttribute(self):
11675
        return self.UserAttribute
11676
    def set_UserAttribute(self, UserAttribute):
11677
        self.UserAttribute = UserAttribute
11678
    def add_UserAttribute(self, value):
11679
        self.UserAttribute.append(value)
11680
    def insert_UserAttribute_at(self, index, value):
11681
        self.UserAttribute.insert(index, value)
11682
    def replace_UserAttribute_at(self, index, value):
11683
        self.UserAttribute[index] = value
11684
    def has__content(self):
11685
        if (
11686
            self.UserAttribute
11687
        ):
11688
            return True
11689
        else:
11690
            return False
11691
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='UserDefinedType', pretty_print=True):
11692
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('UserDefinedType')
11693
        if imported_ns_def_ is not None:
11694
            namespacedef_ = imported_ns_def_
11695
        if pretty_print:
11696
            eol_ = '\n'
11697
        else:
11698
            eol_ = ''
11699
        if self.original_tagname_ is not None and name_ == 'UserDefinedType':
11700
            name_ = self.original_tagname_
11701
        if UseCapturedNS_ and self.ns_prefix_:
11702
            namespaceprefix_ = self.ns_prefix_ + ':'
11703
        showIndent(outfile, level, pretty_print)
11704
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
11705
        already_processed = set()
11706
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='UserDefinedType')
11707
        if self.has__content():
11708
            outfile.write('>%s' % (eol_, ))
11709
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='UserDefinedType', pretty_print=pretty_print)
11710
            showIndent(outfile, level, pretty_print)
11711
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
11712
        else:
11713
            outfile.write('/>%s' % (eol_, ))
11714
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='UserDefinedType'):
11715
        pass
11716
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='UserDefinedType', fromsubclass_=False, pretty_print=True):
11717
        if pretty_print:
11718
            eol_ = '\n'
11719
        else:
11720
            eol_ = ''
11721
        for UserAttribute_ in self.UserAttribute:
11722
            namespaceprefix_ = self.UserAttribute_nsprefix_ + ':' if (UseCapturedNS_ and self.UserAttribute_nsprefix_) else ''
11723
            UserAttribute_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='UserAttribute', pretty_print=pretty_print)
11724
    def to_etree(self, parent_element=None, name_='UserDefinedType', mapping_=None, reverse_mapping_=None, nsmap_=None):
11725
        if parent_element is None:
11726
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
11727
        else:
11728
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
11729
        for UserAttribute_ in self.UserAttribute:
11730
            UserAttribute_.to_etree(element, name_='UserAttribute', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
11731
        if mapping_ is not None:
11732
            mapping_[id(self)] = element
11733
        if reverse_mapping_ is not None:
11734
            reverse_mapping_[element] = self
11735
        return element
11736
    def build(self, node, gds_collector_=None):
11737
        self.gds_collector_ = gds_collector_
11738
        if SaveElementTreeNode:
11739
            self.gds_elementtree_node_ = node
11740
        already_processed = set()
11741
        self.ns_prefix_ = node.prefix
11742
        self._buildAttributes(node, node.attrib, already_processed)
11743
        for child in node:
11744
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
11745
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
11746
        return self
11747
    def _buildAttributes(self, node, attrs, already_processed):
11748
        pass
11749
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
11750
        if nodeName_ == 'UserAttribute':
11751
            obj_ = UserAttributeType.factory(parent_object_=self)
11752
            obj_.build(child_, gds_collector_=gds_collector_)
11753
            self.UserAttribute.append(obj_)
11754
            obj_.original_tagname_ = 'UserAttribute'
11755
    def __hash__(self):
11756
        return hash(self.id)
11757
# end class UserDefinedType
11758
11759
11760
class UserAttributeType(GeneratedsSuper):
11761
    """UserAttributeType -- Structured custom data defined by name, type and value.
11762
    
11763
    """
11764
    __hash__ = GeneratedsSuper.__hash__
11765
    member_data_items_ = [
11766
        MemberSpec_('name', 'string', 0, 1, {'use': 'optional', 'name': 'name'}),
11767
        MemberSpec_('description', 'string', 0, 1, {'use': 'optional', 'name': 'description'}),
11768
        MemberSpec_('type_', 'typeType3', 0, 1, {'use': 'optional', 'name': 'type_'}),
11769
        MemberSpec_('value', 'string', 0, 1, {'use': 'optional', 'name': 'value'}),
11770
    ]
11771
    subclass = None
11772
    superclass = None
11773
    def __init__(self, name=None, description=None, type_=None, value=None, gds_collector_=None, **kwargs_):
11774
        self.gds_collector_ = gds_collector_
11775
        self.gds_elementtree_node_ = None
11776
        self.original_tagname_ = None
11777
        self.parent_object_ = kwargs_.get('parent_object_')
11778
        self.ns_prefix_ = "pc"
11779
        self.name = _cast(None, name)
11780
        self.name_nsprefix_ = "pc"
11781
        self.description = _cast(None, description)
11782
        self.description_nsprefix_ = "pc"
11783
        self.type_ = _cast(None, type_)
11784
        self.type__nsprefix_ = "pc"
11785
        self.value = _cast(None, value)
11786
        self.value_nsprefix_ = "pc"
11787
    def factory(*args_, **kwargs_):
11788
        if CurrentSubclassModule_ is not None:
11789
            subclass = getSubclassFromModule_(
11790
                CurrentSubclassModule_, UserAttributeType)
11791
            if subclass is not None:
11792
                return subclass(*args_, **kwargs_)
11793
        if UserAttributeType.subclass:
11794
            return UserAttributeType.subclass(*args_, **kwargs_)
11795
        else:
11796
            return UserAttributeType(*args_, **kwargs_)
11797
    factory = staticmethod(factory)
11798
    def get_ns_prefix_(self):
11799
        return self.ns_prefix_
11800
    def set_ns_prefix_(self, ns_prefix):
11801
        self.ns_prefix_ = ns_prefix
11802
    def get_name(self):
11803
        return self.name
11804
    def set_name(self, name):
11805
        self.name = name
11806
    def get_description(self):
11807
        return self.description
11808
    def set_description(self, description):
11809
        self.description = description
11810
    def get_type(self):
11811
        return self.type_
11812
    def set_type(self, type_):
11813
        self.type_ = type_
11814
    def get_value(self):
11815
        return self.value
11816
    def set_value(self, value):
11817
        self.value = value
11818
    def validate_typeType3(self, value):
11819
        # Validate type typeType3, a restriction on string.
11820
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
11821
            if not isinstance(value, str):
11822
                lineno = self.gds_get_node_lineno_()
11823
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
11824
                return False
11825
            value = value
11826
            enumerations = ['xsd:string', 'xsd:integer', 'xsd:boolean', 'xsd:float']
11827
            if value not in enumerations:
11828
                lineno = self.gds_get_node_lineno_()
11829
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on typeType3' % {"value" : encode_str_2_3(value), "lineno": lineno} )
11830
                result = False
11831
    def has__content(self):
11832
        if (
11833
11834
        ):
11835
            return True
11836
        else:
11837
            return False
11838
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='UserAttributeType', pretty_print=True):
11839
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('UserAttributeType')
11840
        if imported_ns_def_ is not None:
11841
            namespacedef_ = imported_ns_def_
11842
        if pretty_print:
11843
            eol_ = '\n'
11844
        else:
11845
            eol_ = ''
11846
        if self.original_tagname_ is not None and name_ == 'UserAttributeType':
11847
            name_ = self.original_tagname_
11848
        if UseCapturedNS_ and self.ns_prefix_:
11849
            namespaceprefix_ = self.ns_prefix_ + ':'
11850
        showIndent(outfile, level, pretty_print)
11851
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
11852
        already_processed = set()
11853
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='UserAttributeType')
11854
        if self.has__content():
11855
            outfile.write('>%s' % (eol_, ))
11856
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='UserAttributeType', pretty_print=pretty_print)
11857
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
11858
        else:
11859
            outfile.write('/>%s' % (eol_, ))
11860
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='UserAttributeType'):
11861
        if self.name is not None and 'name' not in already_processed:
11862
            already_processed.add('name')
11863
            outfile.write(' name=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.name), input_name='name')), ))
11864
        if self.description is not None and 'description' not in already_processed:
11865
            already_processed.add('description')
11866
            outfile.write(' description=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.description), input_name='description')), ))
11867
        if self.type_ is not None and 'type_' not in already_processed:
11868
            already_processed.add('type_')
11869
            outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), ))
11870
        if self.value is not None and 'value' not in already_processed:
11871
            already_processed.add('value')
11872
            outfile.write(' value=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.value), input_name='value')), ))
11873
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='UserAttributeType', fromsubclass_=False, pretty_print=True):
11874
        pass
11875
    def to_etree(self, parent_element=None, name_='UserAttributeType', mapping_=None, reverse_mapping_=None, nsmap_=None):
11876
        if parent_element is None:
11877
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
11878
        else:
11879
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
11880
        if self.name is not None:
11881
            element.set('name', self.gds_format_string(self.name))
11882
        if self.description is not None:
11883
            element.set('description', self.gds_format_string(self.description))
11884
        if self.type_ is not None:
11885
            element.set('type', self.gds_format_string(self.type_))
11886
        if self.value is not None:
11887
            element.set('value', self.gds_format_string(self.value))
11888
        if mapping_ is not None:
11889
            mapping_[id(self)] = element
11890
        if reverse_mapping_ is not None:
11891
            reverse_mapping_[element] = self
11892
        return element
11893
    def build(self, node, gds_collector_=None):
11894
        self.gds_collector_ = gds_collector_
11895
        if SaveElementTreeNode:
11896
            self.gds_elementtree_node_ = node
11897
        already_processed = set()
11898
        self.ns_prefix_ = node.prefix
11899
        self._buildAttributes(node, node.attrib, already_processed)
11900
        for child in node:
11901
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
11902
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
11903
        return self
11904
    def _buildAttributes(self, node, attrs, already_processed):
11905
        value = find_attr_value_('name', node)
11906
        if value is not None and 'name' not in already_processed:
11907
            already_processed.add('name')
11908
            self.name = value
11909
        value = find_attr_value_('description', node)
11910
        if value is not None and 'description' not in already_processed:
11911
            already_processed.add('description')
11912
            self.description = value
11913
        value = find_attr_value_('type', node)
11914
        if value is not None and 'type' not in already_processed:
11915
            already_processed.add('type')
11916
            self.type_ = value
11917
            self.validate_typeType3(self.type_)    # validate type typeType3
11918
        value = find_attr_value_('value', node)
11919
        if value is not None and 'value' not in already_processed:
11920
            already_processed.add('value')
11921
            self.value = value
11922
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
11923
        pass
11924
    def __hash__(self):
11925
        return hash(self.id)
11926
# end class UserAttributeType
11927
11928
11929
class TableCellRoleType(GeneratedsSuper):
11930
    """rowIndex -- Cell position in table starting with row 0
11931
    columnIndex -- Cell position in table starting with column 0
11932
    rowSpan -- Number of rows the cell spans (optional; default is 1)
11933
    colSpan -- Number of columns the cell spans (optional; default is 1)
11934
    header --
11935
    Is the cell a column or row header?
11936
    
11937
    """
11938
    __hash__ = GeneratedsSuper.__hash__
11939
    member_data_items_ = [
11940
        MemberSpec_('rowIndex', 'int', 0, 0, {'use': 'required', 'name': 'rowIndex'}),
11941
        MemberSpec_('columnIndex', 'int', 0, 0, {'use': 'required', 'name': 'columnIndex'}),
11942
        MemberSpec_('rowSpan', 'int', 0, 1, {'use': 'optional', 'name': 'rowSpan'}),
11943
        MemberSpec_('colSpan', 'int', 0, 1, {'use': 'optional', 'name': 'colSpan'}),
11944
        MemberSpec_('header', 'boolean', 0, 1, {'use': 'optional', 'name': 'header'}),
11945
    ]
11946
    subclass = None
11947
    superclass = None
11948
    def __init__(self, rowIndex=None, columnIndex=None, rowSpan=None, colSpan=None, header=None, gds_collector_=None, **kwargs_):
11949
        self.gds_collector_ = gds_collector_
11950
        self.gds_elementtree_node_ = None
11951
        self.original_tagname_ = None
11952
        self.parent_object_ = kwargs_.get('parent_object_')
11953
        self.ns_prefix_ = "pc"
11954
        self.rowIndex = _cast(int, rowIndex)
11955
        self.rowIndex_nsprefix_ = "pc"
11956
        self.columnIndex = _cast(int, columnIndex)
11957
        self.columnIndex_nsprefix_ = "pc"
11958
        self.rowSpan = _cast(int, rowSpan)
11959
        self.rowSpan_nsprefix_ = "pc"
11960
        self.colSpan = _cast(int, colSpan)
11961
        self.colSpan_nsprefix_ = "pc"
11962
        self.header = _cast(bool, header)
11963
        self.header_nsprefix_ = "pc"
11964
    def factory(*args_, **kwargs_):
11965
        if CurrentSubclassModule_ is not None:
11966
            subclass = getSubclassFromModule_(
11967
                CurrentSubclassModule_, TableCellRoleType)
11968
            if subclass is not None:
11969
                return subclass(*args_, **kwargs_)
11970
        if TableCellRoleType.subclass:
11971
            return TableCellRoleType.subclass(*args_, **kwargs_)
11972
        else:
11973
            return TableCellRoleType(*args_, **kwargs_)
11974
    factory = staticmethod(factory)
11975
    def get_ns_prefix_(self):
11976
        return self.ns_prefix_
11977
    def set_ns_prefix_(self, ns_prefix):
11978
        self.ns_prefix_ = ns_prefix
11979
    def get_rowIndex(self):
11980
        return self.rowIndex
11981
    def set_rowIndex(self, rowIndex):
11982
        self.rowIndex = rowIndex
11983
    def get_columnIndex(self):
11984
        return self.columnIndex
11985
    def set_columnIndex(self, columnIndex):
11986
        self.columnIndex = columnIndex
11987
    def get_rowSpan(self):
11988
        return self.rowSpan
11989
    def set_rowSpan(self, rowSpan):
11990
        self.rowSpan = rowSpan
11991
    def get_colSpan(self):
11992
        return self.colSpan
11993
    def set_colSpan(self, colSpan):
11994
        self.colSpan = colSpan
11995
    def get_header(self):
11996
        return self.header
11997
    def set_header(self, header):
11998
        self.header = header
11999
    def has__content(self):
12000
        if (
12001
12002
        ):
12003
            return True
12004
        else:
12005
            return False
12006
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='TableCellRoleType', pretty_print=True):
12007
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('TableCellRoleType')
12008
        if imported_ns_def_ is not None:
12009
            namespacedef_ = imported_ns_def_
12010
        if pretty_print:
12011
            eol_ = '\n'
12012
        else:
12013
            eol_ = ''
12014
        if self.original_tagname_ is not None and name_ == 'TableCellRoleType':
12015
            name_ = self.original_tagname_
12016
        if UseCapturedNS_ and self.ns_prefix_:
12017
            namespaceprefix_ = self.ns_prefix_ + ':'
12018
        showIndent(outfile, level, pretty_print)
12019
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
12020
        already_processed = set()
12021
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='TableCellRoleType')
12022
        if self.has__content():
12023
            outfile.write('>%s' % (eol_, ))
12024
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='TableCellRoleType', pretty_print=pretty_print)
12025
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
12026
        else:
12027
            outfile.write('/>%s' % (eol_, ))
12028
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='TableCellRoleType'):
12029
        if self.rowIndex is not None and 'rowIndex' not in already_processed:
12030
            already_processed.add('rowIndex')
12031
            outfile.write(' rowIndex="%s"' % self.gds_format_integer(self.rowIndex, input_name='rowIndex'))
12032
        if self.columnIndex is not None and 'columnIndex' not in already_processed:
12033
            already_processed.add('columnIndex')
12034
            outfile.write(' columnIndex="%s"' % self.gds_format_integer(self.columnIndex, input_name='columnIndex'))
12035
        if self.rowSpan is not None and 'rowSpan' not in already_processed:
12036
            already_processed.add('rowSpan')
12037
            outfile.write(' rowSpan="%s"' % self.gds_format_integer(self.rowSpan, input_name='rowSpan'))
12038
        if self.colSpan is not None and 'colSpan' not in already_processed:
12039
            already_processed.add('colSpan')
12040
            outfile.write(' colSpan="%s"' % self.gds_format_integer(self.colSpan, input_name='colSpan'))
12041
        if self.header is not None and 'header' not in already_processed:
12042
            already_processed.add('header')
12043
            outfile.write(' header="%s"' % self.gds_format_boolean(self.header, input_name='header'))
12044
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='TableCellRoleType', fromsubclass_=False, pretty_print=True):
12045
        pass
12046
    def to_etree(self, parent_element=None, name_='TableCellRoleType', mapping_=None, reverse_mapping_=None, nsmap_=None):
12047
        if parent_element is None:
12048
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
12049
        else:
12050
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
12051
        if self.rowIndex is not None:
12052
            element.set('rowIndex', self.gds_format_integer(self.rowIndex))
12053
        if self.columnIndex is not None:
12054
            element.set('columnIndex', self.gds_format_integer(self.columnIndex))
12055
        if self.rowSpan is not None:
12056
            element.set('rowSpan', self.gds_format_integer(self.rowSpan))
12057
        if self.colSpan is not None:
12058
            element.set('colSpan', self.gds_format_integer(self.colSpan))
12059
        if self.header is not None:
12060
            element.set('header', self.gds_format_boolean(self.header))
12061
        if mapping_ is not None:
12062
            mapping_[id(self)] = element
12063
        if reverse_mapping_ is not None:
12064
            reverse_mapping_[element] = self
12065
        return element
12066
    def build(self, node, gds_collector_=None):
12067
        self.gds_collector_ = gds_collector_
12068
        if SaveElementTreeNode:
12069
            self.gds_elementtree_node_ = node
12070
        already_processed = set()
12071
        self.ns_prefix_ = node.prefix
12072
        self._buildAttributes(node, node.attrib, already_processed)
12073
        for child in node:
12074
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
12075
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
12076
        return self
12077
    def _buildAttributes(self, node, attrs, already_processed):
12078
        value = find_attr_value_('rowIndex', node)
12079
        if value is not None and 'rowIndex' not in already_processed:
12080
            already_processed.add('rowIndex')
12081
            self.rowIndex = self.gds_parse_integer(value, node, 'rowIndex')
12082
        value = find_attr_value_('columnIndex', node)
12083
        if value is not None and 'columnIndex' not in already_processed:
12084
            already_processed.add('columnIndex')
12085
            self.columnIndex = self.gds_parse_integer(value, node, 'columnIndex')
12086
        value = find_attr_value_('rowSpan', node)
12087
        if value is not None and 'rowSpan' not in already_processed:
12088
            already_processed.add('rowSpan')
12089
            self.rowSpan = self.gds_parse_integer(value, node, 'rowSpan')
12090
        value = find_attr_value_('colSpan', node)
12091
        if value is not None and 'colSpan' not in already_processed:
12092
            already_processed.add('colSpan')
12093
            self.colSpan = self.gds_parse_integer(value, node, 'colSpan')
12094
        value = find_attr_value_('header', node)
12095
        if value is not None and 'header' not in already_processed:
12096
            already_processed.add('header')
12097
            if value in ('true', '1'):
12098
                self.header = True
12099
            elif value in ('false', '0'):
12100
                self.header = False
12101
            else:
12102
                raise_parse_error(node, 'Bad boolean attribute')
12103
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
12104
        pass
12105
    def __hash__(self):
12106
        return hash(self.id)
12107
# end class TableCellRoleType
12108
12109
12110 View Code Duplication
class RolesType(GeneratedsSuper):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
12111
    """TableCellRole --
12112
    Data for a region that takes on the role
12113
    of a table cell within a parent table region.
12114
    
12115
    """
12116
    __hash__ = GeneratedsSuper.__hash__
12117
    member_data_items_ = [
12118
        MemberSpec_('TableCellRole', 'TableCellRoleType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'TableCellRole', 'type': 'TableCellRoleType'}, None),
12119
    ]
12120
    subclass = None
12121
    superclass = None
12122
    def __init__(self, TableCellRole=None, gds_collector_=None, **kwargs_):
12123
        self.gds_collector_ = gds_collector_
12124
        self.gds_elementtree_node_ = None
12125
        self.original_tagname_ = None
12126
        self.parent_object_ = kwargs_.get('parent_object_')
12127
        self.ns_prefix_ = "pc"
12128
        self.TableCellRole = TableCellRole
12129
        self.TableCellRole_nsprefix_ = "pc"
12130
    def factory(*args_, **kwargs_):
12131
        if CurrentSubclassModule_ is not None:
12132
            subclass = getSubclassFromModule_(
12133
                CurrentSubclassModule_, RolesType)
12134
            if subclass is not None:
12135
                return subclass(*args_, **kwargs_)
12136
        if RolesType.subclass:
12137
            return RolesType.subclass(*args_, **kwargs_)
12138
        else:
12139
            return RolesType(*args_, **kwargs_)
12140
    factory = staticmethod(factory)
12141
    def get_ns_prefix_(self):
12142
        return self.ns_prefix_
12143
    def set_ns_prefix_(self, ns_prefix):
12144
        self.ns_prefix_ = ns_prefix
12145
    def get_TableCellRole(self):
12146
        return self.TableCellRole
12147
    def set_TableCellRole(self, TableCellRole):
12148
        self.TableCellRole = TableCellRole
12149
    def has__content(self):
12150
        if (
12151
            self.TableCellRole is not None
12152
        ):
12153
            return True
12154
        else:
12155
            return False
12156
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RolesType', pretty_print=True):
12157
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('RolesType')
12158
        if imported_ns_def_ is not None:
12159
            namespacedef_ = imported_ns_def_
12160
        if pretty_print:
12161
            eol_ = '\n'
12162
        else:
12163
            eol_ = ''
12164
        if self.original_tagname_ is not None and name_ == 'RolesType':
12165
            name_ = self.original_tagname_
12166
        if UseCapturedNS_ and self.ns_prefix_:
12167
            namespaceprefix_ = self.ns_prefix_ + ':'
12168
        showIndent(outfile, level, pretty_print)
12169
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
12170
        already_processed = set()
12171
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='RolesType')
12172
        if self.has__content():
12173
            outfile.write('>%s' % (eol_, ))
12174
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='RolesType', pretty_print=pretty_print)
12175
            showIndent(outfile, level, pretty_print)
12176
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
12177
        else:
12178
            outfile.write('/>%s' % (eol_, ))
12179
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='RolesType'):
12180
        pass
12181
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='RolesType', fromsubclass_=False, pretty_print=True):
12182
        if pretty_print:
12183
            eol_ = '\n'
12184
        else:
12185
            eol_ = ''
12186
        if self.TableCellRole is not None:
12187
            namespaceprefix_ = self.TableCellRole_nsprefix_ + ':' if (UseCapturedNS_ and self.TableCellRole_nsprefix_) else ''
12188
            self.TableCellRole.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TableCellRole', pretty_print=pretty_print)
12189
    def to_etree(self, parent_element=None, name_='RolesType', mapping_=None, reverse_mapping_=None, nsmap_=None):
12190
        if parent_element is None:
12191
            element = etree_.Element('{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
12192
        else:
12193
            element = etree_.SubElement(parent_element, '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15}' + name_, nsmap=nsmap_)
12194
        if self.TableCellRole is not None:
12195
            TableCellRole_ = self.TableCellRole
12196
            TableCellRole_.to_etree(element, name_='TableCellRole', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
12197
        if mapping_ is not None:
12198
            mapping_[id(self)] = element
12199
        if reverse_mapping_ is not None:
12200
            reverse_mapping_[element] = self
12201
        return element
12202
    def build(self, node, gds_collector_=None):
12203
        self.gds_collector_ = gds_collector_
12204
        if SaveElementTreeNode:
12205
            self.gds_elementtree_node_ = node
12206
        already_processed = set()
12207
        self.ns_prefix_ = node.prefix
12208
        self._buildAttributes(node, node.attrib, already_processed)
12209
        for child in node:
12210
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
12211
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
12212
        return self
12213
    def _buildAttributes(self, node, attrs, already_processed):
12214
        pass
12215
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
12216
        if nodeName_ == 'TableCellRole':
12217
            obj_ = TableCellRoleType.factory(parent_object_=self)
12218
            obj_.build(child_, gds_collector_=gds_collector_)
12219
            self.TableCellRole = obj_
12220
            obj_.original_tagname_ = 'TableCellRole'
12221
    def __hash__(self):
12222
        return hash(self.id)
12223
# end class RolesType
12224
12225
12226
class CustomRegionType(RegionType):
12227
    """CustomRegionType --
12228
    Regions containing content that is not covered
12229
    by the default types (text, graphic, image,
12230
    line drawing, chart, table, separator, maths,
12231
    map, music, chem, advert, noise, unknown).
12232
      
12233
    * type --
12234
      Information on the type of content represented by this region
12235
    
12236
    """
12237
    __hash__ = GeneratedsSuper.__hash__
12238
    member_data_items_ = [
12239
        MemberSpec_('type_', 'string', 0, 1, {'use': 'optional', 'name': 'type_'}),
12240
    ]
12241
    subclass = None
12242
    superclass = RegionType
12243
    def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, type_=None, gds_collector_=None, **kwargs_):
12244
        self.gds_collector_ = gds_collector_
12245
        self.gds_elementtree_node_ = None
12246
        self.original_tagname_ = None
12247
        self.parent_object_ = kwargs_.get('parent_object_')
12248
        self.ns_prefix_ = "pc"
12249
        super(globals().get("CustomRegionType"), self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion,  **kwargs_)
12250
        self.type_ = _cast(None, type_)
12251
        self.type__nsprefix_ = "pc"
12252
    def factory(*args_, **kwargs_):
12253
        if CurrentSubclassModule_ is not None:
12254
            subclass = getSubclassFromModule_(
12255
                CurrentSubclassModule_, CustomRegionType)
12256
            if subclass is not None:
12257
                return subclass(*args_, **kwargs_)
12258
        if CustomRegionType.subclass:
12259
            return CustomRegionType.subclass(*args_, **kwargs_)
12260
        else:
12261
            return CustomRegionType(*args_, **kwargs_)
12262
    factory = staticmethod(factory)
12263
    def get_ns_prefix_(self):
12264
        return self.ns_prefix_
12265
    def set_ns_prefix_(self, ns_prefix):
12266
        self.ns_prefix_ = ns_prefix
12267
    def get_type(self):
12268
        return self.type_
12269
    def set_type(self, type_):
12270
        self.type_ = type_
12271
    def has__content(self):
12272
        if (
12273
            super(CustomRegionType, self).has__content()
12274
        ):
12275
            return True
12276
        else:
12277
            return False
12278
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='CustomRegionType', pretty_print=True):
12279
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('CustomRegionType')
12280
        if imported_ns_def_ is not None:
12281
            namespacedef_ = imported_ns_def_
12282
        if pretty_print:
12283
            eol_ = '\n'
12284
        else:
12285
            eol_ = ''
12286
        if self.original_tagname_ is not None and name_ == 'CustomRegionType':
12287
            name_ = self.original_tagname_
12288
        if UseCapturedNS_ and self.ns_prefix_:
12289
            namespaceprefix_ = self.ns_prefix_ + ':'
12290
        showIndent(outfile, level, pretty_print)
12291
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
12292
        already_processed = set()
12293
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='CustomRegionType')
12294
        if self.has__content():
12295
            outfile.write('>%s' % (eol_, ))
12296
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='CustomRegionType', pretty_print=pretty_print)
12297
            showIndent(outfile, level, pretty_print)
12298
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
12299
        else:
12300
            outfile.write('/>%s' % (eol_, ))
12301
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='CustomRegionType'):
12302
        super(CustomRegionType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='CustomRegionType')
12303
        if self.type_ is not None and 'type_' not in already_processed:
12304
            already_processed.add('type_')
12305
            outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), ))
12306
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='CustomRegionType', fromsubclass_=False, pretty_print=True):
12307
        super(CustomRegionType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print)
12308
    def to_etree(self, parent_element=None, name_='CustomRegionType', mapping_=None, reverse_mapping_=None, nsmap_=None):
12309
        element = super(CustomRegionType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_)
12310
        if self.type_ is not None:
12311
            element.set('type', self.gds_format_string(self.type_))
12312
        if mapping_ is not None:
12313
            mapping_[id(self)] = element
12314
        if reverse_mapping_ is not None:
12315
            reverse_mapping_[element] = self
12316
        return element
12317
    def build(self, node, gds_collector_=None):
12318
        self.gds_collector_ = gds_collector_
12319
        if SaveElementTreeNode:
12320
            self.gds_elementtree_node_ = node
12321
        already_processed = set()
12322
        self.ns_prefix_ = node.prefix
12323
        self._buildAttributes(node, node.attrib, already_processed)
12324
        for child in node:
12325
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
12326
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
12327
        return self
12328
    def _buildAttributes(self, node, attrs, already_processed):
12329
        value = find_attr_value_('type', node)
12330
        if value is not None and 'type' not in already_processed:
12331
            already_processed.add('type')
12332
            self.type_ = value
12333
        super(CustomRegionType, self)._buildAttributes(node, attrs, already_processed)
12334
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
12335
        super(CustomRegionType, self)._buildChildren(child_, node, nodeName_, True)
12336
        pass
12337
    def __hash__(self):
12338
        return hash(self.id)
12339
# end class CustomRegionType
12340
12341
12342 View Code Duplication
class UnknownRegionType(RegionType):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
12343
    """UnknownRegionType --
12344
    To be used if the region type cannot be ascertained.
12345
    
12346
    """
12347
    __hash__ = GeneratedsSuper.__hash__
12348
    member_data_items_ = [
12349
    ]
12350
    subclass = None
12351
    superclass = RegionType
12352
    def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, gds_collector_=None, **kwargs_):
12353
        self.gds_collector_ = gds_collector_
12354
        self.gds_elementtree_node_ = None
12355
        self.original_tagname_ = None
12356
        self.parent_object_ = kwargs_.get('parent_object_')
12357
        self.ns_prefix_ = "pc"
12358
        super(globals().get("UnknownRegionType"), self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion,  **kwargs_)
12359
    def factory(*args_, **kwargs_):
12360
        if CurrentSubclassModule_ is not None:
12361
            subclass = getSubclassFromModule_(
12362
                CurrentSubclassModule_, UnknownRegionType)
12363
            if subclass is not None:
12364
                return subclass(*args_, **kwargs_)
12365
        if UnknownRegionType.subclass:
12366
            return UnknownRegionType.subclass(*args_, **kwargs_)
12367
        else:
12368
            return UnknownRegionType(*args_, **kwargs_)
12369
    factory = staticmethod(factory)
12370
    def get_ns_prefix_(self):
12371
        return self.ns_prefix_
12372
    def set_ns_prefix_(self, ns_prefix):
12373
        self.ns_prefix_ = ns_prefix
12374
    def has__content(self):
12375
        if (
12376
            super(UnknownRegionType, self).has__content()
12377
        ):
12378
            return True
12379
        else:
12380
            return False
12381
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='UnknownRegionType', pretty_print=True):
12382
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('UnknownRegionType')
12383
        if imported_ns_def_ is not None:
12384
            namespacedef_ = imported_ns_def_
12385
        if pretty_print:
12386
            eol_ = '\n'
12387
        else:
12388
            eol_ = ''
12389
        if self.original_tagname_ is not None and name_ == 'UnknownRegionType':
12390
            name_ = self.original_tagname_
12391
        if UseCapturedNS_ and self.ns_prefix_:
12392
            namespaceprefix_ = self.ns_prefix_ + ':'
12393
        showIndent(outfile, level, pretty_print)
12394
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
12395
        already_processed = set()
12396
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='UnknownRegionType')
12397
        if self.has__content():
12398
            outfile.write('>%s' % (eol_, ))
12399
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='UnknownRegionType', pretty_print=pretty_print)
12400
            showIndent(outfile, level, pretty_print)
12401
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
12402
        else:
12403
            outfile.write('/>%s' % (eol_, ))
12404
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='UnknownRegionType'):
12405
        super(UnknownRegionType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='UnknownRegionType')
12406
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='UnknownRegionType', fromsubclass_=False, pretty_print=True):
12407
        super(UnknownRegionType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print)
12408
    def to_etree(self, parent_element=None, name_='UnknownRegionType', mapping_=None, reverse_mapping_=None, nsmap_=None):
12409
        element = super(UnknownRegionType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_)
12410
        if mapping_ is not None:
12411
            mapping_[id(self)] = element
12412
        if reverse_mapping_ is not None:
12413
            reverse_mapping_[element] = self
12414
        return element
12415
    def build(self, node, gds_collector_=None):
12416
        self.gds_collector_ = gds_collector_
12417
        if SaveElementTreeNode:
12418
            self.gds_elementtree_node_ = node
12419
        already_processed = set()
12420
        self.ns_prefix_ = node.prefix
12421
        self._buildAttributes(node, node.attrib, already_processed)
12422
        for child in node:
12423
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
12424
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
12425
        return self
12426
    def _buildAttributes(self, node, attrs, already_processed):
12427
        super(UnknownRegionType, self)._buildAttributes(node, attrs, already_processed)
12428
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
12429
        super(UnknownRegionType, self)._buildChildren(child_, node, nodeName_, True)
12430
        pass
12431
    def __hash__(self):
12432
        return hash(self.id)
12433
# end class UnknownRegionType
12434
12435
12436 View Code Duplication
class NoiseRegionType(RegionType):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
12437
    """NoiseRegionType --
12438
    Noise regions are regions where no real data lies, only
12439
    false data created by artifacts on the document or
12440
    scanner noise.
12441
    
12442
    """
12443
    __hash__ = GeneratedsSuper.__hash__
12444
    member_data_items_ = [
12445
    ]
12446
    subclass = None
12447
    superclass = RegionType
12448
    def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, gds_collector_=None, **kwargs_):
12449
        self.gds_collector_ = gds_collector_
12450
        self.gds_elementtree_node_ = None
12451
        self.original_tagname_ = None
12452
        self.parent_object_ = kwargs_.get('parent_object_')
12453
        self.ns_prefix_ = "pc"
12454
        super(globals().get("NoiseRegionType"), self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion,  **kwargs_)
12455
    def factory(*args_, **kwargs_):
12456
        if CurrentSubclassModule_ is not None:
12457
            subclass = getSubclassFromModule_(
12458
                CurrentSubclassModule_, NoiseRegionType)
12459
            if subclass is not None:
12460
                return subclass(*args_, **kwargs_)
12461
        if NoiseRegionType.subclass:
12462
            return NoiseRegionType.subclass(*args_, **kwargs_)
12463
        else:
12464
            return NoiseRegionType(*args_, **kwargs_)
12465
    factory = staticmethod(factory)
12466
    def get_ns_prefix_(self):
12467
        return self.ns_prefix_
12468
    def set_ns_prefix_(self, ns_prefix):
12469
        self.ns_prefix_ = ns_prefix
12470
    def has__content(self):
12471
        if (
12472
            super(NoiseRegionType, self).has__content()
12473
        ):
12474
            return True
12475
        else:
12476
            return False
12477
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='NoiseRegionType', pretty_print=True):
12478
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('NoiseRegionType')
12479
        if imported_ns_def_ is not None:
12480
            namespacedef_ = imported_ns_def_
12481
        if pretty_print:
12482
            eol_ = '\n'
12483
        else:
12484
            eol_ = ''
12485
        if self.original_tagname_ is not None and name_ == 'NoiseRegionType':
12486
            name_ = self.original_tagname_
12487
        if UseCapturedNS_ and self.ns_prefix_:
12488
            namespaceprefix_ = self.ns_prefix_ + ':'
12489
        showIndent(outfile, level, pretty_print)
12490
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
12491
        already_processed = set()
12492
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='NoiseRegionType')
12493
        if self.has__content():
12494
            outfile.write('>%s' % (eol_, ))
12495
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='NoiseRegionType', pretty_print=pretty_print)
12496
            showIndent(outfile, level, pretty_print)
12497
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
12498
        else:
12499
            outfile.write('/>%s' % (eol_, ))
12500
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='NoiseRegionType'):
12501
        super(NoiseRegionType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='NoiseRegionType')
12502
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='NoiseRegionType', fromsubclass_=False, pretty_print=True):
12503
        super(NoiseRegionType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print)
12504
    def to_etree(self, parent_element=None, name_='NoiseRegionType', mapping_=None, reverse_mapping_=None, nsmap_=None):
12505
        element = super(NoiseRegionType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_)
12506
        if mapping_ is not None:
12507
            mapping_[id(self)] = element
12508
        if reverse_mapping_ is not None:
12509
            reverse_mapping_[element] = self
12510
        return element
12511
    def build(self, node, gds_collector_=None):
12512
        self.gds_collector_ = gds_collector_
12513
        if SaveElementTreeNode:
12514
            self.gds_elementtree_node_ = node
12515
        already_processed = set()
12516
        self.ns_prefix_ = node.prefix
12517
        self._buildAttributes(node, node.attrib, already_processed)
12518
        for child in node:
12519
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
12520
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
12521
        return self
12522
    def _buildAttributes(self, node, attrs, already_processed):
12523
        super(NoiseRegionType, self)._buildAttributes(node, attrs, already_processed)
12524
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
12525
        super(NoiseRegionType, self)._buildChildren(child_, node, nodeName_, True)
12526
        pass
12527
    def __hash__(self):
12528
        return hash(self.id)
12529
# end class NoiseRegionType
12530
12531
12532 View Code Duplication
class AdvertRegionType(RegionType):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
12533
    """AdvertRegionType --
12534
    Regions containing advertisements.
12535
      
12536
    * orientation --
12537
      The angle the rectangle encapsulating a region
12538
      has to be rotated in clockwise direction
12539
      in order to correct the present skew
12540
      (negative values indicate anti-clockwise rotation).
12541
      Range: -179.999,180
12542
      
12543
    * bgColour --
12544
      The background colour of the region
12545
    
12546
    """
12547
    __hash__ = GeneratedsSuper.__hash__
12548
    member_data_items_ = [
12549
        MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional', 'name': 'orientation'}),
12550
        MemberSpec_('bgColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional', 'name': 'bgColour'}),
12551
    ]
12552
    subclass = None
12553
    superclass = RegionType
12554
    def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, bgColour=None, gds_collector_=None, **kwargs_):
12555
        self.gds_collector_ = gds_collector_
12556
        self.gds_elementtree_node_ = None
12557
        self.original_tagname_ = None
12558
        self.parent_object_ = kwargs_.get('parent_object_')
12559
        self.ns_prefix_ = "pc"
12560
        super(globals().get("AdvertRegionType"), self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion,  **kwargs_)
12561
        self.orientation = _cast(float, orientation)
12562
        self.orientation_nsprefix_ = "pc"
12563
        self.bgColour = _cast(None, bgColour)
12564
        self.bgColour_nsprefix_ = "pc"
12565
    def factory(*args_, **kwargs_):
12566
        if CurrentSubclassModule_ is not None:
12567
            subclass = getSubclassFromModule_(
12568
                CurrentSubclassModule_, AdvertRegionType)
12569
            if subclass is not None:
12570
                return subclass(*args_, **kwargs_)
12571
        if AdvertRegionType.subclass:
12572
            return AdvertRegionType.subclass(*args_, **kwargs_)
12573
        else:
12574
            return AdvertRegionType(*args_, **kwargs_)
12575
    factory = staticmethod(factory)
12576
    def get_ns_prefix_(self):
12577
        return self.ns_prefix_
12578
    def set_ns_prefix_(self, ns_prefix):
12579
        self.ns_prefix_ = ns_prefix
12580
    def get_orientation(self):
12581
        return self.orientation
12582
    def set_orientation(self, orientation):
12583
        self.orientation = orientation
12584
    def get_bgColour(self):
12585
        return self.bgColour
12586
    def set_bgColour(self, bgColour):
12587
        self.bgColour = bgColour
12588
    def validate_ColourSimpleType(self, value):
12589
        # Validate type pc:ColourSimpleType, a restriction on string.
12590
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
12591
            if not isinstance(value, str):
12592
                lineno = self.gds_get_node_lineno_()
12593
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
12594
                return False
12595
            value = value
12596
            enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other']
12597
            if value not in enumerations:
12598
                lineno = self.gds_get_node_lineno_()
12599
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ColourSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
12600
                result = False
12601
    def has__content(self):
12602
        if (
12603
            super(AdvertRegionType, self).has__content()
12604
        ):
12605
            return True
12606
        else:
12607
            return False
12608
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='AdvertRegionType', pretty_print=True):
12609
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('AdvertRegionType')
12610
        if imported_ns_def_ is not None:
12611
            namespacedef_ = imported_ns_def_
12612
        if pretty_print:
12613
            eol_ = '\n'
12614
        else:
12615
            eol_ = ''
12616
        if self.original_tagname_ is not None and name_ == 'AdvertRegionType':
12617
            name_ = self.original_tagname_
12618
        if UseCapturedNS_ and self.ns_prefix_:
12619
            namespaceprefix_ = self.ns_prefix_ + ':'
12620
        showIndent(outfile, level, pretty_print)
12621
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
12622
        already_processed = set()
12623
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='AdvertRegionType')
12624
        if self.has__content():
12625
            outfile.write('>%s' % (eol_, ))
12626
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='AdvertRegionType', pretty_print=pretty_print)
12627
            showIndent(outfile, level, pretty_print)
12628
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
12629
        else:
12630
            outfile.write('/>%s' % (eol_, ))
12631
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='AdvertRegionType'):
12632
        super(AdvertRegionType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='AdvertRegionType')
12633
        if self.orientation is not None and 'orientation' not in already_processed:
12634
            already_processed.add('orientation')
12635
            outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation'))
12636
        if self.bgColour is not None and 'bgColour' not in already_processed:
12637
            already_processed.add('bgColour')
12638
            outfile.write(' bgColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.bgColour), input_name='bgColour')), ))
12639
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='AdvertRegionType', fromsubclass_=False, pretty_print=True):
12640
        super(AdvertRegionType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print)
12641
    def to_etree(self, parent_element=None, name_='AdvertRegionType', mapping_=None, reverse_mapping_=None, nsmap_=None):
12642
        element = super(AdvertRegionType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_)
12643
        if self.orientation is not None:
12644
            element.set('orientation', self.gds_format_float(self.orientation))
12645
        if self.bgColour is not None:
12646
            element.set('bgColour', self.gds_format_string(self.bgColour))
12647
        if mapping_ is not None:
12648
            mapping_[id(self)] = element
12649
        if reverse_mapping_ is not None:
12650
            reverse_mapping_[element] = self
12651
        return element
12652
    def build(self, node, gds_collector_=None):
12653
        self.gds_collector_ = gds_collector_
12654
        if SaveElementTreeNode:
12655
            self.gds_elementtree_node_ = node
12656
        already_processed = set()
12657
        self.ns_prefix_ = node.prefix
12658
        self._buildAttributes(node, node.attrib, already_processed)
12659
        for child in node:
12660
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
12661
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
12662
        return self
12663
    def _buildAttributes(self, node, attrs, already_processed):
12664
        value = find_attr_value_('orientation', node)
12665
        if value is not None and 'orientation' not in already_processed:
12666
            already_processed.add('orientation')
12667
            value = self.gds_parse_float(value, node, 'orientation')
12668
            self.orientation = value
12669
        value = find_attr_value_('bgColour', node)
12670
        if value is not None and 'bgColour' not in already_processed:
12671
            already_processed.add('bgColour')
12672
            self.bgColour = value
12673
            self.validate_ColourSimpleType(self.bgColour)    # validate type ColourSimpleType
12674
        super(AdvertRegionType, self)._buildAttributes(node, attrs, already_processed)
12675
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
12676
        super(AdvertRegionType, self)._buildChildren(child_, node, nodeName_, True)
12677
        pass
12678
    def __hash__(self):
12679
        return hash(self.id)
12680
    # pylint: disable=line-too-long,invalid-name,protected-access,missing-module-docstring
12681
    def _region_class(self, x): # pylint: disable=unused-argument
12682
        return x.__class__.__name__.replace('RegionType', '')
12683
    
12684
    def _get_recursive_regions(self, regions, level, classes=None):
12685
        from .constants import PAGE_REGION_TYPES  # pylint: disable=relative-beyond-top-level,import-outside-toplevel
12686
        if level == 1:
12687
            # stop recursion, filter classes
12688
            if classes:
12689
                return [r for r in regions if self._region_class(r) in classes]
12690
            if regions and regions[0].__class__.__name__ == 'PageType':
12691
                regions = regions[1:]
12692
            return regions
12693
        # find more regions recursively
12694
        more_regions = []
12695
        for region in regions:
12696
            more_regions.append([])
12697
            for class_ in PAGE_REGION_TYPES:
12698
                if class_ == 'Map' and not isinstance(region, PageType): # pylint: disable=undefined-variable
12699
                    # 'Map' is not recursive in 2019 schema
12700
                    continue
12701
                more_regions[-1] += getattr(region, 'get_{}Region'.format(class_))()
12702
        if not any(more_regions):
12703
            return self._get_recursive_regions(regions, 1, classes)
12704
        ret = []
12705
        for r, more in zip(regions, more_regions):
12706
            ret.append(r)
12707
            ret += self._get_recursive_regions(more, level - 1 if level else 0, classes)
12708
        return self._get_recursive_regions(ret, 1, classes)
12709
    
12710
    def _get_recursive_reading_order(self, rogroup):
12711
        if isinstance(rogroup, (OrderedGroupType, OrderedGroupIndexedType)): # pylint: disable=undefined-variable
12712
            elements = rogroup.get_AllIndexed()
12713
        if isinstance(rogroup, (UnorderedGroupType, UnorderedGroupIndexedType)): # pylint: disable=undefined-variable
12714
            elements = (rogroup.get_RegionRef() + rogroup.get_OrderedGroup() + rogroup.get_UnorderedGroup())
12715
        regionrefs = list()
12716
        for elem in elements:
12717
            regionrefs.append(elem.get_regionRef())
12718
            if not isinstance(elem, (RegionRefType, RegionRefIndexedType)): # pylint: disable=undefined-variable
12719
                regionrefs.extend(self._get_recursive_reading_order(elem))
12720
        return regionrefs
12721
    
12722
    def get_AllRegions(self, classes=None, order='document', depth=0):
12723
        """
12724
        Get all the ``*Region`` elements, or only those provided by `classes`.
12725
        Return in document order, unless the top element is ``Page`` and
12726
        `order` is ``reading-order``.
12727
    
12728
        Arguments:
12729
            classes (list): Classes of regions that shall be returned, \
12730
                e.g. ``['Text', 'Image']``
12731
            order ("document"|"reading-order"|"reading-order-only"): Whether to \
12732
                return regions sorted by document order (``document``, default) or by
12733
                reading order with regions not in the reading order at the end of the
12734
                returned list (``reading-order``) or regions not in the reading order
12735
                omitted (``reading-order-only``). The latter two are only available
12736
                on page level.
12737
            depth (int): Recursive depth to look for regions at, set to `0` for \
12738
                all regions at any depth. Default: 0
12739
    
12740
        Returns:
12741
            a list of :py:class:`TextRegionType`, :py:class:`ImageRegionType`, \
12742
                :py:class:`LineDrawingRegionType`, :py:class:`GraphicRegionType`, \
12743
                :py:class:`TableRegionType`, :py:class:`ChartRegionType`, \
12744
                :py:class:`MapRegionType`, :py:class:`SeparatorRegionType`, \
12745
                :py:class:`MathsRegionType`, :py:class:`ChemRegionType`, \
12746
                :py:class:`MusicRegionType`, :py:class:`AdvertRegionType`, \
12747
                :py:class:`NoiseRegionType`, :py:class:`UnknownRegionType`, \
12748
                and/or :py:class:`CustomRegionType`
12749
    
12750
        For example, to get all text anywhere on the page in reading order, use:
12751
        ::
12752
            '\\n'.join(line.get_TextEquiv()[0].Unicode
12753
                      for region in page.get_AllRegions(classes=['Text'], depth=0, order='reading-order')
12754
                      for line in region.get_TextLine())
12755
        """
12756
        if order not in ['document', 'reading-order', 'reading-order-only']:
12757
            raise Exception("Argument 'order' must be either 'document', 'reading-order' or 'reading-order-only', not '{}'".format(order))
12758
        if depth < 0:
12759
            raise Exception("Argument 'depth' must be an integer greater-or-equal 0, not '{}'".format(depth))
12760
        ret = self._get_recursive_regions([self], depth + 1 if depth else 0, classes)
12761
        if self.__class__.__name__ == 'PageType' and order.startswith('reading-order'):
12762
            reading_order = self.get_ReadingOrder()
12763
            if reading_order:
12764
                reading_order = reading_order.get_OrderedGroup() or reading_order.get_UnorderedGroup()
12765
            if reading_order:
12766
                reading_order = self._get_recursive_reading_order(reading_order)
12767
            if reading_order:
12768
                id2region = {region.id: region for region in ret}
12769
                in_reading_order = [id2region[region_id] for region_id in reading_order if region_id in id2region]
12770
                #  print("ret: {} / in_ro: {} / not-in-ro: {}".format(
12771
                #      len(ret),
12772
                #      len([id2region[region_id] for region_id in reading_order if region_id in id2region]),
12773
                #      len([r for r in ret if r not in in_reading_order])
12774
                #      ))
12775
                if order == 'reading-order-only':
12776
                    ret = in_reading_order
12777
                else:
12778
                    ret = in_reading_order + [r for r in ret if r not in in_reading_order]
12779
        return ret
12780
    def set_orientation(self, orientation):
12781
        """
12782
        Set deskewing angle to given `orientation` number.
12783
        Moreover, invalidate self's ``pc:AlternativeImage``s
12784
        (because they will have been rotated and enlarged
12785
        with the angle of the previous value).
12786
        """
12787
        if hasattr(self, 'invalidate_AlternativeImage'):
12788
            # PageType, RegionType:
12789
            self.invalidate_AlternativeImage(feature_selector='deskewed')
12790
        self.orientation = orientation
12791
# end class AdvertRegionType
12792
12793
12794 View Code Duplication
class MusicRegionType(RegionType):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
12795
    """MusicRegionType --
12796
    Regions containing musical notations.
12797
      
12798
    * orientation --
12799
      The angle the rectangle encapsulating a region
12800
      has to be rotated in clockwise direction
12801
      in order to correct the present skew
12802
      (negative values indicate anti-clockwise rotation).
12803
      Range: -179.999,180
12804
      
12805
    * bgColour --
12806
      The background colour of the region
12807
    
12808
    """
12809
    __hash__ = GeneratedsSuper.__hash__
12810
    member_data_items_ = [
12811
        MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional', 'name': 'orientation'}),
12812
        MemberSpec_('bgColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional', 'name': 'bgColour'}),
12813
    ]
12814
    subclass = None
12815
    superclass = RegionType
12816
    def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, bgColour=None, gds_collector_=None, **kwargs_):
12817
        self.gds_collector_ = gds_collector_
12818
        self.gds_elementtree_node_ = None
12819
        self.original_tagname_ = None
12820
        self.parent_object_ = kwargs_.get('parent_object_')
12821
        self.ns_prefix_ = "pc"
12822
        super(globals().get("MusicRegionType"), self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion,  **kwargs_)
12823
        self.orientation = _cast(float, orientation)
12824
        self.orientation_nsprefix_ = "pc"
12825
        self.bgColour = _cast(None, bgColour)
12826
        self.bgColour_nsprefix_ = "pc"
12827
    def factory(*args_, **kwargs_):
12828
        if CurrentSubclassModule_ is not None:
12829
            subclass = getSubclassFromModule_(
12830
                CurrentSubclassModule_, MusicRegionType)
12831
            if subclass is not None:
12832
                return subclass(*args_, **kwargs_)
12833
        if MusicRegionType.subclass:
12834
            return MusicRegionType.subclass(*args_, **kwargs_)
12835
        else:
12836
            return MusicRegionType(*args_, **kwargs_)
12837
    factory = staticmethod(factory)
12838
    def get_ns_prefix_(self):
12839
        return self.ns_prefix_
12840
    def set_ns_prefix_(self, ns_prefix):
12841
        self.ns_prefix_ = ns_prefix
12842
    def get_orientation(self):
12843
        return self.orientation
12844
    def set_orientation(self, orientation):
12845
        self.orientation = orientation
12846
    def get_bgColour(self):
12847
        return self.bgColour
12848
    def set_bgColour(self, bgColour):
12849
        self.bgColour = bgColour
12850
    def validate_ColourSimpleType(self, value):
12851
        # Validate type pc:ColourSimpleType, a restriction on string.
12852
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
12853
            if not isinstance(value, str):
12854
                lineno = self.gds_get_node_lineno_()
12855
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
12856
                return False
12857
            value = value
12858
            enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other']
12859
            if value not in enumerations:
12860
                lineno = self.gds_get_node_lineno_()
12861
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ColourSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
12862
                result = False
12863
    def has__content(self):
12864
        if (
12865
            super(MusicRegionType, self).has__content()
12866
        ):
12867
            return True
12868
        else:
12869
            return False
12870
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='MusicRegionType', pretty_print=True):
12871
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('MusicRegionType')
12872
        if imported_ns_def_ is not None:
12873
            namespacedef_ = imported_ns_def_
12874
        if pretty_print:
12875
            eol_ = '\n'
12876
        else:
12877
            eol_ = ''
12878
        if self.original_tagname_ is not None and name_ == 'MusicRegionType':
12879
            name_ = self.original_tagname_
12880
        if UseCapturedNS_ and self.ns_prefix_:
12881
            namespaceprefix_ = self.ns_prefix_ + ':'
12882
        showIndent(outfile, level, pretty_print)
12883
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
12884
        already_processed = set()
12885
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='MusicRegionType')
12886
        if self.has__content():
12887
            outfile.write('>%s' % (eol_, ))
12888
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='MusicRegionType', pretty_print=pretty_print)
12889
            showIndent(outfile, level, pretty_print)
12890
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
12891
        else:
12892
            outfile.write('/>%s' % (eol_, ))
12893
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='MusicRegionType'):
12894
        super(MusicRegionType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='MusicRegionType')
12895
        if self.orientation is not None and 'orientation' not in already_processed:
12896
            already_processed.add('orientation')
12897
            outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation'))
12898
        if self.bgColour is not None and 'bgColour' not in already_processed:
12899
            already_processed.add('bgColour')
12900
            outfile.write(' bgColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.bgColour), input_name='bgColour')), ))
12901
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='MusicRegionType', fromsubclass_=False, pretty_print=True):
12902
        super(MusicRegionType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print)
12903
    def to_etree(self, parent_element=None, name_='MusicRegionType', mapping_=None, reverse_mapping_=None, nsmap_=None):
12904
        element = super(MusicRegionType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_)
12905
        if self.orientation is not None:
12906
            element.set('orientation', self.gds_format_float(self.orientation))
12907
        if self.bgColour is not None:
12908
            element.set('bgColour', self.gds_format_string(self.bgColour))
12909
        if mapping_ is not None:
12910
            mapping_[id(self)] = element
12911
        if reverse_mapping_ is not None:
12912
            reverse_mapping_[element] = self
12913
        return element
12914
    def build(self, node, gds_collector_=None):
12915
        self.gds_collector_ = gds_collector_
12916
        if SaveElementTreeNode:
12917
            self.gds_elementtree_node_ = node
12918
        already_processed = set()
12919
        self.ns_prefix_ = node.prefix
12920
        self._buildAttributes(node, node.attrib, already_processed)
12921
        for child in node:
12922
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
12923
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
12924
        return self
12925
    def _buildAttributes(self, node, attrs, already_processed):
12926
        value = find_attr_value_('orientation', node)
12927
        if value is not None and 'orientation' not in already_processed:
12928
            already_processed.add('orientation')
12929
            value = self.gds_parse_float(value, node, 'orientation')
12930
            self.orientation = value
12931
        value = find_attr_value_('bgColour', node)
12932
        if value is not None and 'bgColour' not in already_processed:
12933
            already_processed.add('bgColour')
12934
            self.bgColour = value
12935
            self.validate_ColourSimpleType(self.bgColour)    # validate type ColourSimpleType
12936
        super(MusicRegionType, self)._buildAttributes(node, attrs, already_processed)
12937
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
12938
        super(MusicRegionType, self)._buildChildren(child_, node, nodeName_, True)
12939
        pass
12940
    def __hash__(self):
12941
        return hash(self.id)
12942
    # pylint: disable=line-too-long,invalid-name,protected-access,missing-module-docstring
12943
    def _region_class(self, x): # pylint: disable=unused-argument
12944
        return x.__class__.__name__.replace('RegionType', '')
12945
    
12946
    def _get_recursive_regions(self, regions, level, classes=None):
12947
        from .constants import PAGE_REGION_TYPES  # pylint: disable=relative-beyond-top-level,import-outside-toplevel
12948
        if level == 1:
12949
            # stop recursion, filter classes
12950
            if classes:
12951
                return [r for r in regions if self._region_class(r) in classes]
12952
            if regions and regions[0].__class__.__name__ == 'PageType':
12953
                regions = regions[1:]
12954
            return regions
12955
        # find more regions recursively
12956
        more_regions = []
12957
        for region in regions:
12958
            more_regions.append([])
12959
            for class_ in PAGE_REGION_TYPES:
12960
                if class_ == 'Map' and not isinstance(region, PageType): # pylint: disable=undefined-variable
12961
                    # 'Map' is not recursive in 2019 schema
12962
                    continue
12963
                more_regions[-1] += getattr(region, 'get_{}Region'.format(class_))()
12964
        if not any(more_regions):
12965
            return self._get_recursive_regions(regions, 1, classes)
12966
        ret = []
12967
        for r, more in zip(regions, more_regions):
12968
            ret.append(r)
12969
            ret += self._get_recursive_regions(more, level - 1 if level else 0, classes)
12970
        return self._get_recursive_regions(ret, 1, classes)
12971
    
12972
    def _get_recursive_reading_order(self, rogroup):
12973
        if isinstance(rogroup, (OrderedGroupType, OrderedGroupIndexedType)): # pylint: disable=undefined-variable
12974
            elements = rogroup.get_AllIndexed()
12975
        if isinstance(rogroup, (UnorderedGroupType, UnorderedGroupIndexedType)): # pylint: disable=undefined-variable
12976
            elements = (rogroup.get_RegionRef() + rogroup.get_OrderedGroup() + rogroup.get_UnorderedGroup())
12977
        regionrefs = list()
12978
        for elem in elements:
12979
            regionrefs.append(elem.get_regionRef())
12980
            if not isinstance(elem, (RegionRefType, RegionRefIndexedType)): # pylint: disable=undefined-variable
12981
                regionrefs.extend(self._get_recursive_reading_order(elem))
12982
        return regionrefs
12983
    
12984
    def get_AllRegions(self, classes=None, order='document', depth=0):
12985
        """
12986
        Get all the ``*Region`` elements, or only those provided by `classes`.
12987
        Return in document order, unless the top element is ``Page`` and
12988
        `order` is ``reading-order``.
12989
    
12990
        Arguments:
12991
            classes (list): Classes of regions that shall be returned, \
12992
                e.g. ``['Text', 'Image']``
12993
            order ("document"|"reading-order"|"reading-order-only"): Whether to \
12994
                return regions sorted by document order (``document``, default) or by
12995
                reading order with regions not in the reading order at the end of the
12996
                returned list (``reading-order``) or regions not in the reading order
12997
                omitted (``reading-order-only``). The latter two are only available
12998
                on page level.
12999
            depth (int): Recursive depth to look for regions at, set to `0` for \
13000
                all regions at any depth. Default: 0
13001
    
13002
        Returns:
13003
            a list of :py:class:`TextRegionType`, :py:class:`ImageRegionType`, \
13004
                :py:class:`LineDrawingRegionType`, :py:class:`GraphicRegionType`, \
13005
                :py:class:`TableRegionType`, :py:class:`ChartRegionType`, \
13006
                :py:class:`MapRegionType`, :py:class:`SeparatorRegionType`, \
13007
                :py:class:`MathsRegionType`, :py:class:`ChemRegionType`, \
13008
                :py:class:`MusicRegionType`, :py:class:`AdvertRegionType`, \
13009
                :py:class:`NoiseRegionType`, :py:class:`UnknownRegionType`, \
13010
                and/or :py:class:`CustomRegionType`
13011
    
13012
        For example, to get all text anywhere on the page in reading order, use:
13013
        ::
13014
            '\\n'.join(line.get_TextEquiv()[0].Unicode
13015
                      for region in page.get_AllRegions(classes=['Text'], depth=0, order='reading-order')
13016
                      for line in region.get_TextLine())
13017
        """
13018
        if order not in ['document', 'reading-order', 'reading-order-only']:
13019
            raise Exception("Argument 'order' must be either 'document', 'reading-order' or 'reading-order-only', not '{}'".format(order))
13020
        if depth < 0:
13021
            raise Exception("Argument 'depth' must be an integer greater-or-equal 0, not '{}'".format(depth))
13022
        ret = self._get_recursive_regions([self], depth + 1 if depth else 0, classes)
13023
        if self.__class__.__name__ == 'PageType' and order.startswith('reading-order'):
13024
            reading_order = self.get_ReadingOrder()
13025
            if reading_order:
13026
                reading_order = reading_order.get_OrderedGroup() or reading_order.get_UnorderedGroup()
13027
            if reading_order:
13028
                reading_order = self._get_recursive_reading_order(reading_order)
13029
            if reading_order:
13030
                id2region = {region.id: region for region in ret}
13031
                in_reading_order = [id2region[region_id] for region_id in reading_order if region_id in id2region]
13032
                #  print("ret: {} / in_ro: {} / not-in-ro: {}".format(
13033
                #      len(ret),
13034
                #      len([id2region[region_id] for region_id in reading_order if region_id in id2region]),
13035
                #      len([r for r in ret if r not in in_reading_order])
13036
                #      ))
13037
                if order == 'reading-order-only':
13038
                    ret = in_reading_order
13039
                else:
13040
                    ret = in_reading_order + [r for r in ret if r not in in_reading_order]
13041
        return ret
13042
    def set_orientation(self, orientation):
13043
        """
13044
        Set deskewing angle to given `orientation` number.
13045
        Moreover, invalidate self's ``pc:AlternativeImage``s
13046
        (because they will have been rotated and enlarged
13047
        with the angle of the previous value).
13048
        """
13049
        if hasattr(self, 'invalidate_AlternativeImage'):
13050
            # PageType, RegionType:
13051
            self.invalidate_AlternativeImage(feature_selector='deskewed')
13052
        self.orientation = orientation
13053
# end class MusicRegionType
13054
13055
13056
class MapRegionType(RegionType):
13057
    """MapRegionType --
13058
    Regions containing maps.
13059
      
13060
    * orientation --
13061
      The angle the rectangle encapsulating a
13062
      region has to be rotated in clockwise
13063
      direction in order to correct the present
13064
      skew (negative values indicate
13065
      anti-clockwise rotation). Range:
13066
      -179.999,180
13067
    
13068
    """
13069
    __hash__ = GeneratedsSuper.__hash__
13070
    member_data_items_ = [
13071
        MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional', 'name': 'orientation'}),
13072
    ]
13073
    subclass = None
13074
    superclass = RegionType
13075
    def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, gds_collector_=None, **kwargs_):
13076
        self.gds_collector_ = gds_collector_
13077
        self.gds_elementtree_node_ = None
13078
        self.original_tagname_ = None
13079
        self.parent_object_ = kwargs_.get('parent_object_')
13080
        self.ns_prefix_ = "pc"
13081
        super(globals().get("MapRegionType"), self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion,  **kwargs_)
13082
        self.orientation = _cast(float, orientation)
13083
        self.orientation_nsprefix_ = "pc"
13084
    def factory(*args_, **kwargs_):
13085
        if CurrentSubclassModule_ is not None:
13086
            subclass = getSubclassFromModule_(
13087
                CurrentSubclassModule_, MapRegionType)
13088
            if subclass is not None:
13089
                return subclass(*args_, **kwargs_)
13090
        if MapRegionType.subclass:
13091
            return MapRegionType.subclass(*args_, **kwargs_)
13092
        else:
13093
            return MapRegionType(*args_, **kwargs_)
13094
    factory = staticmethod(factory)
13095
    def get_ns_prefix_(self):
13096
        return self.ns_prefix_
13097
    def set_ns_prefix_(self, ns_prefix):
13098
        self.ns_prefix_ = ns_prefix
13099
    def get_orientation(self):
13100
        return self.orientation
13101
    def set_orientation(self, orientation):
13102
        self.orientation = orientation
13103
    def has__content(self):
13104
        if (
13105
            super(MapRegionType, self).has__content()
13106
        ):
13107
            return True
13108
        else:
13109
            return False
13110
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='MapRegionType', pretty_print=True):
13111
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('MapRegionType')
13112
        if imported_ns_def_ is not None:
13113
            namespacedef_ = imported_ns_def_
13114
        if pretty_print:
13115
            eol_ = '\n'
13116
        else:
13117
            eol_ = ''
13118
        if self.original_tagname_ is not None and name_ == 'MapRegionType':
13119
            name_ = self.original_tagname_
13120
        if UseCapturedNS_ and self.ns_prefix_:
13121
            namespaceprefix_ = self.ns_prefix_ + ':'
13122
        showIndent(outfile, level, pretty_print)
13123
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
13124
        already_processed = set()
13125
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='MapRegionType')
13126
        if self.has__content():
13127
            outfile.write('>%s' % (eol_, ))
13128
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='MapRegionType', pretty_print=pretty_print)
13129
            showIndent(outfile, level, pretty_print)
13130
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
13131
        else:
13132
            outfile.write('/>%s' % (eol_, ))
13133
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='MapRegionType'):
13134
        super(MapRegionType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='MapRegionType')
13135
        if self.orientation is not None and 'orientation' not in already_processed:
13136
            already_processed.add('orientation')
13137
            outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation'))
13138
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='MapRegionType', fromsubclass_=False, pretty_print=True):
13139
        super(MapRegionType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print)
13140
    def to_etree(self, parent_element=None, name_='MapRegionType', mapping_=None, reverse_mapping_=None, nsmap_=None):
13141
        element = super(MapRegionType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_)
13142
        if self.orientation is not None:
13143
            element.set('orientation', self.gds_format_float(self.orientation))
13144
        if mapping_ is not None:
13145
            mapping_[id(self)] = element
13146
        if reverse_mapping_ is not None:
13147
            reverse_mapping_[element] = self
13148
        return element
13149
    def build(self, node, gds_collector_=None):
13150
        self.gds_collector_ = gds_collector_
13151
        if SaveElementTreeNode:
13152
            self.gds_elementtree_node_ = node
13153
        already_processed = set()
13154
        self.ns_prefix_ = node.prefix
13155
        self._buildAttributes(node, node.attrib, already_processed)
13156
        for child in node:
13157
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
13158
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
13159
        return self
13160
    def _buildAttributes(self, node, attrs, already_processed):
13161
        value = find_attr_value_('orientation', node)
13162
        if value is not None and 'orientation' not in already_processed:
13163
            already_processed.add('orientation')
13164
            value = self.gds_parse_float(value, node, 'orientation')
13165
            self.orientation = value
13166
        super(MapRegionType, self)._buildAttributes(node, attrs, already_processed)
13167
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
13168
        super(MapRegionType, self)._buildChildren(child_, node, nodeName_, True)
13169
        pass
13170
    def __hash__(self):
13171
        return hash(self.id)
13172
    # pylint: disable=line-too-long,invalid-name,protected-access,missing-module-docstring
13173
    def _region_class(self, x): # pylint: disable=unused-argument
13174
        return x.__class__.__name__.replace('RegionType', '')
13175
    
13176
    def _get_recursive_regions(self, regions, level, classes=None):
13177
        from .constants import PAGE_REGION_TYPES  # pylint: disable=relative-beyond-top-level,import-outside-toplevel
13178
        if level == 1:
13179
            # stop recursion, filter classes
13180
            if classes:
13181
                return [r for r in regions if self._region_class(r) in classes]
13182
            if regions and regions[0].__class__.__name__ == 'PageType':
13183
                regions = regions[1:]
13184
            return regions
13185
        # find more regions recursively
13186
        more_regions = []
13187
        for region in regions:
13188
            more_regions.append([])
13189
            for class_ in PAGE_REGION_TYPES:
13190
                if class_ == 'Map' and not isinstance(region, PageType): # pylint: disable=undefined-variable
13191
                    # 'Map' is not recursive in 2019 schema
13192
                    continue
13193
                more_regions[-1] += getattr(region, 'get_{}Region'.format(class_))()
13194
        if not any(more_regions):
13195
            return self._get_recursive_regions(regions, 1, classes)
13196
        ret = []
13197
        for r, more in zip(regions, more_regions):
13198
            ret.append(r)
13199
            ret += self._get_recursive_regions(more, level - 1 if level else 0, classes)
13200
        return self._get_recursive_regions(ret, 1, classes)
13201
    
13202
    def _get_recursive_reading_order(self, rogroup):
13203
        if isinstance(rogroup, (OrderedGroupType, OrderedGroupIndexedType)): # pylint: disable=undefined-variable
13204
            elements = rogroup.get_AllIndexed()
13205
        if isinstance(rogroup, (UnorderedGroupType, UnorderedGroupIndexedType)): # pylint: disable=undefined-variable
13206
            elements = (rogroup.get_RegionRef() + rogroup.get_OrderedGroup() + rogroup.get_UnorderedGroup())
13207
        regionrefs = list()
13208
        for elem in elements:
13209
            regionrefs.append(elem.get_regionRef())
13210
            if not isinstance(elem, (RegionRefType, RegionRefIndexedType)): # pylint: disable=undefined-variable
13211
                regionrefs.extend(self._get_recursive_reading_order(elem))
13212
        return regionrefs
13213
    
13214
    def get_AllRegions(self, classes=None, order='document', depth=0):
13215
        """
13216
        Get all the ``*Region`` elements, or only those provided by `classes`.
13217
        Return in document order, unless the top element is ``Page`` and
13218
        `order` is ``reading-order``.
13219
    
13220
        Arguments:
13221
            classes (list): Classes of regions that shall be returned, \
13222
                e.g. ``['Text', 'Image']``
13223
            order ("document"|"reading-order"|"reading-order-only"): Whether to \
13224
                return regions sorted by document order (``document``, default) or by
13225
                reading order with regions not in the reading order at the end of the
13226
                returned list (``reading-order``) or regions not in the reading order
13227
                omitted (``reading-order-only``). The latter two are only available
13228
                on page level.
13229
            depth (int): Recursive depth to look for regions at, set to `0` for \
13230
                all regions at any depth. Default: 0
13231
    
13232
        Returns:
13233
            a list of :py:class:`TextRegionType`, :py:class:`ImageRegionType`, \
13234
                :py:class:`LineDrawingRegionType`, :py:class:`GraphicRegionType`, \
13235
                :py:class:`TableRegionType`, :py:class:`ChartRegionType`, \
13236
                :py:class:`MapRegionType`, :py:class:`SeparatorRegionType`, \
13237
                :py:class:`MathsRegionType`, :py:class:`ChemRegionType`, \
13238
                :py:class:`MusicRegionType`, :py:class:`AdvertRegionType`, \
13239
                :py:class:`NoiseRegionType`, :py:class:`UnknownRegionType`, \
13240
                and/or :py:class:`CustomRegionType`
13241
    
13242
        For example, to get all text anywhere on the page in reading order, use:
13243
        ::
13244
            '\\n'.join(line.get_TextEquiv()[0].Unicode
13245
                      for region in page.get_AllRegions(classes=['Text'], depth=0, order='reading-order')
13246
                      for line in region.get_TextLine())
13247
        """
13248
        if order not in ['document', 'reading-order', 'reading-order-only']:
13249
            raise Exception("Argument 'order' must be either 'document', 'reading-order' or 'reading-order-only', not '{}'".format(order))
13250
        if depth < 0:
13251
            raise Exception("Argument 'depth' must be an integer greater-or-equal 0, not '{}'".format(depth))
13252
        ret = self._get_recursive_regions([self], depth + 1 if depth else 0, classes)
13253
        if self.__class__.__name__ == 'PageType' and order.startswith('reading-order'):
13254
            reading_order = self.get_ReadingOrder()
13255
            if reading_order:
13256
                reading_order = reading_order.get_OrderedGroup() or reading_order.get_UnorderedGroup()
13257
            if reading_order:
13258
                reading_order = self._get_recursive_reading_order(reading_order)
13259
            if reading_order:
13260
                id2region = {region.id: region for region in ret}
13261
                in_reading_order = [id2region[region_id] for region_id in reading_order if region_id in id2region]
13262
                #  print("ret: {} / in_ro: {} / not-in-ro: {}".format(
13263
                #      len(ret),
13264
                #      len([id2region[region_id] for region_id in reading_order if region_id in id2region]),
13265
                #      len([r for r in ret if r not in in_reading_order])
13266
                #      ))
13267
                if order == 'reading-order-only':
13268
                    ret = in_reading_order
13269
                else:
13270
                    ret = in_reading_order + [r for r in ret if r not in in_reading_order]
13271
        return ret
13272
    def set_orientation(self, orientation):
13273
        """
13274
        Set deskewing angle to given `orientation` number.
13275
        Moreover, invalidate self's ``pc:AlternativeImage``s
13276
        (because they will have been rotated and enlarged
13277
        with the angle of the previous value).
13278
        """
13279
        if hasattr(self, 'invalidate_AlternativeImage'):
13280
            # PageType, RegionType:
13281
            self.invalidate_AlternativeImage(feature_selector='deskewed')
13282
        self.orientation = orientation
13283
# end class MapRegionType
13284
13285
13286 View Code Duplication
class ChemRegionType(RegionType):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
13287
    """ChemRegionType --
13288
    Regions containing chemical formulas.
13289
      
13290
    * orientation --
13291
      The angle the rectangle encapsulating a
13292
      region has to be rotated in clockwise
13293
      direction in order to correct the present
13294
      skew (negative values indicate
13295
      anti-clockwise rotation). Range:
13296
      -179.999,180
13297
      
13298
    * bgColour --
13299
      The background colour of the region
13300
    
13301
    """
13302
    __hash__ = GeneratedsSuper.__hash__
13303
    member_data_items_ = [
13304
        MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional', 'name': 'orientation'}),
13305
        MemberSpec_('bgColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional', 'name': 'bgColour'}),
13306
    ]
13307
    subclass = None
13308
    superclass = RegionType
13309
    def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, bgColour=None, gds_collector_=None, **kwargs_):
13310
        self.gds_collector_ = gds_collector_
13311
        self.gds_elementtree_node_ = None
13312
        self.original_tagname_ = None
13313
        self.parent_object_ = kwargs_.get('parent_object_')
13314
        self.ns_prefix_ = "pc"
13315
        super(globals().get("ChemRegionType"), self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion,  **kwargs_)
13316
        self.orientation = _cast(float, orientation)
13317
        self.orientation_nsprefix_ = "pc"
13318
        self.bgColour = _cast(None, bgColour)
13319
        self.bgColour_nsprefix_ = "pc"
13320
    def factory(*args_, **kwargs_):
13321
        if CurrentSubclassModule_ is not None:
13322
            subclass = getSubclassFromModule_(
13323
                CurrentSubclassModule_, ChemRegionType)
13324
            if subclass is not None:
13325
                return subclass(*args_, **kwargs_)
13326
        if ChemRegionType.subclass:
13327
            return ChemRegionType.subclass(*args_, **kwargs_)
13328
        else:
13329
            return ChemRegionType(*args_, **kwargs_)
13330
    factory = staticmethod(factory)
13331
    def get_ns_prefix_(self):
13332
        return self.ns_prefix_
13333
    def set_ns_prefix_(self, ns_prefix):
13334
        self.ns_prefix_ = ns_prefix
13335
    def get_orientation(self):
13336
        return self.orientation
13337
    def set_orientation(self, orientation):
13338
        self.orientation = orientation
13339
    def get_bgColour(self):
13340
        return self.bgColour
13341
    def set_bgColour(self, bgColour):
13342
        self.bgColour = bgColour
13343
    def validate_ColourSimpleType(self, value):
13344
        # Validate type pc:ColourSimpleType, a restriction on string.
13345
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
13346
            if not isinstance(value, str):
13347
                lineno = self.gds_get_node_lineno_()
13348
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
13349
                return False
13350
            value = value
13351
            enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other']
13352
            if value not in enumerations:
13353
                lineno = self.gds_get_node_lineno_()
13354
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ColourSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
13355
                result = False
13356
    def has__content(self):
13357
        if (
13358
            super(ChemRegionType, self).has__content()
13359
        ):
13360
            return True
13361
        else:
13362
            return False
13363
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='ChemRegionType', pretty_print=True):
13364
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('ChemRegionType')
13365
        if imported_ns_def_ is not None:
13366
            namespacedef_ = imported_ns_def_
13367
        if pretty_print:
13368
            eol_ = '\n'
13369
        else:
13370
            eol_ = ''
13371
        if self.original_tagname_ is not None and name_ == 'ChemRegionType':
13372
            name_ = self.original_tagname_
13373
        if UseCapturedNS_ and self.ns_prefix_:
13374
            namespaceprefix_ = self.ns_prefix_ + ':'
13375
        showIndent(outfile, level, pretty_print)
13376
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
13377
        already_processed = set()
13378
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='ChemRegionType')
13379
        if self.has__content():
13380
            outfile.write('>%s' % (eol_, ))
13381
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='ChemRegionType', pretty_print=pretty_print)
13382
            showIndent(outfile, level, pretty_print)
13383
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
13384
        else:
13385
            outfile.write('/>%s' % (eol_, ))
13386
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='ChemRegionType'):
13387
        super(ChemRegionType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='ChemRegionType')
13388
        if self.orientation is not None and 'orientation' not in already_processed:
13389
            already_processed.add('orientation')
13390
            outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation'))
13391
        if self.bgColour is not None and 'bgColour' not in already_processed:
13392
            already_processed.add('bgColour')
13393
            outfile.write(' bgColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.bgColour), input_name='bgColour')), ))
13394
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='ChemRegionType', fromsubclass_=False, pretty_print=True):
13395
        super(ChemRegionType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print)
13396
    def to_etree(self, parent_element=None, name_='ChemRegionType', mapping_=None, reverse_mapping_=None, nsmap_=None):
13397
        element = super(ChemRegionType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_)
13398
        if self.orientation is not None:
13399
            element.set('orientation', self.gds_format_float(self.orientation))
13400
        if self.bgColour is not None:
13401
            element.set('bgColour', self.gds_format_string(self.bgColour))
13402
        if mapping_ is not None:
13403
            mapping_[id(self)] = element
13404
        if reverse_mapping_ is not None:
13405
            reverse_mapping_[element] = self
13406
        return element
13407
    def build(self, node, gds_collector_=None):
13408
        self.gds_collector_ = gds_collector_
13409
        if SaveElementTreeNode:
13410
            self.gds_elementtree_node_ = node
13411
        already_processed = set()
13412
        self.ns_prefix_ = node.prefix
13413
        self._buildAttributes(node, node.attrib, already_processed)
13414
        for child in node:
13415
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
13416
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
13417
        return self
13418
    def _buildAttributes(self, node, attrs, already_processed):
13419
        value = find_attr_value_('orientation', node)
13420
        if value is not None and 'orientation' not in already_processed:
13421
            already_processed.add('orientation')
13422
            value = self.gds_parse_float(value, node, 'orientation')
13423
            self.orientation = value
13424
        value = find_attr_value_('bgColour', node)
13425
        if value is not None and 'bgColour' not in already_processed:
13426
            already_processed.add('bgColour')
13427
            self.bgColour = value
13428
            self.validate_ColourSimpleType(self.bgColour)    # validate type ColourSimpleType
13429
        super(ChemRegionType, self)._buildAttributes(node, attrs, already_processed)
13430
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
13431
        super(ChemRegionType, self)._buildChildren(child_, node, nodeName_, True)
13432
        pass
13433
    def __hash__(self):
13434
        return hash(self.id)
13435
    # pylint: disable=line-too-long,invalid-name,protected-access,missing-module-docstring
13436
    def _region_class(self, x): # pylint: disable=unused-argument
13437
        return x.__class__.__name__.replace('RegionType', '')
13438
    
13439
    def _get_recursive_regions(self, regions, level, classes=None):
13440
        from .constants import PAGE_REGION_TYPES  # pylint: disable=relative-beyond-top-level,import-outside-toplevel
13441
        if level == 1:
13442
            # stop recursion, filter classes
13443
            if classes:
13444
                return [r for r in regions if self._region_class(r) in classes]
13445
            if regions and regions[0].__class__.__name__ == 'PageType':
13446
                regions = regions[1:]
13447
            return regions
13448
        # find more regions recursively
13449
        more_regions = []
13450
        for region in regions:
13451
            more_regions.append([])
13452
            for class_ in PAGE_REGION_TYPES:
13453
                if class_ == 'Map' and not isinstance(region, PageType): # pylint: disable=undefined-variable
13454
                    # 'Map' is not recursive in 2019 schema
13455
                    continue
13456
                more_regions[-1] += getattr(region, 'get_{}Region'.format(class_))()
13457
        if not any(more_regions):
13458
            return self._get_recursive_regions(regions, 1, classes)
13459
        ret = []
13460
        for r, more in zip(regions, more_regions):
13461
            ret.append(r)
13462
            ret += self._get_recursive_regions(more, level - 1 if level else 0, classes)
13463
        return self._get_recursive_regions(ret, 1, classes)
13464
    
13465
    def _get_recursive_reading_order(self, rogroup):
13466
        if isinstance(rogroup, (OrderedGroupType, OrderedGroupIndexedType)): # pylint: disable=undefined-variable
13467
            elements = rogroup.get_AllIndexed()
13468
        if isinstance(rogroup, (UnorderedGroupType, UnorderedGroupIndexedType)): # pylint: disable=undefined-variable
13469
            elements = (rogroup.get_RegionRef() + rogroup.get_OrderedGroup() + rogroup.get_UnorderedGroup())
13470
        regionrefs = list()
13471
        for elem in elements:
13472
            regionrefs.append(elem.get_regionRef())
13473
            if not isinstance(elem, (RegionRefType, RegionRefIndexedType)): # pylint: disable=undefined-variable
13474
                regionrefs.extend(self._get_recursive_reading_order(elem))
13475
        return regionrefs
13476
    
13477
    def get_AllRegions(self, classes=None, order='document', depth=0):
13478
        """
13479
        Get all the ``*Region`` elements, or only those provided by `classes`.
13480
        Return in document order, unless the top element is ``Page`` and
13481
        `order` is ``reading-order``.
13482
    
13483
        Arguments:
13484
            classes (list): Classes of regions that shall be returned, \
13485
                e.g. ``['Text', 'Image']``
13486
            order ("document"|"reading-order"|"reading-order-only"): Whether to \
13487
                return regions sorted by document order (``document``, default) or by
13488
                reading order with regions not in the reading order at the end of the
13489
                returned list (``reading-order``) or regions not in the reading order
13490
                omitted (``reading-order-only``). The latter two are only available
13491
                on page level.
13492
            depth (int): Recursive depth to look for regions at, set to `0` for \
13493
                all regions at any depth. Default: 0
13494
    
13495
        Returns:
13496
            a list of :py:class:`TextRegionType`, :py:class:`ImageRegionType`, \
13497
                :py:class:`LineDrawingRegionType`, :py:class:`GraphicRegionType`, \
13498
                :py:class:`TableRegionType`, :py:class:`ChartRegionType`, \
13499
                :py:class:`MapRegionType`, :py:class:`SeparatorRegionType`, \
13500
                :py:class:`MathsRegionType`, :py:class:`ChemRegionType`, \
13501
                :py:class:`MusicRegionType`, :py:class:`AdvertRegionType`, \
13502
                :py:class:`NoiseRegionType`, :py:class:`UnknownRegionType`, \
13503
                and/or :py:class:`CustomRegionType`
13504
    
13505
        For example, to get all text anywhere on the page in reading order, use:
13506
        ::
13507
            '\\n'.join(line.get_TextEquiv()[0].Unicode
13508
                      for region in page.get_AllRegions(classes=['Text'], depth=0, order='reading-order')
13509
                      for line in region.get_TextLine())
13510
        """
13511
        if order not in ['document', 'reading-order', 'reading-order-only']:
13512
            raise Exception("Argument 'order' must be either 'document', 'reading-order' or 'reading-order-only', not '{}'".format(order))
13513
        if depth < 0:
13514
            raise Exception("Argument 'depth' must be an integer greater-or-equal 0, not '{}'".format(depth))
13515
        ret = self._get_recursive_regions([self], depth + 1 if depth else 0, classes)
13516
        if self.__class__.__name__ == 'PageType' and order.startswith('reading-order'):
13517
            reading_order = self.get_ReadingOrder()
13518
            if reading_order:
13519
                reading_order = reading_order.get_OrderedGroup() or reading_order.get_UnorderedGroup()
13520
            if reading_order:
13521
                reading_order = self._get_recursive_reading_order(reading_order)
13522
            if reading_order:
13523
                id2region = {region.id: region for region in ret}
13524
                in_reading_order = [id2region[region_id] for region_id in reading_order if region_id in id2region]
13525
                #  print("ret: {} / in_ro: {} / not-in-ro: {}".format(
13526
                #      len(ret),
13527
                #      len([id2region[region_id] for region_id in reading_order if region_id in id2region]),
13528
                #      len([r for r in ret if r not in in_reading_order])
13529
                #      ))
13530
                if order == 'reading-order-only':
13531
                    ret = in_reading_order
13532
                else:
13533
                    ret = in_reading_order + [r for r in ret if r not in in_reading_order]
13534
        return ret
13535
    def set_orientation(self, orientation):
13536
        """
13537
        Set deskewing angle to given `orientation` number.
13538
        Moreover, invalidate self's ``pc:AlternativeImage``s
13539
        (because they will have been rotated and enlarged
13540
        with the angle of the previous value).
13541
        """
13542
        if hasattr(self, 'invalidate_AlternativeImage'):
13543
            # PageType, RegionType:
13544
            self.invalidate_AlternativeImage(feature_selector='deskewed')
13545
        self.orientation = orientation
13546
# end class ChemRegionType
13547
13548
13549 View Code Duplication
class MathsRegionType(RegionType):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
13550
    """MathsRegionType --
13551
    Regions containing equations and mathematical symbols
13552
    should be marked as maths regions.
13553
      
13554
    * orientation --
13555
      The angle the rectangle encapsulating a region
13556
      has to be rotated in clockwise direction
13557
      in order to correct the present skew
13558
      (negative values indicate anti-clockwise rotation).
13559
      Range: -179.999,180
13560
      
13561
    * bgColour --
13562
      The background colour of the region
13563
    
13564
    """
13565
    __hash__ = GeneratedsSuper.__hash__
13566
    member_data_items_ = [
13567
        MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional', 'name': 'orientation'}),
13568
        MemberSpec_('bgColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional', 'name': 'bgColour'}),
13569
    ]
13570
    subclass = None
13571
    superclass = RegionType
13572
    def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, bgColour=None, gds_collector_=None, **kwargs_):
13573
        self.gds_collector_ = gds_collector_
13574
        self.gds_elementtree_node_ = None
13575
        self.original_tagname_ = None
13576
        self.parent_object_ = kwargs_.get('parent_object_')
13577
        self.ns_prefix_ = "pc"
13578
        super(globals().get("MathsRegionType"), self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion,  **kwargs_)
13579
        self.orientation = _cast(float, orientation)
13580
        self.orientation_nsprefix_ = "pc"
13581
        self.bgColour = _cast(None, bgColour)
13582
        self.bgColour_nsprefix_ = "pc"
13583
    def factory(*args_, **kwargs_):
13584
        if CurrentSubclassModule_ is not None:
13585
            subclass = getSubclassFromModule_(
13586
                CurrentSubclassModule_, MathsRegionType)
13587
            if subclass is not None:
13588
                return subclass(*args_, **kwargs_)
13589
        if MathsRegionType.subclass:
13590
            return MathsRegionType.subclass(*args_, **kwargs_)
13591
        else:
13592
            return MathsRegionType(*args_, **kwargs_)
13593
    factory = staticmethod(factory)
13594
    def get_ns_prefix_(self):
13595
        return self.ns_prefix_
13596
    def set_ns_prefix_(self, ns_prefix):
13597
        self.ns_prefix_ = ns_prefix
13598
    def get_orientation(self):
13599
        return self.orientation
13600
    def set_orientation(self, orientation):
13601
        self.orientation = orientation
13602
    def get_bgColour(self):
13603
        return self.bgColour
13604
    def set_bgColour(self, bgColour):
13605
        self.bgColour = bgColour
13606
    def validate_ColourSimpleType(self, value):
13607
        # Validate type pc:ColourSimpleType, a restriction on string.
13608
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
13609
            if not isinstance(value, str):
13610
                lineno = self.gds_get_node_lineno_()
13611
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
13612
                return False
13613
            value = value
13614
            enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other']
13615
            if value not in enumerations:
13616
                lineno = self.gds_get_node_lineno_()
13617
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ColourSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
13618
                result = False
13619
    def has__content(self):
13620
        if (
13621
            super(MathsRegionType, self).has__content()
13622
        ):
13623
            return True
13624
        else:
13625
            return False
13626
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='MathsRegionType', pretty_print=True):
13627
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('MathsRegionType')
13628
        if imported_ns_def_ is not None:
13629
            namespacedef_ = imported_ns_def_
13630
        if pretty_print:
13631
            eol_ = '\n'
13632
        else:
13633
            eol_ = ''
13634
        if self.original_tagname_ is not None and name_ == 'MathsRegionType':
13635
            name_ = self.original_tagname_
13636
        if UseCapturedNS_ and self.ns_prefix_:
13637
            namespaceprefix_ = self.ns_prefix_ + ':'
13638
        showIndent(outfile, level, pretty_print)
13639
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
13640
        already_processed = set()
13641
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='MathsRegionType')
13642
        if self.has__content():
13643
            outfile.write('>%s' % (eol_, ))
13644
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='MathsRegionType', pretty_print=pretty_print)
13645
            showIndent(outfile, level, pretty_print)
13646
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
13647
        else:
13648
            outfile.write('/>%s' % (eol_, ))
13649
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='MathsRegionType'):
13650
        super(MathsRegionType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='MathsRegionType')
13651
        if self.orientation is not None and 'orientation' not in already_processed:
13652
            already_processed.add('orientation')
13653
            outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation'))
13654
        if self.bgColour is not None and 'bgColour' not in already_processed:
13655
            already_processed.add('bgColour')
13656
            outfile.write(' bgColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.bgColour), input_name='bgColour')), ))
13657
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='MathsRegionType', fromsubclass_=False, pretty_print=True):
13658
        super(MathsRegionType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print)
13659
    def to_etree(self, parent_element=None, name_='MathsRegionType', mapping_=None, reverse_mapping_=None, nsmap_=None):
13660
        element = super(MathsRegionType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_)
13661
        if self.orientation is not None:
13662
            element.set('orientation', self.gds_format_float(self.orientation))
13663
        if self.bgColour is not None:
13664
            element.set('bgColour', self.gds_format_string(self.bgColour))
13665
        if mapping_ is not None:
13666
            mapping_[id(self)] = element
13667
        if reverse_mapping_ is not None:
13668
            reverse_mapping_[element] = self
13669
        return element
13670
    def build(self, node, gds_collector_=None):
13671
        self.gds_collector_ = gds_collector_
13672
        if SaveElementTreeNode:
13673
            self.gds_elementtree_node_ = node
13674
        already_processed = set()
13675
        self.ns_prefix_ = node.prefix
13676
        self._buildAttributes(node, node.attrib, already_processed)
13677
        for child in node:
13678
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
13679
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
13680
        return self
13681
    def _buildAttributes(self, node, attrs, already_processed):
13682
        value = find_attr_value_('orientation', node)
13683
        if value is not None and 'orientation' not in already_processed:
13684
            already_processed.add('orientation')
13685
            value = self.gds_parse_float(value, node, 'orientation')
13686
            self.orientation = value
13687
        value = find_attr_value_('bgColour', node)
13688
        if value is not None and 'bgColour' not in already_processed:
13689
            already_processed.add('bgColour')
13690
            self.bgColour = value
13691
            self.validate_ColourSimpleType(self.bgColour)    # validate type ColourSimpleType
13692
        super(MathsRegionType, self)._buildAttributes(node, attrs, already_processed)
13693
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
13694
        super(MathsRegionType, self)._buildChildren(child_, node, nodeName_, True)
13695
        pass
13696
    def __hash__(self):
13697
        return hash(self.id)
13698
    # pylint: disable=line-too-long,invalid-name,protected-access,missing-module-docstring
13699
    def _region_class(self, x): # pylint: disable=unused-argument
13700
        return x.__class__.__name__.replace('RegionType', '')
13701
    
13702
    def _get_recursive_regions(self, regions, level, classes=None):
13703
        from .constants import PAGE_REGION_TYPES  # pylint: disable=relative-beyond-top-level,import-outside-toplevel
13704
        if level == 1:
13705
            # stop recursion, filter classes
13706
            if classes:
13707
                return [r for r in regions if self._region_class(r) in classes]
13708
            if regions and regions[0].__class__.__name__ == 'PageType':
13709
                regions = regions[1:]
13710
            return regions
13711
        # find more regions recursively
13712
        more_regions = []
13713
        for region in regions:
13714
            more_regions.append([])
13715
            for class_ in PAGE_REGION_TYPES:
13716
                if class_ == 'Map' and not isinstance(region, PageType): # pylint: disable=undefined-variable
13717
                    # 'Map' is not recursive in 2019 schema
13718
                    continue
13719
                more_regions[-1] += getattr(region, 'get_{}Region'.format(class_))()
13720
        if not any(more_regions):
13721
            return self._get_recursive_regions(regions, 1, classes)
13722
        ret = []
13723
        for r, more in zip(regions, more_regions):
13724
            ret.append(r)
13725
            ret += self._get_recursive_regions(more, level - 1 if level else 0, classes)
13726
        return self._get_recursive_regions(ret, 1, classes)
13727
    
13728
    def _get_recursive_reading_order(self, rogroup):
13729
        if isinstance(rogroup, (OrderedGroupType, OrderedGroupIndexedType)): # pylint: disable=undefined-variable
13730
            elements = rogroup.get_AllIndexed()
13731
        if isinstance(rogroup, (UnorderedGroupType, UnorderedGroupIndexedType)): # pylint: disable=undefined-variable
13732
            elements = (rogroup.get_RegionRef() + rogroup.get_OrderedGroup() + rogroup.get_UnorderedGroup())
13733
        regionrefs = list()
13734
        for elem in elements:
13735
            regionrefs.append(elem.get_regionRef())
13736
            if not isinstance(elem, (RegionRefType, RegionRefIndexedType)): # pylint: disable=undefined-variable
13737
                regionrefs.extend(self._get_recursive_reading_order(elem))
13738
        return regionrefs
13739
    
13740
    def get_AllRegions(self, classes=None, order='document', depth=0):
13741
        """
13742
        Get all the ``*Region`` elements, or only those provided by `classes`.
13743
        Return in document order, unless the top element is ``Page`` and
13744
        `order` is ``reading-order``.
13745
    
13746
        Arguments:
13747
            classes (list): Classes of regions that shall be returned, \
13748
                e.g. ``['Text', 'Image']``
13749
            order ("document"|"reading-order"|"reading-order-only"): Whether to \
13750
                return regions sorted by document order (``document``, default) or by
13751
                reading order with regions not in the reading order at the end of the
13752
                returned list (``reading-order``) or regions not in the reading order
13753
                omitted (``reading-order-only``). The latter two are only available
13754
                on page level.
13755
            depth (int): Recursive depth to look for regions at, set to `0` for \
13756
                all regions at any depth. Default: 0
13757
    
13758
        Returns:
13759
            a list of :py:class:`TextRegionType`, :py:class:`ImageRegionType`, \
13760
                :py:class:`LineDrawingRegionType`, :py:class:`GraphicRegionType`, \
13761
                :py:class:`TableRegionType`, :py:class:`ChartRegionType`, \
13762
                :py:class:`MapRegionType`, :py:class:`SeparatorRegionType`, \
13763
                :py:class:`MathsRegionType`, :py:class:`ChemRegionType`, \
13764
                :py:class:`MusicRegionType`, :py:class:`AdvertRegionType`, \
13765
                :py:class:`NoiseRegionType`, :py:class:`UnknownRegionType`, \
13766
                and/or :py:class:`CustomRegionType`
13767
    
13768
        For example, to get all text anywhere on the page in reading order, use:
13769
        ::
13770
            '\\n'.join(line.get_TextEquiv()[0].Unicode
13771
                      for region in page.get_AllRegions(classes=['Text'], depth=0, order='reading-order')
13772
                      for line in region.get_TextLine())
13773
        """
13774
        if order not in ['document', 'reading-order', 'reading-order-only']:
13775
            raise Exception("Argument 'order' must be either 'document', 'reading-order' or 'reading-order-only', not '{}'".format(order))
13776
        if depth < 0:
13777
            raise Exception("Argument 'depth' must be an integer greater-or-equal 0, not '{}'".format(depth))
13778
        ret = self._get_recursive_regions([self], depth + 1 if depth else 0, classes)
13779
        if self.__class__.__name__ == 'PageType' and order.startswith('reading-order'):
13780
            reading_order = self.get_ReadingOrder()
13781
            if reading_order:
13782
                reading_order = reading_order.get_OrderedGroup() or reading_order.get_UnorderedGroup()
13783
            if reading_order:
13784
                reading_order = self._get_recursive_reading_order(reading_order)
13785
            if reading_order:
13786
                id2region = {region.id: region for region in ret}
13787
                in_reading_order = [id2region[region_id] for region_id in reading_order if region_id in id2region]
13788
                #  print("ret: {} / in_ro: {} / not-in-ro: {}".format(
13789
                #      len(ret),
13790
                #      len([id2region[region_id] for region_id in reading_order if region_id in id2region]),
13791
                #      len([r for r in ret if r not in in_reading_order])
13792
                #      ))
13793
                if order == 'reading-order-only':
13794
                    ret = in_reading_order
13795
                else:
13796
                    ret = in_reading_order + [r for r in ret if r not in in_reading_order]
13797
        return ret
13798
    def set_orientation(self, orientation):
13799
        """
13800
        Set deskewing angle to given `orientation` number.
13801
        Moreover, invalidate self's ``pc:AlternativeImage``s
13802
        (because they will have been rotated and enlarged
13803
        with the angle of the previous value).
13804
        """
13805
        if hasattr(self, 'invalidate_AlternativeImage'):
13806
            # PageType, RegionType:
13807
            self.invalidate_AlternativeImage(feature_selector='deskewed')
13808
        self.orientation = orientation
13809
# end class MathsRegionType
13810
13811
13812 View Code Duplication
class SeparatorRegionType(RegionType):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
13813
    """SeparatorRegionType --
13814
    Separators are lines that lie between columns and
13815
    paragraphs and can be used to logically separate
13816
    different articles from each other.
13817
      
13818
    * orientation --
13819
      The angle the rectangle encapsulating a region
13820
      has to be rotated in clockwise direction
13821
      in order to correct the present skew
13822
      (negative values indicate anti-clockwise rotation).
13823
      Range: -179.999,180
13824
      
13825
    * colour --
13826
      The colour of the separator
13827
    
13828
    """
13829
    __hash__ = GeneratedsSuper.__hash__
13830
    member_data_items_ = [
13831
        MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional', 'name': 'orientation'}),
13832
        MemberSpec_('colour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional', 'name': 'colour'}),
13833
    ]
13834
    subclass = None
13835
    superclass = RegionType
13836
    def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, colour=None, gds_collector_=None, **kwargs_):
13837
        self.gds_collector_ = gds_collector_
13838
        self.gds_elementtree_node_ = None
13839
        self.original_tagname_ = None
13840
        self.parent_object_ = kwargs_.get('parent_object_')
13841
        self.ns_prefix_ = "pc"
13842
        super(globals().get("SeparatorRegionType"), self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion,  **kwargs_)
13843
        self.orientation = _cast(float, orientation)
13844
        self.orientation_nsprefix_ = "pc"
13845
        self.colour = _cast(None, colour)
13846
        self.colour_nsprefix_ = "pc"
13847
    def factory(*args_, **kwargs_):
13848
        if CurrentSubclassModule_ is not None:
13849
            subclass = getSubclassFromModule_(
13850
                CurrentSubclassModule_, SeparatorRegionType)
13851
            if subclass is not None:
13852
                return subclass(*args_, **kwargs_)
13853
        if SeparatorRegionType.subclass:
13854
            return SeparatorRegionType.subclass(*args_, **kwargs_)
13855
        else:
13856
            return SeparatorRegionType(*args_, **kwargs_)
13857
    factory = staticmethod(factory)
13858
    def get_ns_prefix_(self):
13859
        return self.ns_prefix_
13860
    def set_ns_prefix_(self, ns_prefix):
13861
        self.ns_prefix_ = ns_prefix
13862
    def get_orientation(self):
13863
        return self.orientation
13864
    def set_orientation(self, orientation):
13865
        self.orientation = orientation
13866
    def get_colour(self):
13867
        return self.colour
13868
    def set_colour(self, colour):
13869
        self.colour = colour
13870
    def validate_ColourSimpleType(self, value):
13871
        # Validate type pc:ColourSimpleType, a restriction on string.
13872
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
13873
            if not isinstance(value, str):
13874
                lineno = self.gds_get_node_lineno_()
13875
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
13876
                return False
13877
            value = value
13878
            enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other']
13879
            if value not in enumerations:
13880
                lineno = self.gds_get_node_lineno_()
13881
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ColourSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
13882
                result = False
13883
    def has__content(self):
13884
        if (
13885
            super(SeparatorRegionType, self).has__content()
13886
        ):
13887
            return True
13888
        else:
13889
            return False
13890
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='SeparatorRegionType', pretty_print=True):
13891
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('SeparatorRegionType')
13892
        if imported_ns_def_ is not None:
13893
            namespacedef_ = imported_ns_def_
13894
        if pretty_print:
13895
            eol_ = '\n'
13896
        else:
13897
            eol_ = ''
13898
        if self.original_tagname_ is not None and name_ == 'SeparatorRegionType':
13899
            name_ = self.original_tagname_
13900
        if UseCapturedNS_ and self.ns_prefix_:
13901
            namespaceprefix_ = self.ns_prefix_ + ':'
13902
        showIndent(outfile, level, pretty_print)
13903
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
13904
        already_processed = set()
13905
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='SeparatorRegionType')
13906
        if self.has__content():
13907
            outfile.write('>%s' % (eol_, ))
13908
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='SeparatorRegionType', pretty_print=pretty_print)
13909
            showIndent(outfile, level, pretty_print)
13910
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
13911
        else:
13912
            outfile.write('/>%s' % (eol_, ))
13913
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='SeparatorRegionType'):
13914
        super(SeparatorRegionType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='SeparatorRegionType')
13915
        if self.orientation is not None and 'orientation' not in already_processed:
13916
            already_processed.add('orientation')
13917
            outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation'))
13918
        if self.colour is not None and 'colour' not in already_processed:
13919
            already_processed.add('colour')
13920
            outfile.write(' colour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.colour), input_name='colour')), ))
13921
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='SeparatorRegionType', fromsubclass_=False, pretty_print=True):
13922
        super(SeparatorRegionType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print)
13923
    def to_etree(self, parent_element=None, name_='SeparatorRegionType', mapping_=None, reverse_mapping_=None, nsmap_=None):
13924
        element = super(SeparatorRegionType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_)
13925
        if self.orientation is not None:
13926
            element.set('orientation', self.gds_format_float(self.orientation))
13927
        if self.colour is not None:
13928
            element.set('colour', self.gds_format_string(self.colour))
13929
        if mapping_ is not None:
13930
            mapping_[id(self)] = element
13931
        if reverse_mapping_ is not None:
13932
            reverse_mapping_[element] = self
13933
        return element
13934
    def build(self, node, gds_collector_=None):
13935
        self.gds_collector_ = gds_collector_
13936
        if SaveElementTreeNode:
13937
            self.gds_elementtree_node_ = node
13938
        already_processed = set()
13939
        self.ns_prefix_ = node.prefix
13940
        self._buildAttributes(node, node.attrib, already_processed)
13941
        for child in node:
13942
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
13943
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
13944
        return self
13945
    def _buildAttributes(self, node, attrs, already_processed):
13946
        value = find_attr_value_('orientation', node)
13947
        if value is not None and 'orientation' not in already_processed:
13948
            already_processed.add('orientation')
13949
            value = self.gds_parse_float(value, node, 'orientation')
13950
            self.orientation = value
13951
        value = find_attr_value_('colour', node)
13952
        if value is not None and 'colour' not in already_processed:
13953
            already_processed.add('colour')
13954
            self.colour = value
13955
            self.validate_ColourSimpleType(self.colour)    # validate type ColourSimpleType
13956
        super(SeparatorRegionType, self)._buildAttributes(node, attrs, already_processed)
13957
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
13958
        super(SeparatorRegionType, self)._buildChildren(child_, node, nodeName_, True)
13959
        pass
13960
    def __hash__(self):
13961
        return hash(self.id)
13962
    # pylint: disable=line-too-long,invalid-name,protected-access,missing-module-docstring
13963
    def _region_class(self, x): # pylint: disable=unused-argument
13964
        return x.__class__.__name__.replace('RegionType', '')
13965
    
13966
    def _get_recursive_regions(self, regions, level, classes=None):
13967
        from .constants import PAGE_REGION_TYPES  # pylint: disable=relative-beyond-top-level,import-outside-toplevel
13968
        if level == 1:
13969
            # stop recursion, filter classes
13970
            if classes:
13971
                return [r for r in regions if self._region_class(r) in classes]
13972
            if regions and regions[0].__class__.__name__ == 'PageType':
13973
                regions = regions[1:]
13974
            return regions
13975
        # find more regions recursively
13976
        more_regions = []
13977
        for region in regions:
13978
            more_regions.append([])
13979
            for class_ in PAGE_REGION_TYPES:
13980
                if class_ == 'Map' and not isinstance(region, PageType): # pylint: disable=undefined-variable
13981
                    # 'Map' is not recursive in 2019 schema
13982
                    continue
13983
                more_regions[-1] += getattr(region, 'get_{}Region'.format(class_))()
13984
        if not any(more_regions):
13985
            return self._get_recursive_regions(regions, 1, classes)
13986
        ret = []
13987
        for r, more in zip(regions, more_regions):
13988
            ret.append(r)
13989
            ret += self._get_recursive_regions(more, level - 1 if level else 0, classes)
13990
        return self._get_recursive_regions(ret, 1, classes)
13991
    
13992
    def _get_recursive_reading_order(self, rogroup):
13993
        if isinstance(rogroup, (OrderedGroupType, OrderedGroupIndexedType)): # pylint: disable=undefined-variable
13994
            elements = rogroup.get_AllIndexed()
13995
        if isinstance(rogroup, (UnorderedGroupType, UnorderedGroupIndexedType)): # pylint: disable=undefined-variable
13996
            elements = (rogroup.get_RegionRef() + rogroup.get_OrderedGroup() + rogroup.get_UnorderedGroup())
13997
        regionrefs = list()
13998
        for elem in elements:
13999
            regionrefs.append(elem.get_regionRef())
14000
            if not isinstance(elem, (RegionRefType, RegionRefIndexedType)): # pylint: disable=undefined-variable
14001
                regionrefs.extend(self._get_recursive_reading_order(elem))
14002
        return regionrefs
14003
    
14004
    def get_AllRegions(self, classes=None, order='document', depth=0):
14005
        """
14006
        Get all the ``*Region`` elements, or only those provided by `classes`.
14007
        Return in document order, unless the top element is ``Page`` and
14008
        `order` is ``reading-order``.
14009
    
14010
        Arguments:
14011
            classes (list): Classes of regions that shall be returned, \
14012
                e.g. ``['Text', 'Image']``
14013
            order ("document"|"reading-order"|"reading-order-only"): Whether to \
14014
                return regions sorted by document order (``document``, default) or by
14015
                reading order with regions not in the reading order at the end of the
14016
                returned list (``reading-order``) or regions not in the reading order
14017
                omitted (``reading-order-only``). The latter two are only available
14018
                on page level.
14019
            depth (int): Recursive depth to look for regions at, set to `0` for \
14020
                all regions at any depth. Default: 0
14021
    
14022
        Returns:
14023
            a list of :py:class:`TextRegionType`, :py:class:`ImageRegionType`, \
14024
                :py:class:`LineDrawingRegionType`, :py:class:`GraphicRegionType`, \
14025
                :py:class:`TableRegionType`, :py:class:`ChartRegionType`, \
14026
                :py:class:`MapRegionType`, :py:class:`SeparatorRegionType`, \
14027
                :py:class:`MathsRegionType`, :py:class:`ChemRegionType`, \
14028
                :py:class:`MusicRegionType`, :py:class:`AdvertRegionType`, \
14029
                :py:class:`NoiseRegionType`, :py:class:`UnknownRegionType`, \
14030
                and/or :py:class:`CustomRegionType`
14031
    
14032
        For example, to get all text anywhere on the page in reading order, use:
14033
        ::
14034
            '\\n'.join(line.get_TextEquiv()[0].Unicode
14035
                      for region in page.get_AllRegions(classes=['Text'], depth=0, order='reading-order')
14036
                      for line in region.get_TextLine())
14037
        """
14038
        if order not in ['document', 'reading-order', 'reading-order-only']:
14039
            raise Exception("Argument 'order' must be either 'document', 'reading-order' or 'reading-order-only', not '{}'".format(order))
14040
        if depth < 0:
14041
            raise Exception("Argument 'depth' must be an integer greater-or-equal 0, not '{}'".format(depth))
14042
        ret = self._get_recursive_regions([self], depth + 1 if depth else 0, classes)
14043
        if self.__class__.__name__ == 'PageType' and order.startswith('reading-order'):
14044
            reading_order = self.get_ReadingOrder()
14045
            if reading_order:
14046
                reading_order = reading_order.get_OrderedGroup() or reading_order.get_UnorderedGroup()
14047
            if reading_order:
14048
                reading_order = self._get_recursive_reading_order(reading_order)
14049
            if reading_order:
14050
                id2region = {region.id: region for region in ret}
14051
                in_reading_order = [id2region[region_id] for region_id in reading_order if region_id in id2region]
14052
                #  print("ret: {} / in_ro: {} / not-in-ro: {}".format(
14053
                #      len(ret),
14054
                #      len([id2region[region_id] for region_id in reading_order if region_id in id2region]),
14055
                #      len([r for r in ret if r not in in_reading_order])
14056
                #      ))
14057
                if order == 'reading-order-only':
14058
                    ret = in_reading_order
14059
                else:
14060
                    ret = in_reading_order + [r for r in ret if r not in in_reading_order]
14061
        return ret
14062
    def set_orientation(self, orientation):
14063
        """
14064
        Set deskewing angle to given `orientation` number.
14065
        Moreover, invalidate self's ``pc:AlternativeImage``s
14066
        (because they will have been rotated and enlarged
14067
        with the angle of the previous value).
14068
        """
14069
        if hasattr(self, 'invalidate_AlternativeImage'):
14070
            # PageType, RegionType:
14071
            self.invalidate_AlternativeImage(feature_selector='deskewed')
14072
        self.orientation = orientation
14073
# end class SeparatorRegionType
14074
14075
14076
class ChartRegionType(RegionType):
14077
    """ChartRegionType --
14078
    Regions containing charts or graphs of any type, should
14079
    be marked as chart regions.
14080
      
14081
    * orientation --
14082
      The angle the rectangle encapsulating a region
14083
      has to be rotated in clockwise direction
14084
      in order to correct the present skew
14085
      (negative values indicate anti-clockwise rotation).
14086
      Range: -179.999,180
14087
      
14088
    * type --
14089
      The type of chart in the region
14090
      
14091
    * numColours --
14092
      An approximation of the number of colours
14093
      used in the region
14094
      
14095
    * bgColour --
14096
      The background colour of the region
14097
      
14098
    * embText --
14099
      Specifies whether the region also contains
14100
      text
14101
    
14102
    """
14103
    __hash__ = GeneratedsSuper.__hash__
14104
    member_data_items_ = [
14105
        MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional', 'name': 'orientation'}),
14106
        MemberSpec_('type_', 'pc:ChartTypeSimpleType', 0, 1, {'use': 'optional', 'name': 'type_'}),
14107
        MemberSpec_('numColours', 'int', 0, 1, {'use': 'optional', 'name': 'numColours'}),
14108
        MemberSpec_('bgColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional', 'name': 'bgColour'}),
14109
        MemberSpec_('embText', 'boolean', 0, 1, {'use': 'optional', 'name': 'embText'}),
14110
    ]
14111
    subclass = None
14112
    superclass = RegionType
14113
    def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, type_=None, numColours=None, bgColour=None, embText=None, gds_collector_=None, **kwargs_):
14114
        self.gds_collector_ = gds_collector_
14115
        self.gds_elementtree_node_ = None
14116
        self.original_tagname_ = None
14117
        self.parent_object_ = kwargs_.get('parent_object_')
14118
        self.ns_prefix_ = "pc"
14119
        super(globals().get("ChartRegionType"), self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion,  **kwargs_)
14120
        self.orientation = _cast(float, orientation)
14121
        self.orientation_nsprefix_ = "pc"
14122
        self.type_ = _cast(None, type_)
14123
        self.type__nsprefix_ = "pc"
14124
        self.numColours = _cast(int, numColours)
14125
        self.numColours_nsprefix_ = "pc"
14126
        self.bgColour = _cast(None, bgColour)
14127
        self.bgColour_nsprefix_ = "pc"
14128
        self.embText = _cast(bool, embText)
14129
        self.embText_nsprefix_ = "pc"
14130
    def factory(*args_, **kwargs_):
14131
        if CurrentSubclassModule_ is not None:
14132
            subclass = getSubclassFromModule_(
14133
                CurrentSubclassModule_, ChartRegionType)
14134
            if subclass is not None:
14135
                return subclass(*args_, **kwargs_)
14136
        if ChartRegionType.subclass:
14137
            return ChartRegionType.subclass(*args_, **kwargs_)
14138
        else:
14139
            return ChartRegionType(*args_, **kwargs_)
14140
    factory = staticmethod(factory)
14141
    def get_ns_prefix_(self):
14142
        return self.ns_prefix_
14143
    def set_ns_prefix_(self, ns_prefix):
14144
        self.ns_prefix_ = ns_prefix
14145
    def get_orientation(self):
14146
        return self.orientation
14147
    def set_orientation(self, orientation):
14148
        self.orientation = orientation
14149
    def get_type(self):
14150
        return self.type_
14151
    def set_type(self, type_):
14152
        self.type_ = type_
14153
    def get_numColours(self):
14154
        return self.numColours
14155
    def set_numColours(self, numColours):
14156
        self.numColours = numColours
14157
    def get_bgColour(self):
14158
        return self.bgColour
14159
    def set_bgColour(self, bgColour):
14160
        self.bgColour = bgColour
14161
    def get_embText(self):
14162
        return self.embText
14163
    def set_embText(self, embText):
14164
        self.embText = embText
14165
    def validate_ChartTypeSimpleType(self, value):
14166
        # Validate type pc:ChartTypeSimpleType, a restriction on string.
14167
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
14168
            if not isinstance(value, str):
14169
                lineno = self.gds_get_node_lineno_()
14170
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
14171
                return False
14172
            value = value
14173
            enumerations = ['bar', 'line', 'pie', 'scatter', 'surface', 'other']
14174
            if value not in enumerations:
14175
                lineno = self.gds_get_node_lineno_()
14176
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ChartTypeSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
14177
                result = False
14178
    def validate_ColourSimpleType(self, value):
14179
        # Validate type pc:ColourSimpleType, a restriction on string.
14180
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
14181
            if not isinstance(value, str):
14182
                lineno = self.gds_get_node_lineno_()
14183
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
14184
                return False
14185
            value = value
14186
            enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other']
14187
            if value not in enumerations:
14188
                lineno = self.gds_get_node_lineno_()
14189
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ColourSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
14190
                result = False
14191
    def has__content(self):
14192
        if (
14193
            super(ChartRegionType, self).has__content()
14194
        ):
14195
            return True
14196
        else:
14197
            return False
14198
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='ChartRegionType', pretty_print=True):
14199
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('ChartRegionType')
14200
        if imported_ns_def_ is not None:
14201
            namespacedef_ = imported_ns_def_
14202
        if pretty_print:
14203
            eol_ = '\n'
14204
        else:
14205
            eol_ = ''
14206
        if self.original_tagname_ is not None and name_ == 'ChartRegionType':
14207
            name_ = self.original_tagname_
14208
        if UseCapturedNS_ and self.ns_prefix_:
14209
            namespaceprefix_ = self.ns_prefix_ + ':'
14210
        showIndent(outfile, level, pretty_print)
14211
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
14212
        already_processed = set()
14213
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='ChartRegionType')
14214
        if self.has__content():
14215
            outfile.write('>%s' % (eol_, ))
14216
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='ChartRegionType', pretty_print=pretty_print)
14217
            showIndent(outfile, level, pretty_print)
14218
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
14219
        else:
14220
            outfile.write('/>%s' % (eol_, ))
14221
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='ChartRegionType'):
14222
        super(ChartRegionType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='ChartRegionType')
14223
        if self.orientation is not None and 'orientation' not in already_processed:
14224
            already_processed.add('orientation')
14225
            outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation'))
14226
        if self.type_ is not None and 'type_' not in already_processed:
14227
            already_processed.add('type_')
14228
            outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), ))
14229
        if self.numColours is not None and 'numColours' not in already_processed:
14230
            already_processed.add('numColours')
14231
            outfile.write(' numColours="%s"' % self.gds_format_integer(self.numColours, input_name='numColours'))
14232
        if self.bgColour is not None and 'bgColour' not in already_processed:
14233
            already_processed.add('bgColour')
14234
            outfile.write(' bgColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.bgColour), input_name='bgColour')), ))
14235
        if self.embText is not None and 'embText' not in already_processed:
14236
            already_processed.add('embText')
14237
            outfile.write(' embText="%s"' % self.gds_format_boolean(self.embText, input_name='embText'))
14238
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='ChartRegionType', fromsubclass_=False, pretty_print=True):
14239
        super(ChartRegionType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print)
14240
    def to_etree(self, parent_element=None, name_='ChartRegionType', mapping_=None, reverse_mapping_=None, nsmap_=None):
14241
        element = super(ChartRegionType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_)
14242
        if self.orientation is not None:
14243
            element.set('orientation', self.gds_format_float(self.orientation))
14244
        if self.type_ is not None:
14245
            element.set('type', self.gds_format_string(self.type_))
14246
        if self.numColours is not None:
14247
            element.set('numColours', self.gds_format_integer(self.numColours))
14248
        if self.bgColour is not None:
14249
            element.set('bgColour', self.gds_format_string(self.bgColour))
14250
        if self.embText is not None:
14251
            element.set('embText', self.gds_format_boolean(self.embText))
14252
        if mapping_ is not None:
14253
            mapping_[id(self)] = element
14254
        if reverse_mapping_ is not None:
14255
            reverse_mapping_[element] = self
14256
        return element
14257
    def build(self, node, gds_collector_=None):
14258
        self.gds_collector_ = gds_collector_
14259
        if SaveElementTreeNode:
14260
            self.gds_elementtree_node_ = node
14261
        already_processed = set()
14262
        self.ns_prefix_ = node.prefix
14263
        self._buildAttributes(node, node.attrib, already_processed)
14264
        for child in node:
14265
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
14266
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
14267
        return self
14268
    def _buildAttributes(self, node, attrs, already_processed):
14269
        value = find_attr_value_('orientation', node)
14270
        if value is not None and 'orientation' not in already_processed:
14271
            already_processed.add('orientation')
14272
            value = self.gds_parse_float(value, node, 'orientation')
14273
            self.orientation = value
14274
        value = find_attr_value_('type', node)
14275
        if value is not None and 'type' not in already_processed:
14276
            already_processed.add('type')
14277
            self.type_ = value
14278
            self.validate_ChartTypeSimpleType(self.type_)    # validate type ChartTypeSimpleType
14279
        value = find_attr_value_('numColours', node)
14280
        if value is not None and 'numColours' not in already_processed:
14281
            already_processed.add('numColours')
14282
            self.numColours = self.gds_parse_integer(value, node, 'numColours')
14283
        value = find_attr_value_('bgColour', node)
14284
        if value is not None and 'bgColour' not in already_processed:
14285
            already_processed.add('bgColour')
14286
            self.bgColour = value
14287
            self.validate_ColourSimpleType(self.bgColour)    # validate type ColourSimpleType
14288
        value = find_attr_value_('embText', node)
14289
        if value is not None and 'embText' not in already_processed:
14290
            already_processed.add('embText')
14291
            if value in ('true', '1'):
14292
                self.embText = True
14293
            elif value in ('false', '0'):
14294
                self.embText = False
14295
            else:
14296
                raise_parse_error(node, 'Bad boolean attribute')
14297
        super(ChartRegionType, self)._buildAttributes(node, attrs, already_processed)
14298
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
14299
        super(ChartRegionType, self)._buildChildren(child_, node, nodeName_, True)
14300
        pass
14301
    def __hash__(self):
14302
        return hash(self.id)
14303
    # pylint: disable=line-too-long,invalid-name,protected-access,missing-module-docstring
14304
    def _region_class(self, x): # pylint: disable=unused-argument
14305
        return x.__class__.__name__.replace('RegionType', '')
14306
    
14307
    def _get_recursive_regions(self, regions, level, classes=None):
14308
        from .constants import PAGE_REGION_TYPES  # pylint: disable=relative-beyond-top-level,import-outside-toplevel
14309
        if level == 1:
14310
            # stop recursion, filter classes
14311
            if classes:
14312
                return [r for r in regions if self._region_class(r) in classes]
14313
            if regions and regions[0].__class__.__name__ == 'PageType':
14314
                regions = regions[1:]
14315
            return regions
14316
        # find more regions recursively
14317
        more_regions = []
14318
        for region in regions:
14319
            more_regions.append([])
14320
            for class_ in PAGE_REGION_TYPES:
14321
                if class_ == 'Map' and not isinstance(region, PageType): # pylint: disable=undefined-variable
14322
                    # 'Map' is not recursive in 2019 schema
14323
                    continue
14324
                more_regions[-1] += getattr(region, 'get_{}Region'.format(class_))()
14325
        if not any(more_regions):
14326
            return self._get_recursive_regions(regions, 1, classes)
14327
        ret = []
14328
        for r, more in zip(regions, more_regions):
14329
            ret.append(r)
14330
            ret += self._get_recursive_regions(more, level - 1 if level else 0, classes)
14331
        return self._get_recursive_regions(ret, 1, classes)
14332
    
14333
    def _get_recursive_reading_order(self, rogroup):
14334
        if isinstance(rogroup, (OrderedGroupType, OrderedGroupIndexedType)): # pylint: disable=undefined-variable
14335
            elements = rogroup.get_AllIndexed()
14336
        if isinstance(rogroup, (UnorderedGroupType, UnorderedGroupIndexedType)): # pylint: disable=undefined-variable
14337
            elements = (rogroup.get_RegionRef() + rogroup.get_OrderedGroup() + rogroup.get_UnorderedGroup())
14338
        regionrefs = list()
14339
        for elem in elements:
14340
            regionrefs.append(elem.get_regionRef())
14341
            if not isinstance(elem, (RegionRefType, RegionRefIndexedType)): # pylint: disable=undefined-variable
14342
                regionrefs.extend(self._get_recursive_reading_order(elem))
14343
        return regionrefs
14344
    
14345
    def get_AllRegions(self, classes=None, order='document', depth=0):
14346
        """
14347
        Get all the ``*Region`` elements, or only those provided by `classes`.
14348
        Return in document order, unless the top element is ``Page`` and
14349
        `order` is ``reading-order``.
14350
    
14351
        Arguments:
14352
            classes (list): Classes of regions that shall be returned, \
14353
                e.g. ``['Text', 'Image']``
14354
            order ("document"|"reading-order"|"reading-order-only"): Whether to \
14355
                return regions sorted by document order (``document``, default) or by
14356
                reading order with regions not in the reading order at the end of the
14357
                returned list (``reading-order``) or regions not in the reading order
14358
                omitted (``reading-order-only``). The latter two are only available
14359
                on page level.
14360
            depth (int): Recursive depth to look for regions at, set to `0` for \
14361
                all regions at any depth. Default: 0
14362
    
14363
        Returns:
14364
            a list of :py:class:`TextRegionType`, :py:class:`ImageRegionType`, \
14365
                :py:class:`LineDrawingRegionType`, :py:class:`GraphicRegionType`, \
14366
                :py:class:`TableRegionType`, :py:class:`ChartRegionType`, \
14367
                :py:class:`MapRegionType`, :py:class:`SeparatorRegionType`, \
14368
                :py:class:`MathsRegionType`, :py:class:`ChemRegionType`, \
14369
                :py:class:`MusicRegionType`, :py:class:`AdvertRegionType`, \
14370
                :py:class:`NoiseRegionType`, :py:class:`UnknownRegionType`, \
14371
                and/or :py:class:`CustomRegionType`
14372
    
14373
        For example, to get all text anywhere on the page in reading order, use:
14374
        ::
14375
            '\\n'.join(line.get_TextEquiv()[0].Unicode
14376
                      for region in page.get_AllRegions(classes=['Text'], depth=0, order='reading-order')
14377
                      for line in region.get_TextLine())
14378
        """
14379
        if order not in ['document', 'reading-order', 'reading-order-only']:
14380
            raise Exception("Argument 'order' must be either 'document', 'reading-order' or 'reading-order-only', not '{}'".format(order))
14381
        if depth < 0:
14382
            raise Exception("Argument 'depth' must be an integer greater-or-equal 0, not '{}'".format(depth))
14383
        ret = self._get_recursive_regions([self], depth + 1 if depth else 0, classes)
14384
        if self.__class__.__name__ == 'PageType' and order.startswith('reading-order'):
14385
            reading_order = self.get_ReadingOrder()
14386
            if reading_order:
14387
                reading_order = reading_order.get_OrderedGroup() or reading_order.get_UnorderedGroup()
14388
            if reading_order:
14389
                reading_order = self._get_recursive_reading_order(reading_order)
14390
            if reading_order:
14391
                id2region = {region.id: region for region in ret}
14392
                in_reading_order = [id2region[region_id] for region_id in reading_order if region_id in id2region]
14393
                #  print("ret: {} / in_ro: {} / not-in-ro: {}".format(
14394
                #      len(ret),
14395
                #      len([id2region[region_id] for region_id in reading_order if region_id in id2region]),
14396
                #      len([r for r in ret if r not in in_reading_order])
14397
                #      ))
14398
                if order == 'reading-order-only':
14399
                    ret = in_reading_order
14400
                else:
14401
                    ret = in_reading_order + [r for r in ret if r not in in_reading_order]
14402
        return ret
14403
    def set_orientation(self, orientation):
14404
        """
14405
        Set deskewing angle to given `orientation` number.
14406
        Moreover, invalidate self's ``pc:AlternativeImage``s
14407
        (because they will have been rotated and enlarged
14408
        with the angle of the previous value).
14409
        """
14410
        if hasattr(self, 'invalidate_AlternativeImage'):
14411
            # PageType, RegionType:
14412
            self.invalidate_AlternativeImage(feature_selector='deskewed')
14413
        self.orientation = orientation
14414
# end class ChartRegionType
14415
14416
14417
class TableRegionType(RegionType):
14418
    """TableRegionType --
14419
    Tabular data in any form is represented with a table
14420
    region. Rows and columns may or may not have separator
14421
    lines; these lines are not separator regions.
14422
      
14423
    * orientation --
14424
      The angle the rectangle encapsulating a	region
14425
      has to be rotated in clockwise direction
14426
      in order to correct the present	skew
14427
      (negative values indicate anti-clockwise rotation).
14428
      Range: -179.999,180
14429
      
14430
    * rows --
14431
      The number of rows present in the table
14432
      
14433
    * columns --
14434
      The number of columns present in the table
14435
      
14436
    * lineColour --
14437
      The colour of the lines used in the region
14438
      
14439
    * bgColour --
14440
      The background colour of the region
14441
      
14442
    * lineSeparators --
14443
      Specifies the presence of line separators
14444
      
14445
    * embText --
14446
      Specifies whether the region also contains
14447
      text
14448
      
14449
    * Grid -- Table grid (visible or virtual grid lines)
14450
    
14451
    """
14452
    __hash__ = GeneratedsSuper.__hash__
14453
    member_data_items_ = [
14454
        MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional', 'name': 'orientation'}),
14455
        MemberSpec_('rows', 'int', 0, 1, {'use': 'optional', 'name': 'rows'}),
14456
        MemberSpec_('columns', 'int', 0, 1, {'use': 'optional', 'name': 'columns'}),
14457
        MemberSpec_('lineColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional', 'name': 'lineColour'}),
14458
        MemberSpec_('bgColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional', 'name': 'bgColour'}),
14459
        MemberSpec_('lineSeparators', 'boolean', 0, 1, {'use': 'optional', 'name': 'lineSeparators'}),
14460
        MemberSpec_('embText', 'boolean', 0, 1, {'use': 'optional', 'name': 'embText'}),
14461
        MemberSpec_('Grid', 'GridType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'Grid', 'type': 'GridType'}, None),
14462
    ]
14463
    subclass = None
14464
    superclass = RegionType
14465
    def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, rows=None, columns=None, lineColour=None, bgColour=None, lineSeparators=None, embText=None, Grid=None, gds_collector_=None, **kwargs_):
14466
        self.gds_collector_ = gds_collector_
14467
        self.gds_elementtree_node_ = None
14468
        self.original_tagname_ = None
14469
        self.parent_object_ = kwargs_.get('parent_object_')
14470
        self.ns_prefix_ = "pc"
14471
        super(globals().get("TableRegionType"), self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion,  **kwargs_)
14472
        self.orientation = _cast(float, orientation)
14473
        self.orientation_nsprefix_ = "pc"
14474
        self.rows = _cast(int, rows)
14475
        self.rows_nsprefix_ = "pc"
14476
        self.columns = _cast(int, columns)
14477
        self.columns_nsprefix_ = "pc"
14478
        self.lineColour = _cast(None, lineColour)
14479
        self.lineColour_nsprefix_ = "pc"
14480
        self.bgColour = _cast(None, bgColour)
14481
        self.bgColour_nsprefix_ = "pc"
14482
        self.lineSeparators = _cast(bool, lineSeparators)
14483
        self.lineSeparators_nsprefix_ = "pc"
14484
        self.embText = _cast(bool, embText)
14485
        self.embText_nsprefix_ = "pc"
14486
        self.Grid = Grid
14487
        self.Grid_nsprefix_ = "pc"
14488
    def factory(*args_, **kwargs_):
14489
        if CurrentSubclassModule_ is not None:
14490
            subclass = getSubclassFromModule_(
14491
                CurrentSubclassModule_, TableRegionType)
14492
            if subclass is not None:
14493
                return subclass(*args_, **kwargs_)
14494
        if TableRegionType.subclass:
14495
            return TableRegionType.subclass(*args_, **kwargs_)
14496
        else:
14497
            return TableRegionType(*args_, **kwargs_)
14498
    factory = staticmethod(factory)
14499
    def get_ns_prefix_(self):
14500
        return self.ns_prefix_
14501
    def set_ns_prefix_(self, ns_prefix):
14502
        self.ns_prefix_ = ns_prefix
14503
    def get_Grid(self):
14504
        return self.Grid
14505
    def set_Grid(self, Grid):
14506
        self.Grid = Grid
14507
    def get_orientation(self):
14508
        return self.orientation
14509
    def set_orientation(self, orientation):
14510
        self.orientation = orientation
14511
    def get_rows(self):
14512
        return self.rows
14513
    def set_rows(self, rows):
14514
        self.rows = rows
14515
    def get_columns(self):
14516
        return self.columns
14517
    def set_columns(self, columns):
14518
        self.columns = columns
14519
    def get_lineColour(self):
14520
        return self.lineColour
14521
    def set_lineColour(self, lineColour):
14522
        self.lineColour = lineColour
14523
    def get_bgColour(self):
14524
        return self.bgColour
14525
    def set_bgColour(self, bgColour):
14526
        self.bgColour = bgColour
14527
    def get_lineSeparators(self):
14528
        return self.lineSeparators
14529
    def set_lineSeparators(self, lineSeparators):
14530
        self.lineSeparators = lineSeparators
14531
    def get_embText(self):
14532
        return self.embText
14533
    def set_embText(self, embText):
14534
        self.embText = embText
14535
    def validate_ColourSimpleType(self, value):
14536
        # Validate type pc:ColourSimpleType, a restriction on string.
14537
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
14538
            if not isinstance(value, str):
14539
                lineno = self.gds_get_node_lineno_()
14540
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
14541
                return False
14542
            value = value
14543
            enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other']
14544
            if value not in enumerations:
14545
                lineno = self.gds_get_node_lineno_()
14546
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ColourSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
14547
                result = False
14548
    def has__content(self):
14549
        if (
14550
            self.Grid is not None or
14551
            super(TableRegionType, self).has__content()
14552
        ):
14553
            return True
14554
        else:
14555
            return False
14556
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='TableRegionType', pretty_print=True):
14557
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('TableRegionType')
14558
        if imported_ns_def_ is not None:
14559
            namespacedef_ = imported_ns_def_
14560
        if pretty_print:
14561
            eol_ = '\n'
14562
        else:
14563
            eol_ = ''
14564
        if self.original_tagname_ is not None and name_ == 'TableRegionType':
14565
            name_ = self.original_tagname_
14566
        if UseCapturedNS_ and self.ns_prefix_:
14567
            namespaceprefix_ = self.ns_prefix_ + ':'
14568
        showIndent(outfile, level, pretty_print)
14569
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
14570
        already_processed = set()
14571
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='TableRegionType')
14572
        if self.has__content():
14573
            outfile.write('>%s' % (eol_, ))
14574
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='TableRegionType', pretty_print=pretty_print)
14575
            showIndent(outfile, level, pretty_print)
14576
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
14577
        else:
14578
            outfile.write('/>%s' % (eol_, ))
14579
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='TableRegionType'):
14580
        super(TableRegionType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='TableRegionType')
14581
        if self.orientation is not None and 'orientation' not in already_processed:
14582
            already_processed.add('orientation')
14583
            outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation'))
14584
        if self.rows is not None and 'rows' not in already_processed:
14585
            already_processed.add('rows')
14586
            outfile.write(' rows="%s"' % self.gds_format_integer(self.rows, input_name='rows'))
14587
        if self.columns is not None and 'columns' not in already_processed:
14588
            already_processed.add('columns')
14589
            outfile.write(' columns="%s"' % self.gds_format_integer(self.columns, input_name='columns'))
14590
        if self.lineColour is not None and 'lineColour' not in already_processed:
14591
            already_processed.add('lineColour')
14592
            outfile.write(' lineColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.lineColour), input_name='lineColour')), ))
14593
        if self.bgColour is not None and 'bgColour' not in already_processed:
14594
            already_processed.add('bgColour')
14595
            outfile.write(' bgColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.bgColour), input_name='bgColour')), ))
14596
        if self.lineSeparators is not None and 'lineSeparators' not in already_processed:
14597
            already_processed.add('lineSeparators')
14598
            outfile.write(' lineSeparators="%s"' % self.gds_format_boolean(self.lineSeparators, input_name='lineSeparators'))
14599
        if self.embText is not None and 'embText' not in already_processed:
14600
            already_processed.add('embText')
14601
            outfile.write(' embText="%s"' % self.gds_format_boolean(self.embText, input_name='embText'))
14602
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='TableRegionType', fromsubclass_=False, pretty_print=True):
14603
        super(TableRegionType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print)
14604
        if pretty_print:
14605
            eol_ = '\n'
14606
        else:
14607
            eol_ = ''
14608
        if self.Grid is not None:
14609
            namespaceprefix_ = self.Grid_nsprefix_ + ':' if (UseCapturedNS_ and self.Grid_nsprefix_) else ''
14610
            self.Grid.export(outfile, level, namespaceprefix_, namespacedef_='', name_='Grid', pretty_print=pretty_print)
14611
    def to_etree(self, parent_element=None, name_='TableRegionType', mapping_=None, reverse_mapping_=None, nsmap_=None):
14612
        element = super(TableRegionType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_)
14613
        if self.orientation is not None:
14614
            element.set('orientation', self.gds_format_float(self.orientation))
14615
        if self.rows is not None:
14616
            element.set('rows', self.gds_format_integer(self.rows))
14617
        if self.columns is not None:
14618
            element.set('columns', self.gds_format_integer(self.columns))
14619
        if self.lineColour is not None:
14620
            element.set('lineColour', self.gds_format_string(self.lineColour))
14621
        if self.bgColour is not None:
14622
            element.set('bgColour', self.gds_format_string(self.bgColour))
14623
        if self.lineSeparators is not None:
14624
            element.set('lineSeparators', self.gds_format_boolean(self.lineSeparators))
14625
        if self.embText is not None:
14626
            element.set('embText', self.gds_format_boolean(self.embText))
14627
        if self.Grid is not None:
14628
            Grid_ = self.Grid
14629
            Grid_.to_etree(element, name_='Grid', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
14630
        if mapping_ is not None:
14631
            mapping_[id(self)] = element
14632
        if reverse_mapping_ is not None:
14633
            reverse_mapping_[element] = self
14634
        return element
14635
    def build(self, node, gds_collector_=None):
14636
        self.gds_collector_ = gds_collector_
14637
        if SaveElementTreeNode:
14638
            self.gds_elementtree_node_ = node
14639
        already_processed = set()
14640
        self.ns_prefix_ = node.prefix
14641
        self._buildAttributes(node, node.attrib, already_processed)
14642
        for child in node:
14643
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
14644
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
14645
        return self
14646
    def _buildAttributes(self, node, attrs, already_processed):
14647
        value = find_attr_value_('orientation', node)
14648
        if value is not None and 'orientation' not in already_processed:
14649
            already_processed.add('orientation')
14650
            value = self.gds_parse_float(value, node, 'orientation')
14651
            self.orientation = value
14652
        value = find_attr_value_('rows', node)
14653
        if value is not None and 'rows' not in already_processed:
14654
            already_processed.add('rows')
14655
            self.rows = self.gds_parse_integer(value, node, 'rows')
14656
        value = find_attr_value_('columns', node)
14657
        if value is not None and 'columns' not in already_processed:
14658
            already_processed.add('columns')
14659
            self.columns = self.gds_parse_integer(value, node, 'columns')
14660
        value = find_attr_value_('lineColour', node)
14661
        if value is not None and 'lineColour' not in already_processed:
14662
            already_processed.add('lineColour')
14663
            self.lineColour = value
14664
            self.validate_ColourSimpleType(self.lineColour)    # validate type ColourSimpleType
14665
        value = find_attr_value_('bgColour', node)
14666
        if value is not None and 'bgColour' not in already_processed:
14667
            already_processed.add('bgColour')
14668
            self.bgColour = value
14669
            self.validate_ColourSimpleType(self.bgColour)    # validate type ColourSimpleType
14670
        value = find_attr_value_('lineSeparators', node)
14671
        if value is not None and 'lineSeparators' not in already_processed:
14672
            already_processed.add('lineSeparators')
14673
            if value in ('true', '1'):
14674
                self.lineSeparators = True
14675
            elif value in ('false', '0'):
14676
                self.lineSeparators = False
14677
            else:
14678
                raise_parse_error(node, 'Bad boolean attribute')
14679
        value = find_attr_value_('embText', node)
14680
        if value is not None and 'embText' not in already_processed:
14681
            already_processed.add('embText')
14682
            if value in ('true', '1'):
14683
                self.embText = True
14684
            elif value in ('false', '0'):
14685
                self.embText = False
14686
            else:
14687
                raise_parse_error(node, 'Bad boolean attribute')
14688
        super(TableRegionType, self)._buildAttributes(node, attrs, already_processed)
14689
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
14690
        if nodeName_ == 'Grid':
14691
            obj_ = GridType.factory(parent_object_=self)
14692
            obj_.build(child_, gds_collector_=gds_collector_)
14693
            self.Grid = obj_
14694
            obj_.original_tagname_ = 'Grid'
14695
        super(TableRegionType, self)._buildChildren(child_, node, nodeName_, True)
14696
    def __hash__(self):
14697
        return hash(self.id)
14698
    # pylint: disable=line-too-long,invalid-name,protected-access,missing-module-docstring
14699
    def _region_class(self, x): # pylint: disable=unused-argument
14700
        return x.__class__.__name__.replace('RegionType', '')
14701
    
14702
    def _get_recursive_regions(self, regions, level, classes=None):
14703
        from .constants import PAGE_REGION_TYPES  # pylint: disable=relative-beyond-top-level,import-outside-toplevel
14704
        if level == 1:
14705
            # stop recursion, filter classes
14706
            if classes:
14707
                return [r for r in regions if self._region_class(r) in classes]
14708
            if regions and regions[0].__class__.__name__ == 'PageType':
14709
                regions = regions[1:]
14710
            return regions
14711
        # find more regions recursively
14712
        more_regions = []
14713
        for region in regions:
14714
            more_regions.append([])
14715
            for class_ in PAGE_REGION_TYPES:
14716
                if class_ == 'Map' and not isinstance(region, PageType): # pylint: disable=undefined-variable
14717
                    # 'Map' is not recursive in 2019 schema
14718
                    continue
14719
                more_regions[-1] += getattr(region, 'get_{}Region'.format(class_))()
14720
        if not any(more_regions):
14721
            return self._get_recursive_regions(regions, 1, classes)
14722
        ret = []
14723
        for r, more in zip(regions, more_regions):
14724
            ret.append(r)
14725
            ret += self._get_recursive_regions(more, level - 1 if level else 0, classes)
14726
        return self._get_recursive_regions(ret, 1, classes)
14727
    
14728
    def _get_recursive_reading_order(self, rogroup):
14729
        if isinstance(rogroup, (OrderedGroupType, OrderedGroupIndexedType)): # pylint: disable=undefined-variable
14730
            elements = rogroup.get_AllIndexed()
14731
        if isinstance(rogroup, (UnorderedGroupType, UnorderedGroupIndexedType)): # pylint: disable=undefined-variable
14732
            elements = (rogroup.get_RegionRef() + rogroup.get_OrderedGroup() + rogroup.get_UnorderedGroup())
14733
        regionrefs = list()
14734
        for elem in elements:
14735
            regionrefs.append(elem.get_regionRef())
14736
            if not isinstance(elem, (RegionRefType, RegionRefIndexedType)): # pylint: disable=undefined-variable
14737
                regionrefs.extend(self._get_recursive_reading_order(elem))
14738
        return regionrefs
14739
    
14740
    def get_AllRegions(self, classes=None, order='document', depth=0):
14741
        """
14742
        Get all the ``*Region`` elements, or only those provided by `classes`.
14743
        Return in document order, unless the top element is ``Page`` and
14744
        `order` is ``reading-order``.
14745
    
14746
        Arguments:
14747
            classes (list): Classes of regions that shall be returned, \
14748
                e.g. ``['Text', 'Image']``
14749
            order ("document"|"reading-order"|"reading-order-only"): Whether to \
14750
                return regions sorted by document order (``document``, default) or by
14751
                reading order with regions not in the reading order at the end of the
14752
                returned list (``reading-order``) or regions not in the reading order
14753
                omitted (``reading-order-only``). The latter two are only available
14754
                on page level.
14755
            depth (int): Recursive depth to look for regions at, set to `0` for \
14756
                all regions at any depth. Default: 0
14757
    
14758
        Returns:
14759
            a list of :py:class:`TextRegionType`, :py:class:`ImageRegionType`, \
14760
                :py:class:`LineDrawingRegionType`, :py:class:`GraphicRegionType`, \
14761
                :py:class:`TableRegionType`, :py:class:`ChartRegionType`, \
14762
                :py:class:`MapRegionType`, :py:class:`SeparatorRegionType`, \
14763
                :py:class:`MathsRegionType`, :py:class:`ChemRegionType`, \
14764
                :py:class:`MusicRegionType`, :py:class:`AdvertRegionType`, \
14765
                :py:class:`NoiseRegionType`, :py:class:`UnknownRegionType`, \
14766
                and/or :py:class:`CustomRegionType`
14767
    
14768
        For example, to get all text anywhere on the page in reading order, use:
14769
        ::
14770
            '\\n'.join(line.get_TextEquiv()[0].Unicode
14771
                      for region in page.get_AllRegions(classes=['Text'], depth=0, order='reading-order')
14772
                      for line in region.get_TextLine())
14773
        """
14774
        if order not in ['document', 'reading-order', 'reading-order-only']:
14775
            raise Exception("Argument 'order' must be either 'document', 'reading-order' or 'reading-order-only', not '{}'".format(order))
14776
        if depth < 0:
14777
            raise Exception("Argument 'depth' must be an integer greater-or-equal 0, not '{}'".format(depth))
14778
        ret = self._get_recursive_regions([self], depth + 1 if depth else 0, classes)
14779
        if self.__class__.__name__ == 'PageType' and order.startswith('reading-order'):
14780
            reading_order = self.get_ReadingOrder()
14781
            if reading_order:
14782
                reading_order = reading_order.get_OrderedGroup() or reading_order.get_UnorderedGroup()
14783
            if reading_order:
14784
                reading_order = self._get_recursive_reading_order(reading_order)
14785
            if reading_order:
14786
                id2region = {region.id: region for region in ret}
14787
                in_reading_order = [id2region[region_id] for region_id in reading_order if region_id in id2region]
14788
                #  print("ret: {} / in_ro: {} / not-in-ro: {}".format(
14789
                #      len(ret),
14790
                #      len([id2region[region_id] for region_id in reading_order if region_id in id2region]),
14791
                #      len([r for r in ret if r not in in_reading_order])
14792
                #      ))
14793
                if order == 'reading-order-only':
14794
                    ret = in_reading_order
14795
                else:
14796
                    ret = in_reading_order + [r for r in ret if r not in in_reading_order]
14797
        return ret
14798
    def set_orientation(self, orientation):
14799
        """
14800
        Set deskewing angle to given `orientation` number.
14801
        Moreover, invalidate self's ``pc:AlternativeImage``s
14802
        (because they will have been rotated and enlarged
14803
        with the angle of the previous value).
14804
        """
14805
        if hasattr(self, 'invalidate_AlternativeImage'):
14806
            # PageType, RegionType:
14807
            self.invalidate_AlternativeImage(feature_selector='deskewed')
14808
        self.orientation = orientation
14809
# end class TableRegionType
14810
14811
14812 View Code Duplication
class GraphicRegionType(RegionType):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
14813
    """GraphicRegionType --
14814
    Regions containing simple graphics, such as a company
14815
    logo, should be marked as graphic regions.
14816
      
14817
    * orientation --
14818
      The angle the rectangle encapsulating a region
14819
      has to be rotated in clockwise direction
14820
      in order to correct the present skew
14821
      (negative values indicate anti-clockwise rotation).
14822
      Range: -179.999,180
14823
      
14824
    * type --
14825
      The type of graphic in the region
14826
      
14827
    * numColours --
14828
      An approximation of the number of colours
14829
      used in the region
14830
      
14831
    * embText --
14832
      Specifies whether the region also contains
14833
      text.
14834
    
14835
    """
14836
    __hash__ = GeneratedsSuper.__hash__
14837
    member_data_items_ = [
14838
        MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional', 'name': 'orientation'}),
14839
        MemberSpec_('type_', 'pc:GraphicsTypeSimpleType', 0, 1, {'use': 'optional', 'name': 'type_'}),
14840
        MemberSpec_('numColours', 'int', 0, 1, {'use': 'optional', 'name': 'numColours'}),
14841
        MemberSpec_('embText', 'boolean', 0, 1, {'use': 'optional', 'name': 'embText'}),
14842
    ]
14843
    subclass = None
14844
    superclass = RegionType
14845
    def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, type_=None, numColours=None, embText=None, gds_collector_=None, **kwargs_):
14846
        self.gds_collector_ = gds_collector_
14847
        self.gds_elementtree_node_ = None
14848
        self.original_tagname_ = None
14849
        self.parent_object_ = kwargs_.get('parent_object_')
14850
        self.ns_prefix_ = "pc"
14851
        super(globals().get("GraphicRegionType"), self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion,  **kwargs_)
14852
        self.orientation = _cast(float, orientation)
14853
        self.orientation_nsprefix_ = "pc"
14854
        self.type_ = _cast(None, type_)
14855
        self.type__nsprefix_ = "pc"
14856
        self.numColours = _cast(int, numColours)
14857
        self.numColours_nsprefix_ = "pc"
14858
        self.embText = _cast(bool, embText)
14859
        self.embText_nsprefix_ = "pc"
14860
    def factory(*args_, **kwargs_):
14861
        if CurrentSubclassModule_ is not None:
14862
            subclass = getSubclassFromModule_(
14863
                CurrentSubclassModule_, GraphicRegionType)
14864
            if subclass is not None:
14865
                return subclass(*args_, **kwargs_)
14866
        if GraphicRegionType.subclass:
14867
            return GraphicRegionType.subclass(*args_, **kwargs_)
14868
        else:
14869
            return GraphicRegionType(*args_, **kwargs_)
14870
    factory = staticmethod(factory)
14871
    def get_ns_prefix_(self):
14872
        return self.ns_prefix_
14873
    def set_ns_prefix_(self, ns_prefix):
14874
        self.ns_prefix_ = ns_prefix
14875
    def get_orientation(self):
14876
        return self.orientation
14877
    def set_orientation(self, orientation):
14878
        self.orientation = orientation
14879
    def get_type(self):
14880
        return self.type_
14881
    def set_type(self, type_):
14882
        self.type_ = type_
14883
    def get_numColours(self):
14884
        return self.numColours
14885
    def set_numColours(self, numColours):
14886
        self.numColours = numColours
14887
    def get_embText(self):
14888
        return self.embText
14889
    def set_embText(self, embText):
14890
        self.embText = embText
14891
    def validate_GraphicsTypeSimpleType(self, value):
14892
        # Validate type pc:GraphicsTypeSimpleType, a restriction on string.
14893
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
14894
            if not isinstance(value, str):
14895
                lineno = self.gds_get_node_lineno_()
14896
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
14897
                return False
14898
            value = value
14899
            enumerations = ['logo', 'letterhead', 'decoration', 'frame', 'handwritten-annotation', 'stamp', 'signature', 'barcode', 'paper-grow', 'punch-hole', 'other']
14900
            if value not in enumerations:
14901
                lineno = self.gds_get_node_lineno_()
14902
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on GraphicsTypeSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
14903
                result = False
14904
    def has__content(self):
14905
        if (
14906
            super(GraphicRegionType, self).has__content()
14907
        ):
14908
            return True
14909
        else:
14910
            return False
14911
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GraphicRegionType', pretty_print=True):
14912
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('GraphicRegionType')
14913
        if imported_ns_def_ is not None:
14914
            namespacedef_ = imported_ns_def_
14915
        if pretty_print:
14916
            eol_ = '\n'
14917
        else:
14918
            eol_ = ''
14919
        if self.original_tagname_ is not None and name_ == 'GraphicRegionType':
14920
            name_ = self.original_tagname_
14921
        if UseCapturedNS_ and self.ns_prefix_:
14922
            namespaceprefix_ = self.ns_prefix_ + ':'
14923
        showIndent(outfile, level, pretty_print)
14924
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
14925
        already_processed = set()
14926
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='GraphicRegionType')
14927
        if self.has__content():
14928
            outfile.write('>%s' % (eol_, ))
14929
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='GraphicRegionType', pretty_print=pretty_print)
14930
            showIndent(outfile, level, pretty_print)
14931
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
14932
        else:
14933
            outfile.write('/>%s' % (eol_, ))
14934
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='GraphicRegionType'):
14935
        super(GraphicRegionType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='GraphicRegionType')
14936
        if self.orientation is not None and 'orientation' not in already_processed:
14937
            already_processed.add('orientation')
14938
            outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation'))
14939
        if self.type_ is not None and 'type_' not in already_processed:
14940
            already_processed.add('type_')
14941
            outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), ))
14942
        if self.numColours is not None and 'numColours' not in already_processed:
14943
            already_processed.add('numColours')
14944
            outfile.write(' numColours="%s"' % self.gds_format_integer(self.numColours, input_name='numColours'))
14945
        if self.embText is not None and 'embText' not in already_processed:
14946
            already_processed.add('embText')
14947
            outfile.write(' embText="%s"' % self.gds_format_boolean(self.embText, input_name='embText'))
14948
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GraphicRegionType', fromsubclass_=False, pretty_print=True):
14949
        super(GraphicRegionType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print)
14950
    def to_etree(self, parent_element=None, name_='GraphicRegionType', mapping_=None, reverse_mapping_=None, nsmap_=None):
14951
        element = super(GraphicRegionType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_)
14952
        if self.orientation is not None:
14953
            element.set('orientation', self.gds_format_float(self.orientation))
14954
        if self.type_ is not None:
14955
            element.set('type', self.gds_format_string(self.type_))
14956
        if self.numColours is not None:
14957
            element.set('numColours', self.gds_format_integer(self.numColours))
14958
        if self.embText is not None:
14959
            element.set('embText', self.gds_format_boolean(self.embText))
14960
        if mapping_ is not None:
14961
            mapping_[id(self)] = element
14962
        if reverse_mapping_ is not None:
14963
            reverse_mapping_[element] = self
14964
        return element
14965
    def build(self, node, gds_collector_=None):
14966
        self.gds_collector_ = gds_collector_
14967
        if SaveElementTreeNode:
14968
            self.gds_elementtree_node_ = node
14969
        already_processed = set()
14970
        self.ns_prefix_ = node.prefix
14971
        self._buildAttributes(node, node.attrib, already_processed)
14972
        for child in node:
14973
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
14974
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
14975
        return self
14976
    def _buildAttributes(self, node, attrs, already_processed):
14977
        value = find_attr_value_('orientation', node)
14978
        if value is not None and 'orientation' not in already_processed:
14979
            already_processed.add('orientation')
14980
            value = self.gds_parse_float(value, node, 'orientation')
14981
            self.orientation = value
14982
        value = find_attr_value_('type', node)
14983
        if value is not None and 'type' not in already_processed:
14984
            already_processed.add('type')
14985
            self.type_ = value
14986
            self.validate_GraphicsTypeSimpleType(self.type_)    # validate type GraphicsTypeSimpleType
14987
        value = find_attr_value_('numColours', node)
14988
        if value is not None and 'numColours' not in already_processed:
14989
            already_processed.add('numColours')
14990
            self.numColours = self.gds_parse_integer(value, node, 'numColours')
14991
        value = find_attr_value_('embText', node)
14992
        if value is not None and 'embText' not in already_processed:
14993
            already_processed.add('embText')
14994
            if value in ('true', '1'):
14995
                self.embText = True
14996
            elif value in ('false', '0'):
14997
                self.embText = False
14998
            else:
14999
                raise_parse_error(node, 'Bad boolean attribute')
15000
        super(GraphicRegionType, self)._buildAttributes(node, attrs, already_processed)
15001
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
15002
        super(GraphicRegionType, self)._buildChildren(child_, node, nodeName_, True)
15003
        pass
15004
    def __hash__(self):
15005
        return hash(self.id)
15006
    # pylint: disable=line-too-long,invalid-name,protected-access,missing-module-docstring
15007
    def _region_class(self, x): # pylint: disable=unused-argument
15008
        return x.__class__.__name__.replace('RegionType', '')
15009
    
15010
    def _get_recursive_regions(self, regions, level, classes=None):
15011
        from .constants import PAGE_REGION_TYPES  # pylint: disable=relative-beyond-top-level,import-outside-toplevel
15012
        if level == 1:
15013
            # stop recursion, filter classes
15014
            if classes:
15015
                return [r for r in regions if self._region_class(r) in classes]
15016
            if regions and regions[0].__class__.__name__ == 'PageType':
15017
                regions = regions[1:]
15018
            return regions
15019
        # find more regions recursively
15020
        more_regions = []
15021
        for region in regions:
15022
            more_regions.append([])
15023
            for class_ in PAGE_REGION_TYPES:
15024
                if class_ == 'Map' and not isinstance(region, PageType): # pylint: disable=undefined-variable
15025
                    # 'Map' is not recursive in 2019 schema
15026
                    continue
15027
                more_regions[-1] += getattr(region, 'get_{}Region'.format(class_))()
15028
        if not any(more_regions):
15029
            return self._get_recursive_regions(regions, 1, classes)
15030
        ret = []
15031
        for r, more in zip(regions, more_regions):
15032
            ret.append(r)
15033
            ret += self._get_recursive_regions(more, level - 1 if level else 0, classes)
15034
        return self._get_recursive_regions(ret, 1, classes)
15035
    
15036
    def _get_recursive_reading_order(self, rogroup):
15037
        if isinstance(rogroup, (OrderedGroupType, OrderedGroupIndexedType)): # pylint: disable=undefined-variable
15038
            elements = rogroup.get_AllIndexed()
15039
        if isinstance(rogroup, (UnorderedGroupType, UnorderedGroupIndexedType)): # pylint: disable=undefined-variable
15040
            elements = (rogroup.get_RegionRef() + rogroup.get_OrderedGroup() + rogroup.get_UnorderedGroup())
15041
        regionrefs = list()
15042
        for elem in elements:
15043
            regionrefs.append(elem.get_regionRef())
15044
            if not isinstance(elem, (RegionRefType, RegionRefIndexedType)): # pylint: disable=undefined-variable
15045
                regionrefs.extend(self._get_recursive_reading_order(elem))
15046
        return regionrefs
15047
    
15048
    def get_AllRegions(self, classes=None, order='document', depth=0):
15049
        """
15050
        Get all the ``*Region`` elements, or only those provided by `classes`.
15051
        Return in document order, unless the top element is ``Page`` and
15052
        `order` is ``reading-order``.
15053
    
15054
        Arguments:
15055
            classes (list): Classes of regions that shall be returned, \
15056
                e.g. ``['Text', 'Image']``
15057
            order ("document"|"reading-order"|"reading-order-only"): Whether to \
15058
                return regions sorted by document order (``document``, default) or by
15059
                reading order with regions not in the reading order at the end of the
15060
                returned list (``reading-order``) or regions not in the reading order
15061
                omitted (``reading-order-only``). The latter two are only available
15062
                on page level.
15063
            depth (int): Recursive depth to look for regions at, set to `0` for \
15064
                all regions at any depth. Default: 0
15065
    
15066
        Returns:
15067
            a list of :py:class:`TextRegionType`, :py:class:`ImageRegionType`, \
15068
                :py:class:`LineDrawingRegionType`, :py:class:`GraphicRegionType`, \
15069
                :py:class:`TableRegionType`, :py:class:`ChartRegionType`, \
15070
                :py:class:`MapRegionType`, :py:class:`SeparatorRegionType`, \
15071
                :py:class:`MathsRegionType`, :py:class:`ChemRegionType`, \
15072
                :py:class:`MusicRegionType`, :py:class:`AdvertRegionType`, \
15073
                :py:class:`NoiseRegionType`, :py:class:`UnknownRegionType`, \
15074
                and/or :py:class:`CustomRegionType`
15075
    
15076
        For example, to get all text anywhere on the page in reading order, use:
15077
        ::
15078
            '\\n'.join(line.get_TextEquiv()[0].Unicode
15079
                      for region in page.get_AllRegions(classes=['Text'], depth=0, order='reading-order')
15080
                      for line in region.get_TextLine())
15081
        """
15082
        if order not in ['document', 'reading-order', 'reading-order-only']:
15083
            raise Exception("Argument 'order' must be either 'document', 'reading-order' or 'reading-order-only', not '{}'".format(order))
15084
        if depth < 0:
15085
            raise Exception("Argument 'depth' must be an integer greater-or-equal 0, not '{}'".format(depth))
15086
        ret = self._get_recursive_regions([self], depth + 1 if depth else 0, classes)
15087
        if self.__class__.__name__ == 'PageType' and order.startswith('reading-order'):
15088
            reading_order = self.get_ReadingOrder()
15089
            if reading_order:
15090
                reading_order = reading_order.get_OrderedGroup() or reading_order.get_UnorderedGroup()
15091
            if reading_order:
15092
                reading_order = self._get_recursive_reading_order(reading_order)
15093
            if reading_order:
15094
                id2region = {region.id: region for region in ret}
15095
                in_reading_order = [id2region[region_id] for region_id in reading_order if region_id in id2region]
15096
                #  print("ret: {} / in_ro: {} / not-in-ro: {}".format(
15097
                #      len(ret),
15098
                #      len([id2region[region_id] for region_id in reading_order if region_id in id2region]),
15099
                #      len([r for r in ret if r not in in_reading_order])
15100
                #      ))
15101
                if order == 'reading-order-only':
15102
                    ret = in_reading_order
15103
                else:
15104
                    ret = in_reading_order + [r for r in ret if r not in in_reading_order]
15105
        return ret
15106
    def set_orientation(self, orientation):
15107
        """
15108
        Set deskewing angle to given `orientation` number.
15109
        Moreover, invalidate self's ``pc:AlternativeImage``s
15110
        (because they will have been rotated and enlarged
15111
        with the angle of the previous value).
15112
        """
15113
        if hasattr(self, 'invalidate_AlternativeImage'):
15114
            # PageType, RegionType:
15115
            self.invalidate_AlternativeImage(feature_selector='deskewed')
15116
        self.orientation = orientation
15117
# end class GraphicRegionType
15118
15119
15120 View Code Duplication
class LineDrawingRegionType(RegionType):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
15121
    """LineDrawingRegionType --
15122
    A line drawing is a single colour illustration without
15123
    solid areas.
15124
      
15125
    * orientation --
15126
      The angle the rectangle encapsulating a region
15127
      has to be rotated in clockwise direction
15128
      in order to correct the present skew
15129
      (negative values indicate anti-clockwise rotation).
15130
      Range: -179.999,180
15131
      
15132
    * penColour --
15133
      The pen (foreground) colour of the region
15134
      
15135
    * bgColour --
15136
      The background colour of the region
15137
      
15138
    * embText --
15139
      Specifies whether the region also contains
15140
      text
15141
    
15142
    """
15143
    __hash__ = GeneratedsSuper.__hash__
15144
    member_data_items_ = [
15145
        MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional', 'name': 'orientation'}),
15146
        MemberSpec_('penColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional', 'name': 'penColour'}),
15147
        MemberSpec_('bgColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional', 'name': 'bgColour'}),
15148
        MemberSpec_('embText', 'boolean', 0, 1, {'use': 'optional', 'name': 'embText'}),
15149
    ]
15150
    subclass = None
15151
    superclass = RegionType
15152
    def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, penColour=None, bgColour=None, embText=None, gds_collector_=None, **kwargs_):
15153
        self.gds_collector_ = gds_collector_
15154
        self.gds_elementtree_node_ = None
15155
        self.original_tagname_ = None
15156
        self.parent_object_ = kwargs_.get('parent_object_')
15157
        self.ns_prefix_ = "pc"
15158
        super(globals().get("LineDrawingRegionType"), self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion,  **kwargs_)
15159
        self.orientation = _cast(float, orientation)
15160
        self.orientation_nsprefix_ = "pc"
15161
        self.penColour = _cast(None, penColour)
15162
        self.penColour_nsprefix_ = "pc"
15163
        self.bgColour = _cast(None, bgColour)
15164
        self.bgColour_nsprefix_ = "pc"
15165
        self.embText = _cast(bool, embText)
15166
        self.embText_nsprefix_ = "pc"
15167
    def factory(*args_, **kwargs_):
15168
        if CurrentSubclassModule_ is not None:
15169
            subclass = getSubclassFromModule_(
15170
                CurrentSubclassModule_, LineDrawingRegionType)
15171
            if subclass is not None:
15172
                return subclass(*args_, **kwargs_)
15173
        if LineDrawingRegionType.subclass:
15174
            return LineDrawingRegionType.subclass(*args_, **kwargs_)
15175
        else:
15176
            return LineDrawingRegionType(*args_, **kwargs_)
15177
    factory = staticmethod(factory)
15178
    def get_ns_prefix_(self):
15179
        return self.ns_prefix_
15180
    def set_ns_prefix_(self, ns_prefix):
15181
        self.ns_prefix_ = ns_prefix
15182
    def get_orientation(self):
15183
        return self.orientation
15184
    def set_orientation(self, orientation):
15185
        self.orientation = orientation
15186
    def get_penColour(self):
15187
        return self.penColour
15188
    def set_penColour(self, penColour):
15189
        self.penColour = penColour
15190
    def get_bgColour(self):
15191
        return self.bgColour
15192
    def set_bgColour(self, bgColour):
15193
        self.bgColour = bgColour
15194
    def get_embText(self):
15195
        return self.embText
15196
    def set_embText(self, embText):
15197
        self.embText = embText
15198
    def validate_ColourSimpleType(self, value):
15199
        # Validate type pc:ColourSimpleType, a restriction on string.
15200
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
15201
            if not isinstance(value, str):
15202
                lineno = self.gds_get_node_lineno_()
15203
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
15204
                return False
15205
            value = value
15206
            enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other']
15207
            if value not in enumerations:
15208
                lineno = self.gds_get_node_lineno_()
15209
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ColourSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
15210
                result = False
15211
    def has__content(self):
15212
        if (
15213
            super(LineDrawingRegionType, self).has__content()
15214
        ):
15215
            return True
15216
        else:
15217
            return False
15218
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='LineDrawingRegionType', pretty_print=True):
15219
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('LineDrawingRegionType')
15220
        if imported_ns_def_ is not None:
15221
            namespacedef_ = imported_ns_def_
15222
        if pretty_print:
15223
            eol_ = '\n'
15224
        else:
15225
            eol_ = ''
15226
        if self.original_tagname_ is not None and name_ == 'LineDrawingRegionType':
15227
            name_ = self.original_tagname_
15228
        if UseCapturedNS_ and self.ns_prefix_:
15229
            namespaceprefix_ = self.ns_prefix_ + ':'
15230
        showIndent(outfile, level, pretty_print)
15231
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
15232
        already_processed = set()
15233
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='LineDrawingRegionType')
15234
        if self.has__content():
15235
            outfile.write('>%s' % (eol_, ))
15236
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='LineDrawingRegionType', pretty_print=pretty_print)
15237
            showIndent(outfile, level, pretty_print)
15238
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
15239
        else:
15240
            outfile.write('/>%s' % (eol_, ))
15241
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='LineDrawingRegionType'):
15242
        super(LineDrawingRegionType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='LineDrawingRegionType')
15243
        if self.orientation is not None and 'orientation' not in already_processed:
15244
            already_processed.add('orientation')
15245
            outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation'))
15246
        if self.penColour is not None and 'penColour' not in already_processed:
15247
            already_processed.add('penColour')
15248
            outfile.write(' penColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.penColour), input_name='penColour')), ))
15249
        if self.bgColour is not None and 'bgColour' not in already_processed:
15250
            already_processed.add('bgColour')
15251
            outfile.write(' bgColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.bgColour), input_name='bgColour')), ))
15252
        if self.embText is not None and 'embText' not in already_processed:
15253
            already_processed.add('embText')
15254
            outfile.write(' embText="%s"' % self.gds_format_boolean(self.embText, input_name='embText'))
15255
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='LineDrawingRegionType', fromsubclass_=False, pretty_print=True):
15256
        super(LineDrawingRegionType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print)
15257
    def to_etree(self, parent_element=None, name_='LineDrawingRegionType', mapping_=None, reverse_mapping_=None, nsmap_=None):
15258
        element = super(LineDrawingRegionType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_)
15259
        if self.orientation is not None:
15260
            element.set('orientation', self.gds_format_float(self.orientation))
15261
        if self.penColour is not None:
15262
            element.set('penColour', self.gds_format_string(self.penColour))
15263
        if self.bgColour is not None:
15264
            element.set('bgColour', self.gds_format_string(self.bgColour))
15265
        if self.embText is not None:
15266
            element.set('embText', self.gds_format_boolean(self.embText))
15267
        if mapping_ is not None:
15268
            mapping_[id(self)] = element
15269
        if reverse_mapping_ is not None:
15270
            reverse_mapping_[element] = self
15271
        return element
15272
    def build(self, node, gds_collector_=None):
15273
        self.gds_collector_ = gds_collector_
15274
        if SaveElementTreeNode:
15275
            self.gds_elementtree_node_ = node
15276
        already_processed = set()
15277
        self.ns_prefix_ = node.prefix
15278
        self._buildAttributes(node, node.attrib, already_processed)
15279
        for child in node:
15280
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
15281
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
15282
        return self
15283
    def _buildAttributes(self, node, attrs, already_processed):
15284
        value = find_attr_value_('orientation', node)
15285
        if value is not None and 'orientation' not in already_processed:
15286
            already_processed.add('orientation')
15287
            value = self.gds_parse_float(value, node, 'orientation')
15288
            self.orientation = value
15289
        value = find_attr_value_('penColour', node)
15290
        if value is not None and 'penColour' not in already_processed:
15291
            already_processed.add('penColour')
15292
            self.penColour = value
15293
            self.validate_ColourSimpleType(self.penColour)    # validate type ColourSimpleType
15294
        value = find_attr_value_('bgColour', node)
15295
        if value is not None and 'bgColour' not in already_processed:
15296
            already_processed.add('bgColour')
15297
            self.bgColour = value
15298
            self.validate_ColourSimpleType(self.bgColour)    # validate type ColourSimpleType
15299
        value = find_attr_value_('embText', node)
15300
        if value is not None and 'embText' not in already_processed:
15301
            already_processed.add('embText')
15302
            if value in ('true', '1'):
15303
                self.embText = True
15304
            elif value in ('false', '0'):
15305
                self.embText = False
15306
            else:
15307
                raise_parse_error(node, 'Bad boolean attribute')
15308
        super(LineDrawingRegionType, self)._buildAttributes(node, attrs, already_processed)
15309
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
15310
        super(LineDrawingRegionType, self)._buildChildren(child_, node, nodeName_, True)
15311
        pass
15312
    def __hash__(self):
15313
        return hash(self.id)
15314
    # pylint: disable=line-too-long,invalid-name,protected-access,missing-module-docstring
15315
    def _region_class(self, x): # pylint: disable=unused-argument
15316
        return x.__class__.__name__.replace('RegionType', '')
15317
    
15318
    def _get_recursive_regions(self, regions, level, classes=None):
15319
        from .constants import PAGE_REGION_TYPES  # pylint: disable=relative-beyond-top-level,import-outside-toplevel
15320
        if level == 1:
15321
            # stop recursion, filter classes
15322
            if classes:
15323
                return [r for r in regions if self._region_class(r) in classes]
15324
            if regions and regions[0].__class__.__name__ == 'PageType':
15325
                regions = regions[1:]
15326
            return regions
15327
        # find more regions recursively
15328
        more_regions = []
15329
        for region in regions:
15330
            more_regions.append([])
15331
            for class_ in PAGE_REGION_TYPES:
15332
                if class_ == 'Map' and not isinstance(region, PageType): # pylint: disable=undefined-variable
15333
                    # 'Map' is not recursive in 2019 schema
15334
                    continue
15335
                more_regions[-1] += getattr(region, 'get_{}Region'.format(class_))()
15336
        if not any(more_regions):
15337
            return self._get_recursive_regions(regions, 1, classes)
15338
        ret = []
15339
        for r, more in zip(regions, more_regions):
15340
            ret.append(r)
15341
            ret += self._get_recursive_regions(more, level - 1 if level else 0, classes)
15342
        return self._get_recursive_regions(ret, 1, classes)
15343
    
15344
    def _get_recursive_reading_order(self, rogroup):
15345
        if isinstance(rogroup, (OrderedGroupType, OrderedGroupIndexedType)): # pylint: disable=undefined-variable
15346
            elements = rogroup.get_AllIndexed()
15347
        if isinstance(rogroup, (UnorderedGroupType, UnorderedGroupIndexedType)): # pylint: disable=undefined-variable
15348
            elements = (rogroup.get_RegionRef() + rogroup.get_OrderedGroup() + rogroup.get_UnorderedGroup())
15349
        regionrefs = list()
15350
        for elem in elements:
15351
            regionrefs.append(elem.get_regionRef())
15352
            if not isinstance(elem, (RegionRefType, RegionRefIndexedType)): # pylint: disable=undefined-variable
15353
                regionrefs.extend(self._get_recursive_reading_order(elem))
15354
        return regionrefs
15355
    
15356
    def get_AllRegions(self, classes=None, order='document', depth=0):
15357
        """
15358
        Get all the ``*Region`` elements, or only those provided by `classes`.
15359
        Return in document order, unless the top element is ``Page`` and
15360
        `order` is ``reading-order``.
15361
    
15362
        Arguments:
15363
            classes (list): Classes of regions that shall be returned, \
15364
                e.g. ``['Text', 'Image']``
15365
            order ("document"|"reading-order"|"reading-order-only"): Whether to \
15366
                return regions sorted by document order (``document``, default) or by
15367
                reading order with regions not in the reading order at the end of the
15368
                returned list (``reading-order``) or regions not in the reading order
15369
                omitted (``reading-order-only``). The latter two are only available
15370
                on page level.
15371
            depth (int): Recursive depth to look for regions at, set to `0` for \
15372
                all regions at any depth. Default: 0
15373
    
15374
        Returns:
15375
            a list of :py:class:`TextRegionType`, :py:class:`ImageRegionType`, \
15376
                :py:class:`LineDrawingRegionType`, :py:class:`GraphicRegionType`, \
15377
                :py:class:`TableRegionType`, :py:class:`ChartRegionType`, \
15378
                :py:class:`MapRegionType`, :py:class:`SeparatorRegionType`, \
15379
                :py:class:`MathsRegionType`, :py:class:`ChemRegionType`, \
15380
                :py:class:`MusicRegionType`, :py:class:`AdvertRegionType`, \
15381
                :py:class:`NoiseRegionType`, :py:class:`UnknownRegionType`, \
15382
                and/or :py:class:`CustomRegionType`
15383
    
15384
        For example, to get all text anywhere on the page in reading order, use:
15385
        ::
15386
            '\\n'.join(line.get_TextEquiv()[0].Unicode
15387
                      for region in page.get_AllRegions(classes=['Text'], depth=0, order='reading-order')
15388
                      for line in region.get_TextLine())
15389
        """
15390
        if order not in ['document', 'reading-order', 'reading-order-only']:
15391
            raise Exception("Argument 'order' must be either 'document', 'reading-order' or 'reading-order-only', not '{}'".format(order))
15392
        if depth < 0:
15393
            raise Exception("Argument 'depth' must be an integer greater-or-equal 0, not '{}'".format(depth))
15394
        ret = self._get_recursive_regions([self], depth + 1 if depth else 0, classes)
15395
        if self.__class__.__name__ == 'PageType' and order.startswith('reading-order'):
15396
            reading_order = self.get_ReadingOrder()
15397
            if reading_order:
15398
                reading_order = reading_order.get_OrderedGroup() or reading_order.get_UnorderedGroup()
15399
            if reading_order:
15400
                reading_order = self._get_recursive_reading_order(reading_order)
15401
            if reading_order:
15402
                id2region = {region.id: region for region in ret}
15403
                in_reading_order = [id2region[region_id] for region_id in reading_order if region_id in id2region]
15404
                #  print("ret: {} / in_ro: {} / not-in-ro: {}".format(
15405
                #      len(ret),
15406
                #      len([id2region[region_id] for region_id in reading_order if region_id in id2region]),
15407
                #      len([r for r in ret if r not in in_reading_order])
15408
                #      ))
15409
                if order == 'reading-order-only':
15410
                    ret = in_reading_order
15411
                else:
15412
                    ret = in_reading_order + [r for r in ret if r not in in_reading_order]
15413
        return ret
15414
    def set_orientation(self, orientation):
15415
        """
15416
        Set deskewing angle to given `orientation` number.
15417
        Moreover, invalidate self's ``pc:AlternativeImage``s
15418
        (because they will have been rotated and enlarged
15419
        with the angle of the previous value).
15420
        """
15421
        if hasattr(self, 'invalidate_AlternativeImage'):
15422
            # PageType, RegionType:
15423
            self.invalidate_AlternativeImage(feature_selector='deskewed')
15424
        self.orientation = orientation
15425
# end class LineDrawingRegionType
15426
15427
15428
class ImageRegionType(RegionType):
15429
    """ImageRegionType --
15430
    An image is considered to be more intricate and complex
15431
    than a graphic. These can be photos or drawings.
15432
      
15433
    * orientation --
15434
      The angle the rectangle encapsulating a region
15435
      has to be rotated in clockwise direction
15436
      in order to correct the present skew
15437
      (negative values indicate anti-clockwise rotation).
15438
      Range: -179.999,180
15439
      
15440
    * colourDepth --
15441
      The colour bit depth required for the region
15442
      
15443
    * bgColour --
15444
      The background colour of the region
15445
      
15446
    * embText --
15447
      Specifies whether the region also contains
15448
      text
15449
    
15450
    """
15451
    __hash__ = GeneratedsSuper.__hash__
15452
    member_data_items_ = [
15453
        MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional', 'name': 'orientation'}),
15454
        MemberSpec_('colourDepth', 'pc:ColourDepthSimpleType', 0, 1, {'use': 'optional', 'name': 'colourDepth'}),
15455
        MemberSpec_('bgColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional', 'name': 'bgColour'}),
15456
        MemberSpec_('embText', 'boolean', 0, 1, {'use': 'optional', 'name': 'embText'}),
15457
    ]
15458
    subclass = None
15459
    superclass = RegionType
15460
    def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, colourDepth=None, bgColour=None, embText=None, gds_collector_=None, **kwargs_):
15461
        self.gds_collector_ = gds_collector_
15462
        self.gds_elementtree_node_ = None
15463
        self.original_tagname_ = None
15464
        self.parent_object_ = kwargs_.get('parent_object_')
15465
        self.ns_prefix_ = "pc"
15466
        super(globals().get("ImageRegionType"), self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion,  **kwargs_)
15467
        self.orientation = _cast(float, orientation)
15468
        self.orientation_nsprefix_ = "pc"
15469
        self.colourDepth = _cast(None, colourDepth)
15470
        self.colourDepth_nsprefix_ = "pc"
15471
        self.bgColour = _cast(None, bgColour)
15472
        self.bgColour_nsprefix_ = "pc"
15473
        self.embText = _cast(bool, embText)
15474
        self.embText_nsprefix_ = "pc"
15475
    def factory(*args_, **kwargs_):
15476
        if CurrentSubclassModule_ is not None:
15477
            subclass = getSubclassFromModule_(
15478
                CurrentSubclassModule_, ImageRegionType)
15479
            if subclass is not None:
15480
                return subclass(*args_, **kwargs_)
15481
        if ImageRegionType.subclass:
15482
            return ImageRegionType.subclass(*args_, **kwargs_)
15483
        else:
15484
            return ImageRegionType(*args_, **kwargs_)
15485
    factory = staticmethod(factory)
15486
    def get_ns_prefix_(self):
15487
        return self.ns_prefix_
15488
    def set_ns_prefix_(self, ns_prefix):
15489
        self.ns_prefix_ = ns_prefix
15490
    def get_orientation(self):
15491
        return self.orientation
15492
    def set_orientation(self, orientation):
15493
        self.orientation = orientation
15494
    def get_colourDepth(self):
15495
        return self.colourDepth
15496
    def set_colourDepth(self, colourDepth):
15497
        self.colourDepth = colourDepth
15498
    def get_bgColour(self):
15499
        return self.bgColour
15500
    def set_bgColour(self, bgColour):
15501
        self.bgColour = bgColour
15502
    def get_embText(self):
15503
        return self.embText
15504
    def set_embText(self, embText):
15505
        self.embText = embText
15506
    def validate_ColourDepthSimpleType(self, value):
15507
        # Validate type pc:ColourDepthSimpleType, a restriction on string.
15508
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
15509
            if not isinstance(value, str):
15510
                lineno = self.gds_get_node_lineno_()
15511
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
15512
                return False
15513
            value = value
15514
            enumerations = ['bilevel', 'greyscale', 'colour', 'other']
15515
            if value not in enumerations:
15516
                lineno = self.gds_get_node_lineno_()
15517
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ColourDepthSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
15518
                result = False
15519
    def validate_ColourSimpleType(self, value):
15520
        # Validate type pc:ColourSimpleType, a restriction on string.
15521
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
15522
            if not isinstance(value, str):
15523
                lineno = self.gds_get_node_lineno_()
15524
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
15525
                return False
15526
            value = value
15527
            enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other']
15528
            if value not in enumerations:
15529
                lineno = self.gds_get_node_lineno_()
15530
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ColourSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
15531
                result = False
15532
    def has__content(self):
15533
        if (
15534
            super(ImageRegionType, self).has__content()
15535
        ):
15536
            return True
15537
        else:
15538
            return False
15539
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='ImageRegionType', pretty_print=True):
15540
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('ImageRegionType')
15541
        if imported_ns_def_ is not None:
15542
            namespacedef_ = imported_ns_def_
15543
        if pretty_print:
15544
            eol_ = '\n'
15545
        else:
15546
            eol_ = ''
15547
        if self.original_tagname_ is not None and name_ == 'ImageRegionType':
15548
            name_ = self.original_tagname_
15549
        if UseCapturedNS_ and self.ns_prefix_:
15550
            namespaceprefix_ = self.ns_prefix_ + ':'
15551
        showIndent(outfile, level, pretty_print)
15552
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
15553
        already_processed = set()
15554
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='ImageRegionType')
15555
        if self.has__content():
15556
            outfile.write('>%s' % (eol_, ))
15557
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='ImageRegionType', pretty_print=pretty_print)
15558
            showIndent(outfile, level, pretty_print)
15559
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
15560
        else:
15561
            outfile.write('/>%s' % (eol_, ))
15562
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='ImageRegionType'):
15563
        super(ImageRegionType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='ImageRegionType')
15564
        if self.orientation is not None and 'orientation' not in already_processed:
15565
            already_processed.add('orientation')
15566
            outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation'))
15567
        if self.colourDepth is not None and 'colourDepth' not in already_processed:
15568
            already_processed.add('colourDepth')
15569
            outfile.write(' colourDepth=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.colourDepth), input_name='colourDepth')), ))
15570
        if self.bgColour is not None and 'bgColour' not in already_processed:
15571
            already_processed.add('bgColour')
15572
            outfile.write(' bgColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.bgColour), input_name='bgColour')), ))
15573
        if self.embText is not None and 'embText' not in already_processed:
15574
            already_processed.add('embText')
15575
            outfile.write(' embText="%s"' % self.gds_format_boolean(self.embText, input_name='embText'))
15576
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='ImageRegionType', fromsubclass_=False, pretty_print=True):
15577
        super(ImageRegionType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print)
15578
    def to_etree(self, parent_element=None, name_='ImageRegionType', mapping_=None, reverse_mapping_=None, nsmap_=None):
15579
        element = super(ImageRegionType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_)
15580
        if self.orientation is not None:
15581
            element.set('orientation', self.gds_format_float(self.orientation))
15582
        if self.colourDepth is not None:
15583
            element.set('colourDepth', self.gds_format_string(self.colourDepth))
15584
        if self.bgColour is not None:
15585
            element.set('bgColour', self.gds_format_string(self.bgColour))
15586
        if self.embText is not None:
15587
            element.set('embText', self.gds_format_boolean(self.embText))
15588
        if mapping_ is not None:
15589
            mapping_[id(self)] = element
15590
        if reverse_mapping_ is not None:
15591
            reverse_mapping_[element] = self
15592
        return element
15593
    def build(self, node, gds_collector_=None):
15594
        self.gds_collector_ = gds_collector_
15595
        if SaveElementTreeNode:
15596
            self.gds_elementtree_node_ = node
15597
        already_processed = set()
15598
        self.ns_prefix_ = node.prefix
15599
        self._buildAttributes(node, node.attrib, already_processed)
15600
        for child in node:
15601
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
15602
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
15603
        return self
15604
    def _buildAttributes(self, node, attrs, already_processed):
15605
        value = find_attr_value_('orientation', node)
15606
        if value is not None and 'orientation' not in already_processed:
15607
            already_processed.add('orientation')
15608
            value = self.gds_parse_float(value, node, 'orientation')
15609
            self.orientation = value
15610
        value = find_attr_value_('colourDepth', node)
15611
        if value is not None and 'colourDepth' not in already_processed:
15612
            already_processed.add('colourDepth')
15613
            self.colourDepth = value
15614
            self.validate_ColourDepthSimpleType(self.colourDepth)    # validate type ColourDepthSimpleType
15615
        value = find_attr_value_('bgColour', node)
15616
        if value is not None and 'bgColour' not in already_processed:
15617
            already_processed.add('bgColour')
15618
            self.bgColour = value
15619
            self.validate_ColourSimpleType(self.bgColour)    # validate type ColourSimpleType
15620
        value = find_attr_value_('embText', node)
15621
        if value is not None and 'embText' not in already_processed:
15622
            already_processed.add('embText')
15623
            if value in ('true', '1'):
15624
                self.embText = True
15625
            elif value in ('false', '0'):
15626
                self.embText = False
15627
            else:
15628
                raise_parse_error(node, 'Bad boolean attribute')
15629
        super(ImageRegionType, self)._buildAttributes(node, attrs, already_processed)
15630
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
15631
        super(ImageRegionType, self)._buildChildren(child_, node, nodeName_, True)
15632
        pass
15633
    def __hash__(self):
15634
        return hash(self.id)
15635
    # pylint: disable=line-too-long,invalid-name,protected-access,missing-module-docstring
15636
    def _region_class(self, x): # pylint: disable=unused-argument
15637
        return x.__class__.__name__.replace('RegionType', '')
15638
    
15639
    def _get_recursive_regions(self, regions, level, classes=None):
15640
        from .constants import PAGE_REGION_TYPES  # pylint: disable=relative-beyond-top-level,import-outside-toplevel
15641
        if level == 1:
15642
            # stop recursion, filter classes
15643
            if classes:
15644
                return [r for r in regions if self._region_class(r) in classes]
15645
            if regions and regions[0].__class__.__name__ == 'PageType':
15646
                regions = regions[1:]
15647
            return regions
15648
        # find more regions recursively
15649
        more_regions = []
15650
        for region in regions:
15651
            more_regions.append([])
15652
            for class_ in PAGE_REGION_TYPES:
15653
                if class_ == 'Map' and not isinstance(region, PageType): # pylint: disable=undefined-variable
15654
                    # 'Map' is not recursive in 2019 schema
15655
                    continue
15656
                more_regions[-1] += getattr(region, 'get_{}Region'.format(class_))()
15657
        if not any(more_regions):
15658
            return self._get_recursive_regions(regions, 1, classes)
15659
        ret = []
15660
        for r, more in zip(regions, more_regions):
15661
            ret.append(r)
15662
            ret += self._get_recursive_regions(more, level - 1 if level else 0, classes)
15663
        return self._get_recursive_regions(ret, 1, classes)
15664
    
15665
    def _get_recursive_reading_order(self, rogroup):
15666
        if isinstance(rogroup, (OrderedGroupType, OrderedGroupIndexedType)): # pylint: disable=undefined-variable
15667
            elements = rogroup.get_AllIndexed()
15668
        if isinstance(rogroup, (UnorderedGroupType, UnorderedGroupIndexedType)): # pylint: disable=undefined-variable
15669
            elements = (rogroup.get_RegionRef() + rogroup.get_OrderedGroup() + rogroup.get_UnorderedGroup())
15670
        regionrefs = list()
15671
        for elem in elements:
15672
            regionrefs.append(elem.get_regionRef())
15673
            if not isinstance(elem, (RegionRefType, RegionRefIndexedType)): # pylint: disable=undefined-variable
15674
                regionrefs.extend(self._get_recursive_reading_order(elem))
15675
        return regionrefs
15676
    
15677
    def get_AllRegions(self, classes=None, order='document', depth=0):
15678
        """
15679
        Get all the ``*Region`` elements, or only those provided by `classes`.
15680
        Return in document order, unless the top element is ``Page`` and
15681
        `order` is ``reading-order``.
15682
    
15683
        Arguments:
15684
            classes (list): Classes of regions that shall be returned, \
15685
                e.g. ``['Text', 'Image']``
15686
            order ("document"|"reading-order"|"reading-order-only"): Whether to \
15687
                return regions sorted by document order (``document``, default) or by
15688
                reading order with regions not in the reading order at the end of the
15689
                returned list (``reading-order``) or regions not in the reading order
15690
                omitted (``reading-order-only``). The latter two are only available
15691
                on page level.
15692
            depth (int): Recursive depth to look for regions at, set to `0` for \
15693
                all regions at any depth. Default: 0
15694
    
15695
        Returns:
15696
            a list of :py:class:`TextRegionType`, :py:class:`ImageRegionType`, \
15697
                :py:class:`LineDrawingRegionType`, :py:class:`GraphicRegionType`, \
15698
                :py:class:`TableRegionType`, :py:class:`ChartRegionType`, \
15699
                :py:class:`MapRegionType`, :py:class:`SeparatorRegionType`, \
15700
                :py:class:`MathsRegionType`, :py:class:`ChemRegionType`, \
15701
                :py:class:`MusicRegionType`, :py:class:`AdvertRegionType`, \
15702
                :py:class:`NoiseRegionType`, :py:class:`UnknownRegionType`, \
15703
                and/or :py:class:`CustomRegionType`
15704
    
15705
        For example, to get all text anywhere on the page in reading order, use:
15706
        ::
15707
            '\\n'.join(line.get_TextEquiv()[0].Unicode
15708
                      for region in page.get_AllRegions(classes=['Text'], depth=0, order='reading-order')
15709
                      for line in region.get_TextLine())
15710
        """
15711
        if order not in ['document', 'reading-order', 'reading-order-only']:
15712
            raise Exception("Argument 'order' must be either 'document', 'reading-order' or 'reading-order-only', not '{}'".format(order))
15713
        if depth < 0:
15714
            raise Exception("Argument 'depth' must be an integer greater-or-equal 0, not '{}'".format(depth))
15715
        ret = self._get_recursive_regions([self], depth + 1 if depth else 0, classes)
15716
        if self.__class__.__name__ == 'PageType' and order.startswith('reading-order'):
15717
            reading_order = self.get_ReadingOrder()
15718
            if reading_order:
15719
                reading_order = reading_order.get_OrderedGroup() or reading_order.get_UnorderedGroup()
15720
            if reading_order:
15721
                reading_order = self._get_recursive_reading_order(reading_order)
15722
            if reading_order:
15723
                id2region = {region.id: region for region in ret}
15724
                in_reading_order = [id2region[region_id] for region_id in reading_order if region_id in id2region]
15725
                #  print("ret: {} / in_ro: {} / not-in-ro: {}".format(
15726
                #      len(ret),
15727
                #      len([id2region[region_id] for region_id in reading_order if region_id in id2region]),
15728
                #      len([r for r in ret if r not in in_reading_order])
15729
                #      ))
15730
                if order == 'reading-order-only':
15731
                    ret = in_reading_order
15732
                else:
15733
                    ret = in_reading_order + [r for r in ret if r not in in_reading_order]
15734
        return ret
15735
    def set_orientation(self, orientation):
15736
        """
15737
        Set deskewing angle to given `orientation` number.
15738
        Moreover, invalidate self's ``pc:AlternativeImage``s
15739
        (because they will have been rotated and enlarged
15740
        with the angle of the previous value).
15741
        """
15742
        if hasattr(self, 'invalidate_AlternativeImage'):
15743
            # PageType, RegionType:
15744
            self.invalidate_AlternativeImage(feature_selector='deskewed')
15745
        self.orientation = orientation
15746
# end class ImageRegionType
15747
15748
15749
class TextRegionType(RegionType):
15750
    """TextRegionType --
15751
    Pure text is represented as a text region. This includes
15752
    drop capitals, but practically ornate text may be
15753
    considered as a graphic.
15754
      
15755
    * orientation --
15756
      The angle the rectangle encapsulating the region
15757
      has to be rotated in clockwise direction
15758
      in order to correct the present skew
15759
      (negative values indicate anti-clockwise rotation).
15760
      (The rotated image can be further referenced
15761
      via
15762
15763
      AlternativeImage
15764
15765
      .)
15766
      Range: -179.999,180
15767
      
15768
    * type --
15769
      The nature of the text in the region
15770
      
15771
    * leading --
15772
      The degree of space in points between the lines of
15773
      text (line spacing)
15774
      
15775
    * readingDirection --
15776
      The direction in which text within lines
15777
      should be read (order of words and characters),
15778
      in addition to
15779
15780
      textLineOrder
15781
15782
      .
15783
      
15784
    * textLineOrder --
15785
      The order of text lines within the block,
15786
      in addition to
15787
15788
      readingDirection
15789
15790
      .
15791
      
15792
    * readingOrientation --
15793
      The angle the baseline of text within the region
15794
      has to be rotated (relative to the rectangle
15795
      encapsulating the region) in clockwise direction
15796
      in order to correct the present skew,
15797
      in addition to
15798
15799
      orientation
15800
15801
      (negative values indicate anti-clockwise rotation).
15802
      Range: -179.999,180
15803
      
15804
    * indented --
15805
      Defines whether a region of text is indented or not
15806
      
15807
    * align -- Text align
15808
    * primaryLanguage --
15809
      The primary language used in the region
15810
      
15811
    * secondaryLanguage --
15812
      The secondary language used in the region
15813
      
15814
    * primaryScript --
15815
      The primary script used in the region
15816
      
15817
    * secondaryScript --
15818
      The secondary script used in the region
15819
    
15820
    """
15821
    __hash__ = GeneratedsSuper.__hash__
15822
    member_data_items_ = [
15823
        MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional', 'name': 'orientation'}),
15824
        MemberSpec_('type_', 'pc:TextTypeSimpleType', 0, 1, {'use': 'optional', 'name': 'type_'}),
15825
        MemberSpec_('leading', 'int', 0, 1, {'use': 'optional', 'name': 'leading'}),
15826
        MemberSpec_('readingDirection', 'pc:ReadingDirectionSimpleType', 0, 1, {'use': 'optional', 'name': 'readingDirection'}),
15827
        MemberSpec_('textLineOrder', 'pc:TextLineOrderSimpleType', 0, 1, {'use': 'optional', 'name': 'textLineOrder'}),
15828
        MemberSpec_('readingOrientation', 'float', 0, 1, {'use': 'optional', 'name': 'readingOrientation'}),
15829
        MemberSpec_('indented', 'boolean', 0, 1, {'use': 'optional', 'name': 'indented'}),
15830
        MemberSpec_('align', 'pc:AlignSimpleType', 0, 1, {'use': 'optional', 'name': 'align'}),
15831
        MemberSpec_('primaryLanguage', 'pc:LanguageSimpleType', 0, 1, {'use': 'optional', 'name': 'primaryLanguage'}),
15832
        MemberSpec_('secondaryLanguage', 'pc:LanguageSimpleType', 0, 1, {'use': 'optional', 'name': 'secondaryLanguage'}),
15833
        MemberSpec_('primaryScript', 'pc:ScriptSimpleType', 0, 1, {'use': 'optional', 'name': 'primaryScript'}),
15834
        MemberSpec_('secondaryScript', 'pc:ScriptSimpleType', 0, 1, {'use': 'optional', 'name': 'secondaryScript'}),
15835
        MemberSpec_('production', 'pc:ProductionSimpleType', 0, 1, {'use': 'optional', 'name': 'production'}),
15836
        MemberSpec_('TextLine', 'TextLineType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'TextLine', 'type': 'TextLineType'}, None),
15837
        MemberSpec_('TextEquiv', 'TextEquivType', 1, 1, {'maxOccurs': 'unbounded', 'minOccurs': '0', 'name': 'TextEquiv', 'type': 'TextEquivType'}, None),
15838
        MemberSpec_('TextStyle', 'TextStyleType', 0, 1, {'maxOccurs': '1', 'minOccurs': '0', 'name': 'TextStyle', 'type': 'TextStyleType'}, None),
15839
    ]
15840
    subclass = None
15841
    superclass = RegionType
15842
    def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, type_=None, leading=None, readingDirection=None, textLineOrder=None, readingOrientation=None, indented=None, align=None, primaryLanguage=None, secondaryLanguage=None, primaryScript=None, secondaryScript=None, production=None, TextLine=None, TextEquiv=None, TextStyle=None, gds_collector_=None, **kwargs_):
15843
        self.gds_collector_ = gds_collector_
15844
        self.gds_elementtree_node_ = None
15845
        self.original_tagname_ = None
15846
        self.parent_object_ = kwargs_.get('parent_object_')
15847
        self.ns_prefix_ = "pc"
15848
        super(globals().get("TextRegionType"), self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion,  **kwargs_)
15849
        self.orientation = _cast(float, orientation)
15850
        self.orientation_nsprefix_ = "pc"
15851
        self.type_ = _cast(None, type_)
15852
        self.type__nsprefix_ = "pc"
15853
        self.leading = _cast(int, leading)
15854
        self.leading_nsprefix_ = "pc"
15855
        self.readingDirection = _cast(None, readingDirection)
15856
        self.readingDirection_nsprefix_ = "pc"
15857
        self.textLineOrder = _cast(None, textLineOrder)
15858
        self.textLineOrder_nsprefix_ = "pc"
15859
        self.readingOrientation = _cast(float, readingOrientation)
15860
        self.readingOrientation_nsprefix_ = "pc"
15861
        self.indented = _cast(bool, indented)
15862
        self.indented_nsprefix_ = "pc"
15863
        self.align = _cast(None, align)
15864
        self.align_nsprefix_ = "pc"
15865
        self.primaryLanguage = _cast(None, primaryLanguage)
15866
        self.primaryLanguage_nsprefix_ = "pc"
15867
        self.secondaryLanguage = _cast(None, secondaryLanguage)
15868
        self.secondaryLanguage_nsprefix_ = "pc"
15869
        self.primaryScript = _cast(None, primaryScript)
15870
        self.primaryScript_nsprefix_ = "pc"
15871
        self.secondaryScript = _cast(None, secondaryScript)
15872
        self.secondaryScript_nsprefix_ = "pc"
15873
        self.production = _cast(None, production)
15874
        self.production_nsprefix_ = "pc"
15875
        if TextLine is None:
15876
            self.TextLine = []
15877
        else:
15878
            self.TextLine = TextLine
15879
        self.TextLine_nsprefix_ = "pc"
15880
        if TextEquiv is None:
15881
            self.TextEquiv = []
15882
        else:
15883
            self.TextEquiv = TextEquiv
15884
        self.TextEquiv_nsprefix_ = "pc"
15885
        self.TextStyle = TextStyle
15886
        self.TextStyle_nsprefix_ = "pc"
15887
    def factory(*args_, **kwargs_):
15888
        if CurrentSubclassModule_ is not None:
15889
            subclass = getSubclassFromModule_(
15890
                CurrentSubclassModule_, TextRegionType)
15891
            if subclass is not None:
15892
                return subclass(*args_, **kwargs_)
15893
        if TextRegionType.subclass:
15894
            return TextRegionType.subclass(*args_, **kwargs_)
15895
        else:
15896
            return TextRegionType(*args_, **kwargs_)
15897
    factory = staticmethod(factory)
15898
    def get_ns_prefix_(self):
15899
        return self.ns_prefix_
15900
    def set_ns_prefix_(self, ns_prefix):
15901
        self.ns_prefix_ = ns_prefix
15902
    def get_TextLine(self):
15903
        return self.TextLine
15904
    def set_TextLine(self, TextLine):
15905
        self.TextLine = TextLine
15906
    def add_TextLine(self, value):
15907
        self.TextLine.append(value)
15908
    def insert_TextLine_at(self, index, value):
15909
        self.TextLine.insert(index, value)
15910
    def replace_TextLine_at(self, index, value):
15911
        self.TextLine[index] = value
15912
    def get_TextEquiv(self):
15913
        return self.TextEquiv
15914
    def set_TextEquiv(self, TextEquiv):
15915
        self.TextEquiv = TextEquiv
15916
    def add_TextEquiv(self, value):
15917
        self.TextEquiv.append(value)
15918
    def insert_TextEquiv_at(self, index, value):
15919
        self.TextEquiv.insert(index, value)
15920
    def replace_TextEquiv_at(self, index, value):
15921
        self.TextEquiv[index] = value
15922
    def get_TextStyle(self):
15923
        return self.TextStyle
15924
    def set_TextStyle(self, TextStyle):
15925
        self.TextStyle = TextStyle
15926
    def get_orientation(self):
15927
        return self.orientation
15928
    def set_orientation(self, orientation):
15929
        self.orientation = orientation
15930
    def get_type(self):
15931
        return self.type_
15932
    def set_type(self, type_):
15933
        self.type_ = type_
15934
    def get_leading(self):
15935
        return self.leading
15936
    def set_leading(self, leading):
15937
        self.leading = leading
15938
    def get_readingDirection(self):
15939
        return self.readingDirection
15940
    def set_readingDirection(self, readingDirection):
15941
        self.readingDirection = readingDirection
15942
    def get_textLineOrder(self):
15943
        return self.textLineOrder
15944
    def set_textLineOrder(self, textLineOrder):
15945
        self.textLineOrder = textLineOrder
15946
    def get_readingOrientation(self):
15947
        return self.readingOrientation
15948
    def set_readingOrientation(self, readingOrientation):
15949
        self.readingOrientation = readingOrientation
15950
    def get_indented(self):
15951
        return self.indented
15952
    def set_indented(self, indented):
15953
        self.indented = indented
15954
    def get_align(self):
15955
        return self.align
15956
    def set_align(self, align):
15957
        self.align = align
15958
    def get_primaryLanguage(self):
15959
        return self.primaryLanguage
15960
    def set_primaryLanguage(self, primaryLanguage):
15961
        self.primaryLanguage = primaryLanguage
15962
    def get_secondaryLanguage(self):
15963
        return self.secondaryLanguage
15964
    def set_secondaryLanguage(self, secondaryLanguage):
15965
        self.secondaryLanguage = secondaryLanguage
15966
    def get_primaryScript(self):
15967
        return self.primaryScript
15968
    def set_primaryScript(self, primaryScript):
15969
        self.primaryScript = primaryScript
15970
    def get_secondaryScript(self):
15971
        return self.secondaryScript
15972
    def set_secondaryScript(self, secondaryScript):
15973
        self.secondaryScript = secondaryScript
15974
    def get_production(self):
15975
        return self.production
15976
    def set_production(self, production):
15977
        self.production = production
15978
    def validate_TextTypeSimpleType(self, value):
15979
        # Validate type pc:TextTypeSimpleType, a restriction on string.
15980
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
15981
            if not isinstance(value, str):
15982
                lineno = self.gds_get_node_lineno_()
15983
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
15984
                return False
15985
            value = value
15986
            enumerations = ['paragraph', 'heading', 'caption', 'header', 'footer', 'page-number', 'drop-capital', 'credit', 'floating', 'signature-mark', 'catch-word', 'marginalia', 'footnote', 'footnote-continued', 'endnote', 'TOC-entry', 'list-label', 'other']
15987
            if value not in enumerations:
15988
                lineno = self.gds_get_node_lineno_()
15989
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on TextTypeSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
15990
                result = False
15991
    def validate_ReadingDirectionSimpleType(self, value):
15992
        # Validate type pc:ReadingDirectionSimpleType, a restriction on string.
15993
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
15994
            if not isinstance(value, str):
15995
                lineno = self.gds_get_node_lineno_()
15996
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
15997
                return False
15998
            value = value
15999
            enumerations = ['left-to-right', 'right-to-left', 'top-to-bottom', 'bottom-to-top']
16000
            if value not in enumerations:
16001
                lineno = self.gds_get_node_lineno_()
16002
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ReadingDirectionSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
16003
                result = False
16004
    def validate_TextLineOrderSimpleType(self, value):
16005
        # Validate type pc:TextLineOrderSimpleType, a restriction on string.
16006
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
16007
            if not isinstance(value, str):
16008
                lineno = self.gds_get_node_lineno_()
16009
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
16010
                return False
16011
            value = value
16012
            enumerations = ['top-to-bottom', 'bottom-to-top', 'left-to-right', 'right-to-left']
16013
            if value not in enumerations:
16014
                lineno = self.gds_get_node_lineno_()
16015
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on TextLineOrderSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
16016
                result = False
16017
    def validate_AlignSimpleType(self, value):
16018
        # Validate type pc:AlignSimpleType, a restriction on string.
16019
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
16020
            if not isinstance(value, str):
16021
                lineno = self.gds_get_node_lineno_()
16022
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
16023
                return False
16024
            value = value
16025
            enumerations = ['left', 'centre', 'right', 'justify']
16026
            if value not in enumerations:
16027
                lineno = self.gds_get_node_lineno_()
16028
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on AlignSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
16029
                result = False
16030
    def validate_LanguageSimpleType(self, value):
16031
        # Validate type pc:LanguageSimpleType, a restriction on string.
16032
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
16033
            if not isinstance(value, str):
16034
                lineno = self.gds_get_node_lineno_()
16035
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
16036
                return False
16037
            value = value
16038
            enumerations = ['Abkhaz', 'Afar', 'Afrikaans', 'Akan', 'Albanian', 'Amharic', 'Arabic', 'Aragonese', 'Armenian', 'Assamese', 'Avaric', 'Avestan', 'Aymara', 'Azerbaijani', 'Bambara', 'Bashkir', 'Basque', 'Belarusian', 'Bengali', 'Bihari', 'Bislama', 'Bosnian', 'Breton', 'Bulgarian', 'Burmese', 'Cambodian', 'Cantonese', 'Catalan', 'Chamorro', 'Chechen', 'Chichewa', 'Chinese', 'Chuvash', 'Cornish', 'Corsican', 'Cree', 'Croatian', 'Czech', 'Danish', 'Divehi', 'Dutch', 'Dzongkha', 'English', 'Esperanto', 'Estonian', 'Ewe', 'Faroese', 'Fijian', 'Finnish', 'French', 'Fula', 'Gaelic', 'Galician', 'Ganda', 'Georgian', 'German', 'Greek', 'Guaraní', 'Gujarati', 'Haitian', 'Hausa', 'Hebrew', 'Herero', 'Hindi', 'Hiri Motu', 'Hungarian', 'Icelandic', 'Ido', 'Igbo', 'Indonesian', 'Interlingua', 'Interlingue', 'Inuktitut', 'Inupiaq', 'Irish', 'Italian', 'Japanese', 'Javanese', 'Kalaallisut', 'Kannada', 'Kanuri', 'Kashmiri', 'Kazakh', 'Khmer', 'Kikuyu', 'Kinyarwanda', 'Kirundi', 'Komi', 'Kongo', 'Korean', 'Kurdish', 'Kwanyama', 'Kyrgyz', 'Lao', 'Latin', 'Latvian', 'Limburgish', 'Lingala', 'Lithuanian', 'Luba-Katanga', 'Luxembourgish', 'Macedonian', 'Malagasy', 'Malay', 'Malayalam', 'Maltese', 'Manx', 'Māori', 'Marathi', 'Marshallese', 'Mongolian', 'Nauru', 'Navajo', 'Ndonga', 'Nepali', 'North Ndebele', 'Northern Sami', 'Norwegian', 'Norwegian Bokmål', 'Norwegian Nynorsk', 'Nuosu', 'Occitan', 'Ojibwe', 'Old Church Slavonic', 'Oriya', 'Oromo', 'Ossetian', 'Pāli', 'Panjabi', 'Pashto', 'Persian', 'Polish', 'Portuguese', 'Punjabi', 'Quechua', 'Romanian', 'Romansh', 'Russian', 'Samoan', 'Sango', 'Sanskrit', 'Sardinian', 'Serbian', 'Shona', 'Sindhi', 'Sinhala', 'Slovak', 'Slovene', 'Somali', 'South Ndebele', 'Southern Sotho', 'Spanish', 'Sundanese', 'Swahili', 'Swati', 'Swedish', 'Tagalog', 'Tahitian', 'Tajik', 'Tamil', 'Tatar', 'Telugu', 'Thai', 'Tibetan', 'Tigrinya', 'Tonga', 'Tsonga', 'Tswana', 'Turkish', 'Turkmen', 'Twi', 'Uighur', 'Ukrainian', 'Urdu', 'Uzbek', 'Venda', 'Vietnamese', 'Volapük', 'Walloon', 'Welsh', 'Western Frisian', 'Wolof', 'Xhosa', 'Yiddish', 'Yoruba', 'Zhuang', 'Zulu', 'other']
16039
            if value not in enumerations:
16040
                lineno = self.gds_get_node_lineno_()
16041
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on LanguageSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
16042
                result = False
16043
    def validate_ScriptSimpleType(self, value):
16044
        # Validate type pc:ScriptSimpleType, a restriction on string.
16045
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
16046
            if not isinstance(value, str):
16047
                lineno = self.gds_get_node_lineno_()
16048
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
16049
                return False
16050
            value = value
16051
            enumerations = ['Adlm - Adlam', 'Afak - Afaka', 'Aghb - Caucasian Albanian', 'Ahom - Ahom, Tai Ahom', 'Arab - Arabic', 'Aran - Arabic (Nastaliq variant)', 'Armi - Imperial Aramaic', 'Armn - Armenian', 'Avst - Avestan', 'Bali - Balinese', 'Bamu - Bamum', 'Bass - Bassa Vah', 'Batk - Batak', 'Beng - Bengali', 'Bhks - Bhaiksuki', 'Blis - Blissymbols', 'Bopo - Bopomofo', 'Brah - Brahmi', 'Brai - Braille', 'Bugi - Buginese', 'Buhd - Buhid', 'Cakm - Chakma', 'Cans - Unified Canadian Aboriginal Syllabics', 'Cari - Carian', 'Cham - Cham', 'Cher - Cherokee', 'Cirt - Cirth', 'Copt - Coptic', 'Cprt - Cypriot', 'Cyrl - Cyrillic', 'Cyrs - Cyrillic (Old Church Slavonic variant)', 'Deva - Devanagari (Nagari)', 'Dsrt - Deseret (Mormon)', 'Dupl - Duployan shorthand, Duployan stenography', 'Egyd - Egyptian demotic', 'Egyh - Egyptian hieratic', 'Egyp - Egyptian hieroglyphs', 'Elba - Elbasan', 'Ethi - Ethiopic', 'Geok - Khutsuri (Asomtavruli and Nuskhuri)', 'Geor - Georgian (Mkhedruli)', 'Glag - Glagolitic', 'Goth - Gothic', 'Gran - Grantha', 'Grek - Greek', 'Gujr - Gujarati', 'Guru - Gurmukhi', 'Hanb - Han with Bopomofo', 'Hang - Hangul', 'Hani - Han (Hanzi, Kanji, Hanja)', 'Hano - Hanunoo (Hanunóo)', 'Hans - Han (Simplified variant)', 'Hant - Han (Traditional variant)', 'Hatr - Hatran', 'Hebr - Hebrew', 'Hira - Hiragana', 'Hluw - Anatolian Hieroglyphs', 'Hmng - Pahawh Hmong', 'Hrkt - Japanese syllabaries', 'Hung - Old Hungarian (Hungarian Runic)', 'Inds - Indus (Harappan)', 'Ital - Old Italic (Etruscan, Oscan etc.)', 'Jamo - Jamo', 'Java - Javanese', 'Jpan - Japanese', 'Jurc - Jurchen', 'Kali - Kayah Li', 'Kana - Katakana', 'Khar - Kharoshthi', 'Khmr - Khmer', 'Khoj - Khojki', 'Kitl - Khitan large script', 'Kits - Khitan small script', 'Knda - Kannada', 'Kore - Korean (alias for Hangul + Han)', 'Kpel - Kpelle', 'Kthi - Kaithi', 'Lana - Tai Tham (Lanna)', 'Laoo - Lao', 'Latf - Latin (Fraktur variant)', 'Latg - Latin (Gaelic variant)', 'Latn - Latin', 'Leke - Leke', 'Lepc - Lepcha (Róng)', 'Limb - Limbu', 'Lina - Linear A', 'Linb - Linear B', 'Lisu - Lisu (Fraser)', 'Loma - Loma', 'Lyci - Lycian', 'Lydi - Lydian', 'Mahj - Mahajani', 'Mand - Mandaic, Mandaean', 'Mani - Manichaean', 'Marc - Marchen', 'Maya - Mayan hieroglyphs', 'Mend - Mende Kikakui', 'Merc - Meroitic Cursive', 'Mero - Meroitic Hieroglyphs', 'Mlym - Malayalam', 'Modi - Modi, Moḍī', 'Mong - Mongolian', 'Moon - Moon (Moon code, Moon script, Moon type)', 'Mroo - Mro, Mru', 'Mtei - Meitei Mayek (Meithei, Meetei)', 'Mult - Multani', 'Mymr - Myanmar (Burmese)', 'Narb - Old North Arabian (Ancient North Arabian)', 'Nbat - Nabataean', 'Newa - Newa, Newar, Newari', 'Nkgb - Nakhi Geba', 'Nkoo - N’Ko', 'Nshu - Nüshu', 'Ogam - Ogham', 'Olck - Ol Chiki (Ol Cemet’, Ol, Santali)', 'Orkh - Old Turkic, Orkhon Runic', 'Orya - Oriya', 'Osge - Osage', 'Osma - Osmanya', 'Palm - Palmyrene', 'Pauc - Pau Cin Hau', 'Perm - Old Permic', 'Phag - Phags-pa', 'Phli - Inscriptional Pahlavi', 'Phlp - Psalter Pahlavi', 'Phlv - Book Pahlavi', 'Phnx - Phoenician', 'Piqd - Klingon (KLI pIqaD)', 'Plrd - Miao (Pollard)', 'Prti - Inscriptional Parthian', 'Rjng - Rejang (Redjang, Kaganga)', 'Roro - Rongorongo', 'Runr - Runic', 'Samr - Samaritan', 'Sara - Sarati', 'Sarb - Old South Arabian', 'Saur - Saurashtra', 'Sgnw - SignWriting', 'Shaw - Shavian (Shaw)', 'Shrd - Sharada, Śāradā', 'Sidd - Siddham', 'Sind - Khudawadi, Sindhi', 'Sinh - Sinhala', 'Sora - Sora Sompeng', 'Sund - Sundanese', 'Sylo - Syloti Nagri', 'Syrc - Syriac', 'Syre - Syriac (Estrangelo variant)', 'Syrj - Syriac (Western variant)', 'Syrn - Syriac (Eastern variant)', 'Tagb - Tagbanwa', 'Takr - Takri', 'Tale - Tai Le', 'Talu - New Tai Lue', 'Taml - Tamil', 'Tang - Tangut', 'Tavt - Tai Viet', 'Telu - Telugu', 'Teng - Tengwar', 'Tfng - Tifinagh (Berber)', 'Tglg - Tagalog (Baybayin, Alibata)', 'Thaa - Thaana', 'Thai - Thai', 'Tibt - Tibetan', 'Tirh - Tirhuta', 'Ugar - Ugaritic', 'Vaii - Vai', 'Visp - Visible Speech', 'Wara - Warang Citi (Varang Kshiti)', 'Wole - Woleai', 'Xpeo - Old Persian', 'Xsux - Cuneiform, Sumero-Akkadian', 'Yiii - Yi', 'Zinh - Code for inherited script', 'Zmth - Mathematical notation', 'Zsye - Symbols (Emoji variant)', 'Zsym - Symbols', 'Zxxx - Code for unwritten documents', 'Zyyy - Code for undetermined script', 'Zzzz - Code for uncoded script', 'other']
16052
            if value not in enumerations:
16053
                lineno = self.gds_get_node_lineno_()
16054
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ScriptSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
16055
                result = False
16056
    def validate_ProductionSimpleType(self, value):
16057
        # Validate type pc:ProductionSimpleType, a restriction on string.
16058
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
16059
            if not isinstance(value, str):
16060
                lineno = self.gds_get_node_lineno_()
16061
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
16062
                return False
16063
            value = value
16064
            enumerations = ['printed', 'typewritten', 'handwritten-cursive', 'handwritten-printscript', 'medieval-manuscript', 'other']
16065
            if value not in enumerations:
16066
                lineno = self.gds_get_node_lineno_()
16067
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ProductionSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
16068
                result = False
16069
    def has__content(self):
16070
        if (
16071
            self.TextLine or
16072
            self.TextEquiv or
16073
            self.TextStyle is not None or
16074
            super(TextRegionType, self).has__content()
16075
        ):
16076
            return True
16077
        else:
16078
            return False
16079
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='TextRegionType', pretty_print=True):
16080
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('TextRegionType')
16081
        if imported_ns_def_ is not None:
16082
            namespacedef_ = imported_ns_def_
16083
        if pretty_print:
16084
            eol_ = '\n'
16085
        else:
16086
            eol_ = ''
16087
        if self.original_tagname_ is not None and name_ == 'TextRegionType':
16088
            name_ = self.original_tagname_
16089
        if UseCapturedNS_ and self.ns_prefix_:
16090
            namespaceprefix_ = self.ns_prefix_ + ':'
16091
        showIndent(outfile, level, pretty_print)
16092
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
16093
        already_processed = set()
16094
        self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='TextRegionType')
16095
        if self.has__content():
16096
            outfile.write('>%s' % (eol_, ))
16097
            self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='TextRegionType', pretty_print=pretty_print)
16098
            showIndent(outfile, level, pretty_print)
16099
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
16100
        else:
16101
            outfile.write('/>%s' % (eol_, ))
16102
    def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='TextRegionType'):
16103
        super(TextRegionType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='TextRegionType')
16104
        if self.orientation is not None and 'orientation' not in already_processed:
16105
            already_processed.add('orientation')
16106
            outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation'))
16107
        if self.type_ is not None and 'type_' not in already_processed:
16108
            already_processed.add('type_')
16109
            outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), ))
16110
        if self.leading is not None and 'leading' not in already_processed:
16111
            already_processed.add('leading')
16112
            outfile.write(' leading="%s"' % self.gds_format_integer(self.leading, input_name='leading'))
16113
        if self.readingDirection is not None and 'readingDirection' not in already_processed:
16114
            already_processed.add('readingDirection')
16115
            outfile.write(' readingDirection=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.readingDirection), input_name='readingDirection')), ))
16116
        if self.textLineOrder is not None and 'textLineOrder' not in already_processed:
16117
            already_processed.add('textLineOrder')
16118
            outfile.write(' textLineOrder=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.textLineOrder), input_name='textLineOrder')), ))
16119
        if self.readingOrientation is not None and 'readingOrientation' not in already_processed:
16120
            already_processed.add('readingOrientation')
16121
            outfile.write(' readingOrientation="%s"' % self.gds_format_float(self.readingOrientation, input_name='readingOrientation'))
16122
        if self.indented is not None and 'indented' not in already_processed:
16123
            already_processed.add('indented')
16124
            outfile.write(' indented="%s"' % self.gds_format_boolean(self.indented, input_name='indented'))
16125
        if self.align is not None and 'align' not in already_processed:
16126
            already_processed.add('align')
16127
            outfile.write(' align=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.align), input_name='align')), ))
16128
        if self.primaryLanguage is not None and 'primaryLanguage' not in already_processed:
16129
            already_processed.add('primaryLanguage')
16130
            outfile.write(' primaryLanguage=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.primaryLanguage), input_name='primaryLanguage')), ))
16131
        if self.secondaryLanguage is not None and 'secondaryLanguage' not in already_processed:
16132
            already_processed.add('secondaryLanguage')
16133
            outfile.write(' secondaryLanguage=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.secondaryLanguage), input_name='secondaryLanguage')), ))
16134
        if self.primaryScript is not None and 'primaryScript' not in already_processed:
16135
            already_processed.add('primaryScript')
16136
            outfile.write(' primaryScript=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.primaryScript), input_name='primaryScript')), ))
16137
        if self.secondaryScript is not None and 'secondaryScript' not in already_processed:
16138
            already_processed.add('secondaryScript')
16139
            outfile.write(' secondaryScript=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.secondaryScript), input_name='secondaryScript')), ))
16140
        if self.production is not None and 'production' not in already_processed:
16141
            already_processed.add('production')
16142
            outfile.write(' production=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.production), input_name='production')), ))
16143
    def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='TextRegionType', fromsubclass_=False, pretty_print=True):
16144
        super(TextRegionType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print)
16145
        if pretty_print:
16146
            eol_ = '\n'
16147
        else:
16148
            eol_ = ''
16149
        for TextLine_ in self.TextLine:
16150
            namespaceprefix_ = self.TextLine_nsprefix_ + ':' if (UseCapturedNS_ and self.TextLine_nsprefix_) else ''
16151
            TextLine_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TextLine', pretty_print=pretty_print)
16152
        for TextEquiv_ in self.TextEquiv:
16153
            namespaceprefix_ = self.TextEquiv_nsprefix_ + ':' if (UseCapturedNS_ and self.TextEquiv_nsprefix_) else ''
16154
            TextEquiv_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TextEquiv', pretty_print=pretty_print)
16155
        if self.TextStyle is not None:
16156
            namespaceprefix_ = self.TextStyle_nsprefix_ + ':' if (UseCapturedNS_ and self.TextStyle_nsprefix_) else ''
16157
            self.TextStyle.export(outfile, level, namespaceprefix_, namespacedef_='', name_='TextStyle', pretty_print=pretty_print)
16158
    def to_etree(self, parent_element=None, name_='TextRegionType', mapping_=None, reverse_mapping_=None, nsmap_=None):
16159
        element = super(TextRegionType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_)
16160
        if self.orientation is not None:
16161
            element.set('orientation', self.gds_format_float(self.orientation))
16162
        if self.type_ is not None:
16163
            element.set('type', self.gds_format_string(self.type_))
16164
        if self.leading is not None:
16165
            element.set('leading', self.gds_format_integer(self.leading))
16166
        if self.readingDirection is not None:
16167
            element.set('readingDirection', self.gds_format_string(self.readingDirection))
16168
        if self.textLineOrder is not None:
16169
            element.set('textLineOrder', self.gds_format_string(self.textLineOrder))
16170
        if self.readingOrientation is not None:
16171
            element.set('readingOrientation', self.gds_format_float(self.readingOrientation))
16172
        if self.indented is not None:
16173
            element.set('indented', self.gds_format_boolean(self.indented))
16174
        if self.align is not None:
16175
            element.set('align', self.gds_format_string(self.align))
16176
        if self.primaryLanguage is not None:
16177
            element.set('primaryLanguage', self.gds_format_string(self.primaryLanguage))
16178
        if self.secondaryLanguage is not None:
16179
            element.set('secondaryLanguage', self.gds_format_string(self.secondaryLanguage))
16180
        if self.primaryScript is not None:
16181
            element.set('primaryScript', self.gds_format_string(self.primaryScript))
16182
        if self.secondaryScript is not None:
16183
            element.set('secondaryScript', self.gds_format_string(self.secondaryScript))
16184
        if self.production is not None:
16185
            element.set('production', self.gds_format_string(self.production))
16186
        for TextLine_ in self.TextLine:
16187
            TextLine_.to_etree(element, name_='TextLine', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
16188
        for TextEquiv_ in self.TextEquiv:
16189
            TextEquiv_.to_etree(element, name_='TextEquiv', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
16190
        if self.TextStyle is not None:
16191
            TextStyle_ = self.TextStyle
16192
            TextStyle_.to_etree(element, name_='TextStyle', mapping_=mapping_, reverse_mapping_=reverse_mapping_, nsmap_=nsmap_)
16193
        if mapping_ is not None:
16194
            mapping_[id(self)] = element
16195
        if reverse_mapping_ is not None:
16196
            reverse_mapping_[element] = self
16197
        return element
16198
    def build(self, node, gds_collector_=None):
16199
        self.gds_collector_ = gds_collector_
16200
        if SaveElementTreeNode:
16201
            self.gds_elementtree_node_ = node
16202
        already_processed = set()
16203
        self.ns_prefix_ = node.prefix
16204
        self._buildAttributes(node, node.attrib, already_processed)
16205
        for child in node:
16206
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
16207
            self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
16208
        return self
16209
    def _buildAttributes(self, node, attrs, already_processed):
16210
        value = find_attr_value_('orientation', node)
16211
        if value is not None and 'orientation' not in already_processed:
16212
            already_processed.add('orientation')
16213
            value = self.gds_parse_float(value, node, 'orientation')
16214
            self.orientation = value
16215
        value = find_attr_value_('type', node)
16216
        if value is not None and 'type' not in already_processed:
16217
            already_processed.add('type')
16218
            self.type_ = value
16219
            self.validate_TextTypeSimpleType(self.type_)    # validate type TextTypeSimpleType
16220
        value = find_attr_value_('leading', node)
16221
        if value is not None and 'leading' not in already_processed:
16222
            already_processed.add('leading')
16223
            self.leading = self.gds_parse_integer(value, node, 'leading')
16224
        value = find_attr_value_('readingDirection', node)
16225
        if value is not None and 'readingDirection' not in already_processed:
16226
            already_processed.add('readingDirection')
16227
            self.readingDirection = value
16228
            self.validate_ReadingDirectionSimpleType(self.readingDirection)    # validate type ReadingDirectionSimpleType
16229
        value = find_attr_value_('textLineOrder', node)
16230
        if value is not None and 'textLineOrder' not in already_processed:
16231
            already_processed.add('textLineOrder')
16232
            self.textLineOrder = value
16233
            self.validate_TextLineOrderSimpleType(self.textLineOrder)    # validate type TextLineOrderSimpleType
16234
        value = find_attr_value_('readingOrientation', node)
16235
        if value is not None and 'readingOrientation' not in already_processed:
16236
            already_processed.add('readingOrientation')
16237
            value = self.gds_parse_float(value, node, 'readingOrientation')
16238
            self.readingOrientation = value
16239
        value = find_attr_value_('indented', node)
16240
        if value is not None and 'indented' not in already_processed:
16241
            already_processed.add('indented')
16242
            if value in ('true', '1'):
16243
                self.indented = True
16244
            elif value in ('false', '0'):
16245
                self.indented = False
16246
            else:
16247
                raise_parse_error(node, 'Bad boolean attribute')
16248
        value = find_attr_value_('align', node)
16249
        if value is not None and 'align' not in already_processed:
16250
            already_processed.add('align')
16251
            self.align = value
16252
            self.validate_AlignSimpleType(self.align)    # validate type AlignSimpleType
16253
        value = find_attr_value_('primaryLanguage', node)
16254
        if value is not None and 'primaryLanguage' not in already_processed:
16255
            already_processed.add('primaryLanguage')
16256
            self.primaryLanguage = value
16257
            self.validate_LanguageSimpleType(self.primaryLanguage)    # validate type LanguageSimpleType
16258
        value = find_attr_value_('secondaryLanguage', node)
16259
        if value is not None and 'secondaryLanguage' not in already_processed:
16260
            already_processed.add('secondaryLanguage')
16261
            self.secondaryLanguage = value
16262
            self.validate_LanguageSimpleType(self.secondaryLanguage)    # validate type LanguageSimpleType
16263
        value = find_attr_value_('primaryScript', node)
16264
        if value is not None and 'primaryScript' not in already_processed:
16265
            already_processed.add('primaryScript')
16266
            self.primaryScript = value
16267
            self.validate_ScriptSimpleType(self.primaryScript)    # validate type ScriptSimpleType
16268
        value = find_attr_value_('secondaryScript', node)
16269
        if value is not None and 'secondaryScript' not in already_processed:
16270
            already_processed.add('secondaryScript')
16271
            self.secondaryScript = value
16272
            self.validate_ScriptSimpleType(self.secondaryScript)    # validate type ScriptSimpleType
16273
        value = find_attr_value_('production', node)
16274
        if value is not None and 'production' not in already_processed:
16275
            already_processed.add('production')
16276
            self.production = value
16277
            self.validate_ProductionSimpleType(self.production)    # validate type ProductionSimpleType
16278
        super(TextRegionType, self)._buildAttributes(node, attrs, already_processed)
16279
    def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
16280
        if nodeName_ == 'TextLine':
16281
            obj_ = TextLineType.factory(parent_object_=self)
16282
            obj_.build(child_, gds_collector_=gds_collector_)
16283
            self.TextLine.append(obj_)
16284
            obj_.original_tagname_ = 'TextLine'
16285
        elif nodeName_ == 'TextEquiv':
16286
            obj_ = TextEquivType.factory(parent_object_=self)
16287
            obj_.build(child_, gds_collector_=gds_collector_)
16288
            self.TextEquiv.append(obj_)
16289
            obj_.original_tagname_ = 'TextEquiv'
16290
        elif nodeName_ == 'TextStyle':
16291
            obj_ = TextStyleType.factory(parent_object_=self)
16292
            obj_.build(child_, gds_collector_=gds_collector_)
16293
            self.TextStyle = obj_
16294
            obj_.original_tagname_ = 'TextStyle'
16295
        super(TextRegionType, self)._buildChildren(child_, node, nodeName_, True)
16296
    def __hash__(self):
16297
        return hash(self.id)
16298
    # pylint: disable=line-too-long,invalid-name,protected-access,missing-module-docstring
16299
    def _region_class(self, x): # pylint: disable=unused-argument
16300
        return x.__class__.__name__.replace('RegionType', '')
16301
    
16302
    def _get_recursive_regions(self, regions, level, classes=None):
16303
        from .constants import PAGE_REGION_TYPES  # pylint: disable=relative-beyond-top-level,import-outside-toplevel
16304
        if level == 1:
16305
            # stop recursion, filter classes
16306
            if classes:
16307
                return [r for r in regions if self._region_class(r) in classes]
16308
            if regions and regions[0].__class__.__name__ == 'PageType':
16309
                regions = regions[1:]
16310
            return regions
16311
        # find more regions recursively
16312
        more_regions = []
16313
        for region in regions:
16314
            more_regions.append([])
16315
            for class_ in PAGE_REGION_TYPES:
16316
                if class_ == 'Map' and not isinstance(region, PageType): # pylint: disable=undefined-variable
16317
                    # 'Map' is not recursive in 2019 schema
16318
                    continue
16319
                more_regions[-1] += getattr(region, 'get_{}Region'.format(class_))()
16320
        if not any(more_regions):
16321
            return self._get_recursive_regions(regions, 1, classes)
16322
        ret = []
16323
        for r, more in zip(regions, more_regions):
16324
            ret.append(r)
16325
            ret += self._get_recursive_regions(more, level - 1 if level else 0, classes)
16326
        return self._get_recursive_regions(ret, 1, classes)
16327
    
16328
    def _get_recursive_reading_order(self, rogroup):
16329
        if isinstance(rogroup, (OrderedGroupType, OrderedGroupIndexedType)): # pylint: disable=undefined-variable
16330
            elements = rogroup.get_AllIndexed()
16331
        if isinstance(rogroup, (UnorderedGroupType, UnorderedGroupIndexedType)): # pylint: disable=undefined-variable
16332
            elements = (rogroup.get_RegionRef() + rogroup.get_OrderedGroup() + rogroup.get_UnorderedGroup())
16333
        regionrefs = list()
16334
        for elem in elements:
16335
            regionrefs.append(elem.get_regionRef())
16336
            if not isinstance(elem, (RegionRefType, RegionRefIndexedType)): # pylint: disable=undefined-variable
16337
                regionrefs.extend(self._get_recursive_reading_order(elem))
16338
        return regionrefs
16339
    
16340
    def get_AllRegions(self, classes=None, order='document', depth=0):
16341
        """
16342
        Get all the ``*Region`` elements, or only those provided by `classes`.
16343
        Return in document order, unless the top element is ``Page`` and
16344
        `order` is ``reading-order``.
16345
    
16346
        Arguments:
16347
            classes (list): Classes of regions that shall be returned, \
16348
                e.g. ``['Text', 'Image']``
16349
            order ("document"|"reading-order"|"reading-order-only"): Whether to \
16350
                return regions sorted by document order (``document``, default) or by
16351
                reading order with regions not in the reading order at the end of the
16352
                returned list (``reading-order``) or regions not in the reading order
16353
                omitted (``reading-order-only``). The latter two are only available
16354
                on page level.
16355
            depth (int): Recursive depth to look for regions at, set to `0` for \
16356
                all regions at any depth. Default: 0
16357
    
16358
        Returns:
16359
            a list of :py:class:`TextRegionType`, :py:class:`ImageRegionType`, \
16360
                :py:class:`LineDrawingRegionType`, :py:class:`GraphicRegionType`, \
16361
                :py:class:`TableRegionType`, :py:class:`ChartRegionType`, \
16362
                :py:class:`MapRegionType`, :py:class:`SeparatorRegionType`, \
16363
                :py:class:`MathsRegionType`, :py:class:`ChemRegionType`, \
16364
                :py:class:`MusicRegionType`, :py:class:`AdvertRegionType`, \
16365
                :py:class:`NoiseRegionType`, :py:class:`UnknownRegionType`, \
16366
                and/or :py:class:`CustomRegionType`
16367
    
16368
        For example, to get all text anywhere on the page in reading order, use:
16369
        ::
16370
            '\\n'.join(line.get_TextEquiv()[0].Unicode
16371
                      for region in page.get_AllRegions(classes=['Text'], depth=0, order='reading-order')
16372
                      for line in region.get_TextLine())
16373
        """
16374
        if order not in ['document', 'reading-order', 'reading-order-only']:
16375
            raise Exception("Argument 'order' must be either 'document', 'reading-order' or 'reading-order-only', not '{}'".format(order))
16376
        if depth < 0:
16377
            raise Exception("Argument 'depth' must be an integer greater-or-equal 0, not '{}'".format(depth))
16378
        ret = self._get_recursive_regions([self], depth + 1 if depth else 0, classes)
16379
        if self.__class__.__name__ == 'PageType' and order.startswith('reading-order'):
16380
            reading_order = self.get_ReadingOrder()
16381
            if reading_order:
16382
                reading_order = reading_order.get_OrderedGroup() or reading_order.get_UnorderedGroup()
16383
            if reading_order:
16384
                reading_order = self._get_recursive_reading_order(reading_order)
16385
            if reading_order:
16386
                id2region = {region.id: region for region in ret}
16387
                in_reading_order = [id2region[region_id] for region_id in reading_order if region_id in id2region]
16388
                #  print("ret: {} / in_ro: {} / not-in-ro: {}".format(
16389
                #      len(ret),
16390
                #      len([id2region[region_id] for region_id in reading_order if region_id in id2region]),
16391
                #      len([r for r in ret if r not in in_reading_order])
16392
                #      ))
16393
                if order == 'reading-order-only':
16394
                    ret = in_reading_order
16395
                else:
16396
                    ret = in_reading_order + [r for r in ret if r not in in_reading_order]
16397
        return ret
16398
    def set_orientation(self, orientation):
16399
        """
16400
        Set deskewing angle to given `orientation` number.
16401
        Moreover, invalidate self's ``pc:AlternativeImage``s
16402
        (because they will have been rotated and enlarged
16403
        with the angle of the previous value).
16404
        """
16405
        if hasattr(self, 'invalidate_AlternativeImage'):
16406
            # PageType, RegionType:
16407
            self.invalidate_AlternativeImage(feature_selector='deskewed')
16408
        self.orientation = orientation
16409
# end class TextRegionType
16410
16411
16412
#
16413
# End data representation classes.
16414
#
16415
16416
16417
GDSClassesMapping = {
16418
    'PcGts': PcGtsType,
16419
}
16420
16421
16422
USAGE_TEXT = """
16423
Usage: python <Parser>.py [ -s ] <in_xml_file>
16424
"""
16425
16426
16427
def usage():
16428
    print(USAGE_TEXT)
16429
    sys.exit(1)
16430
16431
16432
def get_root_tag(node):
16433
    tag = Tag_pattern_.match(node.tag).groups()[-1]
16434
    prefix_tag = TagNamePrefix + tag
16435
    rootClass = GDSClassesMapping.get(prefix_tag)
16436
    if rootClass is None:
16437
        rootClass = globals().get(prefix_tag)
16438
    return tag, rootClass
16439
16440
16441
def get_required_ns_prefix_defs(rootNode):
16442
    '''Get all name space prefix definitions required in this XML doc.
16443
    Return a dictionary of definitions and a char string of definitions.
16444
    '''
16445
    nsmap = {
16446
        prefix: uri
16447
        for node in rootNode.iter()
16448
        for (prefix, uri) in node.nsmap.items()
16449
        if prefix is not None
16450
    }
16451
    namespacedefs = ' '.join([
16452
        'xmlns:{}="{}"'.format(prefix, uri)
16453
        for prefix, uri in nsmap.items()
16454
    ])
16455
    return nsmap, namespacedefs
16456
16457
16458
def parse(inFileName, silence=False, print_warnings=True):
16459
    global CapturedNsmap_
16460
    gds_collector = GdsCollector_()
16461
    parser = None
16462
    doc = parsexml_(inFileName, parser)
16463
    rootNode = doc.getroot()
16464
    rootTag, rootClass = get_root_tag(rootNode)
16465
    if rootClass is None:
16466
        rootTag = 'PcGts'
16467
        rootClass = PcGts
16468
    rootObj = rootClass.factory()
16469
    rootObj.build(rootNode, gds_collector_=gds_collector)
16470
    CapturedNsmap_, namespacedefs = get_required_ns_prefix_defs(rootNode)
16471
    if not SaveElementTreeNode:
16472
        doc = None
16473
        rootNode = None
16474
##     if not silence:
16475
##         sys.stdout.write('<?xml version="1.0" ?>\n')
16476
##         rootObj.export(
16477
##             sys.stdout, 0, name_=rootTag,
16478
##             namespacedef_=namespacedefs,
16479
##             pretty_print=True)
16480
    if print_warnings and len(gds_collector.get_messages()) > 0:
16481
        separator = ('-' * 50) + '\n'
16482
        sys.stderr.write(separator)
16483
        sys.stderr.write('----- Warnings -- count: {} -----\n'.format(
16484
            len(gds_collector.get_messages()), ))
16485
        gds_collector.write_messages(sys.stderr)
16486
        sys.stderr.write(separator)
16487
    return rootObj
16488
16489
16490
def parseEtree(inFileName, silence=False, print_warnings=True,
16491
               mapping=None, reverse_mapping=None, nsmap=None):
16492
    parser = None
16493
    doc = parsexml_(inFileName, parser)
16494
    gds_collector = GdsCollector_()
16495
    rootNode = doc.getroot()
16496
    rootTag, rootClass = get_root_tag(rootNode)
16497
    if rootClass is None:
16498
        rootTag = 'PcGts'
16499
        rootClass = PcGts
16500
    rootObj = rootClass.factory()
16501
    rootObj.build(rootNode, gds_collector_=gds_collector)
16502
    if mapping is None:
16503
        mapping = {}
16504
    if reverse_mapping is None:
16505
        reverse_mapping = {}
16506
    rootElement = rootObj.to_etree(
16507
        None, name_=rootTag, mapping_=mapping,
16508
        reverse_mapping_=reverse_mapping, nsmap_=nsmap)
16509
    reverse_node_mapping = rootObj.gds_reverse_node_mapping(mapping)
16510
    # Enable Python to collect the space used by the DOM.
16511
    if not SaveElementTreeNode:
16512
        doc = None
16513
        rootNode = None
16514
##     if not silence:
16515
##         content = etree_.tostring(
16516
##             rootElement, pretty_print=True,
16517
##             xml_declaration=True, encoding="utf-8")
16518
##         sys.stdout.write(str(content))
16519
##         sys.stdout.write('\n')
16520
    if print_warnings and len(gds_collector.get_messages()) > 0:
16521
        separator = ('-' * 50) + '\n'
16522
        sys.stderr.write(separator)
16523
        sys.stderr.write('----- Warnings -- count: {} -----\n'.format(
16524
            len(gds_collector.get_messages()), ))
16525
        gds_collector.write_messages(sys.stderr)
16526
        sys.stderr.write(separator)
16527
    return rootObj, rootElement, mapping, reverse_node_mapping
16528
16529
16530 View Code Duplication
def parseString(inString, silence=False, print_warnings=True):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
16531
    '''Parse a string, create the object tree, and export it.
16532
16533
    Arguments:
16534
    - inString -- A string.  This XML fragment should not start
16535
      with an XML declaration containing an encoding.
16536
    - silence -- A boolean.  If False, export the object.
16537
    Returns -- The root object in the tree.
16538
    '''
16539
    parser = None
16540
    rootNode= parsexmlstring_(inString, parser)
16541
    gds_collector = GdsCollector_()
16542
    rootTag, rootClass = get_root_tag(rootNode)
16543
    if rootClass is None:
16544
        rootTag = 'PcGts'
16545
        rootClass = PcGts
16546
    rootObj = rootClass.factory()
16547
    rootObj.build(rootNode, gds_collector_=gds_collector)
16548
    if not SaveElementTreeNode:
16549
        rootNode = None
16550
##     if not silence:
16551
##         sys.stdout.write('<?xml version="1.0" ?>\n')
16552
##         rootObj.export(
16553
##             sys.stdout, 0, name_=rootTag,
16554
##             namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"')
16555
    if print_warnings and len(gds_collector.get_messages()) > 0:
16556
        separator = ('-' * 50) + '\n'
16557
        sys.stderr.write(separator)
16558
        sys.stderr.write('----- Warnings -- count: {} -----\n'.format(
16559
            len(gds_collector.get_messages()), ))
16560
        gds_collector.write_messages(sys.stderr)
16561
        sys.stderr.write(separator)
16562
    return rootObj
16563
16564
16565 View Code Duplication
def parseLiteral(inFileName, silence=False, print_warnings=True):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
16566
    parser = None
16567
    doc = parsexml_(inFileName, parser)
16568
    gds_collector = GdsCollector_()
16569
    rootNode = doc.getroot()
16570
    rootTag, rootClass = get_root_tag(rootNode)
16571
    if rootClass is None:
16572
        rootTag = 'PcGts'
16573
        rootClass = PcGts
16574
    rootObj = rootClass.factory()
16575
    rootObj.build(rootNode, gds_collector_=gds_collector)
16576
    # Enable Python to collect the space used by the DOM.
16577
    if not SaveElementTreeNode:
16578
        doc = None
16579
        rootNode = None
16580
##     if not silence:
16581
##         sys.stdout.write('#from ocrd_page_generateds import *\n\n')
16582
##         sys.stdout.write('import ocrd_page_generateds as model_\n\n')
16583
##         sys.stdout.write('rootObj = model_.rootClass(\n')
16584
##         rootObj.exportLiteral(sys.stdout, 0, name_=rootTag)
16585
##         sys.stdout.write(')\n')
16586
    if print_warnings and len(gds_collector.get_messages()) > 0:
16587
        separator = ('-' * 50) + '\n'
16588
        sys.stderr.write(separator)
16589
        sys.stderr.write('----- Warnings -- count: {} -----\n'.format(
16590
            len(gds_collector.get_messages()), ))
16591
        gds_collector.write_messages(sys.stderr)
16592
        sys.stderr.write(separator)
16593
    return rootObj
16594
16595
16596
def main():
16597
    args = sys.argv[1:]
16598
    if len(args) == 1:
16599
        parse(args[0])
16600
    else:
16601
        usage()
16602
16603
16604
if __name__ == '__main__':
16605
    #import pdb; pdb.set_trace()
16606
    main()
16607
16608
RenameMappings_ = {
16609
}
16610
16611
#
16612
# Mapping of namespaces to types defined in them
16613
# and the file in which each is defined.
16614
# simpleTypes are marked "ST" and complexTypes "CT".
16615
NamespaceToDefMappings_ = {'http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15': [('ColourSimpleType',
16616
                                                                      'src/ocrd_validators/page.xsd',
16617
                                                                      'ST'),
16618
                                                                     ('ReadingDirectionSimpleType',
16619
                                                                      'src/ocrd_validators/page.xsd',
16620
                                                                      'ST'),
16621
                                                                     ('TextLineOrderSimpleType',
16622
                                                                      'src/ocrd_validators/page.xsd',
16623
                                                                      'ST'),
16624
                                                                     ('TextTypeSimpleType',
16625
                                                                      'src/ocrd_validators/page.xsd',
16626
                                                                      'ST'),
16627
                                                                     ('PageTypeSimpleType',
16628
                                                                      'src/ocrd_validators/page.xsd',
16629
                                                                      'ST'),
16630
                                                                     ('ConfSimpleType',
16631
                                                                      'src/ocrd_validators/page.xsd',
16632
                                                                      'ST'),
16633
                                                                     ('LanguageSimpleType',
16634
                                                                      'src/ocrd_validators/page.xsd',
16635
                                                                      'ST'),
16636
                                                                     ('ScriptSimpleType',
16637
                                                                      'src/ocrd_validators/page.xsd',
16638
                                                                      'ST'),
16639
                                                                     ('ColourDepthSimpleType',
16640
                                                                      'src/ocrd_validators/page.xsd',
16641
                                                                      'ST'),
16642
                                                                     ('GraphicsTypeSimpleType',
16643
                                                                      'src/ocrd_validators/page.xsd',
16644
                                                                      'ST'),
16645
                                                                     ('ChartTypeSimpleType',
16646
                                                                      'src/ocrd_validators/page.xsd',
16647
                                                                      'ST'),
16648
                                                                     ('PointsType',
16649
                                                                      'src/ocrd_validators/page.xsd',
16650
                                                                      'ST'),
16651
                                                                     ('ProductionSimpleType',
16652
                                                                      'src/ocrd_validators/page.xsd',
16653
                                                                      'ST'),
16654
                                                                     ('AlignSimpleType',
16655
                                                                      'src/ocrd_validators/page.xsd',
16656
                                                                      'ST'),
16657
                                                                     ('GroupTypeSimpleType',
16658
                                                                      'src/ocrd_validators/page.xsd',
16659
                                                                      'ST'),
16660
                                                                     ('TextDataTypeSimpleType',
16661
                                                                      'src/ocrd_validators/page.xsd',
16662
                                                                      'ST'),
16663
                                                                     ('UnderlineStyleSimpleType',
16664
                                                                      'src/ocrd_validators/page.xsd',
16665
                                                                      'ST'),
16666
                                                                     ('PcGtsType',
16667
                                                                      'src/ocrd_validators/page.xsd',
16668
                                                                      'CT'),
16669
                                                                     ('MetadataType',
16670
                                                                      'src/ocrd_validators/page.xsd',
16671
                                                                      'CT'),
16672
                                                                     ('MetadataItemType',
16673
                                                                      'src/ocrd_validators/page.xsd',
16674
                                                                      'CT'),
16675
                                                                     ('LabelsType',
16676
                                                                      'src/ocrd_validators/page.xsd',
16677
                                                                      'CT'),
16678
                                                                     ('LabelType',
16679
                                                                      'src/ocrd_validators/page.xsd',
16680
                                                                      'CT'),
16681
                                                                     ('PageType',
16682
                                                                      'src/ocrd_validators/page.xsd',
16683
                                                                      'CT'),
16684
                                                                     ('TextRegionType',
16685
                                                                      'src/ocrd_validators/page.xsd',
16686
                                                                      'CT'),
16687
                                                                     ('CoordsType',
16688
                                                                      'src/ocrd_validators/page.xsd',
16689
                                                                      'CT'),
16690
                                                                     ('TextLineType',
16691
                                                                      'src/ocrd_validators/page.xsd',
16692
                                                                      'CT'),
16693
                                                                     ('WordType',
16694
                                                                      'src/ocrd_validators/page.xsd',
16695
                                                                      'CT'),
16696
                                                                     ('GlyphType',
16697
                                                                      'src/ocrd_validators/page.xsd',
16698
                                                                      'CT'),
16699
                                                                     ('TextEquivType',
16700
                                                                      'src/ocrd_validators/page.xsd',
16701
                                                                      'CT'),
16702
                                                                     ('ImageRegionType',
16703
                                                                      'src/ocrd_validators/page.xsd',
16704
                                                                      'CT'),
16705
                                                                     ('LineDrawingRegionType',
16706
                                                                      'src/ocrd_validators/page.xsd',
16707
                                                                      'CT'),
16708
                                                                     ('GraphicRegionType',
16709
                                                                      'src/ocrd_validators/page.xsd',
16710
                                                                      'CT'),
16711
                                                                     ('TableRegionType',
16712
                                                                      'src/ocrd_validators/page.xsd',
16713
                                                                      'CT'),
16714
                                                                     ('GridType',
16715
                                                                      'src/ocrd_validators/page.xsd',
16716
                                                                      'CT'),
16717
                                                                     ('GridPointsType',
16718
                                                                      'src/ocrd_validators/page.xsd',
16719
                                                                      'CT'),
16720
                                                                     ('ChartRegionType',
16721
                                                                      'src/ocrd_validators/page.xsd',
16722
                                                                      'CT'),
16723
                                                                     ('SeparatorRegionType',
16724
                                                                      'src/ocrd_validators/page.xsd',
16725
                                                                      'CT'),
16726
                                                                     ('MathsRegionType',
16727
                                                                      'src/ocrd_validators/page.xsd',
16728
                                                                      'CT'),
16729
                                                                     ('ChemRegionType',
16730
                                                                      'src/ocrd_validators/page.xsd',
16731
                                                                      'CT'),
16732
                                                                     ('MapRegionType',
16733
                                                                      'src/ocrd_validators/page.xsd',
16734
                                                                      'CT'),
16735
                                                                     ('MusicRegionType',
16736
                                                                      'src/ocrd_validators/page.xsd',
16737
                                                                      'CT'),
16738
                                                                     ('AdvertRegionType',
16739
                                                                      'src/ocrd_validators/page.xsd',
16740
                                                                      'CT'),
16741
                                                                     ('NoiseRegionType',
16742
                                                                      'src/ocrd_validators/page.xsd',
16743
                                                                      'CT'),
16744
                                                                     ('UnknownRegionType',
16745
                                                                      'src/ocrd_validators/page.xsd',
16746
                                                                      'CT'),
16747
                                                                     ('CustomRegionType',
16748
                                                                      'src/ocrd_validators/page.xsd',
16749
                                                                      'CT'),
16750
                                                                     ('PrintSpaceType',
16751
                                                                      'src/ocrd_validators/page.xsd',
16752
                                                                      'CT'),
16753
                                                                     ('ReadingOrderType',
16754
                                                                      'src/ocrd_validators/page.xsd',
16755
                                                                      'CT'),
16756
                                                                     ('RegionRefIndexedType',
16757
                                                                      'src/ocrd_validators/page.xsd',
16758
                                                                      'CT'),
16759
                                                                     ('OrderedGroupIndexedType',
16760
                                                                      'src/ocrd_validators/page.xsd',
16761
                                                                      'CT'),
16762
                                                                     ('UnorderedGroupIndexedType',
16763
                                                                      'src/ocrd_validators/page.xsd',
16764
                                                                      'CT'),
16765
                                                                     ('RegionRefType',
16766
                                                                      'src/ocrd_validators/page.xsd',
16767
                                                                      'CT'),
16768
                                                                     ('OrderedGroupType',
16769
                                                                      'src/ocrd_validators/page.xsd',
16770
                                                                      'CT'),
16771
                                                                     ('UnorderedGroupType',
16772
                                                                      'src/ocrd_validators/page.xsd',
16773
                                                                      'CT'),
16774
                                                                     ('BorderType',
16775
                                                                      'src/ocrd_validators/page.xsd',
16776
                                                                      'CT'),
16777
                                                                     ('LayersType',
16778
                                                                      'src/ocrd_validators/page.xsd',
16779
                                                                      'CT'),
16780
                                                                     ('LayerType',
16781
                                                                      'src/ocrd_validators/page.xsd',
16782
                                                                      'CT'),
16783
                                                                     ('BaselineType',
16784
                                                                      'src/ocrd_validators/page.xsd',
16785
                                                                      'CT'),
16786
                                                                     ('RelationsType',
16787
                                                                      'src/ocrd_validators/page.xsd',
16788
                                                                      'CT'),
16789
                                                                     ('RelationType',
16790
                                                                      'src/ocrd_validators/page.xsd',
16791
                                                                      'CT'),
16792
                                                                     ('TextStyleType',
16793
                                                                      'src/ocrd_validators/page.xsd',
16794
                                                                      'CT'),
16795
                                                                     ('RegionType',
16796
                                                                      'src/ocrd_validators/page.xsd',
16797
                                                                      'CT'),
16798
                                                                     ('AlternativeImageType',
16799
                                                                      'src/ocrd_validators/page.xsd',
16800
                                                                      'CT'),
16801
                                                                     ('GraphemesType',
16802
                                                                      'src/ocrd_validators/page.xsd',
16803
                                                                      'CT'),
16804
                                                                     ('GraphemeBaseType',
16805
                                                                      'src/ocrd_validators/page.xsd',
16806
                                                                      'CT'),
16807
                                                                     ('GraphemeType',
16808
                                                                      'src/ocrd_validators/page.xsd',
16809
                                                                      'CT'),
16810
                                                                     ('NonPrintingCharType',
16811
                                                                      'src/ocrd_validators/page.xsd',
16812
                                                                      'CT'),
16813
                                                                     ('GraphemeGroupType',
16814
                                                                      'src/ocrd_validators/page.xsd',
16815
                                                                      'CT'),
16816
                                                                     ('UserDefinedType',
16817
                                                                      'src/ocrd_validators/page.xsd',
16818
                                                                      'CT'),
16819
                                                                     ('UserAttributeType',
16820
                                                                      'src/ocrd_validators/page.xsd',
16821
                                                                      'CT'),
16822
                                                                     ('TableCellRoleType',
16823
                                                                      'src/ocrd_validators/page.xsd',
16824
                                                                      'CT'),
16825
                                                                     ('RolesType',
16826
                                                                      'src/ocrd_validators/page.xsd',
16827
                                                                      'CT')]}
16828
16829
__all__ = [
16830
    "AdvertRegionType",
16831
    "AlternativeImageType",
16832
    "BaselineType",
16833
    "BorderType",
16834
    "ChartRegionType",
16835
    "ChemRegionType",
16836
    "CoordsType",
16837
    "CustomRegionType",
16838
    "GlyphType",
16839
    "GraphemeBaseType",
16840
    "GraphemeGroupType",
16841
    "GraphemeType",
16842
    "GraphemesType",
16843
    "GraphicRegionType",
16844
    "GridPointsType",
16845
    "GridType",
16846
    "ImageRegionType",
16847
    "LabelType",
16848
    "LabelsType",
16849
    "LayerType",
16850
    "LayersType",
16851
    "LineDrawingRegionType",
16852
    "MapRegionType",
16853
    "MathsRegionType",
16854
    "MetadataItemType",
16855
    "MetadataType",
16856
    "MusicRegionType",
16857
    "NoiseRegionType",
16858
    "NonPrintingCharType",
16859
    "OrderedGroupIndexedType",
16860
    "OrderedGroupType",
16861
    "PageType",
16862
    "PcGtsType",
16863
    "PrintSpaceType",
16864
    "ReadingOrderType",
16865
    "RegionRefIndexedType",
16866
    "RegionRefType",
16867
    "RegionType",
16868
    "RelationType",
16869
    "RelationsType",
16870
    "RolesType",
16871
    "SeparatorRegionType",
16872
    "TableCellRoleType",
16873
    "TableRegionType",
16874
    "TextEquivType",
16875
    "TextLineType",
16876
    "TextRegionType",
16877
    "TextStyleType",
16878
    "UnknownRegionType",
16879
    "UnorderedGroupIndexedType",
16880
    "UnorderedGroupType",
16881
    "UserAttributeType",
16882
    "UserDefinedType",
16883
    "WordType"
16884
]
16885