def _ExpandDirectories(filenames):
 expanded = set()
 for filename in filenames:
  if (not os.path.isdir(filename)):
   expanded.add(filename)
   continue
  for (root, _, files) in os.walk(filename):
   for loopfile in files:
    fullname = os.path.join(root, loopfile)
    if fullname.startswith(('.' + os.path.sep)):
     fullname = fullname[len(('.' + os.path.sep)):]
    expanded.add(fullname)
 filtered = []
 for filename in expanded:
  if (os.path.splitext(filename)[1][1:] in GetAllExtensions()):
   filtered.append(filename)
 return filtered

def _ExpandDirectories ( filenames ) : expanded = set ( ) for filename in filenames : if ( not os . path . isdir ( filename ) ) : expanded . add ( filename ) continue for ( root , _ , files ) in os . walk ( filename ) : for loopfile in files : fullname = os . path . join ( root , loopfile ) if fullname . startswith ( ( '.' + os . path . sep ) ) : fullname = fullname [ len ( ( '.' + os . path . sep ) ) : ] expanded . add ( fullname ) filtered = [ ] for filename in expanded : if ( os . path . splitext ( filename ) [ 1 ] [ 1 : ] in GetAllExtensions ( ) ) : filtered . append ( filename ) return filtered
searches a list of filenames and replaces directories in the list with all files descending from those directories .