parameters: (compilation_db, selection)
return_statement: return new_db
docstring: Return a new compilation database reduced to the paths in selection.
docstring_summary: Return a new compilation database reduced to the paths in selection.
docstring_tokens: Return a new compilation database reduced to the paths in selection .
function: def slice_compilation_db(compilation_db, selection):
      """ Return a new compilation database reduced to the paths in selection. """
      if not selection:
          return compilation_db
  
      # Canonicalize selection paths to match compilation database.
      selection = [os.path.realpath(p) for p in selection]
  
      new_db = []
      for path in selection:
          if not os.path.exists(path):
              print('warning: \'%s\' not found on disk.' % path, file=sys.stderr)
              continue
  
          found = [e for e in compilation_db if is_subpath_of(e['file'], path)]
          if not found:
              print('warning: \'%s\' not found in compilation database.' % path,
                    file=sys.stderr)
              continue
  
          new_db.extend(found)
  
      return new_db
function_tokens: def slice_compilation_db ( compilation_db , selection ) : if not selection : return compilation_db # Canonicalize selection paths to match compilation database. selection = [ os . path . realpath ( p ) for p in selection ] new_db = [ ] for path in selection : if not os . path . exists ( path ) : print ( 'warning: \'%s\' not found on disk.' % path , file = sys . stderr ) continue found = [ e for e in compilation_db if is_subpath_of ( e [ 'file' ] , path ) ] if not found : print ( 'warning: \'%s\' not found in compilation database.' % path , file = sys . stderr ) continue new_db . extend ( found ) return new_db