import json


def LoadEmulatedDevices(registry):
  """Loads a list of emulated devices from the DevTools JSON registry.

  See, for example, third_party/WebKit/Source/devtools/front_end
  /emulated_devices/module.json.

  Args:
    registry: A file-like object for the device registry (should be JSON).

  Returns:
    {'device_name': device}
  """
  json_dict = json.load(registry)
  devices = {}
  for device in json_dict['extensions']:
    device = device['device']
    devices[device['title']] = device
  return devices