def _find_stats(self): stats = self._character['Stats'] if '$id' in stats: return stats ref = stats['$ref'] return search_recursively(self._party_data, ref, id_matches)
def test_in_dict_match(): data = {'blah': expected_node} result = search_recursively(data, expected_key, example_algorithm) assert result == expected_node
def test_deeply_nested_match(): data = {'blah': ['blarg', None, {'foo': ['jar', {'blob': expected_node}]}]} result = search_recursively(data, expected_key, example_algorithm) assert result == expected_node
def test_in_array_match(): data = ['blarg', {'foo': 'bar'}, expected_node] result = search_recursively(data, expected_key, example_algorithm) assert result == expected_node
def test_no_match(): data = {'blah': ['blarg', {'foo': 'bar'}]} result = search_recursively(data, expected_key, example_algorithm) assert result == None
def test_top_node_match(): result = search_recursively(expected_node, expected_key, example_algorithm) assert result == expected_node
def _find_character(self): return search_recursively(self._party_data, self._key, _key_matches)
def _search_for_player(entity): if 'Stats' in entity['Descriptor']: return entity['Descriptor'] ref = entity['Descriptor']['$ref'] return search_recursively(entity, ref, id_matches)