@classmethod<EOL><INDENT>def from_table_index(cls, table, index):<DEDENT>
attributes = None<EOL>if index.range_key is None:<EOL><INDENT>range_key = None<EOL><DEDENT>else:<EOL><INDENT>range_key = index.range_key.name<EOL><DEDENT>if hasattr(index, "<STR_LIT>"):<EOL><INDENT>is_global = True<EOL>hash_key = index.hash_key.name<EOL><DEDENT>else:<EOL><INDENT>hash_key = table.hash_key.name<EOL>is_global = False<EOL><DEDENT>if index.projection_type in ("<STR_LIT>", "<STR_LIT>"):<EOL><INDENT>attributes = set([table.hash_key.name])<EOL>if table.range_key is not None:<EOL><INDENT>attributes.add(table.range_key.name)<EOL><DEDENT>if getattr(index, "<STR_LIT>", None) is not None:<EOL><INDENT>attributes.add(index.hash_key.name)<EOL><DEDENT>if index.range_key is not None:<EOL><INDENT>attributes.add(index.range_key.name)<EOL><DEDENT>if index.include_fields is not None:<EOL><INDENT>attributes.update(index.include_fields)<EOL><DEDENT><DEDENT>return cls(index.name, is_global, hash_key, range_key, attributes)<EOL>
Factory method