<s> from __future__ import absolute_import , division , print_function , unicode_literals <EOL> from liberapay . elsewhere . _base import PlatformOAuth2 <EOL> from liberapay . elsewhere . _exceptions import CantReadMembership <EOL> from liberapay . elsewhere . _extractors import key <EOL> from liberapay . elsewhere . _paginators import header_links_paginator <EOL> class GitHub ( PlatformOAuth2 ) : <EOL> name = '<STR_LIT>' <EOL> display_name = '<STR_LIT>' <EOL> account_url = '<STR_LIT>' <EOL> allows_team_connect = True <EOL> auth_url = '<STR_LIT>' <EOL> access_token_url = '<STR_LIT>' <EOL> oauth_email_scope = '<STR_LIT>' <EOL> oauth_default_scope = [ '<STR_LIT>' ] <EOL> api_format = '<STR_LIT>' <EOL> api_paginator = header_links_paginator ( ) <EOL> api_url = '<STR_LIT>' <EOL> api_app_auth_params = '<STR_LIT>' <EOL> api_user_info_path = '<STR_LIT>' <EOL> api_user_name_info_path = '<STR_LIT>' <EOL> api_user_self_info_path = '<STR_LIT>' <EOL> api_team_members_path = '<STR_LIT>' <EOL> api_friends_path = '<STR_LIT>' <EOL> ratelimit_headers_prefix = '<STR_LIT>' <EOL> x_user_id = key ( '<STR_LIT:id>' ) <EOL> x_user_name = key ( '<STR_LIT>' ) <EOL> x_display_name = key ( '<STR_LIT:name>' ) <EOL> x_email = key ( '<STR_LIT:email>' ) <EOL> x_gravatar_id = key ( '<STR_LIT>' ) <EOL> x_avatar_url = key ( '<STR_LIT>' ) <EOL> x_is_team = key ( '<STR_LIT:type>' , clean = lambda t : t . lower ( ) == '<STR_LIT>' ) <EOL> def get_CantReadMembership_url ( self , ** kw ) : <EOL> return '<STR_LIT>' + self . api_key <EOL> def is_team_member ( self , org_name , sess , account ) : <EOL> org_name = org_name . lower ( ) <EOL> response = self . api_get ( <EOL> '<STR_LIT>' + org_name + '<STR_LIT>' + account . user_name , <EOL> sess = sess , error_handler = None <EOL> ) <EOL> if response . status_code == <NUM_LIT> : <EOL> return True <EOL> elif response . status_code != <NUM_LIT> : <EOL> self . api_error_handler ( response , True ) <EOL> response = self . api_get ( <EOL> '<STR_LIT>' + org_name , sess = sess , error_handler = None <EOL> ) <EOL> if response . status_code == <NUM_LIT> : <EOL> raise CantReadMembership <EOL> elif response . status_code >= <NUM_LIT> : <EOL> self . api_error_handler ( response , True ) <EOL> membership = self . api_parser ( response ) <EOL> if membership [ '<STR_LIT:state>' ] == '<STR_LIT>' : <EOL> return True <EOL> user_orgs = self . api_parser ( self . api_get ( '<STR_LIT>' , sess = sess ) ) <EOL> return any ( org . get ( '<STR_LIT>' ) == org_name for org in user_orgs ) </s>
