def register_prompt_expansion(self, key, func):
        """Register a percent-expansion function for the prompt format method. The
        function must take one argument, and return a string. The argument is
        the character expanded on.
        """
        key = str(key)[0]
        if not key in self._PROMPT_EXPANSIONS:
            self._PROMPT_EXPANSIONS[key] = func
        else:
            raise ValueError("expansion key %r already exists." % (key, ))
dataset/ETHPy150Open kdart/pycopia/CLI/pycopia/UI.py/UserInterface.register_prompt_expansion/original