def normalize(input, case_mapping=protocol.DEFAULT_CASE_MAPPING):
    """ Normalize input according to case mapping. """
    if case_mapping not in protocol.CASE_MAPPINGS:
        raise pydle.protocol.ProtocolViolation('Unknown case mapping ({})'.format(case_mapping))

    input = input.lower()

    if case_mapping in ('rfc1459', 'rfc1459-strict'):
        input = input.replace('{', '[').replace('}', ']').replace('|', '\\')
    if case_mapping == 'rfc1459':
        input = input.replace('~', '^')

    return input
def normalize ( input , case_mapping = protocol . DEFAULT_CASE_MAPPING ) : if case_mapping not in protocol . CASE_MAPPINGS : raise pydle . protocol . ProtocolViolation ( 'Unknown case mapping ({})' . format ( case_mapping ) ) input = input . lower ( ) if case_mapping in ( 'rfc1459' , 'rfc1459-strict' ) : input = input . replace ( '{' , '[' ) . replace ( '}' , ']' ) . replace ( '|' , '\\' ) if case_mapping == 'rfc1459' : input = input . replace ( '~' , '^' ) return input
Normalize input according to case mapping.