(aiatools3) ewpatton@mbp2:aiatools (master)$ ipython Python 3.6.5 (default, Jun 25 2018, 11:04:29) Type 'copyright', 'credits' or 'license' for more information IPython 6.4.0 -- An enhanced Interactive Python. Type '?' for help. In [1]: from aiatools import * In [2]: Button Out[2]: aiatools.component_types.Button In [3]: procedures_callnoreturn Out[3]: BlockType('procedures_callnoreturn', aiatools.block_types.Procedures, ) In [4]: aia = AIAFile('test_aias/Yahtzee5.aia') In [5]: aia.blocks().count() Out[5]: 1245 In [6]: aia.blocks().count(group_by=type) Out[6]: {'component_event': 23, 'procedures_callnoreturn': 26, 'procedures_defnoreturn': 5, 'component_set_get': 151, 'logic_false': 63, 'lexical_variable_set': 79, 'math_number': 255, 'logic_boolean': 40, 'lexical_variable_get': 178, 'text': 76, 'controls_if': 83, 'logic_compare': 70, 'lists_select_item': 34, 'logic_operation': 24, 'text_compare': 13, 'local_declaration_statement': 7, 'lists_create_with': 5, 'controls_forRange': 12, 'math_add': 32, 'lists_insert_item': 3, 'math_compare': 25, 'component_method': 7, 'math_multiply': 6, 'lists_replace_item': 5, 'math_random_int': 10, 'math_subtract': 2, 'text_join': 1, 'global_declaration': 10} In [7]: aia.components().count(group_by=type) Out[7]: {aiatools.component_types.Form: 1, aiatools.component_types.TableArrangement: 1, aiatools.component_types.HorizontalArrangement: 22, aiatools.component_types.Notifier: 2, aiatools.component_types.Button: 20, aiatools.component_types.Label: 31, aiatools.component_types.VerticalArrangement: 5} In [8]: aia.blocks(type == global_declaration) Out[8]: [Block('1027', 'global_declaration'), Block('1134', 'global_declaration'), Block('1187', 'global_declaration'), Block('1221', 'global_declaration'), Block('1223', 'global_declaration'), Block('1236', 'global_declaration'), Block('1238', 'global_declaration'), Block('1240', 'global_declaration'), Block('1242', 'global_declaration'), Block('1244', 'global_declaration')] In [9]: aia.blocks(type == global_declaration).count() Out[9]: 10 In [10]: aia.blocks(type == global_declaration).map(fields.NAME) Out[10]: ['Hold1', 'Hold2', 'diceValues', 'Hold3', 'diceHold', 'Hold4', 'spinsLeft', 'Hold5', 'buttonPressed', 'buttonsFilled'] In [11]: aia.blocks(type == is_procedure) Out[11]: [] In [12]: aia.blocksis_procedure) File "", line 1 aia.blocksis_procedure) ^ SyntaxError: invalid syntax In [13]: aia.blocks(is_procedure) Out[13]: [Block('3', 'procedures_defnoreturn'), Block('104', 'procedures_defnoreturn'), Block('316', 'procedures_defnoreturn'), Block('652', 'procedures_defnoreturn'), Block('916', 'procedures_defnoreturn')] In [14]: aia.blocks(is_procedure).map(fields.NAME) Out[14]: ['ResetValues', 'updateDice', 'CheckSingles', 'spinCleanUp', 'updateLeftScore'] In [15]: aia.components(type == Button).map(fields.Name) Out[15]: [] In [16]: aia.components(type == Button).map(name) Out[16]: ['spinDice', 'ResetButton', 'onesValue', 'twosValue', 'threesValue', 'foursValue', 'fivesValue', 'sixesValue', 'kind3Value', 'kind4Value', 'ChanceValue', 'yahtzeeValue', 'fullHouseValue', 'smallStraightValue', 'largeStraightValue', 'Dice1', 'Dice2', 'Dice3', 'Dice4', 'Dice5'] In [17]: aia.components(type == Button)['ResetButton'] Out[17]: {} In [18]: aia.blocks(mutation.instance_name == 'ResetButton') Out[18]: [Block('1', 'component_event')] In [19]: aia.blocks(mutation.instance_name == 'ResetButton').map(mutation.event_name) Out[19]: ['Click'] In [20]: aia.blocks(mutation.instance_name == 'ResetButton').descendants().count() Out[20]: 2 In [21]: aia.blocks(mutation.event_name == Button.Click).map(height) Out[21]: [1, 3, 3, 8, 4, 3, 9, 3, 3, 4, 3, 10, 8, 7, 8, 4, 4, 4, 4, 4] In [22]: aia.blocks(mutation.event_name == Button.Click).map(len) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) in () ----> 1 aia.blocks(mutation.event_name == Button.Click).map(len) ~/Programming/mit/aiatools/aiatools/selectors.py in map(self, functor) 339 A list in the value space of ``functor``. 340 """ --> 341 return [functor(x) for x in self if functor(x) is not None] 342 343 def select(self, selector): ~/Programming/mit/aiatools/aiatools/selectors.py in (.0) 339 A list in the value space of ``functor``. 340 """ --> 341 return [functor(x) for x in self if functor(x) is not None] 342 343 def select(self, selector): TypeError: object of type 'Block' has no len() In [23]: aia.blocks(mutation.event_name == Button.Click).map(length) --------------------------------------------------------------------------- NameError Traceback (most recent call last) in () ----> 1 aia.blocks(mutation.event_name == Button.Click).map(length) NameError: name 'length' is not defined In [24]: aia.blocks(mutation.event_name == Button.Click) Out[24]: [Block('1', 'component_event'), Block('95', 'component_event'), Block('125', 'component_event'), Block('225', 'component_event'), Block('408', 'component_event'), Block('472', 'component_event'), Block('481', 'component_event'), Block('617', 'component_event'), Block('628', 'component_event'), Block('637', 'component_event'), Block('697', 'component_event'), Block('706', 'component_event'), Block('828', 'component_event'), Block('950', 'component_event'), Block('1029', 'component_event'), Block('1117', 'component_event'), Block('1136', 'component_event'), Block('1153', 'component_event'), Block('1170', 'component_event'), Block('1204', 'component_event')] In [25]: aia.blocks(mutation.event_name == Button.Click).map(lambda x: len(select(x).descendants())) Out[25]: [2, 9, 9, 91, 64, 9, 136, 9, 9, 15, 9, 122, 88, 77, 88, 17, 17, 17, 17, 17] In [26]: aia.blocks(mutation.event_name == Button.Click).blocks(lambda x: select(x).descendants().cou ...: nt() == 136) Out[26]: [Block('481', 'component_event')] In [27]: aia.blocks(mutation.event_name == Button.Click).blocks(lambda x: select(x).descendants().cou ...: nt() == 136).descendants() Out[27]: [Block('481', 'component_event'), Block('482', 'lexical_variable_set'), Block('483', 'text'), Block('484', 'controls_if'), Block('485', 'logic_compare'), Block('486', 'lexical_variable_get'), Block('487', 'math_number'), Block('488', 'local_declaration_statement'), Block('489', 'math_number'), Block('490', 'logic_false'), Block('491', 'lists_create_with'), Block('492', 'math_number'), Block('493', 'math_number'), Block('494', 'math_number'), Block('495', 'math_number'), Block('496', 'math_number'), Block('497', 'math_number'), Block('498', 'math_number'), Block('499', 'math_number'), Block('500', 'controls_forRange'), Block('501', 'math_number'), Block('502', 'math_number'), Block('503', 'math_number'), Block('504', 'controls_forRange'), Block('505', 'math_number'), Block('506', 'math_number'), Block('507', 'math_number'), Block('508', 'controls_if'), Block('509', 'logic_compare'), Block('510', 'lists_select_item'), Block('511', 'lexical_variable_get'), Block('512', 'lexical_variable_get'), Block('513', 'lexical_variable_get'), Block('514', 'lexical_variable_set'), Block('515', 'math_add'), Block('516', 'lexical_variable_get'), Block('517', 'math_number'), Block('518', 'lists_insert_item'), Block('519', 'lexical_variable_get'), Block('520', 'lexical_variable_get'), Block('521', 'lexical_variable_get'), Block('522', 'lexical_variable_set'), Block('523', 'math_number'), Block('524', 'controls_if'), Block('525', 'logic_operation'), Block('526', 'math_compare'), Block('527', 'lists_select_item'), Block('528', 'lexical_variable_get'), Block('529', 'math_number'), Block('530', 'math_number'), Block('531', 'logic_operation'), Block('532', 'math_compare'), Block('533', 'lists_select_item'), Block('534', 'lexical_variable_get'), Block('535', 'math_number'), Block('536', 'math_number'), Block('537', 'logic_operation'), Block('538', 'math_compare'), Block('539', 'lists_select_item'), Block('540', 'lexical_variable_get'), Block('541', 'math_number'), Block('542', 'math_number'), Block('543', 'math_compare'), Block('544', 'lists_select_item'), Block('545', 'lexical_variable_get'), Block('546', 'math_number'), Block('547', 'math_number'), Block('548', 'lexical_variable_set'), Block('549', 'logic_boolean'), Block('550', 'controls_if'), Block('551', 'logic_operation'), Block('552', 'math_compare'), Block('553', 'lists_select_item'), Block('554', 'lexical_variable_get'), Block('555', 'math_number'), Block('556', 'math_number'), Block('557', 'logic_operation'), Block('558', 'math_compare'), Block('559', 'lists_select_item'), Block('560', 'lexical_variable_get'), Block('561', 'math_number'), Block('562', 'math_number'), Block('563', 'logic_operation'), Block('564', 'math_compare'), Block('565', 'lists_select_item'), Block('566', 'lexical_variable_get'), Block('567', 'math_number'), Block('568', 'math_number'), Block('569', 'math_compare'), Block('570', 'lists_select_item'), Block('571', 'lexical_variable_get'), Block('572', 'math_number'), Block('573', 'math_number'), Block('574', 'lexical_variable_set'), Block('575', 'logic_boolean'), Block('576', 'controls_if'), Block('577', 'logic_operation'), Block('578', 'math_compare'), Block('579', 'lists_select_item'), Block('580', 'lexical_variable_get'), Block('581', 'math_number'), Block('582', 'math_number'), Block('583', 'logic_operation'), Block('584', 'math_compare'), Block('585', 'lists_select_item'), Block('586', 'lexical_variable_get'), Block('587', 'math_number'), Block('588', 'math_number'), Block('589', 'logic_operation'), Block('590', 'math_compare'), Block('591', 'lists_select_item'), Block('592', 'lexical_variable_get'), Block('593', 'math_number'), Block('594', 'math_number'), Block('595', 'math_compare'), Block('596', 'lists_select_item'), Block('597', 'lexical_variable_get'), Block('598', 'math_number'), Block('599', 'math_number'), Block('600', 'lexical_variable_set'), Block('601', 'logic_boolean'), Block('602', 'controls_if'), Block('603', 'math_compare'), Block('604', 'lexical_variable_get'), Block('605', 'logic_boolean'), Block('606', 'component_set_get'), Block('607', 'math_number'), Block('608', 'component_set_get'), Block('609', 'logic_false'), Block('610', 'procedures_callnoreturn'), Block('611', 'component_method'), Block('612', 'text'), Block('613', 'text'), Block('614', 'text'), Block('615', 'text'), Block('616', 'logic_false')] In [28]: aia.blocks(mutation.event_name == Button.Click).blocks(lambda x: select(x).descendants().cou ...: nt() == 136).descendants().map(lambda x: (kind(x), type(x))) Out[28]: [(, 'component_event'), (, 'lexical_variable_set'), (, 'text'), (, 'controls_if'), (, 'logic_compare'), (, 'lexical_variable_get'), (, 'math_number'), (, 'local_declaration_statement'), (, 'math_number'), (, 'logic_false'), (, 'lists_create_with'), (, 'math_number'), (, 'math_number'), (, 'math_number'), (, 'math_number'), (, 'math_number'), (, 'math_number'), (, 'math_number'), (, 'math_number'), (, 'controls_forRange'), (, 'math_number'), (, 'math_number'), (, 'math_number'), (, 'controls_forRange'), (, 'math_number'), (, 'math_number'), (, 'math_number'), (, 'controls_if'), (, 'logic_compare'), (, 'lists_select_item'), (, 'lexical_variable_get'), (, 'lexical_variable_get'), (, 'lexical_variable_get'), (, 'lexical_variable_set'), (, 'math_add'), (, 'lexical_variable_get'), (, 'math_number'), (, 'lists_insert_item'), (, 'lexical_variable_get'), (, 'lexical_variable_get'), (, 'lexical_variable_get'), (, 'lexical_variable_set'), (, 'math_number'), (, 'controls_if'), (, 'logic_operation'), (, 'math_compare'), (, 'lists_select_item'), (, 'lexical_variable_get'), (, 'math_number'), (, 'math_number'), (, 'logic_operation'), (, 'math_compare'), (, 'lists_select_item'), (, 'lexical_variable_get'), (, 'math_number'), (, 'math_number'), (, 'logic_operation'), (, 'math_compare'), (, 'lists_select_item'), (, 'lexical_variable_get'), (, 'math_number'), (, 'math_number'), (, 'math_compare'), (, 'lists_select_item'), (, 'lexical_variable_get'), (, 'math_number'), (, 'math_number'), (, 'lexical_variable_set'), (, 'logic_boolean'), (, 'controls_if'), (, 'logic_operation'), (, 'math_compare'), (, 'lists_select_item'), (, 'lexical_variable_get'), (, 'math_number'), (, 'math_number'), (, 'logic_operation'), (, 'math_compare'), (, 'lists_select_item'), (, 'lexical_variable_get'), (, 'math_number'), (, 'math_number'), (, 'logic_operation'), (, 'math_compare'), (, 'lists_select_item'), (, 'lexical_variable_get'), (, 'math_number'), (, 'math_number'), (, 'math_compare'), (, 'lists_select_item'), (, 'lexical_variable_get'), (, 'math_number'), (, 'math_number'), (, 'lexical_variable_set'), (, 'logic_boolean'), (, 'controls_if'), (, 'logic_operation'), (, 'math_compare'), (, 'lists_select_item'), (, 'lexical_variable_get'), (, 'math_number'), (, 'math_number'), (, 'logic_operation'), (, 'math_compare'), (, 'lists_select_item'), (, 'lexical_variable_get'), (, 'math_number'), (, 'math_number'), (, 'logic_operation'), (, 'math_compare'), (, 'lists_select_item'), (, 'lexical_variable_get'), (, 'math_number'), (, 'math_number'), (, 'math_compare'), (, 'lists_select_item'), (, 'lexical_variable_get'), (, 'math_number'), (, 'math_number'), (, 'lexical_variable_set'), (, 'logic_boolean'), (, 'controls_if'), (, 'math_compare'), (, 'lexical_variable_get'), (, 'logic_boolean'), (, 'component_set_get'), (, 'math_number'), (, 'component_set_get'), (, 'logic_false'), (, 'procedures_callnoreturn'), (, 'component_method'), (, 'text'), (, 'text'), (, 'text'), (, 'text'), (, 'logic_false')] In [29]: Do you really want to exit ([y]/n)? y