(url, username=None, password=None, token=None, data=None,
    OTP=None, headers=None, params=None, files=None)
return r
Query GitHub API.

    In case of a multipage result, DOES NOT query the next page.
Query GitHub API.
Query GitHub API .
def query_GitHub(url, username=None, password=None, token=None, data=None,
    OTP=None, headers=None, params=None, files=None):
    """
    Query GitHub API.

    In case of a multipage result, DOES NOT query the next page.

    """
    headers = headers or {}

    if OTP:
        headers['X-GitHub-OTP'] = OTP

    if token:
        auth = OAuth2(client_id=username, token=dict(access_token=token,
            token_type='bearer'))
    else:
        auth = HTTPBasicAuth(username, password)
    if data:
        r = requests.post(url, auth=auth, data=data, headers=headers,
            params=params, files=files)
    else:
        r = requests.get(url, auth=auth, headers=headers, params=params, stream=True)

    if r.status_code == 401:
        two_factor = r.headers.get('X-GitHub-OTP')
        if two_factor:
            print("A two-factor authentication code is required:", two_factor.split(';')[1].strip())
            OTP = raw_input("Authentication code: ")
            return query_GitHub(url, username=username, password=password,
                token=token, data=data, OTP=OTP)

        raise AuthenticationFailed("invalid username or password")

    r.raise_for_status()
    return r
def query_GitHub ( url , username = None , password = None , token = None , data = None , OTP = None , headers = None , params = None , files = None ) : headers = headers or { } if OTP : headers [ 'X-GitHub-OTP' ] = OTP if token : auth = OAuth2 ( client_id = username , token = dict ( access_token = token , token_type = 'bearer' ) ) else : auth = HTTPBasicAuth ( username , password ) if data : r = requests . post ( url , auth = auth , data = data , headers = headers , params = params , files = files ) else : r = requests . get ( url , auth = auth , headers = headers , params = params , stream = True ) if r . status_code == 401 : two_factor = r . headers . get ( 'X-GitHub-OTP' ) if two_factor : print ( "A two-factor authentication code is required:" , two_factor . split ( ';' ) [ 1 ] . strip ( ) ) OTP = raw_input ( "Authentication code: " ) return query_GitHub ( url , username = username , password = password , token = token , data = data , OTP = OTP ) raise AuthenticationFailed ( "invalid username or password" ) r . raise_for_status ( ) return r