def extract_code_from_args(args):
    """
    Extracts the access code from the arguments dictionary (given back
    from github)
    """
    if args is None:
        raise_error("Couldn't extract GitHub authentication code "
                    "from response")

    # TODO: Is there a case where the length of the error will be < 0?
    error = args.get("error_description", None)
    if error is not None:
        if len(error) >= 0:
            raise_github_error(error)
        else:
            raise_error("Something went wrong")

    access_code = args.get("code", None)

    # access_code is supposed to be a list with 1 thing in it
    if not isinstance(access_code, list) or access_code[0] is None or \
            len(access_code) != 1 or len(access_code[0]) <= 0:

        raise_error("Couldn't extract GitHub authentication code from "
                    "response")

    # If we get here, everything was good - no errors
    access_code = access_code[0].decode('ascii')
    return access_code
Extracts the access code from the arguments dictionary (given back
    from github)