def list_files(targets=[], ftypes=[], use_shebang=True, modified_only=False, exclude=[], group_by_ftype=False, extless_only=False):
 ftypes = [x.strip('.') for x in ftypes]
 ftypes_set = set(ftypes)
 repository_root = subprocess.check_output(['git', 'rev-parse', '--show-toplevel']).strip().decode('utf-8')
 exclude_abspaths = [os.path.join(repository_root, fpath).rstrip('/') for fpath in exclude]
 cmdline = (['git', 'ls-files'] + targets)
 if modified_only:
  cmdline.append('-m')
 files_gen = (x.strip() for x in subprocess.check_output(cmdline, universal_newlines=True).split('\n'))
 files = list(filter(os.path.isfile, files_gen))
 result_dict = defaultdict(list)
 result_list = []
 for fpath in files:
  ext = os.path.splitext(fpath)[1]
  if (extless_only and ext):
   continue
  absfpath = abspath(fpath)
  if any((((absfpath == expath) or absfpath.startswith((expath + '/'))) for expath in exclude_abspaths)):
   continue
  if (ftypes or group_by_ftype):
   try:
    filetype = get_ftype(fpath, use_shebang)
   except (OSError, UnicodeDecodeError) as e:
    etype = e.__class__.__name__
    print(('Error: %s while determining type of file "%s":' % (etype, fpath)), file=sys.stderr)
    print(e, file=sys.stderr)
    filetype = ''
   if (ftypes and (filetype not in ftypes_set)):
    continue
  if group_by_ftype:
   result_dict[filetype].append(fpath)
  else:
   result_list.append(fpath)
 if group_by_ftype:
  return result_dict
 else:
  return result_list

def list_files ( targets = [ ] , ftypes = [ ] , use_shebang = True , modified_only = False , exclude = [ ] , group_by_ftype = False , extless_only = False ) : ftypes = [ x . strip ( '.' ) for x in ftypes ] ftypes_set = set ( ftypes ) repository_root = subprocess . check_output ( [ 'git' , 'rev-parse' , '--show-toplevel' ] ) . strip ( ) . decode ( 'utf-8' ) exclude_abspaths = [ os . path . join ( repository_root , fpath ) . rstrip ( '/' ) for fpath in exclude ] cmdline = ( [ 'git' , 'ls-files' ] + targets ) if modified_only : cmdline . append ( '-m' ) files_gen = ( x . strip ( ) for x in subprocess . check_output ( cmdline , universal_newlines = True ) . split ( '\n' ) ) files = list ( filter ( os . path . isfile , files_gen ) ) result_dict = defaultdict ( list ) result_list = [ ] for fpath in files : ext = os . path . splitext ( fpath ) [ 1 ] if ( extless_only and ext ) : continue absfpath = abspath ( fpath ) if any ( ( ( ( absfpath == expath ) or absfpath . startswith ( ( expath + '/' ) ) ) for expath in exclude_abspaths ) ) : continue if ( ftypes or group_by_ftype ) : try : filetype = get_ftype ( fpath , use_shebang ) except ( OSError , UnicodeDecodeError ) as e : etype = e . __class__ . __name__ print ( ( 'Error: %s while determining type of file "%s":' % ( etype , fpath ) ) , file = sys . stderr ) print ( e , file = sys . stderr ) filetype = '' if ( ftypes and ( filetype not in ftypes_set ) ) : continue if group_by_ftype : result_dict [ filetype ] . append ( fpath ) else : result_list . append ( fpath ) if group_by_ftype : return result_dict else : return result_list
returns a list of all files in pylearn2 with the given suffix .