def get_issue_metadata(issue=None, current_branch=None, server=CODE_REVIEW):
    """Gets metadata JSON for a code review issue.

    Args:
        issue: Integer; containing an ID of a code review issue. Defaults to
            None and in this case is replaced by a call to get_current_issue.
        current_branch: String; containing the name of a branch.
            Defaults to None.
        server: String; the address of the Rietveld server hosting the code
            review. Defaults to CODE_REVIEW.

    Returns:
        Parsed dictionary from JSON payload.

    Raises:
        GitRvException: If the API request for the issue info does not return a
            200 status code.
    """
    issue = issue or get_current_issue(current_branch=current_branch)
    issue_path = ISSUE_URI_PATH_TEMPLATE % {ISSUE: issue}

    # TODO(dhermes): httplib doesn't check certs, should we use a different
    #                library not packaged in stdlib? SSL must be used because
    #                without it the API request returns a 301.
    with contextlib.closing(httplib.HTTPSConnection(server)) as connection:
      connection.request('GET', issue_path)

      response = connection.getresponse()
      if response.status != 200:
          template_values = {ISSUE: issue, SERVER: server,
                             STATUS: response.status,
                             REASON: response.reason}
          raise GitRvException(ISSUE_INFO_ERROR_TEMPLATE % template_values)

      payload = response.read()

    return json.loads(payload)
dataset/ETHPy150Open googlearchive/git-rv/utils.py/get_issue_metadata/original