def CreatePullRequest(
      self, access_token, codereview_issue_number, origin, description):
    """Creates a pull request.

    Args:
      access_token: string containing the github access token.
      codereview_issue_number: an integer or string containing the codereview
                               issue number.
      origin: a string containing the origin of the pull request e.g.
              "username:feature".
      description: a string containing the description.

    Returns:
      A boolean indicating the pull request was created.
    """
    title = b'{0!s}: {1:s}'.format(codereview_issue_number, description)
    body = (
        b'[Code review: {0!s}: {1:s}]'
        b'(https://codereview.appspot.com/{0!s}/)').format(
            codereview_issue_number, description)

    post_data = (
        b'{{\n'
        b'  "title": "{0:s}",\n'
        b'  "body": "{1:s}",\n'
        b'  "head": "{2:s}",\n'
        b'  "base": "master"\n'
        b'}}\n').format(title, body, origin)

    github_url = (
        u'https://api.github.com/repos/{0:s}/{1:s}/pulls?'
        u'access_token={2:s}').format(
            self._organization, self._project, access_token)

    request = urllib_request.Request(github_url)

    # This will change the request into a POST.
    request.add_data(post_data)

    try:
      url_object = urllib_request.urlopen(request)
    except urllib_error.HTTPError as exception:
      logging.error(
          u'Failed creating pull request: {0!s} with error: {1:s}'.format(
              codereview_issue_number, exception))
      return False

    if url_object.code not in (200, 201):
      logging.error(
          u'Failed creating pull request: {0!s} with status code: {1:d}'.format(
              codereview_issue_number, url_object.code))
      return False

    return True
dataset/ETHPy150Open log2timeline/dfvfs/utils/review.py/GitHubHelper.CreatePullRequest/original