def field2token()

in metropolis/metropolis.py [0:0]


    def field2token(self, table_name: str, field: str, query: Any) -> List[str]:
        """This function queries all records for a certain field value, and returns
        the tokens for the matching records.

        Warning: this runs in linear time.

        Args:
            table_name: Table name.
            field: Field name. See README.md for details.
            query: Query to match against. Needs to type match the content of the
                query field.

        Returns:
            List of tokens for the matching records.
        """
        matches = []
        for member in getattr(self, table_name):
            if member[field] == query:
                matches.append(member["token"])
        return matches