def _auto_compile(self, template, use_format=False):
        """Compile replacements."""

        is_replace = _is_replace(template)
        is_string = isinstance(template, (str, bytes))
        if is_replace and use_format != template.use_format:
            raise ValueError("Compiled replace cannot be a format object!")
        if is_replace or (is_string and self.auto_compile):
            return self.compile(template, (FORMAT if use_format and not is_replace else 0))
        elif is_string and use_format:
            # Reject an attempt to run format replace when auto-compiling
            # of template strings has been disabled and we are using a
            # template string.
            raise AttributeError('Format replaces cannot be called without compiling replace template!')
        else:
            return template
def _auto_compile ( self , template , use_format = False ) : is_replace = _is_replace ( template ) is_string = isinstance ( template , ( str , bytes ) ) if is_replace and use_format != template . use_format : raise ValueError ( "Compiled replace cannot be a format object!" ) if is_replace or ( is_string and self . auto_compile ) : return self . compile ( template , ( FORMAT if use_format and not is_replace else 0 ) ) elif is_string and use_format : raise AttributeError ( 'Format replaces cannot be called without compiling replace template!' ) else : return template
Compile replacements.