@gen.coroutine
def GetUDIDTimestamps(merged_store, files):
  """Iterate over all files and build a dict of UDID -> last-seen-timestamp."""
  last_seen = {}
  for f in files:
    # Let exceptions surface.
    contents = yield gen.Task(merged_store.Get, f)
    dev_list = json.loads(contents)
    for entry in dev_list:
      timestamp = entry['timestamp']
      # The device dict is found under different keys based on the operation (ping vs update user/device)
      device_dict = entry['request'].get('device', entry['request'].get('device_dict', None))
      if not device_dict:
        # Some User.RegisterOperation entries do not have a device_dict.
        continue

      udid = device_dict.get('test_udid', None)
      if not udid:
        continue
      prev_seen = last_seen.get(udid, 0)
      if timestamp > prev_seen:
        last_seen[udid] = timestamp

  raise gen.Return(last_seen)
dataset/ETHPy150Open viewfinderco/viewfinder/scripts/find_unused_provisioned_devices.py/GetUDIDTimestamps/original