def condition2checker(condition):
 if (type(condition) in [str, unicode]):
  def smatcher(info):
   return fnmatch.fnmatch(info.filename, condition)
  return smatcher
 elif ((type(condition) in [list, tuple]) and (type(condition[0]) in [int, long])):
  def imatcher(info):
   return (info.index in condition)
  return imatcher
 elif callable(condition):
  return condition
 else:
  raise TypeError

def condition2checker ( condition ) : if ( type ( condition ) in [ str , unicode ] ) : def smatcher ( info ) : return fnmatch . fnmatch ( info . filename , condition ) return smatcher elif ( ( type ( condition ) in [ list , tuple ] ) and ( type ( condition [ 0 ] ) in [ int , long ] ) ) : def imatcher ( info ) : return ( info . index in condition ) return imatcher elif callable ( condition ) : return condition else : raise TypeError
converts different condition types to callback .