def initialize_nick_templates(in_template, out_template):
 regex_string = fnmatch.translate(in_template)
 regex_string = (regex_string[:(-7)] + '(?:[\\n\\r]*?)\\Z(?ms)')
 regex_args = [match.group(2) for match in _RE_NICK_ARG.finditer(regex_string)]
 temp_args = [match.group(2) for match in _RE_NICK_TEMPLATE_ARG.finditer(out_template)]
 if (set(regex_args) != set(temp_args)):
  raise NickTemplateInvalid
 regex_string = _RE_NICK_SPACE.sub('\\s+', regex_string)
 regex_string = _RE_NICK_ARG.sub((lambda m: ('(?P<arg%s>.+?)' % m.group(2))), regex_string)
 template_string = _RE_NICK_TEMPLATE_ARG.sub((lambda m: ('{arg%s}' % m.group(2))), out_template)
 return (regex_string, template_string)

def initialize_nick_templates ( in_template , out_template ) : regex_string = fnmatch . translate ( in_template ) regex_string = ( regex_string [ : ( - 7 ) ] + '(?:[\\n\\r]*?)\\Z(?ms)' ) regex_args = [ match . group ( 2 ) for match in _RE_NICK_ARG . finditer ( regex_string ) ] temp_args = [ match . group ( 2 ) for match in _RE_NICK_TEMPLATE_ARG . finditer ( out_template ) ] if ( set ( regex_args ) != set ( temp_args ) ) : raise NickTemplateInvalid regex_string = _RE_NICK_SPACE . sub ( '\\s+' , regex_string ) regex_string = _RE_NICK_ARG . sub ( ( lambda m : ( '(?P<arg%s>.+?)' % m . group ( 2 ) ) ) , regex_string ) template_string = _RE_NICK_TEMPLATE_ARG . sub ( ( lambda m : ( '{arg%s}' % m . group ( 2 ) ) ) , out_template ) return ( regex_string , template_string )
initialize the nick templates for matching and remapping a string .