def gather_filenames(arglist):
 l = []
 for filename in arglist:
  if os.path.isdir(filename):
   thislist = []
   for (dirpath, dirnames, filenames) in os.walk(filename):
    for f in filenames:
     if _is_valid_filename(f):
      f = os.path.join(dirpath, f)
      thislist.append(f)
   thislist.sort()
   l.extend(thislist)
  else:
   l.append(filename)
 return l

def gather_filenames ( arglist ) : l = [ ] for filename in arglist : if os . path . isdir ( filename ) : thislist = [ ] for ( dirpath , dirnames , filenames ) in os . walk ( filename ) : for f in filenames : if _is_valid_filename ( f ) : f = os . path . join ( dirpath , f ) thislist . append ( f ) thislist . sort ( ) l . extend ( thislist ) else : l . append ( filename ) return l
collect script files from within directories .