@@ 13308-13468 (lines=161) @@ | ||
13305 | # end class MathsRegionType |
|
13306 | ||
13307 | ||
13308 | class SeparatorRegionType(RegionType): |
|
13309 | """SeparatorRegionType -- |
|
13310 | Separators are lines that lie between columns and |
|
13311 | paragraphs and can be used to logically separate |
|
13312 | different articles from each other. |
|
13313 | ||
13314 | * orientation -- |
|
13315 | The angle the rectangle encapsulating a region |
|
13316 | has to be rotated in clockwise direction |
|
13317 | in order to correct the present skew |
|
13318 | (negative values indicate anti-clockwise rotation). |
|
13319 | Range: -179.999,180 |
|
13320 | ||
13321 | * colour -- |
|
13322 | The colour of the separator |
|
13323 | ||
13324 | """ |
|
13325 | __hash__ = GeneratedsSuper.__hash__ |
|
13326 | member_data_items_ = [ |
|
13327 | MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional', 'name': 'orientation'}), |
|
13328 | MemberSpec_('colour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional', 'name': 'colour'}), |
|
13329 | ] |
|
13330 | subclass = None |
|
13331 | superclass = RegionType |
|
13332 | 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_): |
|
13333 | self.gds_collector_ = gds_collector_ |
|
13334 | self.gds_elementtree_node_ = None |
|
13335 | self.original_tagname_ = None |
|
13336 | self.parent_object_ = kwargs_.get('parent_object_') |
|
13337 | self.ns_prefix_ = "pc" |
|
13338 | 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_) |
|
13339 | self.orientation = _cast(float, orientation) |
|
13340 | self.orientation_nsprefix_ = "pc" |
|
13341 | self.colour = _cast(None, colour) |
|
13342 | self.colour_nsprefix_ = "pc" |
|
13343 | def factory(*args_, **kwargs_): |
|
13344 | if CurrentSubclassModule_ is not None: |
|
13345 | subclass = getSubclassFromModule_( |
|
13346 | CurrentSubclassModule_, SeparatorRegionType) |
|
13347 | if subclass is not None: |
|
13348 | return subclass(*args_, **kwargs_) |
|
13349 | if SeparatorRegionType.subclass: |
|
13350 | return SeparatorRegionType.subclass(*args_, **kwargs_) |
|
13351 | else: |
|
13352 | return SeparatorRegionType(*args_, **kwargs_) |
|
13353 | factory = staticmethod(factory) |
|
13354 | def get_ns_prefix_(self): |
|
13355 | return self.ns_prefix_ |
|
13356 | def set_ns_prefix_(self, ns_prefix): |
|
13357 | self.ns_prefix_ = ns_prefix |
|
13358 | def get_orientation(self): |
|
13359 | return self.orientation |
|
13360 | def set_orientation(self, orientation): |
|
13361 | self.orientation = orientation |
|
13362 | def get_colour(self): |
|
13363 | return self.colour |
|
13364 | def set_colour(self, colour): |
|
13365 | self.colour = colour |
|
13366 | def validate_ColourSimpleType(self, value): |
|
13367 | # Validate type pc:ColourSimpleType, a restriction on string. |
|
13368 | if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: |
|
13369 | if not isinstance(value, str): |
|
13370 | lineno = self.gds_get_node_lineno_() |
|
13371 | self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) |
|
13372 | return False |
|
13373 | value = value |
|
13374 | enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other'] |
|
13375 | if value not in enumerations: |
|
13376 | lineno = self.gds_get_node_lineno_() |
|
13377 | 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} ) |
|
13378 | result = False |
|
13379 | def has__content(self): |
|
13380 | if ( |
|
13381 | super(SeparatorRegionType, self).has__content() |
|
13382 | ): |
|
13383 | return True |
|
13384 | else: |
|
13385 | return False |
|
13386 | def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='SeparatorRegionType', pretty_print=True): |
|
13387 | imported_ns_def_ = GenerateDSNamespaceDefs_.get('SeparatorRegionType') |
|
13388 | if imported_ns_def_ is not None: |
|
13389 | namespacedef_ = imported_ns_def_ |
|
13390 | if pretty_print: |
|
13391 | eol_ = '\n' |
|
13392 | else: |
|
13393 | eol_ = '' |
|
13394 | if self.original_tagname_ is not None and name_ == 'SeparatorRegionType': |
|
13395 | name_ = self.original_tagname_ |
|
13396 | if UseCapturedNS_ and self.ns_prefix_: |
|
13397 | namespaceprefix_ = self.ns_prefix_ + ':' |
|
13398 | showIndent(outfile, level, pretty_print) |
|
13399 | outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) |
|
13400 | already_processed = set() |
|
13401 | self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='SeparatorRegionType') |
|
13402 | if self.has__content(): |
|
13403 | outfile.write('>%s' % (eol_, )) |
|
13404 | self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='SeparatorRegionType', pretty_print=pretty_print) |
|
13405 | showIndent(outfile, level, pretty_print) |
|
13406 | outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_)) |
|
13407 | else: |
|
13408 | outfile.write('/>%s' % (eol_, )) |
|
13409 | def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='SeparatorRegionType'): |
|
13410 | super(SeparatorRegionType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='SeparatorRegionType') |
|
13411 | if self.orientation is not None and 'orientation' not in already_processed: |
|
13412 | already_processed.add('orientation') |
|
13413 | outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation')) |
|
13414 | if self.colour is not None and 'colour' not in already_processed: |
|
13415 | already_processed.add('colour') |
|
13416 | outfile.write(' colour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.colour), input_name='colour')), )) |
|
13417 | 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): |
|
13418 | super(SeparatorRegionType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print) |
|
13419 | def to_etree(self, parent_element=None, name_='SeparatorRegionType', mapping_=None, reverse_mapping_=None, nsmap_=None): |
|
13420 | element = super(SeparatorRegionType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_) |
|
13421 | if self.orientation is not None: |
|
13422 | element.set('orientation', self.gds_format_float(self.orientation)) |
|
13423 | if self.colour is not None: |
|
13424 | element.set('colour', self.gds_format_string(self.colour)) |
|
13425 | if mapping_ is not None: |
|
13426 | mapping_[id(self)] = element |
|
13427 | if reverse_mapping_ is not None: |
|
13428 | reverse_mapping_[element] = self |
|
13429 | return element |
|
13430 | def build(self, node, gds_collector_=None): |
|
13431 | self.gds_collector_ = gds_collector_ |
|
13432 | if SaveElementTreeNode: |
|
13433 | self.gds_elementtree_node_ = node |
|
13434 | already_processed = set() |
|
13435 | self.ns_prefix_ = node.prefix |
|
13436 | self._buildAttributes(node, node.attrib, already_processed) |
|
13437 | for child in node: |
|
13438 | nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] |
|
13439 | self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) |
|
13440 | return self |
|
13441 | def _buildAttributes(self, node, attrs, already_processed): |
|
13442 | value = find_attr_value_('orientation', node) |
|
13443 | if value is not None and 'orientation' not in already_processed: |
|
13444 | already_processed.add('orientation') |
|
13445 | value = self.gds_parse_float(value, node, 'orientation') |
|
13446 | self.orientation = value |
|
13447 | value = find_attr_value_('colour', node) |
|
13448 | if value is not None and 'colour' not in already_processed: |
|
13449 | already_processed.add('colour') |
|
13450 | self.colour = value |
|
13451 | self.validate_ColourSimpleType(self.colour) # validate type ColourSimpleType |
|
13452 | super(SeparatorRegionType, self)._buildAttributes(node, attrs, already_processed) |
|
13453 | def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): |
|
13454 | super(SeparatorRegionType, self)._buildChildren(child_, node, nodeName_, True) |
|
13455 | pass |
|
13456 | def __hash__(self): |
|
13457 | return hash(self.id) |
|
13458 | def set_orientation(self, orientation): |
|
13459 | """ |
|
13460 | Set deskewing angle to given `orientation` number. |
|
13461 | Moreover, invalidate self's ``pc:AlternativeImage``s |
|
13462 | (because they will have been rotated and enlarged |
|
13463 | with the angle of the previous value). |
|
13464 | """ |
|
13465 | if hasattr(self, 'invalidate_AlternativeImage'): |
|
13466 | # PageType, RegionType: |
|
13467 | self.invalidate_AlternativeImage(feature_selector='deskewed') |
|
13468 | self.orientation = orientation |
|
13469 | # end class SeparatorRegionType |
|
13470 | ||
13471 | ||
@@ 13145-13304 (lines=160) @@ | ||
13142 | # end class ChemRegionType |
|
13143 | ||
13144 | ||
13145 | class MathsRegionType(RegionType): |
|
13146 | """MathsRegionType -- |
|
13147 | Regions containing equations and mathematical symbols |
|
13148 | should be marked as maths regions. |
|
13149 | ||
13150 | * orientation -- |
|
13151 | The angle the rectangle encapsulating a region |
|
13152 | has to be rotated in clockwise direction |
|
13153 | in order to correct the present skew |
|
13154 | (negative values indicate anti-clockwise rotation). |
|
13155 | Range: -179.999,180 |
|
13156 | ||
13157 | * bgColour -- |
|
13158 | The background colour of the region |
|
13159 | ||
13160 | """ |
|
13161 | __hash__ = GeneratedsSuper.__hash__ |
|
13162 | member_data_items_ = [ |
|
13163 | MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional', 'name': 'orientation'}), |
|
13164 | MemberSpec_('bgColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional', 'name': 'bgColour'}), |
|
13165 | ] |
|
13166 | subclass = None |
|
13167 | superclass = RegionType |
|
13168 | 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_): |
|
13169 | self.gds_collector_ = gds_collector_ |
|
13170 | self.gds_elementtree_node_ = None |
|
13171 | self.original_tagname_ = None |
|
13172 | self.parent_object_ = kwargs_.get('parent_object_') |
|
13173 | self.ns_prefix_ = "pc" |
|
13174 | 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_) |
|
13175 | self.orientation = _cast(float, orientation) |
|
13176 | self.orientation_nsprefix_ = "pc" |
|
13177 | self.bgColour = _cast(None, bgColour) |
|
13178 | self.bgColour_nsprefix_ = "pc" |
|
13179 | def factory(*args_, **kwargs_): |
|
13180 | if CurrentSubclassModule_ is not None: |
|
13181 | subclass = getSubclassFromModule_( |
|
13182 | CurrentSubclassModule_, MathsRegionType) |
|
13183 | if subclass is not None: |
|
13184 | return subclass(*args_, **kwargs_) |
|
13185 | if MathsRegionType.subclass: |
|
13186 | return MathsRegionType.subclass(*args_, **kwargs_) |
|
13187 | else: |
|
13188 | return MathsRegionType(*args_, **kwargs_) |
|
13189 | factory = staticmethod(factory) |
|
13190 | def get_ns_prefix_(self): |
|
13191 | return self.ns_prefix_ |
|
13192 | def set_ns_prefix_(self, ns_prefix): |
|
13193 | self.ns_prefix_ = ns_prefix |
|
13194 | def get_orientation(self): |
|
13195 | return self.orientation |
|
13196 | def set_orientation(self, orientation): |
|
13197 | self.orientation = orientation |
|
13198 | def get_bgColour(self): |
|
13199 | return self.bgColour |
|
13200 | def set_bgColour(self, bgColour): |
|
13201 | self.bgColour = bgColour |
|
13202 | def validate_ColourSimpleType(self, value): |
|
13203 | # Validate type pc:ColourSimpleType, a restriction on string. |
|
13204 | if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: |
|
13205 | if not isinstance(value, str): |
|
13206 | lineno = self.gds_get_node_lineno_() |
|
13207 | self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) |
|
13208 | return False |
|
13209 | value = value |
|
13210 | enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other'] |
|
13211 | if value not in enumerations: |
|
13212 | lineno = self.gds_get_node_lineno_() |
|
13213 | 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} ) |
|
13214 | result = False |
|
13215 | def has__content(self): |
|
13216 | if ( |
|
13217 | super(MathsRegionType, self).has__content() |
|
13218 | ): |
|
13219 | return True |
|
13220 | else: |
|
13221 | return False |
|
13222 | def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='MathsRegionType', pretty_print=True): |
|
13223 | imported_ns_def_ = GenerateDSNamespaceDefs_.get('MathsRegionType') |
|
13224 | if imported_ns_def_ is not None: |
|
13225 | namespacedef_ = imported_ns_def_ |
|
13226 | if pretty_print: |
|
13227 | eol_ = '\n' |
|
13228 | else: |
|
13229 | eol_ = '' |
|
13230 | if self.original_tagname_ is not None and name_ == 'MathsRegionType': |
|
13231 | name_ = self.original_tagname_ |
|
13232 | if UseCapturedNS_ and self.ns_prefix_: |
|
13233 | namespaceprefix_ = self.ns_prefix_ + ':' |
|
13234 | showIndent(outfile, level, pretty_print) |
|
13235 | outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) |
|
13236 | already_processed = set() |
|
13237 | self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='MathsRegionType') |
|
13238 | if self.has__content(): |
|
13239 | outfile.write('>%s' % (eol_, )) |
|
13240 | self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='MathsRegionType', pretty_print=pretty_print) |
|
13241 | showIndent(outfile, level, pretty_print) |
|
13242 | outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_)) |
|
13243 | else: |
|
13244 | outfile.write('/>%s' % (eol_, )) |
|
13245 | def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='MathsRegionType'): |
|
13246 | super(MathsRegionType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='MathsRegionType') |
|
13247 | if self.orientation is not None and 'orientation' not in already_processed: |
|
13248 | already_processed.add('orientation') |
|
13249 | outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation')) |
|
13250 | if self.bgColour is not None and 'bgColour' not in already_processed: |
|
13251 | already_processed.add('bgColour') |
|
13252 | outfile.write(' bgColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.bgColour), input_name='bgColour')), )) |
|
13253 | 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): |
|
13254 | super(MathsRegionType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print) |
|
13255 | def to_etree(self, parent_element=None, name_='MathsRegionType', mapping_=None, reverse_mapping_=None, nsmap_=None): |
|
13256 | element = super(MathsRegionType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_) |
|
13257 | if self.orientation is not None: |
|
13258 | element.set('orientation', self.gds_format_float(self.orientation)) |
|
13259 | if self.bgColour is not None: |
|
13260 | element.set('bgColour', self.gds_format_string(self.bgColour)) |
|
13261 | if mapping_ is not None: |
|
13262 | mapping_[id(self)] = element |
|
13263 | if reverse_mapping_ is not None: |
|
13264 | reverse_mapping_[element] = self |
|
13265 | return element |
|
13266 | def build(self, node, gds_collector_=None): |
|
13267 | self.gds_collector_ = gds_collector_ |
|
13268 | if SaveElementTreeNode: |
|
13269 | self.gds_elementtree_node_ = node |
|
13270 | already_processed = set() |
|
13271 | self.ns_prefix_ = node.prefix |
|
13272 | self._buildAttributes(node, node.attrib, already_processed) |
|
13273 | for child in node: |
|
13274 | nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] |
|
13275 | self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) |
|
13276 | return self |
|
13277 | def _buildAttributes(self, node, attrs, already_processed): |
|
13278 | value = find_attr_value_('orientation', node) |
|
13279 | if value is not None and 'orientation' not in already_processed: |
|
13280 | already_processed.add('orientation') |
|
13281 | value = self.gds_parse_float(value, node, 'orientation') |
|
13282 | self.orientation = value |
|
13283 | value = find_attr_value_('bgColour', node) |
|
13284 | if value is not None and 'bgColour' not in already_processed: |
|
13285 | already_processed.add('bgColour') |
|
13286 | self.bgColour = value |
|
13287 | self.validate_ColourSimpleType(self.bgColour) # validate type ColourSimpleType |
|
13288 | super(MathsRegionType, self)._buildAttributes(node, attrs, already_processed) |
|
13289 | def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): |
|
13290 | super(MathsRegionType, self)._buildChildren(child_, node, nodeName_, True) |
|
13291 | pass |
|
13292 | def __hash__(self): |
|
13293 | return hash(self.id) |
|
13294 | def set_orientation(self, orientation): |
|
13295 | """ |
|
13296 | Set deskewing angle to given `orientation` number. |
|
13297 | Moreover, invalidate self's ``pc:AlternativeImage``s |
|
13298 | (because they will have been rotated and enlarged |
|
13299 | with the angle of the previous value). |
|
13300 | """ |
|
13301 | if hasattr(self, 'invalidate_AlternativeImage'): |
|
13302 | # PageType, RegionType: |
|
13303 | self.invalidate_AlternativeImage(feature_selector='deskewed') |
|
13304 | self.orientation = orientation |
|
13305 | # end class MathsRegionType |
|
13306 | ||
13307 | ||
@@ 12982-13141 (lines=160) @@ | ||
12979 | # end class MapRegionType |
|
12980 | ||
12981 | ||
12982 | class ChemRegionType(RegionType): |
|
12983 | """ChemRegionType -- |
|
12984 | Regions containing chemical formulas. |
|
12985 | ||
12986 | * orientation -- |
|
12987 | The angle the rectangle encapsulating a |
|
12988 | region has to be rotated in clockwise |
|
12989 | direction in order to correct the present |
|
12990 | skew (negative values indicate |
|
12991 | anti-clockwise rotation). Range: |
|
12992 | -179.999,180 |
|
12993 | ||
12994 | * bgColour -- |
|
12995 | The background colour of the region |
|
12996 | ||
12997 | """ |
|
12998 | __hash__ = GeneratedsSuper.__hash__ |
|
12999 | member_data_items_ = [ |
|
13000 | MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional', 'name': 'orientation'}), |
|
13001 | MemberSpec_('bgColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional', 'name': 'bgColour'}), |
|
13002 | ] |
|
13003 | subclass = None |
|
13004 | superclass = RegionType |
|
13005 | 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_): |
|
13006 | self.gds_collector_ = gds_collector_ |
|
13007 | self.gds_elementtree_node_ = None |
|
13008 | self.original_tagname_ = None |
|
13009 | self.parent_object_ = kwargs_.get('parent_object_') |
|
13010 | self.ns_prefix_ = "pc" |
|
13011 | 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_) |
|
13012 | self.orientation = _cast(float, orientation) |
|
13013 | self.orientation_nsprefix_ = "pc" |
|
13014 | self.bgColour = _cast(None, bgColour) |
|
13015 | self.bgColour_nsprefix_ = "pc" |
|
13016 | def factory(*args_, **kwargs_): |
|
13017 | if CurrentSubclassModule_ is not None: |
|
13018 | subclass = getSubclassFromModule_( |
|
13019 | CurrentSubclassModule_, ChemRegionType) |
|
13020 | if subclass is not None: |
|
13021 | return subclass(*args_, **kwargs_) |
|
13022 | if ChemRegionType.subclass: |
|
13023 | return ChemRegionType.subclass(*args_, **kwargs_) |
|
13024 | else: |
|
13025 | return ChemRegionType(*args_, **kwargs_) |
|
13026 | factory = staticmethod(factory) |
|
13027 | def get_ns_prefix_(self): |
|
13028 | return self.ns_prefix_ |
|
13029 | def set_ns_prefix_(self, ns_prefix): |
|
13030 | self.ns_prefix_ = ns_prefix |
|
13031 | def get_orientation(self): |
|
13032 | return self.orientation |
|
13033 | def set_orientation(self, orientation): |
|
13034 | self.orientation = orientation |
|
13035 | def get_bgColour(self): |
|
13036 | return self.bgColour |
|
13037 | def set_bgColour(self, bgColour): |
|
13038 | self.bgColour = bgColour |
|
13039 | def validate_ColourSimpleType(self, value): |
|
13040 | # Validate type pc:ColourSimpleType, a restriction on string. |
|
13041 | if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: |
|
13042 | if not isinstance(value, str): |
|
13043 | lineno = self.gds_get_node_lineno_() |
|
13044 | self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) |
|
13045 | return False |
|
13046 | value = value |
|
13047 | enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other'] |
|
13048 | if value not in enumerations: |
|
13049 | lineno = self.gds_get_node_lineno_() |
|
13050 | 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} ) |
|
13051 | result = False |
|
13052 | def has__content(self): |
|
13053 | if ( |
|
13054 | super(ChemRegionType, self).has__content() |
|
13055 | ): |
|
13056 | return True |
|
13057 | else: |
|
13058 | return False |
|
13059 | def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='ChemRegionType', pretty_print=True): |
|
13060 | imported_ns_def_ = GenerateDSNamespaceDefs_.get('ChemRegionType') |
|
13061 | if imported_ns_def_ is not None: |
|
13062 | namespacedef_ = imported_ns_def_ |
|
13063 | if pretty_print: |
|
13064 | eol_ = '\n' |
|
13065 | else: |
|
13066 | eol_ = '' |
|
13067 | if self.original_tagname_ is not None and name_ == 'ChemRegionType': |
|
13068 | name_ = self.original_tagname_ |
|
13069 | if UseCapturedNS_ and self.ns_prefix_: |
|
13070 | namespaceprefix_ = self.ns_prefix_ + ':' |
|
13071 | showIndent(outfile, level, pretty_print) |
|
13072 | outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) |
|
13073 | already_processed = set() |
|
13074 | self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='ChemRegionType') |
|
13075 | if self.has__content(): |
|
13076 | outfile.write('>%s' % (eol_, )) |
|
13077 | self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='ChemRegionType', pretty_print=pretty_print) |
|
13078 | showIndent(outfile, level, pretty_print) |
|
13079 | outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_)) |
|
13080 | else: |
|
13081 | outfile.write('/>%s' % (eol_, )) |
|
13082 | def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='ChemRegionType'): |
|
13083 | super(ChemRegionType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='ChemRegionType') |
|
13084 | if self.orientation is not None and 'orientation' not in already_processed: |
|
13085 | already_processed.add('orientation') |
|
13086 | outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation')) |
|
13087 | if self.bgColour is not None and 'bgColour' not in already_processed: |
|
13088 | already_processed.add('bgColour') |
|
13089 | outfile.write(' bgColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.bgColour), input_name='bgColour')), )) |
|
13090 | 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): |
|
13091 | super(ChemRegionType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print) |
|
13092 | def to_etree(self, parent_element=None, name_='ChemRegionType', mapping_=None, reverse_mapping_=None, nsmap_=None): |
|
13093 | element = super(ChemRegionType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_) |
|
13094 | if self.orientation is not None: |
|
13095 | element.set('orientation', self.gds_format_float(self.orientation)) |
|
13096 | if self.bgColour is not None: |
|
13097 | element.set('bgColour', self.gds_format_string(self.bgColour)) |
|
13098 | if mapping_ is not None: |
|
13099 | mapping_[id(self)] = element |
|
13100 | if reverse_mapping_ is not None: |
|
13101 | reverse_mapping_[element] = self |
|
13102 | return element |
|
13103 | def build(self, node, gds_collector_=None): |
|
13104 | self.gds_collector_ = gds_collector_ |
|
13105 | if SaveElementTreeNode: |
|
13106 | self.gds_elementtree_node_ = node |
|
13107 | already_processed = set() |
|
13108 | self.ns_prefix_ = node.prefix |
|
13109 | self._buildAttributes(node, node.attrib, already_processed) |
|
13110 | for child in node: |
|
13111 | nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] |
|
13112 | self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) |
|
13113 | return self |
|
13114 | def _buildAttributes(self, node, attrs, already_processed): |
|
13115 | value = find_attr_value_('orientation', node) |
|
13116 | if value is not None and 'orientation' not in already_processed: |
|
13117 | already_processed.add('orientation') |
|
13118 | value = self.gds_parse_float(value, node, 'orientation') |
|
13119 | self.orientation = value |
|
13120 | value = find_attr_value_('bgColour', node) |
|
13121 | if value is not None and 'bgColour' not in already_processed: |
|
13122 | already_processed.add('bgColour') |
|
13123 | self.bgColour = value |
|
13124 | self.validate_ColourSimpleType(self.bgColour) # validate type ColourSimpleType |
|
13125 | super(ChemRegionType, self)._buildAttributes(node, attrs, already_processed) |
|
13126 | def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): |
|
13127 | super(ChemRegionType, self)._buildChildren(child_, node, nodeName_, True) |
|
13128 | pass |
|
13129 | def __hash__(self): |
|
13130 | return hash(self.id) |
|
13131 | def set_orientation(self, orientation): |
|
13132 | """ |
|
13133 | Set deskewing angle to given `orientation` number. |
|
13134 | Moreover, invalidate self's ``pc:AlternativeImage``s |
|
13135 | (because they will have been rotated and enlarged |
|
13136 | with the angle of the previous value). |
|
13137 | """ |
|
13138 | if hasattr(self, 'invalidate_AlternativeImage'): |
|
13139 | # PageType, RegionType: |
|
13140 | self.invalidate_AlternativeImage(feature_selector='deskewed') |
|
13141 | self.orientation = orientation |
|
13142 | # end class ChemRegionType |
|
13143 | ||
13144 | ||
@@ 12690-12848 (lines=159) @@ | ||
12687 | # end class AdvertRegionType |
|
12688 | ||
12689 | ||
12690 | class MusicRegionType(RegionType): |
|
12691 | """MusicRegionType -- |
|
12692 | Regions containing musical notations. |
|
12693 | ||
12694 | * orientation -- |
|
12695 | The angle the rectangle encapsulating a region |
|
12696 | has to be rotated in clockwise direction |
|
12697 | in order to correct the present skew |
|
12698 | (negative values indicate anti-clockwise rotation). |
|
12699 | Range: -179.999,180 |
|
12700 | ||
12701 | * bgColour -- |
|
12702 | The background colour of the region |
|
12703 | ||
12704 | """ |
|
12705 | __hash__ = GeneratedsSuper.__hash__ |
|
12706 | member_data_items_ = [ |
|
12707 | MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional', 'name': 'orientation'}), |
|
12708 | MemberSpec_('bgColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional', 'name': 'bgColour'}), |
|
12709 | ] |
|
12710 | subclass = None |
|
12711 | superclass = RegionType |
|
12712 | 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_): |
|
12713 | self.gds_collector_ = gds_collector_ |
|
12714 | self.gds_elementtree_node_ = None |
|
12715 | self.original_tagname_ = None |
|
12716 | self.parent_object_ = kwargs_.get('parent_object_') |
|
12717 | self.ns_prefix_ = "pc" |
|
12718 | 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_) |
|
12719 | self.orientation = _cast(float, orientation) |
|
12720 | self.orientation_nsprefix_ = "pc" |
|
12721 | self.bgColour = _cast(None, bgColour) |
|
12722 | self.bgColour_nsprefix_ = "pc" |
|
12723 | def factory(*args_, **kwargs_): |
|
12724 | if CurrentSubclassModule_ is not None: |
|
12725 | subclass = getSubclassFromModule_( |
|
12726 | CurrentSubclassModule_, MusicRegionType) |
|
12727 | if subclass is not None: |
|
12728 | return subclass(*args_, **kwargs_) |
|
12729 | if MusicRegionType.subclass: |
|
12730 | return MusicRegionType.subclass(*args_, **kwargs_) |
|
12731 | else: |
|
12732 | return MusicRegionType(*args_, **kwargs_) |
|
12733 | factory = staticmethod(factory) |
|
12734 | def get_ns_prefix_(self): |
|
12735 | return self.ns_prefix_ |
|
12736 | def set_ns_prefix_(self, ns_prefix): |
|
12737 | self.ns_prefix_ = ns_prefix |
|
12738 | def get_orientation(self): |
|
12739 | return self.orientation |
|
12740 | def set_orientation(self, orientation): |
|
12741 | self.orientation = orientation |
|
12742 | def get_bgColour(self): |
|
12743 | return self.bgColour |
|
12744 | def set_bgColour(self, bgColour): |
|
12745 | self.bgColour = bgColour |
|
12746 | def validate_ColourSimpleType(self, value): |
|
12747 | # Validate type pc:ColourSimpleType, a restriction on string. |
|
12748 | if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: |
|
12749 | if not isinstance(value, str): |
|
12750 | lineno = self.gds_get_node_lineno_() |
|
12751 | self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) |
|
12752 | return False |
|
12753 | value = value |
|
12754 | enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other'] |
|
12755 | if value not in enumerations: |
|
12756 | lineno = self.gds_get_node_lineno_() |
|
12757 | 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} ) |
|
12758 | result = False |
|
12759 | def has__content(self): |
|
12760 | if ( |
|
12761 | super(MusicRegionType, self).has__content() |
|
12762 | ): |
|
12763 | return True |
|
12764 | else: |
|
12765 | return False |
|
12766 | def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='MusicRegionType', pretty_print=True): |
|
12767 | imported_ns_def_ = GenerateDSNamespaceDefs_.get('MusicRegionType') |
|
12768 | if imported_ns_def_ is not None: |
|
12769 | namespacedef_ = imported_ns_def_ |
|
12770 | if pretty_print: |
|
12771 | eol_ = '\n' |
|
12772 | else: |
|
12773 | eol_ = '' |
|
12774 | if self.original_tagname_ is not None and name_ == 'MusicRegionType': |
|
12775 | name_ = self.original_tagname_ |
|
12776 | if UseCapturedNS_ and self.ns_prefix_: |
|
12777 | namespaceprefix_ = self.ns_prefix_ + ':' |
|
12778 | showIndent(outfile, level, pretty_print) |
|
12779 | outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) |
|
12780 | already_processed = set() |
|
12781 | self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='MusicRegionType') |
|
12782 | if self.has__content(): |
|
12783 | outfile.write('>%s' % (eol_, )) |
|
12784 | self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='MusicRegionType', pretty_print=pretty_print) |
|
12785 | showIndent(outfile, level, pretty_print) |
|
12786 | outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_)) |
|
12787 | else: |
|
12788 | outfile.write('/>%s' % (eol_, )) |
|
12789 | def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='MusicRegionType'): |
|
12790 | super(MusicRegionType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='MusicRegionType') |
|
12791 | if self.orientation is not None and 'orientation' not in already_processed: |
|
12792 | already_processed.add('orientation') |
|
12793 | outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation')) |
|
12794 | if self.bgColour is not None and 'bgColour' not in already_processed: |
|
12795 | already_processed.add('bgColour') |
|
12796 | outfile.write(' bgColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.bgColour), input_name='bgColour')), )) |
|
12797 | 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): |
|
12798 | super(MusicRegionType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print) |
|
12799 | def to_etree(self, parent_element=None, name_='MusicRegionType', mapping_=None, reverse_mapping_=None, nsmap_=None): |
|
12800 | element = super(MusicRegionType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_) |
|
12801 | if self.orientation is not None: |
|
12802 | element.set('orientation', self.gds_format_float(self.orientation)) |
|
12803 | if self.bgColour is not None: |
|
12804 | element.set('bgColour', self.gds_format_string(self.bgColour)) |
|
12805 | if mapping_ is not None: |
|
12806 | mapping_[id(self)] = element |
|
12807 | if reverse_mapping_ is not None: |
|
12808 | reverse_mapping_[element] = self |
|
12809 | return element |
|
12810 | def build(self, node, gds_collector_=None): |
|
12811 | self.gds_collector_ = gds_collector_ |
|
12812 | if SaveElementTreeNode: |
|
12813 | self.gds_elementtree_node_ = node |
|
12814 | already_processed = set() |
|
12815 | self.ns_prefix_ = node.prefix |
|
12816 | self._buildAttributes(node, node.attrib, already_processed) |
|
12817 | for child in node: |
|
12818 | nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] |
|
12819 | self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) |
|
12820 | return self |
|
12821 | def _buildAttributes(self, node, attrs, already_processed): |
|
12822 | value = find_attr_value_('orientation', node) |
|
12823 | if value is not None and 'orientation' not in already_processed: |
|
12824 | already_processed.add('orientation') |
|
12825 | value = self.gds_parse_float(value, node, 'orientation') |
|
12826 | self.orientation = value |
|
12827 | value = find_attr_value_('bgColour', node) |
|
12828 | if value is not None and 'bgColour' not in already_processed: |
|
12829 | already_processed.add('bgColour') |
|
12830 | self.bgColour = value |
|
12831 | self.validate_ColourSimpleType(self.bgColour) # validate type ColourSimpleType |
|
12832 | super(MusicRegionType, self)._buildAttributes(node, attrs, already_processed) |
|
12833 | def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): |
|
12834 | super(MusicRegionType, self)._buildChildren(child_, node, nodeName_, True) |
|
12835 | pass |
|
12836 | def __hash__(self): |
|
12837 | return hash(self.id) |
|
12838 | def set_orientation(self, orientation): |
|
12839 | """ |
|
12840 | Set deskewing angle to given `orientation` number. |
|
12841 | Moreover, invalidate self's ``pc:AlternativeImage``s |
|
12842 | (because they will have been rotated and enlarged |
|
12843 | with the angle of the previous value). |
|
12844 | """ |
|
12845 | if hasattr(self, 'invalidate_AlternativeImage'): |
|
12846 | # PageType, RegionType: |
|
12847 | self.invalidate_AlternativeImage(feature_selector='deskewed') |
|
12848 | self.orientation = orientation |
|
12849 | # end class MusicRegionType |
|
12850 | ||
12851 | ||
@@ 12528-12686 (lines=159) @@ | ||
12525 | # end class NoiseRegionType |
|
12526 | ||
12527 | ||
12528 | class AdvertRegionType(RegionType): |
|
12529 | """AdvertRegionType -- |
|
12530 | Regions containing advertisements. |
|
12531 | ||
12532 | * orientation -- |
|
12533 | The angle the rectangle encapsulating a region |
|
12534 | has to be rotated in clockwise direction |
|
12535 | in order to correct the present skew |
|
12536 | (negative values indicate anti-clockwise rotation). |
|
12537 | Range: -179.999,180 |
|
12538 | ||
12539 | * bgColour -- |
|
12540 | The background colour of the region |
|
12541 | ||
12542 | """ |
|
12543 | __hash__ = GeneratedsSuper.__hash__ |
|
12544 | member_data_items_ = [ |
|
12545 | MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional', 'name': 'orientation'}), |
|
12546 | MemberSpec_('bgColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional', 'name': 'bgColour'}), |
|
12547 | ] |
|
12548 | subclass = None |
|
12549 | superclass = RegionType |
|
12550 | 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_): |
|
12551 | self.gds_collector_ = gds_collector_ |
|
12552 | self.gds_elementtree_node_ = None |
|
12553 | self.original_tagname_ = None |
|
12554 | self.parent_object_ = kwargs_.get('parent_object_') |
|
12555 | self.ns_prefix_ = "pc" |
|
12556 | 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_) |
|
12557 | self.orientation = _cast(float, orientation) |
|
12558 | self.orientation_nsprefix_ = "pc" |
|
12559 | self.bgColour = _cast(None, bgColour) |
|
12560 | self.bgColour_nsprefix_ = "pc" |
|
12561 | def factory(*args_, **kwargs_): |
|
12562 | if CurrentSubclassModule_ is not None: |
|
12563 | subclass = getSubclassFromModule_( |
|
12564 | CurrentSubclassModule_, AdvertRegionType) |
|
12565 | if subclass is not None: |
|
12566 | return subclass(*args_, **kwargs_) |
|
12567 | if AdvertRegionType.subclass: |
|
12568 | return AdvertRegionType.subclass(*args_, **kwargs_) |
|
12569 | else: |
|
12570 | return AdvertRegionType(*args_, **kwargs_) |
|
12571 | factory = staticmethod(factory) |
|
12572 | def get_ns_prefix_(self): |
|
12573 | return self.ns_prefix_ |
|
12574 | def set_ns_prefix_(self, ns_prefix): |
|
12575 | self.ns_prefix_ = ns_prefix |
|
12576 | def get_orientation(self): |
|
12577 | return self.orientation |
|
12578 | def set_orientation(self, orientation): |
|
12579 | self.orientation = orientation |
|
12580 | def get_bgColour(self): |
|
12581 | return self.bgColour |
|
12582 | def set_bgColour(self, bgColour): |
|
12583 | self.bgColour = bgColour |
|
12584 | def validate_ColourSimpleType(self, value): |
|
12585 | # Validate type pc:ColourSimpleType, a restriction on string. |
|
12586 | if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: |
|
12587 | if not isinstance(value, str): |
|
12588 | lineno = self.gds_get_node_lineno_() |
|
12589 | self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) |
|
12590 | return False |
|
12591 | value = value |
|
12592 | enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other'] |
|
12593 | if value not in enumerations: |
|
12594 | lineno = self.gds_get_node_lineno_() |
|
12595 | 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} ) |
|
12596 | result = False |
|
12597 | def has__content(self): |
|
12598 | if ( |
|
12599 | super(AdvertRegionType, self).has__content() |
|
12600 | ): |
|
12601 | return True |
|
12602 | else: |
|
12603 | return False |
|
12604 | def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='AdvertRegionType', pretty_print=True): |
|
12605 | imported_ns_def_ = GenerateDSNamespaceDefs_.get('AdvertRegionType') |
|
12606 | if imported_ns_def_ is not None: |
|
12607 | namespacedef_ = imported_ns_def_ |
|
12608 | if pretty_print: |
|
12609 | eol_ = '\n' |
|
12610 | else: |
|
12611 | eol_ = '' |
|
12612 | if self.original_tagname_ is not None and name_ == 'AdvertRegionType': |
|
12613 | name_ = self.original_tagname_ |
|
12614 | if UseCapturedNS_ and self.ns_prefix_: |
|
12615 | namespaceprefix_ = self.ns_prefix_ + ':' |
|
12616 | showIndent(outfile, level, pretty_print) |
|
12617 | outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) |
|
12618 | already_processed = set() |
|
12619 | self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='AdvertRegionType') |
|
12620 | if self.has__content(): |
|
12621 | outfile.write('>%s' % (eol_, )) |
|
12622 | self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='AdvertRegionType', pretty_print=pretty_print) |
|
12623 | showIndent(outfile, level, pretty_print) |
|
12624 | outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_)) |
|
12625 | else: |
|
12626 | outfile.write('/>%s' % (eol_, )) |
|
12627 | def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='AdvertRegionType'): |
|
12628 | super(AdvertRegionType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='AdvertRegionType') |
|
12629 | if self.orientation is not None and 'orientation' not in already_processed: |
|
12630 | already_processed.add('orientation') |
|
12631 | outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation')) |
|
12632 | if self.bgColour is not None and 'bgColour' not in already_processed: |
|
12633 | already_processed.add('bgColour') |
|
12634 | outfile.write(' bgColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.bgColour), input_name='bgColour')), )) |
|
12635 | 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): |
|
12636 | super(AdvertRegionType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print) |
|
12637 | def to_etree(self, parent_element=None, name_='AdvertRegionType', mapping_=None, reverse_mapping_=None, nsmap_=None): |
|
12638 | element = super(AdvertRegionType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_) |
|
12639 | if self.orientation is not None: |
|
12640 | element.set('orientation', self.gds_format_float(self.orientation)) |
|
12641 | if self.bgColour is not None: |
|
12642 | element.set('bgColour', self.gds_format_string(self.bgColour)) |
|
12643 | if mapping_ is not None: |
|
12644 | mapping_[id(self)] = element |
|
12645 | if reverse_mapping_ is not None: |
|
12646 | reverse_mapping_[element] = self |
|
12647 | return element |
|
12648 | def build(self, node, gds_collector_=None): |
|
12649 | self.gds_collector_ = gds_collector_ |
|
12650 | if SaveElementTreeNode: |
|
12651 | self.gds_elementtree_node_ = node |
|
12652 | already_processed = set() |
|
12653 | self.ns_prefix_ = node.prefix |
|
12654 | self._buildAttributes(node, node.attrib, already_processed) |
|
12655 | for child in node: |
|
12656 | nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] |
|
12657 | self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) |
|
12658 | return self |
|
12659 | def _buildAttributes(self, node, attrs, already_processed): |
|
12660 | value = find_attr_value_('orientation', node) |
|
12661 | if value is not None and 'orientation' not in already_processed: |
|
12662 | already_processed.add('orientation') |
|
12663 | value = self.gds_parse_float(value, node, 'orientation') |
|
12664 | self.orientation = value |
|
12665 | value = find_attr_value_('bgColour', node) |
|
12666 | if value is not None and 'bgColour' not in already_processed: |
|
12667 | already_processed.add('bgColour') |
|
12668 | self.bgColour = value |
|
12669 | self.validate_ColourSimpleType(self.bgColour) # validate type ColourSimpleType |
|
12670 | super(AdvertRegionType, self)._buildAttributes(node, attrs, already_processed) |
|
12671 | def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): |
|
12672 | super(AdvertRegionType, self)._buildChildren(child_, node, nodeName_, True) |
|
12673 | pass |
|
12674 | def __hash__(self): |
|
12675 | return hash(self.id) |
|
12676 | def set_orientation(self, orientation): |
|
12677 | """ |
|
12678 | Set deskewing angle to given `orientation` number. |
|
12679 | Moreover, invalidate self's ``pc:AlternativeImage``s |
|
12680 | (because they will have been rotated and enlarged |
|
12681 | with the angle of the previous value). |
|
12682 | """ |
|
12683 | if hasattr(self, 'invalidate_AlternativeImage'): |
|
12684 | # PageType, RegionType: |
|
12685 | self.invalidate_AlternativeImage(feature_selector='deskewed') |
|
12686 | self.orientation = orientation |
|
12687 | # end class AdvertRegionType |
|
12688 | ||
12689 |