def _replace_conditional(match, string):
 conditional_match = _CONDITIONAL.search(string)
 while conditional_match:
  start = conditional_match.start()
  end = _find_closing_brace(string, (start + 4))
  args = _split_conditional(string[(start + 4):(end - 1)])
  rv = ''
  if match.group(int(conditional_match.group(1))):
   rv = unescape(_replace_conditional(match, args[0]))
  elif (len(args) > 1):
   rv = unescape(_replace_conditional(match, args[1]))
  string = ((string[:start] + rv) + string[end:])
  conditional_match = _CONDITIONAL.search(string)
 return string

def _replace_conditional ( match , string ) : conditional_match = _CONDITIONAL . search ( string ) while conditional_match : start = conditional_match . start ( ) end = _find_closing_brace ( string , ( start + 4 ) ) args = _split_conditional ( string [ ( start + 4 ) : ( end - 1 ) ] ) rv = '' if match . group ( int ( conditional_match . group ( 1 ) ) ) : rv = unescape ( _replace_conditional ( match , args [ 0 ] ) ) elif ( len ( args ) > 1 ) : rv = unescape ( _replace_conditional ( match , args [ 1 ] ) ) string = ( ( string [ : start ] + rv ) + string [ end : ] ) conditional_match = _CONDITIONAL . search ( string ) return string
replaces a conditional match in a transformation .