def _ComponentFromDirmd(json_data, subpath):
  """Returns the component for a subpath based on dirmd output.

  Returns an empty string if no component can be extracted

  Args:
    json_data: json object output from dirmd.
    subpath: The subpath for the directory being queried, e.g. src/storage'.
  """
  # If no component exists for the directory, or if METADATA migration is
  # incomplete there will be no component information.
  return json_data.get('dirs', {}).get(subpath,
                                       {}).get('monorail',
                                               {}).get('component', '')