import re


def get_conf_line_hash(line):
    """
    Removes whitespace, lowercases, comments and sorts params if present.
    Returns empty line for comment-only lines

    We don't care about order of params and kinds of whitespace in config lines
    so normalize it to compare. We do care about case in paths, but to simplify
    testing we pretend we don't.
    """

    def sort_params(params):
        return ",".join(sorted(params.split(",")))

    line = line.split("#")[0]

    params_pattern = re.compile(r"(.*?\s)(\S+=\S+)")
    match = params_pattern.search(line)
    if match:
        sorted_params = sort_params(match.group(2))
        line = match.group(1) + sorted_params

    return "".join(line.lower().split())