How to use config_set method in autotest

Best Python code snippet using autotest_python

pgegen.py

Source:pgegen.py Github

copy

Full Screen

...6 config.optionxform = str7 elf = args.elf8 def sym_get(name):9 return f'{elf.get_sym(name).st_value & 0xFFFFFF:X}'10 def config_set(name, value):11 config.set(args.code, name, value)12 def get_size_rawasm(sym):13 i = elf.symbols_sorted.index(sym) + 114 while elf.symbols_sorted[i].st_value == sym.st_value:15 i += 116 return elf.symbols_sorted[i].st_value - sym.st_value17 print('Building config... ', end='', flush=True)18 config.add_section(args.code)19 config_set('ROMName', args.name)20 gItems = elf.get_sym('gItems')21 config_set('ItemData', f'{gItems.st_value & 0xFFFFFF:X}')22 gMoveNames = elf.get_sym('gMoveNames')23 config_set('AttackNames', f'{gMoveNames.st_value & 0xFFFFFF:X}')24 TMHMMoves = elf.get_sym('gTMHMMoves')25 config_set('TMData', f'{TMHMMoves.st_value & 0xFFFFFF:X}')26 config_set('TotalTMsPlusHMs', f'{TMHMMoves.st_size // 2}')27 config_set('TotalTMs', f'{TMHMMoves.st_size // 2 - 8}')28 config_set('NumberOfItems', f'{gItems.st_size // 44}')29 config_set('NumberOfAttacks', f'{gMoveNames.st_size // 13}')30 gSpeciesNames = elf.get_sym('gSpeciesNames')31 config_set('PokemonNames', f'{gSpeciesNames.st_value & 0xFFFFFF:X}')32 npokes = gSpeciesNames.st_size // 1133 config_set('NumberOfPokemon', f'{npokes}')34 config_set('NationalDexTable', sym_get('gSpeciesToNationalPokedexNum'))35 config_set('SecondDexTable', sym_get('gSpeciesToHoennPokedexNum'))36 gPokedexEntries = elf.get_sym('gPokedexEntries')37 config_set('PokedexData', f'{gPokedexEntries.st_value & 0xFFFFFF:X}')38 config_set('NumberOfDexEntries', f'{gPokedexEntries.st_size // 36}')39 config_set('PokemonData', sym_get('gBaseStats'))40 gAbilityNames = elf.get_sym('gAbilityNames')41 config_set('AbilityNames', f'{gAbilityNames.st_value & 0xFFFFFF:X}')42 config_set('NumberOfAbilities', f'{get_size_rawasm(gAbilityNames) // 13}')43 gMapGroups = elf.get_sym('gMapGroups')44 config_set('Pointer2PointersToMapBanks', f'{gMapGroups.st_value & 0xFFFFFF:X}')45 ptrs = []46 while True:47 grp = elf.get_sym(f'gMapGroup{len(ptrs)}')48 if grp.st_name is None:49 break50 config_set(f'OriginalBankPointer{len(ptrs)}', f'{grp.st_value & 0xFFFFFF:X}')51 ptrs.append(grp.st_value)52 ptrs.append(gMapGroups.st_value)53 sorted_ptrs = sorted(ptrs)54 for i, ptr in enumerate(ptrs[:-1]):55 j = sorted_ptrs.index(ptr)56 size = sorted_ptrs[j + 1] - ptr - 457 config_set(f'NumberOfMapsInBank{i}', f'{size // 4}')58 gRegionMapEntries = elf.get_sym('gRegionMapEntries')59 config_set('MapLabelData', f'{gRegionMapEntries.st_value & 0xFFFFFF:X}')60 config_set('NumberOfMapLabels', f'{gRegionMapEntries.st_size // 8}')61 config_set('PokemonFrontSprites', sym_get('gMonFrontPicTable'))62 config_set('PokemonBackSprites', sym_get('gMonBackPicTable'))63 config_set('PokemonNormalPal', sym_get('gMonPaletteTable'))64 config_set('PokemonShinyPal', sym_get('gMonShinyPaletteTable'))65 config_set('IconPointerTable', sym_get('gMonIconTable'))66 config_set('IconPalTable', sym_get('gMonIconPaletteIndices'))67 config_set('CryTable', sym_get('gCryTable'))68 config_set('CryTable2', sym_get('gCryTable2'))69 config_set('FootPrintTable', sym_get('sMonFootprintTable'))70 config_set('PokemonAttackTable', sym_get('gLevelUpLearnsets'))71 gEvolutionTable = elf.get_sym('gEvolutionTable')72 config_set('PokemonEvolutions', f'{gEvolutionTable.st_value & 0xFFFFFF:X}')73 gTMHMLearnsets = elf.get_sym('gTMHMLearnsets')74 config_set('TMHMCompatibility', f'{gTMHMLearnsets.st_value & 0xFFFFFF:X}')75 config_set('TMHMLenPerPoke', f'{gTMHMLearnsets.st_size // npokes}')76 config_set('EnemyYTable', sym_get('gMonFrontPicCoords'))77 config_set('PlayerYTable', sym_get('gMonBackPicCoords'))78 config_set('EnemyAltitudeTable', sym_get('gEnemyMonElevation'))79 config_set('AttackData', sym_get('gBattleMoves'))80 config_set('ContestMoveData', sym_get('gContestMoves'))81 config_set('ContestMoveEffectData', sym_get('gContestEffects'))82 config_set('AttackDescriptionTable', sym_get('gMoveDescriptionPointers'))83 config_set('AbilityDescriptionTable', sym_get('gAbilityDescriptionPointers'))84 try:85 config_set('StarterPokemon', sym_get('sStarterMon'))86 except AttributeError:87 config_set('StarterPokemon', '')88 config_set('StarterPokemonLevel', '')89 config_set('StarterEncounterPokemon', '')90 config_set('StarterEncounterPokemonLevel', '')91 config_set('AttackAnimationTable', sym_get('gBattleAnims_Moves'))92 # This breaks, not needed for Pokemon HUD anyway93 # general_tileset = elf.get_sym('gTileset_General')94 # tileset_no = 095 # while True:96 # sym = elf.symbols[elf.symbols.index(general_tileset.st_value + 0x18 * (tileset_no + 1))]97 # if sym is None or not (sym.st_name and sym.st_name.startswith('gTileset_')):98 # break99 # sh = sym.st_sh100 # elf.seek(sh.sh_offset + sym.st_value - sh.sh_addr + 12)101 # val = int.from_bytes(elf.read(4), 'little', signed=False)102 # val2 = int.from_bytes(elf.read(4), 'little', signed=False)103 # config_set(f'NumberOfTilesInTilset{0x286D0C + 0x18 * tileset_no:6X}', f'{(val2 - val) // 16:X}')104 # tileset_no += 1105 # Hardcode this for now, something's definitely fishy106 config_set('NumberOfTilesInTilset286D0C', '90')107 config_set('NumberOfTilesInTilset286D24', '15D')108 config_set('NumberOfTilesInTilset286D3C', '90')109 config_set('NumberOfTilesInTilset286D54', '16C')110 config_set('NumberOfTilesInTilset286D6C', '1B2')111 config_set('NumberOfTilesInTilset286D84', '11E')112 config_set('NumberOfTilesInTilset286D9C', '152')113 config_set('NumberOfTilesInTilset286DB4', '10B')114 config_set('NumberOfTilesInTilset286DCC', '15F')115 config_set('NumberOfTilesInTilset286DE4', '16B')116 config_set('NumberOfTilesInTilset286DFC', 'A8')117 config_set('NumberOfTilesInTilset286E14', 'BF')118 config_set('NumberOfTilesInTilset286E2C', 'FE')119 config_set('NumberOfTilesInTilset286E44', '118')120 config_set('NumberOfTilesInTilset286E5C', 'C6')121 config_set('NumberOfTilesInTilset286E74', '19E')122 config_set('NumberOfTilesInTilset286E8C', '3A')123 config_set('NumberOfTilesInTilset286EA4', '68')124 config_set('NumberOfTilesInTilset286EBC', '01')125 config_set('NumberOfTilesInTilset286ED4', '9F')126 config_set('NumberOfTilesInTilset286EEC', '65')127 config_set('NumberOfTilesInTilset286F04', '100')128 config_set('NumberOfTilesInTilset286F1C', '87')129 config_set('NumberOfTilesInTilset286F34', '48')130 config_set('NumberOfTilesInTilset286F4C', '44')131 config_set('NumberOfTilesInTilset286F64', '1FE')132 config_set('NumberOfTilesInTilset286F7C', 'F8')133 config_set('NumberOfTilesInTilset286F94', '53')134 config_set('NumberOfTilesInTilset286FAC', '144')135 config_set('NumberOfTilesInTilset286FC4', '144')136 config_set('NumberOfTilesInTilset286FDC', '144')137 config_set('NumberOfTilesInTilset286FF4', '144')138 config_set('NumberOfTilesInTilset28700C', '144')139 config_set('NumberOfTilesInTilset287024', '144')140 config_set('NumberOfTilesInTilset28703C', '26')141 config_set('NumberOfTilesInTilset287054', '3A')142 config_set('NumberOfTilesInTilset28706C', 'E0')143 config_set('NumberOfTilesInTilset287084', '8F')144 config_set('NumberOfTilesInTilset28709C', 'AB')145 config_set('NumberOfTilesInTilset2870B4', '9A')146 config_set('NumberOfTilesInTilset2870CC', 'EC')147 config_set('NumberOfTilesInTilset2870E4', '8C')148 config_set('NumberOfTilesInTilset2870FC', '63')149 config_set('NumberOfTilesInTilset287114', '60')150 config_set('NumberOfTilesInTilset28712C', '38')151 config_set('NumberOfTilesInTilset287144', '3D')152 config_set('NumberOfTilesInTilset28715C', '52')153 config_set('NumberOfTilesInTilset287174', '2A')154 config_set('NumberOfTilesInTilset28718C', '95')155 config_set('NumberOfTilesInTilset2871A4', '35')156 config_set('NumberOfTilesInTilset2871BC', '49')157 config_set('NumberOfTilesInTilset2871D4', 'FC')158 config_set('NumberOfTilesInTilset2871EC', '14B')159 config_set('NumberOfTilesInTilset287204', '83')160 config_set('IconPals', sym_get('gMonIconPalettes'))161 config_set('JamboLearnableMovesTerm', '0000FF') # ??????????????162 config_set('StartSearchingForSpaceOffset', '800000') # ??????????????163 config_set('FreeSpaceSearchInterval', '100') # ???????????????164 config_set('NumberOfEvolutionsPerPokemon', f'{gEvolutionTable.st_size // (npokes * 8)}')165 # Hardcode these166 config_set('NumberOfEvolutionTypes', '15')167 config_set('EvolutionName0', 'None')168 config_set('EvolutionName1', 'Happiness')169 config_set('EvolutionName2', 'Happiness (Day)')170 config_set('EvolutionName3', 'Happiness (Night)')171 config_set('EvolutionName4', 'Level')172 config_set('EvolutionName5', 'Trade')173 config_set('EvolutionName6', 'Trade w/ Item')174 config_set('EvolutionName7', 'Item')175 config_set('EvolutionName8', 'Atk > Def')176 config_set('EvolutionName9', 'Atk = Def')177 config_set('EvolutionName10', 'Atk < Def')178 config_set('EvolutionName11', 'High Personality')179 config_set('EvolutionName12', 'Low Personality')180 config_set('EvolutionName13', 'Allow Pokemon Creation')181 config_set('EvolutionName14', 'Create Extra Pokemon')182 config_set('EvolutionName15', 'Max Beauty')183 config_set('Evolution0Param', 'none')184 config_set('Evolution1Param', 'evolvesbutnoparms')185 config_set('Evolution2Param', 'evolvesbutnoparms')186 config_set('Evolution3Param', 'evolvesbutnoparms')187 config_set('Evolution4Param', 'level')188 config_set('Evolution5Param', 'evolvesbutnoparms')189 config_set('Evolution6Param', 'item')190 config_set('Evolution7Param', 'item')191 config_set('Evolution8Param', 'level')192 config_set('Evolution9Param', 'level')193 config_set('Evolution10Param', 'level')194 config_set('Evolution11Param', 'level')195 config_set('Evolution12Param', 'level')196 config_set('Evolution13Param', 'evolvesbutnoparms')197 config_set('Evolution14Param', 'level')198 config_set('Evolution15Param', 'evolvesbasedonvalue')199 config_set('MoveTutorAttacks', '0')200 config_set('CryConversionTable', sym_get('gSpeciesIdToCryId'))201 config_set('MoveTutorCompatibility', '0')202 config_set('EggMoveTable', sym_get('gEggMoves'))203 config_set('EggMoveTableLimiter', sym_get('GetEggMoves')) # static function204 gTrainers = elf.get_sym('gTrainers')205 config_set('TrainerTable', f'{gTrainers.st_value & 0xFFFFFF:X}')206 config_set('NumberOfTrainers', f'{gTrainers.st_size // 40 - 1}')207 gTrainerClassNames = elf.get_sym('gTrainerClassNames')208 config_set('TrainerClasses', f'{gTrainerClassNames.st_value & 0xFFFFFF:X}')209 config_set('NumberOfTrainerClasses', f'{gTrainerClassNames.st_size // 13}')210 gTrainerFrontPicTable = elf.get_sym('gTrainerFrontPicTable')211 gTrainerFrontPicPaletteTable = elf.get_sym('gTrainerFrontPicPaletteTable')212 config_set('TrainerImageTable', f'{gTrainerFrontPicTable.st_value & 0xFFFFFF:X}')213 size = gTrainerFrontPicPaletteTable.st_value - gTrainerFrontPicTable.st_value214 config_set('NumberOfTrainerImages', f'{size // 8}')215 config_set('TrainerPaletteTable', f'{gTrainerFrontPicPaletteTable.st_value & 0xFFFFFF:X}')216 config_set('DexSizeTrainerSprite', '0')217 gIngameTrades = elf.get_sym('gIngameTrades')218 config_set('TradeData', f'{gIngameTrades.st_value & 0xFFFFFF:X}')219 config_set('NumberOfTrades', f'{gIngameTrades.st_size // 60}')220 # RAM locations221 gPlayerParty = elf.get_sym('gPlayerParty')222 config_set('gPlayerParty', f'{gPlayerParty.st_value:X}')223 config_set('PartyBytes', f'{gPlayerParty.st_size:X}')224 gPokemonStoragePtr = elf.get_sym('gPokemonStoragePtr')225 gSaveBlock1Ptr = elf.get_sym('gSaveBlock1Ptr')226 gSaveBlock2Ptr = elf.get_sym('gSaveBlock2Ptr')227 gPokemonStorage = elf.get_sym('gPokemonStorage')228 is_rs = None in (gPokemonStoragePtr.st_name, gSaveBlock1Ptr.st_name, gSaveBlock2Ptr.st_name)229 if is_rs:230 # RS231 config_set('PCBlockAddress', f'{gPokemonStorage.st_value:X}')232 config_set('SaveBlock1Address', f'{elf.get_sym("gSaveBlock1").st_value:X}')233 config_set('SaveBlock2Address', f'{elf.get_sym("gSaveBlock2").st_value:X}')234 else:235 # Emerald236 config_set('PCBlockAddress', f'*{gPokemonStoragePtr.st_value:X}')237 config_set('SaveBlock1Address', f'*{gSaveBlock1Ptr.st_value:X}')238 config_set('SaveBlock2Address', f'*{gSaveBlock2Ptr.st_value:X}')239 config_set('PCBytes', f'{gPokemonStorage.st_size:X}')240 # Assume these offsets are unchanged from vanilla241 if is_rs:242 config_set('DaycareOffset', '2F9C')243 config_set('MoneyOffset', '490')244 # Skip encryption key offset245 config_set('ItemPCOffset', '498')246 config_set('ItemPCCount', '32')247 config_set('ItemPocketOffset', '560')248 config_set('ItemPocketCount', '14')249 config_set('ItemKeyOffset', '5B0')250 config_set('ItemKeyCount', '14')251 config_set('ItemBallOffset', '600')252 config_set('ItemBallCount', '10')253 config_set('ItemTMOffset', '640')254 config_set('ItemTMCount', '40')255 config_set('ItemBerriesOffset', '740')256 config_set('ItemBerriesCount', '2E')257 config_set('FlagsOffset', '1220')258 config_set('BadgeFlag', '807') # 100:7259 config_set('IwramMusicAddr', sym_get('sCurrentMapMusic'))260 config_set('EvolutionMusicIds', '178 179')261 # Skip rival name262 else:263 # Assume Emerald for now264 config_set('DaycareOffset', '3030')265 config_set('MoneyOffset', '490')266 config_set('EncryptionKeyOffset', 'AC')267 config_set('ItemPCOffset', '498')268 config_set('ItemPCCount', '32')269 config_set('ItemPocketOffset', '560')270 config_set('ItemPocketCount', '1E')271 config_set('ItemKeyOffset', '5D8')272 config_set('ItemKeyCount', '1E')273 config_set('ItemBallOffset', '650')274 config_set('ItemBallCount', '10')275 config_set('ItemTMOffset', '690')276 config_set('ItemTMCount', '40')277 config_set('ItemBerriesOffset', '790')278 config_set('ItemBerriesCount', '2E')279 config_set('FlagsOffset', '1270')280 config_set('BadgeFlag', '867') # 10E:7281 config_set('IwramMusicAddr', sym_get('sCurrentMapMusic'))282 config_set('EvolutionMusicIds', '178 179')283 # Skip rival name284 config_set('CurrentAreaAddr', f'{elf.get_sym("gMapHeader").st_value:X}+14')285 config_set('gBattleTypeFlags', f'{elf.get_sym("gBattleTypeFlags").st_value:X}')286 config_set('gTrainerBattleOpponent_A', f'{(elf.get_sym("gTrainerBattleOpponent_A") or elf.get_sym("gTrainerBattleOpponent")).st_value:X}')287 config_set('gEnemyParty', f'{elf.get_sym("gEnemyParty").st_value:X}')288 config_set('gBattlersCount', f'{elf.get_sym("gBattlersCount").st_value:X}')289 config_set('gBattlerPartyIndexes', f'{elf.get_sym("gBattlerPartyIndexes").st_value:X}')290 config_set('gBattlerPositions', f'{(elf.get_sym("gBattlerPositions") or elf.get_sym("gBanksBySide")).st_value:X}')291 gBattleMons = elf.get_sym("gBattleMons")292 config_set('gBattleMons', f'{gBattleMons.st_value:X}')293 config_set('gBattleMonsBytes', f'{get_size_rawasm(gBattleMons):X}')294 if is_rs:295 config_set('InBattleAddr', f'{elf.get_sym("gMain").st_value:X}+43D')296 else:297 config_set('InBattleAddr', f'{elf.get_sym("gMain").st_value:X}+439')298 print('done')299 print('writing config... ', end='', flush=True)300 config.write(args.output, space_around_delimiters=False)301 print('done')302 print('Process complete!')303def main():304 parser = argparse.ArgumentParser()305 parser.add_argument('elf', type=Elf.from_filename)306 parser.add_argument('output', type=argparse.FileType('w'))307 parser.add_argument('--code', default='BPEE')308 parser.add_argument('--name', default='TriHard Emerald (English)')309 args = parser.parse_args()310 pgegen(args)311if __name__ == '__main__':...

Full Screen

Full Screen

validation.py

Source:validation.py Github

copy

Full Screen

...133 'regex:%s' % common.REF_CONFIG_SET_RGX.pattern,134 *args, **kwargs)135def self_rule(*args, **kwargs):136 """Shortcut for rule() for current appid."""137 return rule(common.self_config_set(), *args, **kwargs)138def is_defined_for(config_set, path):139 """Returns True if validation is defined for given config_set and path."""140 return DEFAULT_RULE_SET.is_defined_for(config_set, path)141def validate(config_set, path, content, ctx=None):142 """Validates a config.143 If ctx is not specified, raises a ValueError on a first validation error.144 """145 DEFAULT_RULE_SET.validate(config_set, path, content, ctx=ctx)146def is_valid(config_set, path, content):147 """Returns True if the config is valid."""148 try:149 validate(config_set, path, content)150 return True151 except ValueError:...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful