@staticmethod
  def FindPathByUuid(path, uuid, arch):
    def ViewfinderPath(uuid):
      p = os.path.join(_VIEWFINDER_DSYMS_UUID_PATH, uuid)
      if not os.path.exists(p):
        return None
      p = open(p).read().strip();
      if not p:
        return None
      return os.path.join(_VIEWFINDER_DSYMS_PATH, p, _VIEWFINDER_DSYMS_SUFFIX)

    def DsymForUuid(path, uuid, arch):
      dwarfdump = subprocess.Popen(
          ['dwarfdump', '--arch=%s' % arch, '--uuid', path],
          stdout=subprocess.PIPE, stderr=subprocess.PIPE)
      for line in dwarfdump.stdout:
        if uuid in line:
          return ' '.join(line.strip().split(' ')[3:])
      return None

    try:
      p = uuid_cache[uuid]
    except KeyError:
      p = ViewfinderPath(uuid)

      if not p:
        mdfind = subprocess.Popen(
            ['mdfind', 'com_apple_xcode_dsym_uuids = ' + uuid],
            stdout=subprocess.PIPE)

        try:
          p = iter(mdfind.stdout).next()[:-1] # Strip \n
          if p.endswith(".xcarchive"):
            dsym_folder = os.path.join(p, "dSYMs")
            dsyms = glob.glob(os.path.join(p, "dSYMs/*.dSYM"))
            # I only know how to handle the case for one dsym. I'm sure there's a
            # way to figure out which we want for multiple-dsym xcarchives (if such
            # a thing exists?).
            if len(dsyms) == 1:
              p = os.path.join(p, "dSYMs", dsyms[0])
            else:
              p = None
        except __HOLE__:
          p = None

        mdfind.wait()

      if p:
        # Translate the path to the dsym directory to the correct dsym file.
        p = DsymForUuid(p, uuid, arch)
      else:
        # Unable to find a dsym file, search through the symbol dirs looking for
        # an appropriately named library containing the desired uuid.
        global symbol_dirs
        for d in symbol_dirs:
          p = '%s/%s' % (d, path)
          if os.path.exists(p):
            p = DsymForUuid(p, uuid, arch)
            if p:
              break
          p = None

      uuid_cache[uuid] = p

    return p
dataset/ETHPy150Open viewfinderco/viewfinder/clients/ios/scripts/symbolicator.py/Symbolicator.FindPathByUuid