tools/variations/cleanup_stale_fieldtrial_configs.py
def is_literal_used(literal):
  """Check if a given string literal is used in the codebase."""
  if literal in _LITERAL_CACHE:
    return _LITERAL_CACHE[literal]

  git_grep_cmd = ('git', 'grep', '--threads', '2', '-l', '\"%s\"' % literal)
  git_grep_proc = subprocess.Popen(git_grep_cmd, stdout=subprocess.PIPE)
  # Check for >1 since fieldtrial_testing_config.json will always be a result.
  if len(git_grep_proc.stdout.read().splitlines()) > 1:
    _LITERAL_CACHE[literal] = True
    return True

  bash_find_cmd = ('bash', '-c', 'find', '.', '-type', 'f', '|', 'grep', '-E',
                   '\"\\.(h|cc)$\"', '|', 'grep', '-E',
                   '\"(/out/|/build/|/gen/)\"', '|', 'xargs', 'grep', '-l',
                   '\\\"%s\\\"' % literal)
  bash_find_proc = subprocess.Popen(bash_find_cmd, stdout=subprocess.PIPE)
  used = len(bash_find_proc.stdout.read().splitlines()) > 0
  _LITERAL_CACHE[literal] = used
  if not used:
    print('Did not find', repr(literal))

  return used
Check if a given string literal is used in the codebase.
Check if a given string literal is used in the codebase.
Check if a given string literal is used in the codebase .
def is_literal_used(literal):
  if literal in _LITERAL_CACHE:
    return _LITERAL_CACHE[literal]
  git_grep_cmd = ('git', 'grep', '--threads', '2', '-l', '\"%s\"' % literal)
  git_grep_proc = subprocess.Popen(git_grep_cmd, stdout=subprocess.PIPE)
  if len(git_grep_proc.stdout.read().splitlines()) > 1:
    _LITERAL_CACHE[literal] = True
    return True
  bash_find_cmd = ('bash', '-c', 'find', '.', '-type', 'f', '|', 'grep', '-E',
                   '\"\\.(h|cc)$\"', '|', 'grep', '-E',
                   '\"(/out/|/build/|/gen/)\"', '|', 'xargs', 'grep', '-l',
                   '\\\"%s\\\"' % literal)
  bash_find_proc = subprocess.Popen(bash_find_cmd, stdout=subprocess.PIPE)
  used = len(bash_find_proc.stdout.read().splitlines()) > 0
  _LITERAL_CACHE[literal] = used
  if not used:
    print('Did not find', repr(literal))
  return used
def is_literal_used ( literal ) : if literal in _LITERAL_CACHE : return _LITERAL_CACHE [ literal ] git_grep_cmd = ( 'git' , 'grep' , '--threads' , '2' , '-l' , '\"%s\"' % literal ) git_grep_proc = subprocess . Popen ( git_grep_cmd , stdout = subprocess . PIPE ) if len ( git_grep_proc . stdout . read ( ) . splitlines ( ) ) > 1 : _LITERAL_CACHE [ literal ] = True return True bash_find_cmd = ( 'bash' , '-c' , 'find' , '.' , '-type' , 'f' , '|' , 'grep' , '-E' , '\"\\.(h|cc)$\"' , '|' , 'grep' , '-E' , '\"(/out/|/build/|/gen/)\"' , '|' , 'xargs' , 'grep' , '-l' , '\\\"%s\\\"' % literal ) bash_find_proc = subprocess . Popen ( bash_find_cmd , stdout = subprocess . PIPE ) used = len ( bash_find_proc . stdout . read ( ) . splitlines ( ) ) > 0 _LITERAL_CACHE [ literal ] = used if not used : print ( 'Did not find' , repr ( literal ) ) return used
Check if a given string literal is used in the codebase.
Check if a given string literal is used in the codebase .
"""Check if a given string literal is used in the codebase.""" # Check for >1 since fieldtrial_testing_config.json will always be a result.
literal