def clean_lead_ws_description(metadata, field_name):
    """ Sometimes the metadata fields are a mess, this function is intended to remove the leading
    extra space some authors add in front of the 'description' field and to handle some other
    field cases.

    :param metadata: the metadata text
    :param field_name: the name of the field, like 'description'
    :rtype: string
    :return: the processed metadata
    """
    def calc_leading(line):
        return len(line.lstrip()) - len(line)

    def most_common(lst):
        return max(set(lst), key=lst.count)

    if field_name.lower() == 'description':
        leading_ws_count = [calc_leading(line) for line in metadata.splitlines()]
        most_common_ws_count = most_common(leading_ws_count)

        strip_split = metadata.strip().splitlines()
        return '\n'.join([line[most_common_ws_count:] if line.startswith(' ' * most_common_ws_count) else line
                          for line in strip_split])
    else:
        return ' '.join([line.strip() for line in metadata.splitlines()])
dataset/ETHPy150Open perone/stallion/stallion/metadata.py/clean_lead_ws_description/swapped operands of `-`