Best Python code snippet using elementium_python
Attribute.py
Source:Attribute.py
1###############################################################################2# dominions #3#-----------------------------------------------------------------------------#4# #5# Licensed under the Apache License, Version 2.0 (the "License"); #6# you may not use this file except in compliance with the License. #7# You may obtain a copy of the License at #8# #9# http://www.apache.org/licenses/LICENSE-2.0 #10# #11# Unless required by applicable law or agreed to in writing, software #12# distributed under the License is distributed on an "AS IS" BASIS, #13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #14# See the License for the specific language governing permissions and #15# limitations under the License. #16# #17###############################################################################18""" Attributes applied to instances of various Dominions types. """19__docformat__ = "reStructuredText"20from collections import (21 namedtuple as _namedtuple,22 OrderedDict as _OrderedDict,23)24from sqlalchemy import (25 Table as _SQLA_Table,26 Column as _SQLA_Column,27 ForeignKey as _SQLA_ForeignKey,28 Integer as _SQLA_Integer,29 String as _SQLA_String,30)31from sqlalchemy.ext.declarative import (32 declared_attr as _SQLA_declared_attr,33)34from sqlalchemy.orm import (35 relationship as _SQLA_relationship,36)37from sqlalchemy.orm.util import (38 polymorphic_union as _SQLA_polymorphic_union,39)40from dominions.utils import (41 PrettyFormatConfig as _PrettyFormatConfig,42)43from dominions.DataTable import (44 DataTableRow as _DataTableRow,45)46from dominions.constants_tables import (47 AttributeKey,48 AttributeKeys_DataTable,49 MapTerrainType,50 MapTerrainTypes_DataTable,51)52_AttributesBuilderData = _namedtuple(53 "AttributesBuilderData",54 "value_table_name value_title value_mixin_class_name"55)56ATTRIBUTES_BUILDER_DATA = _OrderedDict( )57ATTRIBUTES_BUILDER_DATA[ 35 ] = _AttributesBuilderData(58 "unknown_values", "<Unknown Attribute>",59 "AttributeValue_GenericValue"60)61ATTRIBUTES_BUILDER_DATA[ 36 ] = _AttributesBuilderData(62 "unknown_values", "<Unknown Attribute>",63 "AttributeValue_GenericValue"64)65ATTRIBUTES_BUILDER_DATA[ 41 ] = _AttributesBuilderData(66 "unknown_values", "<Unknown Attribute>",67 "AttributeValue_GenericValue"68)69ATTRIBUTES_BUILDER_DATA[ 43 ] = _AttributesBuilderData(70 "unknown_values", "<Unknown Attribute>",71 "AttributeValue_GenericValue"72)73ATTRIBUTES_BUILDER_DATA[ 46 ] = _AttributesBuilderData(74 "unknown_values", "<Unknown Attribute>",75 "AttributeValue_GenericValue"76)77ATTRIBUTES_BUILDER_DATA[ 47 ] = _AttributesBuilderData(78 "unknown_values", "<Unknown Attribute>",79 "AttributeValue_GenericValue"80)81ATTRIBUTES_BUILDER_DATA[ 52 ] = _AttributesBuilderData(82 "capital_magic_sites", "Capital Magic Site {Ntn: #startsite}",83 "AttributeValue_GenericValue"84)85ATTRIBUTES_BUILDER_DATA[ 59 ] = _AttributesBuilderData(86 "unknown_values", "<Unknown Attribute>",87 "AttributeValue_GenericValue"88)89ATTRIBUTES_BUILDER_DATA[ 69 ] = _AttributesBuilderData(90 "unknown_values", "<Unknown Attribute>",91 "AttributeValue_GenericValue"92)93ATTRIBUTES_BUILDER_DATA[ 73 ] = _AttributesBuilderData(94 "unknown_values", "<Unknown Attribute>",95 "AttributeValue_GenericValue"96)97ATTRIBUTES_BUILDER_DATA[ 74 ] = _AttributesBuilderData(98 "unknown_values", "<Unknown Attribute>",99 "AttributeValue_GenericValue"100)101ATTRIBUTES_BUILDER_DATA[ 75 ] = _AttributesBuilderData(102 "unknown_values", "<Unknown Attribute>",103 "AttributeValue_GenericValue"104)105ATTRIBUTES_BUILDER_DATA[ 76 ] = _AttributesBuilderData(106 "unknown_values", "<Unknown Attribute>",107 "AttributeValue_GenericValue"108)109ATTRIBUTES_BUILDER_DATA[ 77 ] = _AttributesBuilderData(110 "unknown_values", "<Unknown Attribute>",111 "AttributeValue_GenericValue"112)113ATTRIBUTES_BUILDER_DATA[ 78 ] = _AttributesBuilderData(114 "unknown_values", "<Unknown Attribute>",115 "AttributeValue_GenericValue"116)117ATTRIBUTES_BUILDER_DATA[ 79 ] = _AttributesBuilderData(118 "unknown_values", "<Unknown Attribute>",119 "AttributeValue_GenericValue"120)121ATTRIBUTES_BUILDER_DATA[ 80 ] = _AttributesBuilderData(122 "unknown_values", "<Unknown Attribute>",123 "AttributeValue_GenericValue"124)125ATTRIBUTES_BUILDER_DATA[ 81 ] = _AttributesBuilderData(126 "unknown_values", "<Unknown Attribute>",127 "AttributeValue_GenericValue"128)129ATTRIBUTES_BUILDER_DATA[ 82 ] = _AttributesBuilderData(130 "unknown_values", "<Unknown Attribute>",131 "AttributeValue_GenericValue"132)133ATTRIBUTES_BUILDER_DATA[ 83 ] = _AttributesBuilderData(134 "unknown_values", "<Unknown Attribute>",135 "AttributeValue_GenericValue"136)137ATTRIBUTES_BUILDER_DATA[ 84 ] = _AttributesBuilderData(138 "unknown_values", "<Unknown Attribute>",139 "AttributeValue_GenericValue"140)141ATTRIBUTES_BUILDER_DATA[ 85 ] = _AttributesBuilderData(142 "unknown_values", "<Unknown Attribute>",143 "AttributeValue_GenericValue"144)145ATTRIBUTES_BUILDER_DATA[ 90 ] = _AttributesBuilderData(146 "unknown_values", "<Unknown Attribute>",147 "AttributeValue_GenericValue"148)149ATTRIBUTES_BUILDER_DATA[ 91 ] = _AttributesBuilderData(150 "unknown_values", "<Unknown Attribute>",151 "AttributeValue_GenericValue"152)153ATTRIBUTES_BUILDER_DATA[ 92 ] = _AttributesBuilderData(154 "unknown_values", "<Unknown Attribute>",155 "AttributeValue_GenericValue"156)157ATTRIBUTES_BUILDER_DATA[ 93 ] = _AttributesBuilderData(158 "unknown_values", "<Unknown Attribute>",159 "AttributeValue_GenericValue"160)161ATTRIBUTES_BUILDER_DATA[ 94 ] = _AttributesBuilderData(162 "unknown_values", "<Unknown Attribute>",163 "AttributeValue_GenericValue"164)165ATTRIBUTES_BUILDER_DATA[ 95 ] = _AttributesBuilderData(166 "unknown_values", "<Unknown Attribute>",167 "AttributeValue_GenericValue"168)169ATTRIBUTES_BUILDER_DATA[ 100 ] = _AttributesBuilderData(170 "capital_magic_sites",171 "Capital Magic Site (Unholy?) {Ntn: #startsite}",172 "AttributeValue_GenericValue"173)174ATTRIBUTES_BUILDER_DATA[ 122 ] = _AttributesBuilderData(175 "unknown_values", "<Unknown Attribute>",176 "AttributeValue_GenericValue"177)178ATTRIBUTES_BUILDER_DATA[ 123 ] = _AttributesBuilderData(179 "unknown_values", "<Unknown Attribute>",180 "AttributeValue_GenericValue"181)182ATTRIBUTES_BUILDER_DATA[ 124 ] = _AttributesBuilderData(183 "unknown_values", "<Unknown Attribute>",184 "AttributeValue_GenericValue"185)186ATTRIBUTES_BUILDER_DATA[ 125 ] = _AttributesBuilderData(187 "unknown_values", "<Unknown Attribute>",188 "AttributeValue_GenericValue"189)190ATTRIBUTES_BUILDER_DATA[ 126 ] = _AttributesBuilderData(191 "unknown_values", "<Unknown Attribute>",192 "AttributeValue_GenericValue"193)194ATTRIBUTES_BUILDER_DATA[ 127 ] = _AttributesBuilderData(195 "unknown_values", "<Unknown Attribute>",196 "AttributeValue_GenericValue"197)198ATTRIBUTES_BUILDER_DATA[ 131 ] = _AttributesBuilderData(199 "unknown_values", "<Unknown Attribute>",200 "AttributeValue_GenericValue"201)202ATTRIBUTES_BUILDER_DATA[ 132 ] = _AttributesBuilderData(203 "unknown_values", "<Unknown Attribute>",204 "AttributeValue_GenericValue"205)206ATTRIBUTES_BUILDER_DATA[ 133 ] = _AttributesBuilderData(207 "unknown_values", "<Unknown Attribute>",208 "AttributeValue_GenericValue"209)210ATTRIBUTES_BUILDER_DATA[ 134 ] = _AttributesBuilderData(211 "unknown_values", "<Unknown Attribute>",212 "AttributeValue_GenericValue"213)214ATTRIBUTES_BUILDER_DATA[ 136 ] = _AttributesBuilderData(215 "unknown_values", "<Unknown Attribute>",216 "AttributeValue_GenericValue"217)218ATTRIBUTES_BUILDER_DATA[ 137 ] = _AttributesBuilderData(219 "unknown_values", "<Unknown Attribute>",220 "AttributeValue_GenericValue"221)222ATTRIBUTES_BUILDER_DATA[ 138 ] = _AttributesBuilderData(223 "unknown_values", "<Unknown Attribute>",224 "AttributeValue_GenericValue"225)226ATTRIBUTES_BUILDER_DATA[ 139 ] = _AttributesBuilderData(227 "unique_heroes", "National Unique Hero {Ntn: #hero1}",228 "AttributeValue_Monster"229)230ATTRIBUTES_BUILDER_DATA[ 140 ] = _AttributesBuilderData(231 "unique_heroes", "National Unique Hero {Ntn: #hero2}",232 "AttributeValue_Monster"233)234ATTRIBUTES_BUILDER_DATA[ 141 ] = _AttributesBuilderData(235 "unique_heroes", "National Unique Hero {Ntn: #hero3}",236 "AttributeValue_Monster"237)238ATTRIBUTES_BUILDER_DATA[ 142 ] = _AttributesBuilderData(239 "unique_heroes", "National Unique Hero {Ntn: #hero4}",240 "AttributeValue_Monster"241)242ATTRIBUTES_BUILDER_DATA[ 143 ] = _AttributesBuilderData(243 "unique_heroes", "National Unique Hero {Ntn: #hero5}",244 "AttributeValue_Monster"245)246ATTRIBUTES_BUILDER_DATA[ 144 ] = _AttributesBuilderData(247 "unique_heroes", "National Unique Hero {Ntn: #hero6}",248 "AttributeValue_Monster"249)250ATTRIBUTES_BUILDER_DATA[ 145 ] = _AttributesBuilderData(251 "generic_heroes", "National Generic Hero {Ntn: #multihero1}",252 "AttributeValue_Monster"253)254ATTRIBUTES_BUILDER_DATA[ 146 ] = _AttributesBuilderData(255 "generic_heroes", "National Generic Hero {Ntn: #multihero2}",256 "AttributeValue_Monster"257)258ATTRIBUTES_BUILDER_DATA[ 156 ] = _AttributesBuilderData(259 "unknown_values", "<Unknown Attribute>",260 "AttributeValue_GenericValue"261)262ATTRIBUTES_BUILDER_DATA[ 157 ] = _AttributesBuilderData(263 "unknown_values", "<Unknown Attribute>",264 "AttributeValue_GenericValue"265)266ATTRIBUTES_BUILDER_DATA[ 158 ] = _AttributesBuilderData(267 "recruitable_units", "Coastal Fort Commander {Ntn: #coastcom1}",268 "AttributeValue_Monster"269)270ATTRIBUTES_BUILDER_DATA[ 159 ] = _AttributesBuilderData(271 "recruitable_units", "Coastal Fort Commander {Ntn: #coastcom2}",272 "AttributeValue_Monster"273)274ATTRIBUTES_BUILDER_DATA[ 160 ] = _AttributesBuilderData(275 "recruitable_units", "Coastal Fort Troop {Ntn: #coastunit1}",276 "AttributeValue_Monster"277)278ATTRIBUTES_BUILDER_DATA[ 161 ] = _AttributesBuilderData(279 "recruitable_units", "Coastal Fort Troop {Ntn: #coastunit2}",280 "AttributeValue_Monster"281)282ATTRIBUTES_BUILDER_DATA[ 162 ] = _AttributesBuilderData(283 "recruitable_units", "Coastal Fort Troop {Ntn: #coastunit3}",284 "AttributeValue_Monster"285)286ATTRIBUTES_BUILDER_DATA[ 163 ] = _AttributesBuilderData(287 "unknown_values", "<Unknown Attribute>",288 "AttributeValue_GenericValue"289)290ATTRIBUTES_BUILDER_DATA[ 167 ] = _AttributesBuilderData(291 "unknown_values", "<Unknown Attribute>",292 "AttributeValue_GenericValue"293)294ATTRIBUTES_BUILDER_DATA[ 168 ] = _AttributesBuilderData(295 "unknown_values", "<Unknown Attribute>",296 "AttributeValue_GenericValue"297)298ATTRIBUTES_BUILDER_DATA[ 169 ] = _AttributesBuilderData(299 "unknown_values", "<Unknown Attribute>",300 "AttributeValue_GenericValue"301)302ATTRIBUTES_BUILDER_DATA[ 170 ] = _AttributesBuilderData(303 "unknown_values", "<Unknown Attribute>",304 "AttributeValue_GenericValue"305)306ATTRIBUTES_BUILDER_DATA[ 171 ] = _AttributesBuilderData(307 "unknown_values", "<Unknown Attribute>",308 "AttributeValue_GenericValue"309)310ATTRIBUTES_BUILDER_DATA[ 172 ] = _AttributesBuilderData(311 "unknown_values", "<Unknown Attribute>",312 "AttributeValue_GenericValue"313)314ATTRIBUTES_BUILDER_DATA[ 173 ] = _AttributesBuilderData(315 "unknown_values", "<Unknown Attribute>",316 "AttributeValue_GenericValue"317)318ATTRIBUTES_BUILDER_DATA[ 174 ] = _AttributesBuilderData(319 "unknown_values", "<Unknown Attribute>",320 "AttributeValue_GenericValue"321)322ATTRIBUTES_BUILDER_DATA[ 175 ] = _AttributesBuilderData(323 "unknown_values", "<Unknown Attribute>",324 "AttributeValue_GenericValue"325)326ATTRIBUTES_BUILDER_DATA[ 176 ] = _AttributesBuilderData(327 "unknown_values", "<Unknown Attribute>",328 "AttributeValue_GenericValue"329)330ATTRIBUTES_BUILDER_DATA[ 177 ] = _AttributesBuilderData(331 "unknown_values", "<Unknown Attribute>",332 "AttributeValue_GenericValue"333)334ATTRIBUTES_BUILDER_DATA[ 178 ] = _AttributesBuilderData(335 "unknown_values", "<Unknown Attribute>",336 "AttributeValue_GenericValue"337)338ATTRIBUTES_BUILDER_DATA[ 179 ] = _AttributesBuilderData(339 "unknown_values", "<Unknown Attribute>",340 "AttributeValue_GenericValue"341)342ATTRIBUTES_BUILDER_DATA[ 180 ] = _AttributesBuilderData(343 "unknown_values", "<Unknown Attribute>",344 "AttributeValue_GenericValue"345)346ATTRIBUTES_BUILDER_DATA[ 185 ] = _AttributesBuilderData(347 "unknown_values", "<Unknown Attribute>",348 "AttributeValue_GenericValue"349)350ATTRIBUTES_BUILDER_DATA[ 186 ] = _AttributesBuilderData(351 "unknown_values", "<Unknown Attribute>",352 "AttributeValue_GenericValue"353)354ATTRIBUTES_BUILDER_DATA[ 187 ] = _AttributesBuilderData(355 "unknown_values", "<Unknown Attribute>",356 "AttributeValue_GenericValue"357)358ATTRIBUTES_BUILDER_DATA[ 188 ] = _AttributesBuilderData(359 "unknown_values", "<Unknown Attribute>",360 "AttributeValue_GenericValue"361)362ATTRIBUTES_BUILDER_DATA[ 189 ] = _AttributesBuilderData(363 "unknown_values", "<Unknown Attribute>",364 "AttributeValue_GenericValue"365)366ATTRIBUTES_BUILDER_DATA[ 190 ] = _AttributesBuilderData(367 "unknown_values", "<Unknown Attribute>",368 "AttributeValue_GenericValue"369)370ATTRIBUTES_BUILDER_DATA[ 191 ] = _AttributesBuilderData(371 "unknown_values", "<Unknown Attribute>",372 "AttributeValue_GenericValue"373)374ATTRIBUTES_BUILDER_DATA[ 193 ] = _AttributesBuilderData(375 "unknown_values", "<Unknown Attribute>",376 "AttributeValue_GenericValue"377)378ATTRIBUTES_BUILDER_DATA[ 194 ] = _AttributesBuilderData(379 "unknown_values", "<Unknown Attribute>",380 "AttributeValue_GenericValue"381)382ATTRIBUTES_BUILDER_DATA[ 195 ] = _AttributesBuilderData(383 "unknown_values", "<Unknown Attribute>",384 "AttributeValue_GenericValue"385)386ATTRIBUTES_BUILDER_DATA[ 196 ] = _AttributesBuilderData(387 "unknown_values", "<Unknown Attribute>",388 "AttributeValue_GenericValue"389)390ATTRIBUTES_BUILDER_DATA[ 197 ] = _AttributesBuilderData(391 "unknown_values", "<Unknown Attribute>",392 "AttributeValue_GenericValue"393)394ATTRIBUTES_BUILDER_DATA[ 198 ] = _AttributesBuilderData(395 "unknown_values", "<Unknown Attribute>",396 "AttributeValue_GenericValue"397)398ATTRIBUTES_BUILDER_DATA[ 199 ] = _AttributesBuilderData(399 "unknown_values", "<Unknown Attribute>",400 "AttributeValue_GenericValue"401)402ATTRIBUTES_BUILDER_DATA[ 200 ] = _AttributesBuilderData(403 "unknown_values", "<Unknown Attribute>",404 "AttributeValue_GenericValue"405)406ATTRIBUTES_BUILDER_DATA[ 205 ] = _AttributesBuilderData(407 "unknown_values", "<Unknown Attribute>",408 "AttributeValue_GenericValue"409)410ATTRIBUTES_BUILDER_DATA[ 207 ] = _AttributesBuilderData(411 "unknown_values", "<Unknown Attribute>",412 "AttributeValue_GenericValue"413)414ATTRIBUTES_BUILDER_DATA[ 210 ] = _AttributesBuilderData(415 "unknown_values", "<Unknown Attribute>",416 "AttributeValue_GenericValue"417)418ATTRIBUTES_BUILDER_DATA[ 211 ] = _AttributesBuilderData(419 "unknown_values", "<Unknown Attribute>",420 "AttributeValue_GenericValue"421)422ATTRIBUTES_BUILDER_DATA[ 213 ] = _AttributesBuilderData(423 "unknown_values", "<Unknown Attribute>",424 "AttributeValue_GenericValue"425)426ATTRIBUTES_BUILDER_DATA[ 217 ] = _AttributesBuilderData(427 "unknown_values", "<Unknown Attribute>",428 "AttributeValue_GenericValue"429)430ATTRIBUTES_BUILDER_DATA[ 220 ] = _AttributesBuilderData(431 "unknown_values", "<Unknown Attribute>",432 "AttributeValue_GenericValue"433)434ATTRIBUTES_BUILDER_DATA[ 221 ] = _AttributesBuilderData(435 "unknown_values", "<Unknown Attribute>",436 "AttributeValue_GenericValue"437)438ATTRIBUTES_BUILDER_DATA[ 222 ] = _AttributesBuilderData(439 "unknown_values", "<Unknown Attribute>",440 "AttributeValue_GenericValue"441)442ATTRIBUTES_BUILDER_DATA[ 223 ] = _AttributesBuilderData(443 "unknown_values", "<Unknown Attribute>",444 "AttributeValue_GenericValue"445)446ATTRIBUTES_BUILDER_DATA[ 261 ] = _AttributesBuilderData(447 "unknown_values", "<Unknown Attribute>",448 "AttributeValue_GenericValue"449)450ATTRIBUTES_BUILDER_DATA[ 263 ] = _AttributesBuilderData(451 "unknown_values", "<Unknown Attribute>",452 "AttributeValue_GenericValue"453)454ATTRIBUTES_BUILDER_DATA[ 264 ] = _AttributesBuilderData(455 "unknown_values", "<Unknown Attribute>",456 "AttributeValue_GenericValue"457)458ATTRIBUTES_BUILDER_DATA[ 265 ] = _AttributesBuilderData(459 "unknown_values", "<Unknown Attribute>",460 "AttributeValue_GenericValue"461)462ATTRIBUTES_BUILDER_DATA[ 266 ] = _AttributesBuilderData(463 "boolean_values", "Material Composition: Ferrous",464 "AttributeValue_Boolean"465)466ATTRIBUTES_BUILDER_DATA[ 267 ] = _AttributesBuilderData(467 "boolean_values", "Material Composition: Ferrous",468 "AttributeValue_Boolean"469)470ATTRIBUTES_BUILDER_DATA[ 268 ] = _AttributesBuilderData(471 "boolean_values", "Material Composition: Flammable",472 "AttributeValue_Boolean"473)474ATTRIBUTES_BUILDER_DATA[ 269 ] = _AttributesBuilderData(475 "boolean_values", "Material Composition: Flammable",476 "AttributeValue_Boolean"477)478ATTRIBUTES_BUILDER_DATA[ 270 ] = _AttributesBuilderData(479 "unknown_values", "<Unknown Attribute>",480 "AttributeValue_GenericValue"481)482ATTRIBUTES_BUILDER_DATA[ 271 ] = _AttributesBuilderData(483 "unknown_values", "<Unknown Attribute>",484 "AttributeValue_GenericValue"485)486ATTRIBUTES_BUILDER_DATA[ 272 ] = _AttributesBuilderData(487 "unknown_values", "<Unknown Attribute>",488 "AttributeValue_GenericValue"489)490ATTRIBUTES_BUILDER_DATA[ 273 ] = _AttributesBuilderData(491 "unknown_values", "<Unknown Attribute>",492 "AttributeValue_GenericValue"493)494ATTRIBUTES_BUILDER_DATA[ 274 ] = _AttributesBuilderData(495 "unknown_values", "<Unknown Attribute>",496 "AttributeValue_GenericValue"497)498ATTRIBUTES_BUILDER_DATA[ 275 ] = _AttributesBuilderData(499 "unknown_values", "<Unknown Attribute>",500 "AttributeValue_GenericValue"501)502ATTRIBUTES_BUILDER_DATA[ 278 ] = _AttributesBuilderData(503 "restrict_to_nations", "Restrict to Nation {Spl: #restricted}",504 "AttributeValue_Nation"505)506ATTRIBUTES_BUILDER_DATA[ 279 ] = _AttributesBuilderData(507 "unknown_values", "<Unknown Attribute>",508 "AttributeValue_GenericValue"509)510ATTRIBUTES_BUILDER_DATA[ 280 ] = _AttributesBuilderData(511 "unknown_values", "<Unknown Attribute>",512 "AttributeValue_GenericValue"513)514ATTRIBUTES_BUILDER_DATA[ 287 ] = _AttributesBuilderData(515 "unknown_values", "<Unknown Attribute>",516 "AttributeValue_GenericValue"517)518ATTRIBUTES_BUILDER_DATA[ 288 ] = _AttributesBuilderData(519 "unknown_values", "<Unknown Attribute>",520 "AttributeValue_GenericValue"521)522ATTRIBUTES_BUILDER_DATA[ 289 ] = _AttributesBuilderData(523 "unknown_values", "<Unknown Attribute>",524 "AttributeValue_GenericValue"525)526ATTRIBUTES_BUILDER_DATA[ 290 ] = _AttributesBuilderData(527 "unknown_values", "<Unknown Attribute>",528 "AttributeValue_GenericValue"529)530ATTRIBUTES_BUILDER_DATA[ 293 ] = _AttributesBuilderData(531 "unknown_values", "<Unknown Attribute>",532 "AttributeValue_GenericValue"533)534ATTRIBUTES_BUILDER_DATA[ 294 ] = _AttributesBuilderData(535 "unknown_values", "<Unknown Attribute>",536 "AttributeValue_GenericValue"537)538ATTRIBUTES_BUILDER_DATA[ 295 ] = _AttributesBuilderData(539 "unknown_values", "<Unknown Attribute>",540 "AttributeValue_GenericValue"541)542ATTRIBUTES_BUILDER_DATA[ 296 ] = _AttributesBuilderData(543 "unknown_values", "<Unknown Attribute>",544 "AttributeValue_GenericValue"545)546ATTRIBUTES_BUILDER_DATA[ 297 ] = _AttributesBuilderData(547 "unknown_values", "<Unknown Attribute>",548 "AttributeValue_GenericValue"549)550ATTRIBUTES_BUILDER_DATA[ 298 ] = _AttributesBuilderData(551 "unknown_values", "<Unknown Attribute>",552 "AttributeValue_GenericValue"553)554ATTRIBUTES_BUILDER_DATA[ 299 ] = _AttributesBuilderData(555 "unknown_values", "<Unknown Attribute>",556 "AttributeValue_GenericValue"557)558ATTRIBUTES_BUILDER_DATA[ 300 ] = _AttributesBuilderData(559 "unknown_values", "<Unknown Attribute>",560 "AttributeValue_GenericValue"561)562ATTRIBUTES_BUILDER_DATA[ 302 ] = _AttributesBuilderData(563 "unknown_values", "<Unknown Attribute>",564 "AttributeValue_GenericValue"565)566ATTRIBUTES_BUILDER_DATA[ 303 ] = _AttributesBuilderData(567 "unknown_values", "<Unknown Attribute>",568 "AttributeValue_GenericValue"569)570ATTRIBUTES_BUILDER_DATA[ 304 ] = _AttributesBuilderData(571 "unknown_values", "<Unknown Attribute>",572 "AttributeValue_GenericValue"573)574ATTRIBUTES_BUILDER_DATA[ 305 ] = _AttributesBuilderData(575 "unknown_values", "<Unknown Attribute>",576 "AttributeValue_GenericValue"577)578ATTRIBUTES_BUILDER_DATA[ 306 ] = _AttributesBuilderData(579 "unknown_values", "<Unknown Attribute>",580 "AttributeValue_GenericValue"581)582ATTRIBUTES_BUILDER_DATA[ 404 ] = _AttributesBuilderData(583 "unknown_values", "<Unknown Attribute>",584 "AttributeValue_GenericValue"585)586ATTRIBUTES_BUILDER_DATA[ 426 ] = _AttributesBuilderData(587 "unknown_values", "<Unknown Attribute>",588 "AttributeValue_GenericValue"589)590ATTRIBUTES_BUILDER_DATA[ 477 ] = _AttributesBuilderData(591 "unknown_values", "<Unknown Attribute>",592 "AttributeValue_GenericValue"593)594ATTRIBUTES_BUILDER_DATA[ 700 ] = _AttributesBuilderData(595 "map_ranges", "Map Range {Spl: #provrange}",596 "AttributeValue_GenericValue"597)598ATTRIBUTES_BUILDER_DATA[ 701 ] = _AttributesBuilderData(599 "map_terrain_types", "<Unknown Attribute>",600 "AttributeValue_MapTerrainType"601)602ATTRIBUTES_BUILDER_DATA[ 702 ] = _AttributesBuilderData(603 "map_terrain_types", "Source Terrain (?) {Spl: #onlygeosrc}",604 "AttributeValue_MapTerrainType"605)606ATTRIBUTES_BUILDER_DATA[ 703 ] = _AttributesBuilderData(607 "boolean_values", "Only Target Own Provinces (?) {Spl: #onlyowndst}",608 "AttributeValue_Boolean"609)610ATTRIBUTES_BUILDER_DATA[ 704 ] = _AttributesBuilderData(611 "unknown_values", "<Unknown Attribute>",612 "AttributeValue_GenericValue"613)614ATTRIBUTES_BUILDER_DATA[ 705 ] = _AttributesBuilderData(615 "unknown_values", "<Unknown Attribute>",616 "AttributeValue_GenericValue"617)618ATTRIBUTES_BUILDER_DATA[ 706 ] = _AttributesBuilderData(619 "boolean_values", "No Path over Land (?) {Spl: #nolandtrace}",620 "AttributeValue_Boolean"621)622ATTRIBUTES_BUILDER_DATA[ 707 ] = _AttributesBuilderData(623 "unknown_values", "<Unknown Attribute>",624 "AttributeValue_GenericValue"625)626ATTRIBUTES_BUILDER_DATA[ 708 ] = _AttributesBuilderData(627 "unknown_values", "<Unknown Attribute>",628 "AttributeValue_GenericValue"629)630ATTRIBUTES_BUILDER_DATA[ 709 ] = _AttributesBuilderData(631 "unknown_values", "<Unknown Attribute>",632 "AttributeValue_GenericValue"633)634ATTRIBUTES_BUILDER_DATA[ 711 ] = _AttributesBuilderData(635 "unknown_values", "<Unknown Attribute>",636 "AttributeValue_GenericValue"637)638class Attribute( _DataTableRow ):639 """ An attribute of a Dominions object. """640 __tablename__ = "attributes"641 record_id = _SQLA_Column(642 _SQLA_Integer, primary_key = True, autoincrement = "ignore_fk"643 )644 attribute_number = _SQLA_Column(645 _SQLA_Integer,646 _SQLA_ForeignKey(647 AttributeKey.TABLE_NAME( ) + "." + AttributeKey.KEY_NAME( )648 )649 )650 object_type = _SQLA_Column( _SQLA_String )651 raw_value = _SQLA_Column( _SQLA_Integer )652 _KEY_NAME = "record_id"653 @classmethod654 def __declare_last__( cls ):655 # Perform late binding against abstract concrete bases.656 cls.value = _SQLA_relationship( AttributeValue, uselist = False )657 @classmethod658 def from_raw_data( cls, attribute_number, object_type, raw_value ):659 """ Creates an instance from a set of raw arguments. """660 args = {661 "attribute_number": attribute_number,662 "object_type": object_type,663 "raw_value": raw_value,664 }665 self = cls( **args )666 self.value = eval(667 "Attribute{attribute_number}Value.from_raw_value".format(668 attribute_number = args[ "attribute_number" ]669 )670 )(671 attribute_record_id = self.record_id,672 attribute_number = attribute_number,673 raw_value = raw_value674 )675 return self676 def pformat_object( self,677 tables, pformat_config = _PrettyFormatConfig( )678 ):679 """ Nicely formats the object for display. """680 return self.value.pformat_object(681 tables, pformat_config = pformat_config682 )683class Attribute_ForeignKey( _DataTableRow ):684 """ Abstraction for attribute record ID as a foreign key. """685 __abstract__ = True686 @_SQLA_declared_attr687 def attribute_record_id( cls ):688 return _SQLA_Column(689 _SQLA_Integer,690 _SQLA_ForeignKey(691 Attribute.TABLE_NAME( ) + "." + Attribute.KEY_NAME( )692 ),693 primary_key = True694 )695 _KEY_NAME = "attribute_record_id"696 _KEY_FORMAT = "d"697class AttributeValue_BASE( _DataTableRow ):698 """ A value of an attribute. """699 __abstract__ = True700 @classmethod701 def generated_SQLA_Table( cls, value_table_name ):702 """ Returns a SQLAlchemy table to be mapped to an object. """703 return _SQLA_Table(704 value_table_name + "_by_attribute", cls.metadata, 705 _SQLA_Column( "record_id", _SQLA_Integer, primary_key = True ),706 _SQLA_Column(707 "attribute_record_id", _SQLA_Integer,708 _SQLA_ForeignKey(709 Attribute.TABLE_NAME( ) + "." + Attribute.KEY_NAME( )710 )711 ),712 _SQLA_Column(713 "attribute_number", _SQLA_Integer,714 _SQLA_ForeignKey(715 AttributeKey.TABLE_NAME( ) + "." + AttributeKey.KEY_NAME( )716 )717 ),718 *cls._generated_SQLA_Table_columns( ),719 keep_existing = True720 )721 @classmethod722 def _generated_SQLA_Table_columns( cls ):723 """ Returns additional SQLAlchemy columns for a table mapping. """724 return [ ]725 @classmethod726 def generated_SQLA_Mapper_arguments( cls, attribute_number ):727 """ Returns additional arguments for the SQLAlchemy mapper. """728 return { }729 @classmethod730 def from_raw_value( cls,731 attribute_record_id, attribute_number, raw_value732 ):733 """ Creates an instance from a raw value.734 (Dummy implementation - override.) """735 return cls(736 attribute_record_id = attribute_record_id,737 attribute_number = attribute_number738 )739 def pformat_object( self,740 tables, pformat_config = _PrettyFormatConfig( )741 ):742 """ Nicely formats the object for display. """743 template = pformat_config.indent744 args = { }745 if pformat_config.render_title:746 template += "{title}"747 args[ "title" ] = self.TITLE( )748 if pformat_config.render_key_with_object:749 template += " [{attribute_number}]: "750 args[ "attribute_number" ] = self.attribute_number751 else:752 template += ": "753 else:754 if pformat_config.render_key_with_object:755 template += "{attribute_number}"756 args[ "attribute_number" ] = self.attribute_number757 template += "{value}"758 args[ "value" ] = self._pformat_object(759 tables, pformat_config = pformat_config760 )761 return template.format( **args )762class AttributeValue_Boolean( AttributeValue_BASE ):763 """ A value of an attribute. """764 __abstract__ = True765 @classmethod766 def _generated_SQLA_Table_columns( cls ):767 """ Returns additional SQLAlchemy columns for a table mapping. """768 return [769 _SQLA_Column( "value", _SQLA_Integer ) 770 ]771 @classmethod772 def from_raw_value( cls,773 attribute_record_id, attribute_number, raw_value774 ):775 """ Creates an instance from a raw value. """776 args = {777 "attribute_record_id": attribute_record_id,778 "attribute_number": attribute_number,779 "value": raw_value780 }781 return cls( **args )782 def pformat_object( self,783 tables, pformat_config = _PrettyFormatConfig( )784 ):785 """ Nicely formats the object for display. """786 template = pformat_config.indent787 args = { }788 if pformat_config.render_title:789 template += "{title}"790 args[ "title" ] = self.TITLE( )791 if pformat_config.render_key_with_object:792 template += " [{attribute_number}]"793 args[ "attribute_number" ] = self.attribute_number794 else:795 if pformat_config.render_key_with_object:796 template += "{attribute_number}"797 args[ "attribute_number" ] = self.attribute_number798 return template.format( **args )799class AttributeValue_GenericValue( AttributeValue_BASE ):800 """ A value of an attribute. """801 __abstract__ = True802 @classmethod803 def _generated_SQLA_Table_columns( cls ):804 """ Returns additional SQLAlchemy columns for a table mapping. """805 return [806 _SQLA_Column( "value", _SQLA_Integer ) 807 ]808 @classmethod809 def from_raw_value( cls,810 attribute_record_id, attribute_number, raw_value811 ):812 """ Creates an instance from a raw value. """813 args = {814 "attribute_record_id": attribute_record_id,815 "attribute_number": attribute_number,816 "value": raw_value817 }818 return cls( **args )819 def _pformat_object( self,820 tables, pformat_config = _PrettyFormatConfig( )821 ):822 """ Nicely formats the object for display. """823 return self.value824class AttributeValue_Nation( AttributeValue_BASE ):825 """ A value of an attribute. """826 __abstract__ = True827 @classmethod828 def _generated_SQLA_Table_columns( cls ):829 """ Returns additional SQLAlchemy columns for a table mapping. """830 # TODO: Add foreign key against nations table.831 return [832 _SQLA_Column( "nation_number", _SQLA_Integer ) 833 ]834 @classmethod835 def from_raw_value( cls,836 attribute_record_id, attribute_number, raw_value837 ):838 """ Creates an instance from a raw value. """839 args = {840 "attribute_record_id": attribute_record_id,841 "attribute_number": attribute_number842 }843 args[ "nation_number" ] = raw_value - 100844 return cls( **args )845 def _pformat_object( self,846 tables, pformat_config = _PrettyFormatConfig( )847 ):848 """ Nicely formats the object for display. """849 # TODO: Lookup nation name from nations table.850 return self.nation_number851class AttributeValue_Monster( AttributeValue_BASE ):852 """ A value of an attribute. """853 __abstract__ = True854 @classmethod855 def _generated_SQLA_Table_columns( cls ):856 """ Returns additional SQLAlchemy columns for a table mapping. """857 # TODO: Add foreign key against monster table.858 return [859 _SQLA_Column( "monster_number", _SQLA_Integer ) 860 ]861 @classmethod862 def from_raw_value( cls,863 attribute_record_id, attribute_number, raw_value864 ):865 """ Creates an instance from a raw value. """866 args = {867 "attribute_record_id": attribute_record_id,868 "attribute_number": attribute_number869 }870 args[ "monster_number" ] = raw_value871 return cls( **args )872 def _pformat_object( self,873 tables, pformat_config = _PrettyFormatConfig( )874 ):875 """ Nicely formats the object for display. """876 # TODO: Lookup monster name from monsters table.877 return self.monster_number878_BitmaskAssociationTableBuilderData \879= _namedtuple(880 "BitmaskAssociationTableBuilderData",881 "class_name_base table_name_base key_name title_base"882)883for _builder_data in [884 _BitmaskAssociationTableBuilderData(885 "MapTerrainType", "map_terrain_types", "terrain_type",886 "Terrain Type"887 ),888]:889 exec( """890class Attribute{class_name_base}_ASSOCIATE( _DataTableRow ):891 ''' A bitmaskable type associated with an attribute. '''892 __tablename__ = "{table_name_base}_for_attributes"893 _TITLE = "{title_base}"894 _KEY_NAME = "{key_name}"895 _KEY_FORMAT = "d"896 attribute_value_record_id = _SQLA_Column(897 _SQLA_Integer,898 _SQLA_ForeignKey( "{table_name_base}_by_attribute.record_id" ),899 primary_key = True900 )901 {key_name} = _SQLA_Column(902 _SQLA_Integer,903 _SQLA_ForeignKey(904 {class_name_base}.TABLE_NAME( )905 + "." + {class_name_base}.KEY_NAME( )906 ),907 primary_key = True908 )909 def pformat_object( self,910 tables, pformat_config = _PrettyFormatConfig( )911 ):912 ''' Nicely formats the object for display. '''913 return \\914 tables[ {class_name_base}s_DataTable.LABEL( ) ]\\915 .pformat_table_lookup(916 self.{key_name}, tables, pformat_config = pformat_config917 )918class AttributeValue_{class_name_base}( AttributeValue_BASE ):919 ''' A value of an attribute. '''920 __abstract__ = True921 @_SQLA_declared_attr922 def {key_name}s( cls ):923 return _SQLA_relationship( Attribute{class_name_base}_ASSOCIATE )924 @classmethod925 def from_raw_value( cls,926 attribute_record_id, attribute_number, raw_value927 ):928 ''' Creates an instance from a raw value. '''929 args = {{930 "attribute_record_id": attribute_record_id,931 "attribute_number": attribute_number932 }}933 self = cls( **args )934 {key_name}s = [ ]935 for bit_position in range( 64 ):936 bit_value = 2 ** bit_position937 if raw_value & bit_value:938 {key_name}s.append( Attribute{class_name_base}_ASSOCIATE(939 {key_name} = bit_value940 ) )941 self.{key_name}s = {key_name}s942 return self943 def _pformat_object( self,944 tables, pformat_config = _PrettyFormatConfig( )945 ):946 ''' Nicely formats the object for display. '''947 pformat_config_1 = pformat_config.clone(948 indent = pformat_config.indent + 4 * " ", render_title = False949 )950 template = "\\n{{{key_name}s}}"951 args = {{ }}952 args[ "{key_name}s" ] = "\\n".join( [953 {key_name}.pformat_object(954 tables, pformat_config = pformat_config_1955 )956 for {key_name} in self.{key_name}s957 ] )958 return template.format( **args )959 """.format( **vars( _builder_data ) ) )960_attribute_tables_polymorphic_map = { }961for _attribute_number, _builder_data in ATTRIBUTES_BUILDER_DATA.items( ):962 exec( """963_attribute_tables_polymorphic_map[ {attribute_number} ] \\964= {value_mixin_class_name}.generated_SQLA_Table( "{value_table_name}" )965 """.format(966 attribute_number = _attribute_number,967 **vars( _builder_data )968 ) )969_attribute_tables_polymorphic_union = _SQLA_polymorphic_union(970 _attribute_tables_polymorphic_map, "attribute_number_VIRTUAL",971 aliasname = "attribute_union"972)973class AttributeValue( _DataTableRow ):974 """ A value of an attribute. """975 _punion = _attribute_tables_polymorphic_union976 __table__ = _punion977 __mapper_args__ = { "polymorphic_on": _punion.c.attribute_number_VIRTUAL }978for _attribute_number, _builder_data in ATTRIBUTES_BUILDER_DATA.items( ):979 exec( """980class Attribute{attribute_number}Value(981 AttributeValue, {value_mixin_class_name}982):983 ''' A value of an attribute. '''984 __table__ = _attribute_tables_polymorphic_map[ {attribute_number} ]985 __mapper_args__ = {{986 "polymorphic_identity": {attribute_number},987 "concrete": True988 }}989 __mapper_args__.update(990 {value_mixin_class_name}.generated_SQLA_Mapper_arguments(991 {attribute_number}992 )993 )994 _TITLE = "{value_title}"995 """.format(996 attribute_number = _attribute_number,997 **vars( _builder_data )998 ) )999###############################################################################...
v8_attributes.py
Source:v8_attributes.py
...89 'argument_cpp_type': idl_type.cpp_type_args(used_as_rvalue_type=True),90 'cached_attribute_validation_method': cached_attribute_validation_method,91 'conditional_string': v8_utilities.conditional_string(attribute),92 'constructor_type': idl_type.constructor_type_name93 if is_constructor_attribute(attribute) else None,94 'cpp_name': cpp_name(attribute),95 'cpp_type': idl_type.cpp_type,96 'cpp_type_initializer': idl_type.cpp_type_initializer,97 'deprecate_as': v8_utilities.deprecate_as(attribute), # [DeprecateAs]98 'enum_type': idl_type.enum_type,99 'enum_values': idl_type.enum_values,100 'exposed_test': v8_utilities.exposed(attribute, interface), # [Exposed]101 'has_custom_getter': has_custom_getter(attribute),102 'has_custom_setter': has_custom_setter(attribute),103 'has_setter': has_setter(attribute),104 'idl_type': str(idl_type), # need trailing [] on array for Dictionary::ConversionContext::setConversionType105 'is_call_with_execution_context': has_extended_attribute_value(attribute, 'CallWith', 'ExecutionContext'),106 'is_call_with_script_state': has_extended_attribute_value(attribute, 'CallWith', 'ScriptState'),107 'is_check_security_for_frame': is_check_security_for_frame,108 'is_check_security_for_node': is_check_security_for_node,109 'is_check_security_for_window': is_check_security_for_window,110 'is_custom_element_callbacks': is_custom_element_callbacks,111 'is_expose_js_accessors': is_expose_js_accessors(interface, attribute),112 'is_getter_raises_exception': # [RaisesException]113 'RaisesException' in extended_attributes and114 extended_attributes['RaisesException'] in (None, 'Getter'),115 'is_implemented_in_private_script': is_implemented_in_private_script,116 'is_keep_alive_for_gc': keep_alive_for_gc,117 'is_lenient_this': 'LenientThis' in extended_attributes,118 'is_nullable': idl_type.is_nullable,119 'is_explicit_nullable': idl_type.is_explicit_nullable,120 'is_partial_interface_member':121 'PartialInterfaceImplementedAs' in extended_attributes,122 'is_per_world_bindings': 'PerWorldBindings' in extended_attributes,123 'is_put_forwards': 'PutForwards' in extended_attributes,124 'is_read_only': attribute.is_read_only,125 'is_reflect': is_reflect,126 'is_replaceable': 'Replaceable' in attribute.extended_attributes,127 'is_static': attribute.is_static,128 'is_url': 'URL' in extended_attributes,129 'is_unforgeable': is_unforgeable(interface, attribute),130 'on_instance': v8_utilities.on_instance(interface, attribute),131 'on_interface': v8_utilities.on_interface(interface, attribute),132 'on_prototype': v8_utilities.on_prototype(interface, attribute),133 'use_output_parameter_for_result': idl_type.use_output_parameter_for_result,134 'measure_as': v8_utilities.measure_as(attribute, interface), # [MeasureAs]135 'name': attribute.name,136 'only_exposed_to_private_script': is_only_exposed_to_private_script,137 'private_script_v8_value_to_local_cpp_value': idl_type.v8_value_to_local_cpp_value(138 extended_attributes, 'v8Value', 'cppValue', bailout_return_value='false', isolate='scriptState->isolate()'),139 'property_attributes': property_attributes(interface, attribute),140 'reflect_empty': extended_attributes.get('ReflectEmpty'),141 'reflect_invalid': extended_attributes.get('ReflectInvalid', ''),142 'reflect_missing': extended_attributes.get('ReflectMissing'),143 'reflect_only': extended_attribute_value_as_list(attribute, 'ReflectOnly'),144 'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(attribute), # [RuntimeEnabled]145 'should_be_exposed_to_script': not (is_implemented_in_private_script and is_only_exposed_to_private_script),146 'world_suffixes': ['', 'ForMainWorld']147 if 'PerWorldBindings' in extended_attributes148 else [''], # [PerWorldBindings]149 }150 if is_constructor_attribute(attribute):151 update_constructor_attribute_context(interface, attribute, context)152 if not has_custom_getter(attribute):153 getter_context(interface, attribute, context)154 if not has_custom_setter(attribute) and has_setter(attribute):155 setter_context(interface, attribute, context)156 return context157################################################################################158# Getter159################################################################################160def getter_context(interface, attribute, context):161 idl_type = attribute.idl_type162 base_idl_type = idl_type.base_type163 extended_attributes = attribute.extended_attributes164 cpp_value = getter_expression(interface, attribute, context)165 # Normally we can inline the function call into the return statement to166 # avoid the overhead of using a Ref<> temporary, but for some cases167 # (nullable types, EventHandler, [CachedAttribute], or if there are168 # exceptions), we need to use a local variable.169 # FIXME: check if compilers are smart enough to inline this, and if so,170 # always use a local variable (for readability and CG simplicity).171 release = False172 if 'ImplementedInPrivateScript' in extended_attributes:173 if (not idl_type.is_wrapper_type and174 not idl_type.is_basic_type and175 not idl_type.is_enum):176 raise Exception('Private scripts supports only primitive types and DOM wrappers.')177 context['cpp_value_original'] = cpp_value178 cpp_value = 'result'179 # EventHandler has special handling180 if base_idl_type != 'EventHandler':181 release = idl_type.release182 elif (idl_type.is_explicit_nullable or183 base_idl_type == 'EventHandler' or184 'CachedAttribute' in extended_attributes or185 'ReflectOnly' in extended_attributes or186 context['is_keep_alive_for_gc'] or187 context['is_getter_raises_exception']):188 context['cpp_value_original'] = cpp_value189 cpp_value = 'cppValue'190 # EventHandler has special handling191 if base_idl_type != 'EventHandler':192 release = idl_type.release193 def v8_set_return_value_statement(for_main_world=False):194 if context['is_keep_alive_for_gc'] or 'CachedAttribute' in extended_attributes:195 return 'v8SetReturnValue(info, v8Value)'196 return idl_type.v8_set_return_value(197 cpp_value, extended_attributes=extended_attributes, script_wrappable='impl',198 release=release, for_main_world=for_main_world, is_static=attribute.is_static)199 context.update({200 'cpp_value': cpp_value,201 'cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value(202 cpp_value=cpp_value, creation_context='holder',203 extended_attributes=extended_attributes),204 'v8_set_return_value_for_main_world': v8_set_return_value_statement(for_main_world=True),205 'v8_set_return_value': v8_set_return_value_statement(),206 })207def getter_expression(interface, attribute, context):208 arguments = []209 this_getter_base_name = getter_base_name(interface, attribute, arguments)210 getter_name = scoped_name(interface, attribute, this_getter_base_name)211 if 'ImplementedInPrivateScript' in attribute.extended_attributes:212 arguments.append('toLocalFrame(toFrameIfNotDetached(info.GetIsolate()->GetCurrentContext()))')213 arguments.append('impl')214 arguments.append('&result')215 arguments.extend(v8_utilities.call_with_arguments(216 attribute.extended_attributes.get('CallWith')))217 # Members of IDL partial interface definitions are implemented in C++ as218 # static member functions, which for instance members (non-static members)219 # take *impl as their first argument220 if ('PartialInterfaceImplementedAs' in attribute.extended_attributes and221 not 'ImplementedInPrivateScript' in attribute.extended_attributes and222 not attribute.is_static):223 arguments.append('*impl')224 if attribute.idl_type.is_explicit_nullable:225 arguments.append('isNull')226 if context['is_getter_raises_exception']:227 arguments.append('exceptionState')228 if attribute.idl_type.use_output_parameter_for_result:229 arguments.append('result')230 return '%s(%s)' % (getter_name, ', '.join(arguments))231CONTENT_ATTRIBUTE_GETTER_NAMES = {232 'boolean': 'fastHasAttribute',233 'long': 'getIntegralAttribute',234 'unsigned long': 'getUnsignedIntegralAttribute',235}236def getter_base_name(interface, attribute, arguments):237 extended_attributes = attribute.extended_attributes238 if 'ImplementedInPrivateScript' in extended_attributes:239 return '%sAttributeGetter' % uncapitalize(cpp_name(attribute))240 if 'Reflect' not in extended_attributes:241 return uncapitalize(cpp_name(attribute))242 content_attribute_name = extended_attributes['Reflect'] or attribute.name.lower()243 if content_attribute_name in ['class', 'id', 'name']:244 # Special-case for performance optimization.245 return 'get%sAttribute' % content_attribute_name.capitalize()246 arguments.append(scoped_content_attribute_name(interface, attribute))247 base_idl_type = attribute.idl_type.base_type248 if base_idl_type in CONTENT_ATTRIBUTE_GETTER_NAMES:249 return CONTENT_ATTRIBUTE_GETTER_NAMES[base_idl_type]250 if 'URL' in attribute.extended_attributes:251 return 'getURLAttribute'252 return 'fastGetAttribute'253def is_keep_alive_for_gc(interface, attribute):254 idl_type = attribute.idl_type255 base_idl_type = idl_type.base_type256 extended_attributes = attribute.extended_attributes257 return (258 # For readonly attributes, for performance reasons we keep the attribute259 # wrapper alive while the owner wrapper is alive, because the attribute260 # never changes.261 (attribute.is_read_only and262 idl_type.is_wrapper_type and263 # There are some exceptions, however:264 not(265 # Node lifetime is managed by object grouping.266 inherits_interface(interface.name, 'Node') or267 inherits_interface(base_idl_type, 'Node') or268 # A self-reference is unnecessary.269 attribute.name == 'self' or270 # FIXME: Remove these hard-coded hacks.271 base_idl_type in ['EventTarget', 'Window'] or272 base_idl_type.startswith(('HTML', 'SVG')))))273################################################################################274# Setter275################################################################################276def setter_context(interface, attribute, context):277 if 'PutForwards' in attribute.extended_attributes:278 # Use target interface and attribute in place of original interface and279 # attribute from this point onwards.280 target_interface_name = attribute.idl_type.base_type281 target_attribute_name = attribute.extended_attributes['PutForwards']282 interface = interfaces[target_interface_name]283 try:284 attribute = next(candidate285 for candidate in interface.attributes286 if candidate.name == target_attribute_name)287 except StopIteration:288 raise Exception('[PutForward] target not found:\n'289 'Attribute "%s" is not present in interface "%s"' %290 (target_attribute_name, target_interface_name))291 if ('Replaceable' in attribute.extended_attributes or292 is_constructor_attribute(attribute)):293 context['cpp_setter'] = '%sCreateDataProperty(propertyName, v8Value, info)' % cpp_name(interface)294 return295 extended_attributes = attribute.extended_attributes296 idl_type = attribute.idl_type297 # [RaisesException], [RaisesException=Setter]298 is_setter_raises_exception = (299 'RaisesException' in extended_attributes and300 extended_attributes['RaisesException'] in [None, 'Setter'])301 # [TypeChecking=Interface] / [LegacyInterfaceTypeChecking]302 has_type_checking_interface = (303 not is_legacy_interface_type_checking(interface, attribute) and304 idl_type.is_wrapper_type)305 context.update({306 'has_setter_exception_state':307 is_setter_raises_exception or has_type_checking_interface or308 idl_type.v8_conversion_needs_exception_state,309 'has_type_checking_interface': has_type_checking_interface,310 'is_setter_call_with_execution_context': has_extended_attribute_value(311 attribute, 'SetterCallWith', 'ExecutionContext'),312 'is_setter_raises_exception': is_setter_raises_exception,313 'private_script_cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value(314 'cppValue', isolate='scriptState->isolate()',315 creation_context='scriptState->context()->Global()'),316 'v8_value_to_local_cpp_value': idl_type.v8_value_to_local_cpp_value(317 extended_attributes, 'v8Value', 'cppValue'),318 })319 # setter_expression() depends on context values we set above.320 context['cpp_setter'] = setter_expression(interface, attribute, context)321def setter_expression(interface, attribute, context):322 extended_attributes = attribute.extended_attributes323 arguments = v8_utilities.call_with_arguments(324 extended_attributes.get('SetterCallWith') or325 extended_attributes.get('CallWith'))326 this_setter_base_name = setter_base_name(interface, attribute, arguments)327 setter_name = scoped_name(interface, attribute, this_setter_base_name)328 # Members of IDL partial interface definitions are implemented in C++ as329 # static member functions, which for instance members (non-static members)330 # take *impl as their first argument331 if ('PartialInterfaceImplementedAs' in extended_attributes and332 not 'ImplementedInPrivateScript' in extended_attributes and333 not attribute.is_static):334 arguments.append('*impl')335 idl_type = attribute.idl_type336 if 'ImplementedInPrivateScript' in extended_attributes:337 arguments.append('toLocalFrame(toFrameIfNotDetached(info.GetIsolate()->GetCurrentContext()))')338 arguments.append('impl')339 arguments.append('cppValue')340 elif idl_type.base_type == 'EventHandler':341 getter_name = scoped_name(interface, attribute, cpp_name(attribute))342 context['event_handler_getter_expression'] = '%s(%s)' % (343 getter_name, ', '.join(arguments))344 if (interface.name in ['Window', 'WorkerGlobalScope'] and345 attribute.name == 'onerror'):346 includes.add('bindings/core/v8/V8ErrorHandler.h')347 arguments.append('V8EventListenerList::findOrCreateWrapper<V8ErrorHandler>(v8Value, true, ScriptState::current(info.GetIsolate()))')348 else:349 arguments.append('V8EventListenerList::getEventListener(ScriptState::current(info.GetIsolate()), v8Value, true, ListenerFindOrCreate)')350 elif idl_type.is_interface_type:351 # FIXME: should be able to eliminate WTF::getPtr in most or all cases352 arguments.append('WTF::getPtr(cppValue)')353 else:354 arguments.append('cppValue')355 if context['is_setter_raises_exception']:356 arguments.append('exceptionState')357 return '%s(%s)' % (setter_name, ', '.join(arguments))358CONTENT_ATTRIBUTE_SETTER_NAMES = {359 'boolean': 'setBooleanAttribute',360 'long': 'setIntegralAttribute',361 'unsigned long': 'setUnsignedIntegralAttribute',362}363def setter_base_name(interface, attribute, arguments):364 if 'ImplementedInPrivateScript' in attribute.extended_attributes:365 return '%sAttributeSetter' % uncapitalize(cpp_name(attribute))366 if 'Reflect' not in attribute.extended_attributes:367 return 'set%s' % capitalize(cpp_name(attribute))368 arguments.append(scoped_content_attribute_name(interface, attribute))369 base_idl_type = attribute.idl_type.base_type370 if base_idl_type in CONTENT_ATTRIBUTE_SETTER_NAMES:371 return CONTENT_ATTRIBUTE_SETTER_NAMES[base_idl_type]372 return 'setAttribute'373def scoped_content_attribute_name(interface, attribute):374 content_attribute_name = attribute.extended_attributes['Reflect'] or attribute.name.lower()375 if interface.name.startswith('SVG'):376 namespace = 'SVGNames'377 else:378 namespace = 'HTMLNames'379 includes.add('core/%s.h' % namespace)380 return '%s::%sAttr' % (namespace, content_attribute_name)381################################################################################382# Attribute configuration383################################################################################384# [PutForwards], [Replaceable]385def has_setter(attribute):386 return (not attribute.is_read_only or387 'PutForwards' in attribute.extended_attributes or388 'Replaceable' in attribute.extended_attributes)389# [DoNotCheckSecurity], [Unforgeable]390def access_control_list(interface, attribute):391 extended_attributes = attribute.extended_attributes392 access_control = []393 if 'DoNotCheckSecurity' in extended_attributes:394 do_not_check_security = extended_attributes['DoNotCheckSecurity']395 if do_not_check_security == 'Setter':396 access_control.append('v8::ALL_CAN_WRITE')397 else:398 access_control.append('v8::ALL_CAN_READ')399 if has_setter(attribute):400 access_control.append('v8::ALL_CAN_WRITE')401 if is_unforgeable(interface, attribute):402 access_control.append('v8::PROHIBITS_OVERWRITING')403 return access_control or ['v8::DEFAULT']404# [NotEnumerable], [Unforgeable]405def property_attributes(interface, attribute):406 extended_attributes = attribute.extended_attributes407 property_attributes_list = []408 if ('NotEnumerable' in extended_attributes or409 is_constructor_attribute(attribute)):410 property_attributes_list.append('v8::DontEnum')411 if is_unforgeable(interface, attribute):412 property_attributes_list.append('v8::DontDelete')413 return property_attributes_list or ['v8::None']414# [Custom], [Custom=Getter]415def has_custom_getter(attribute):416 extended_attributes = attribute.extended_attributes417 return ('Custom' in extended_attributes and418 extended_attributes['Custom'] in [None, 'Getter'])419# [Custom], [Custom=Setter]420def has_custom_setter(attribute):421 extended_attributes = attribute.extended_attributes422 return (not attribute.is_read_only and423 'Custom' in extended_attributes and424 extended_attributes['Custom'] in [None, 'Setter'])425# [ExposeJSAccessors]426def is_expose_js_accessors(interface, attribute):427 # Default behavior428 is_accessor = True429 if ('ExposeJSAccessors' in interface.extended_attributes and430 'DoNotExposeJSAccessors' in interface.extended_attributes):431 raise Exception('Both of ExposeJSAccessors and DoNotExposeJSAccessors are specified at a time in an interface: ' + interface.name)432 if 'ExposeJSAccessors' in interface.extended_attributes:433 is_accessor = True434 if 'DoNotExposeJSAccessors' in interface.extended_attributes:435 is_accessor = False436 # Note that ExposeJSAccessors and DoNotExposeJSAccessors are more powerful437 # than 'static', [Unforgeable] and [OverrideBuiltins].438 if ('ExposeJSAccessors' in attribute.extended_attributes and439 'DoNotExposeJSAccessors' in attribute.extended_attributes):440 raise Exception('Both of ExposeJSAccessors and DoNotExposeJSAccessors are specified at a time on an attribute: ' + attribute.name + ' in an interface: ' + interface.name)441 if 'ExposeJSAccessors' in attribute.extended_attributes:442 return True443 if 'DoNotExposeJSAccessors' in attribute.extended_attributes:444 return False445 # These attributes must not be accessors on prototype chains.446 if (is_constructor_attribute(attribute) or447 attribute.is_static or448 is_unforgeable(interface, attribute) or449 'OverrideBuiltins' in interface.extended_attributes):450 return False451 # The members of Window interface must be placed on the instance object.452 if interface.name == 'Window':453 return False454 return is_accessor455################################################################################456# Constructors457################################################################################458idl_types.IdlType.constructor_type_name = property(459 # FIXME: replace this with a [ConstructorAttribute] extended attribute460 lambda self: strip_suffix(self.base_type, 'Constructor'))461def is_constructor_attribute(attribute):462 # FIXME: replace this with [ConstructorAttribute] extended attribute463 return attribute.idl_type.name.endswith('Constructor')464def update_constructor_attribute_context(interface, attribute, context):465 context['needs_constructor_getter_callback'] = context['measure_as'] or context['deprecate_as']466 # When the attribute name is the same as the interface name, do not generate467 # callback functions for each attribute and use468 # {{cpp_class}}ConstructorAttributeSetterCallback. Otherwise, generate469 # a callback function in order to hard-code the attribute name....
contactConsts.js
Source:contactConsts.js
1/*2* Copyright 2012 Research In Motion Limited.3*4* Licensed under the Apache License, Version 2.0 (the "License");5* you may not use this file except in compliance with the License.6* You may obtain a copy of the License at7*8* http://www.apache.org/licenses/LICENSE-2.09*10* Unless required by applicable law or agreed to in writing, software11* distributed under the License is distributed on an "AS IS" BASIS,12* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13* See the License for the specific language governing permissions and14* limitations under the License.15*/16var ATTRIBUTE_KIND,17 ATTRIBUTE_SUBKIND,18 kindAttributeMap = {},19 subKindAttributeMap = {},20 _TITLE = 26,21 _START_DATE = 43,22 _END_DATE = 44;23function populateKindAttributeMap() {24 ATTRIBUTE_KIND = {25 Invalid: 0,26 Phone: 1,27 Fax: 2,28 Pager: 3,29 Email: 4,30 Website: 5,31 Feed: 6,32 Profile: 7,33 Family: 8,34 Person: 9,35 Date: 10,36 Group: 11,37 Name: 12,38 StockSymbol: 13,39 Ranking: 14,40 OrganizationAffiliation: 15,41 Education: 16,42 Note: 17,43 InstantMessaging: 18,44 VideoChat: 19,45 ConnectionCount: 20,46 Hidden: 21,47 Biography: 22,48 Sound: 23,49 Notification: 24,50 MessageSound: 25,51 MessageNotification: 2652 };53 kindAttributeMap[ATTRIBUTE_KIND.Phone] = "phoneNumbers";54 kindAttributeMap[ATTRIBUTE_KIND.Fax] = "faxNumbers";55 kindAttributeMap[ATTRIBUTE_KIND.Pager] = "pagerNumber";56 kindAttributeMap[ATTRIBUTE_KIND.Email] = "emails";57 kindAttributeMap[ATTRIBUTE_KIND.Website] = "urls";58 kindAttributeMap[ATTRIBUTE_KIND.Profile] = "socialNetworks";59 kindAttributeMap[ATTRIBUTE_KIND.OrganizationAffiliation] = "organizations";60 kindAttributeMap[ATTRIBUTE_KIND.Education] = "education";61 kindAttributeMap[ATTRIBUTE_KIND.Note] = "note";62 kindAttributeMap[ATTRIBUTE_KIND.InstantMessaging] = "ims";63 kindAttributeMap[ATTRIBUTE_KIND.VideoChat] = "videoChat";64 kindAttributeMap[ATTRIBUTE_KIND.Sound] = "ringtone";65}66function populateSubKindAttributeMap() {67 ATTRIBUTE_SUBKIND = {68 Invalid: 0,69 Other: 1,70 Home: 2,71 Work: 3,72 PhoneMobile: 4,73 FaxDirect: 5,74 Blog: 6,75 WebsiteResume: 7,76 WebsitePortfolio: 8,77 WebsitePersonal: 9,78 WebsiteCompany: 10,79 ProfileFacebook: 11,80 ProfileTwitter: 12,81 ProfileLinkedIn: 13,82 ProfileGist: 14,83 ProfileTungle: 15,84 FamilySpouse: 16,85 FamilyChild: 17,86 FamilyParent: 18,87 PersonManager: 19,88 PersonAssistant: 20,89 DateBirthday: 21,90 DateAnniversary: 22,91 GroupDepartment: 23,92 NameGiven: 24,93 NameSurname: 25,94 Title: _TITLE,95 NameSuffix: 27,96 NameMiddle: 28,97 NameNickname: 29,98 NameAlias: 30,99 NameDisplayName: 31,100 NamePhoneticGiven: 32,101 NamePhoneticSurname: 33,102 StockSymbolNyse: 34,103 StockSymbolNasdaq: 35,104 StockSymbolTse: 36,105 StockSymbolLse: 37,106 StockSymbolTsx: 38,107 RankingKlout: 39,108 RankingTrstRank: 40,109 OrganizationAffiliationName: 41,110 OrganizationAffiliationPhoneticName: 42,111 OrganizationAffiliationTitle: _TITLE,112 StartDate: _START_DATE,113 EndDate: _END_DATE,114 OrganizationAffiliationDetails: 45,115 EducationInstitutionName: 46,116 EducationStartDate: _START_DATE,117 EducationEndDate: _END_DATE,118 EducationDegree: 47,119 EducationConcentration: 48,120 EducationActivities: 49,121 EducationNotes: 50,122 InstantMessagingBbmPin: 51,123 InstantMessagingAim: 52,124 InstantMessagingAliwangwang: 53,125 InstantMessagingGoogleTalk: 54,126 InstantMessagingSametime: 55,127 InstantMessagingIcq: 56,128 InstantMessagingIrc: 57,129 InstantMessagingJabber: 58,130 InstantMessagingMsLcs: 59,131 InstantMessagingMsn: 60,132 InstantMessagingQq: 61,133 InstantMessagingSkype: 62,134 InstantMessagingYahooMessenger: 63,135 InstantMessagingYahooMessengerJapan: 64,136 VideoChatBbPlaybook: 65,137 HiddenLinkedIn: 66,138 HiddenFacebook: 67,139 HiddenTwitter: 68,140 ConnectionCountLinkedIn: 69,141 ConnectionCountFacebook: 70,142 ConnectionCountTwitter: 71,143 HiddenChecksum: 72,144 HiddenSpeedDial: 73,145 BiographyFacebook: 74,146 BiographyTwitter: 75,147 BiographyLinkedIn: 76,148 SoundRingtone: 77,149 SimContactType: 78,150 EcoID: 79,151 Personal: 80,152 StockSymbolAll: 81,153 NotificationVibration: 82,154 NotificationLED: 83,155 MessageNotificationVibration: 84,156 MessageNotificationLED: 85,157 MessageNotificationDuringCall: 86,158 VideoChatPin: 87159 };160 subKindAttributeMap[ATTRIBUTE_SUBKIND.Other] = "other";161 subKindAttributeMap[ATTRIBUTE_SUBKIND.Home] = "home";162 subKindAttributeMap[ATTRIBUTE_SUBKIND.Work] = "work";163 subKindAttributeMap[ATTRIBUTE_SUBKIND.PhoneMobile] = "mobile";164 subKindAttributeMap[ATTRIBUTE_SUBKIND.FaxDirect] = "direct";165 subKindAttributeMap[ATTRIBUTE_SUBKIND.Blog] = "blog";166 subKindAttributeMap[ATTRIBUTE_SUBKIND.WebsiteResume] = "resume";167 subKindAttributeMap[ATTRIBUTE_SUBKIND.WebsitePortfolio] = "portfolio";168 subKindAttributeMap[ATTRIBUTE_SUBKIND.WebsitePersonal] = "personal";169 subKindAttributeMap[ATTRIBUTE_SUBKIND.WebsiteCompany] = "company";170 subKindAttributeMap[ATTRIBUTE_SUBKIND.ProfileFacebook] = "facebook";171 subKindAttributeMap[ATTRIBUTE_SUBKIND.ProfileTwitter] = "twitter";172 subKindAttributeMap[ATTRIBUTE_SUBKIND.ProfileLinkedIn] = "linkedin";173 subKindAttributeMap[ATTRIBUTE_SUBKIND.ProfileGist] = "gist";174 subKindAttributeMap[ATTRIBUTE_SUBKIND.ProfileTungle] = "tungle";175 subKindAttributeMap[ATTRIBUTE_SUBKIND.DateBirthday] = "birthday";176 subKindAttributeMap[ATTRIBUTE_SUBKIND.DateAnniversary] = "anniversary";177 subKindAttributeMap[ATTRIBUTE_SUBKIND.NameGiven] = "givenName";178 subKindAttributeMap[ATTRIBUTE_SUBKIND.NameSurname] = "familyName";179 subKindAttributeMap[ATTRIBUTE_SUBKIND.Title] = "honorificPrefix";180 subKindAttributeMap[ATTRIBUTE_SUBKIND.NameSuffix] = "honorificSuffix";181 subKindAttributeMap[ATTRIBUTE_SUBKIND.NameMiddle] = "middleName";182 subKindAttributeMap[ATTRIBUTE_SUBKIND.NamePhoneticGiven] = "phoneticGivenName";183 subKindAttributeMap[ATTRIBUTE_SUBKIND.NamePhoneticSurname] = "phoneticFamilyName";184 subKindAttributeMap[ATTRIBUTE_SUBKIND.NameNickname] = "nickname";185 subKindAttributeMap[ATTRIBUTE_SUBKIND.NameDisplayName] = "displayName";186 subKindAttributeMap[ATTRIBUTE_SUBKIND.OrganizationAffiliationName] = "name";187 subKindAttributeMap[ATTRIBUTE_SUBKIND.OrganizationAffiliationDetails] = "department";188 subKindAttributeMap[ATTRIBUTE_SUBKIND.Title] = "title";189 subKindAttributeMap[ATTRIBUTE_SUBKIND.InstantMessagingBbmPin] = "BbmPin";190 subKindAttributeMap[ATTRIBUTE_SUBKIND.InstantMessagingAim] = "Aim";191 subKindAttributeMap[ATTRIBUTE_SUBKIND.InstantMessagingAliwangwang] = "Aliwangwang";192 subKindAttributeMap[ATTRIBUTE_SUBKIND.InstantMessagingGoogleTalk] = "GoogleTalk";193 subKindAttributeMap[ATTRIBUTE_SUBKIND.InstantMessagingSametime] = "Sametime";194 subKindAttributeMap[ATTRIBUTE_SUBKIND.InstantMessagingIcq] = "Icq";195 subKindAttributeMap[ATTRIBUTE_SUBKIND.InstantMessagingJabber] = "Jabber";196 subKindAttributeMap[ATTRIBUTE_SUBKIND.InstantMessagingMsLcs] = "MsLcs";197 subKindAttributeMap[ATTRIBUTE_SUBKIND.InstantMessagingSkype] = "Skype";198 subKindAttributeMap[ATTRIBUTE_SUBKIND.InstantMessagingYahooMessenger] = "YahooMessenger";199 subKindAttributeMap[ATTRIBUTE_SUBKIND.InstantMessagingYahooMessengerJapan] = "YahooMessegerJapan";200 subKindAttributeMap[ATTRIBUTE_SUBKIND.VideoChatBbPlaybook] = "BbPlaybook";201 subKindAttributeMap[ATTRIBUTE_SUBKIND.SoundRingtone] = "ringtone";202 subKindAttributeMap[ATTRIBUTE_SUBKIND.Personal] = "personal";203}204module.exports = {205 getKindAttributeMap: function () {206 if (!ATTRIBUTE_KIND) {207 populateKindAttributeMap();208 }209 return kindAttributeMap;210 },211 getSubKindAttributeMap: function () {212 if (!ATTRIBUTE_SUBKIND) {213 populateSubKindAttributeMap();214 }215 return subKindAttributeMap;216 }...
writeAttributes.py
Source:writeAttributes.py
1# !/usr/bin/python2import sys3import utility4if len(sys.argv) < 2:5 print "Usage:",sys.argv[0],"cdif-input-file"6 sys.exit(64)7input_file=sys.argv[1]8input_file=open(input_file, 'r')9output_file="attributesWithIDs.txt"10output_file=open(output_file, 'w')11attributeContainmentFile=open("attributeBelongsToClass.txt", 'w')12attributeTypeFile=open("attributeHasClassAsType.txt", 'w')13attributeVisibilityFile = open("attributeVisibility.txt", 'w')14attributeSignatureFile = open("attributeSignature.txt", 'w')15for line in input_file:16 line = line.strip()17 18 if line.startswith("(Attribute FM"):19 cdifId=line.split("M")[1] 20 21 name = ""22 uniqueName=""23 parentClassName = ""24 declaredType = ""25 accessControlQualifier = ""26 declaredClass = ""27 sourceFile = ""28 lineNr = ""29 parentSourceFile = ""30 parentLineNr = ""31 typeSourceFile = ""32 typeLineNr = ""33 34 for attributeLine in input_file:35 attributeLine = attributeLine.strip()36 37 if attributeLine.startswith(")"):38 break39 elif attributeLine.startswith("(name \""):40 name = attributeLine.split("\"")[1]41 uniqueName = name42 elif attributeLine.startswith("(belongsTo \""):43 parentClassName = attributeLine.split("\"")[1]44 elif attributeLine.startswith("(declaredType \""):45 declaredType = attributeLine.split("\"")[1]46 elif attributeLine.startswith("(declaredClass \""):47 declaredClass = attributeLine.split("\"")[1]48 elif attributeLine.startswith("(accessControlQualifier \""):49 accessControlQualifier = attributeLine.split("\"")[1]50 elif attributeLine.startswith("(sourceAnchor "):51 sourceFile = attributeLine.split("\"")[1]52 lineNr = attributeLine.split("\"")[2].split(" ")[2] 53 elif attributeLine.startswith("(typeSourceAnchor "):54 typeSourceFile = attributeLine.split("\"")[1]55 typeLineNr = attributeLine.split("\"")[2].split(" ")[2] 56 elif attributeLine.startswith("(parentSourceAnchor "): 57 parentSourceFile = attributeLine.split("\"")[1]58 parentLineNr = attributeLine.split("\"")[2].split(" ")[2] 59 if ( parentClassName != "" ):60 uniqueName=parentClassName+"."+name61 attrInfo=cdifId + "\t\"" + uniqueName + "\"\n"62 output_file.write(attrInfo)63 attributeOwnerId = utility.getClassId(parentSourceFile,parentLineNr)64 65 if attributeOwnerId != "":66 attrContainmentInfo=cdifId + "\t" + attributeOwnerId + "\n"67 attributeContainmentFile.write(attrContainmentInfo)68 69 if ( declaredClass != "" and typeSourceFile != ""):70 declaredClassId = utility.getClassId(typeSourceFile,typeLineNr)71 72 if declaredClassId != "":73 attrTypeInfo=cdifId + "\t" + declaredClassId + "\n"74 attributeTypeFile.write(attrTypeInfo)75 76input_file.close()77output_file.close()78attributeContainmentFile.close()79attributeTypeFile.close()80attributeVisibilityFile.close()...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!