'Helper function for _copy_create_ssl_vhost_skeleton to prepare the
new HTTPS VirtualHost contents. Currently disabling the rewrites'

def _sift_rewrite_rules(self, contents):

    result = []
    sift = False
    contents = iter(contents)
    comment = '#    Some    rewrite    rules    in    this    file    were    disabled    on    your    HTTPS    site,\n#    because    they    have    the    potential    to    create    redirection    loops.\n'
    for line in contents:
        A = line.lower().lstrip().startswith('rewritecond')
        B = line.lower().lstrip().startswith('rewriterule')
        if (not (A or B)):
            result.append(line)
            continue
        if (B and (not self._sift_rewrite_rule(line))):
            result.append(line)
            continue
        if (B and self._sift_rewrite_rule(line)):
            if (not sift):
                result.append(comment)
                sift = True
            result.append(('#    ' + line))
            continue
        chunk = []
        if A:
            chunk.append(line)
            line = next(contents)
            while (not line.lower().lstrip().startswith('rewriterule')):
                chunk.append(line)
                line = next(contents)
            chunk.append(line)
            if self._sift_rewrite_rule(line):
                if (not sift):
                    result.append(comment)
                    sift = True
                result.append('\n'.join([('#    ' + l) for l in chunk]))
                continue
            else:
                result.append('\n'.join(chunk))
                continue
    return (result, sift)
