Gets a formatting template which can be used to efficiently
        format a partial number where digits are added one by one.

def _get_formatting_template(self, number_pattern, number_format):
        """Gets a formatting template which can be used to efficiently
        format a partial number where digits are added one by one."""
        # Create a phone number consisting only of the digit 9 that matches the
        # number_pattern by applying the pattern to the longest_phone_number string.
        longest_phone_number = unicod("999999999999999")
        number_re = re.compile(number_pattern)
        m = number_re.search(longest_phone_number)  # this will always succeed
        a_phone_number = m.group(0)
        # No formatting template can be created if the number of digits
        # entered so far is longer than the maximum the current formatting
        # rule can accommodate.
        if len(a_phone_number) < len(self._national_number):
            return U_EMPTY_STRING
        # Formats the number according to number_format
        template = re.sub(number_pattern, number_format, a_phone_number)
        # Replaces each digit with character _DIGIT_PLACEHOLDER
        template = re.sub("9", _DIGIT_PLACEHOLDER, template)
        return template