@classmethod
def compute_rewritestring(cls, strip_extensions=False, digestlength=None,
    keep_dirs=False, hashfun='sha1'):
    """
        >>> Rewriter.compute_rewritestring()
        '%(abspath|content|sha1|base64)s%(suffix)s'
        >>> Rewriter.compute_rewritestring(strip_extensions=True)
        '%(abspath|content|sha1|base64)s'
        >>> Rewriter.compute_rewritestring(digestlength=3)
        '%(abspath|content|sha1|base64|3)s%(suffix)s'
        """
    if hashfun == 'identity':
        return '%(relpath)s'
    initial = ['abspath', 'content', hashfun, 'base64']
    if digestlength:
        initial.append(str(digestlength))
    rewritestring = '%(' + '|'.join(initial) + ')s'
    if keep_dirs:
        rewritestring = '%(reldir)s' + rewritestring
    if not strip_extensions:
        rewritestring += '%(suffix)s'
    return rewritestring
