:py:mod:`idaes_flowsheet_processor.util` ======================================== .. py:module:: idaes_flowsheet_processor.util .. autoapi-nested-parse:: Utility functions. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: idaes_flowsheet_processor.util.ShortPrefix .. py:class:: ShortPrefix(words, lowercase: bool = True) Map unique prefixes to words. Usage: >>> sp = ShortPrefix(["apple", "banana", "apricot", "berry"]) >>> sp.match("app") # Returns "apple" >>> sp.match("ap") # Returns [] (ambiguous) >>> sp.match("ban") # Returns "banana" >>> sp.match("b") # Returns None (ambiguous) >>> sp.could_be("ap") # Returns ["apple", "apricot"] >>> sp.could_be("b") # Returns ["banana", "berry"] >>> sp.could_be("c") # Returns [] (no matches) .. py:property:: words :type: list[str] Get the list of words that were used to construct the prefix map. .. py:method:: match(s: str) -> Union[str, None] Find the unique word for a given prefix string. :returns: The unique word that matches the prefix, or None if no unique word, or any word, matches. :rtype: str or None .. py:method:: could_be(s: str) -> list[str] Find all words that _could_ match a given prefix string. Note that this will not return words that are unambiguous matches. Put another way, if :meth:`match` returns a word for this input, then this method will return an empty list. :returns: A list of words that could match the prefix. :rtype: list of str