idx int64 0 63k | question stringlengths 61 4.03k | target stringlengths 6 1.23k |
|---|---|---|
14,000 | def get_log_events ( self , user_id , page = 0 , per_page = 50 , sort = None , include_totals = False ) : params = { 'per_page' : per_page , 'page' : page , 'include_totals' : str ( include_totals ) . lower ( ) , 'sort' : sort } url = self . _url ( '{}/logs' . format ( user_id ) ) return self . client . get ( url , par... | Retrieve every log event for a specific user id |
14,001 | def all ( self , stage = 'login_success' , enabled = True , fields = None , include_fields = True , page = None , per_page = None , include_totals = False ) : params = { 'stage' : stage , 'fields' : fields and ',' . join ( fields ) or None , 'include_fields' : str ( include_fields ) . lower ( ) , 'page' : page , 'per_p... | Retrieves a list of all rules . |
14,002 | def get_failed_job ( self , id ) : url = self . _url ( '{}/errors' . format ( id ) ) return self . client . get ( url ) | Get failed job error details |
14,003 | def get_results ( self , job_id ) : url = self . _url ( '%s/results' % job_id ) return self . client . get ( url ) | Get results of a job |
14,004 | def export_users ( self , body ) : return self . client . post ( self . _url ( 'users-exports' ) , data = body ) | Export all users to a file using a long running job . |
14,005 | def import_users ( self , connection_id , file_obj , upsert = False ) : return self . client . file_post ( self . _url ( 'users-imports' ) , data = { 'connection_id' : connection_id , 'upsert' : str ( upsert ) . lower ( ) } , files = { 'users' : file_obj } ) | Imports users to a connection from a file . |
14,006 | def send_verification_email ( self , body ) : return self . client . post ( self . _url ( 'verification-email' ) , data = body ) | Send verification email . |
14,007 | def config ( self , body ) : return self . client . post ( self . _url ( ) , data = body ) | Configure the email provider . |
14,008 | def userinfo ( self , access_token ) : return self . get ( url = 'https://{}/userinfo' . format ( self . domain ) , headers = { 'Authorization' : 'Bearer {}' . format ( access_token ) } ) | Returns the user information based on the Auth0 access token . This endpoint will work only if openid was granted as a scope for the access_token . |
14,009 | def tokeninfo ( self , jwt ) : warnings . warn ( "/tokeninfo will be deprecated in future releases" , DeprecationWarning ) return self . post ( url = 'https://{}/tokeninfo' . format ( self . domain ) , data = { 'id_token' : jwt } , headers = { 'Content-Type' : 'application/json' } ) | Returns user profile based on the user s jwt |
14,010 | def all ( self , page = None , per_page = None , include_totals = False , extra_params = None ) : params = extra_params or { } params . update ( { 'page' : page , 'per_page' : per_page , 'include_totals' : str ( include_totals ) . lower ( ) } ) return self . client . get ( self . _url ( ) , params = params ) | Retrieves all grants . |
14,011 | def change_password ( self , client_id , email , connection , password = None ) : return self . post ( 'https://{}/dbconnections/change_password' . format ( self . domain ) , data = { 'client_id' : client_id , 'email' : email , 'password' : password , 'connection' : connection , } , headers = { 'Content-Type' : 'applic... | Asks to change a password for a given user . |
14,012 | def encrypt ( self , k , a , m ) : hkey = k [ : _inbytes ( self . keysize ) ] ekey = k [ _inbytes ( self . keysize ) : ] iv = _randombits ( self . blocksize ) cipher = Cipher ( algorithms . AES ( ekey ) , modes . CBC ( iv ) , backend = self . backend ) encryptor = cipher . encryptor ( ) padder = PKCS7 ( self . blocksiz... | Encrypt according to the selected encryption and hashing functions . |
14,013 | def encrypt ( self , k , a , m ) : iv = _randombits ( 96 ) cipher = Cipher ( algorithms . AES ( k ) , modes . GCM ( iv ) , backend = self . backend ) encryptor = cipher . encryptor ( ) encryptor . authenticate_additional_data ( a ) e = encryptor . update ( m ) + encryptor . finalize ( ) return ( iv , e , encryptor . ta... | Encrypt accoriding to the selected encryption and hashing functions . |
14,014 | def from_json ( cls , key ) : obj = cls ( ) try : jkey = json_decode ( key ) except Exception as e : raise InvalidJWKValue ( e ) obj . import_key ( ** jkey ) return obj | Creates a RFC 7517 JWK from the standard JSON format . |
14,015 | def export ( self , private_key = True ) : if private_key is True : return self . _export_all ( ) else : return self . export_public ( ) | Exports the key in the standard JSON format . Exports the key regardless of type if private_key is False and the key is_symmetric an exceptionis raised . |
14,016 | def has_public ( self ) : if self . is_symmetric : return False reg = JWKValuesRegistry [ self . _params [ 'kty' ] ] for value in reg : if reg [ value ] . public and value in self . _key : return True | Whether this JWK has an asymmetric Public key . |
14,017 | def get_curve ( self , arg ) : k = self . _key if self . _params [ 'kty' ] not in [ 'EC' , 'OKP' ] : raise InvalidJWKType ( 'Not an EC or OKP key' ) if arg and k [ 'crv' ] != arg : raise InvalidJWKValue ( 'Curve requested is "%s", but ' 'key curve is "%s"' % ( arg , k [ 'crv' ] ) ) return self . _get_curve_by_name ( k ... | Gets the Elliptic Curve associated with the key . |
14,018 | def get_op_key ( self , operation = None , arg = None ) : validops = self . _params . get ( 'key_ops' , list ( JWKOperationsRegistry . keys ( ) ) ) if validops is not list : validops = [ validops ] if operation is None : if self . _params [ 'kty' ] == 'oct' : return self . _key [ 'k' ] raise InvalidJWKOperation ( opera... | Get the key object associated to the requested opration . For example the public RSA key for the verify operation or the private EC key for the decrypt operation . |
14,019 | def thumbprint ( self , hashalg = hashes . SHA256 ( ) ) : t = { 'kty' : self . _params [ 'kty' ] } for name , val in iteritems ( JWKValuesRegistry [ t [ 'kty' ] ] ) : if val . required : t [ name ] = self . _key [ name ] digest = hashes . Hash ( hashalg , backend = default_backend ( ) ) digest . update ( bytes ( json_e... | Returns the key thumbprint as specified by RFC 7638 . |
14,020 | def add ( self , elem ) : if not isinstance ( elem , JWK ) : raise TypeError ( 'Only JWK objects are valid elements' ) set . add ( self , elem ) | Adds a JWK object to the set |
14,021 | def export ( self , private_keys = True ) : exp_dict = dict ( ) for k , v in iteritems ( self ) : if k == 'keys' : keys = list ( ) for jwk in v : keys . append ( json_decode ( jwk . export ( private_keys ) ) ) v = keys exp_dict [ k ] = v return json_encode ( exp_dict ) | Exports a RFC 7517 keyset using the standard JSON format |
14,022 | def import_keyset ( self , keyset ) : try : jwkset = json_decode ( keyset ) except Exception : raise InvalidJWKValue ( ) if 'keys' not in jwkset : raise InvalidJWKValue ( ) for k , v in iteritems ( jwkset ) : if k == 'keys' : for jwk in v : self [ 'keys' ] . add ( JWK ( ** jwk ) ) else : self [ k ] = v | Imports a RFC 7517 keyset using the standard JSON format . |
14,023 | def add_recipient ( self , key , header = None ) : if self . plaintext is None : raise ValueError ( 'Missing plaintext' ) if not isinstance ( self . plaintext , bytes ) : raise ValueError ( "Plaintext must be 'bytes'" ) if isinstance ( header , dict ) : header = json_encode ( header ) jh = self . _get_jose_header ( hea... | Encrypt the plaintext with the given key . |
14,024 | def serialize ( self , compact = False ) : if 'ciphertext' not in self . objects : raise InvalidJWEOperation ( "No available ciphertext" ) if compact : for invalid in 'aad' , 'unprotected' : if invalid in self . objects : raise InvalidJWEOperation ( "Can't use compact encoding when the '%s' parameter" "is set" % invali... | Serializes the object into a JWE token . |
14,025 | def decrypt ( self , key ) : if 'ciphertext' not in self . objects : raise InvalidJWEOperation ( "No available ciphertext" ) self . decryptlog = list ( ) if 'recipients' in self . objects : for rec in self . objects [ 'recipients' ] : try : self . _decrypt ( key , rec ) except Exception as e : self . decryptlog . appen... | Decrypt a JWE token . |
14,026 | def deserialize ( self , raw_jwe , key = None ) : self . objects = dict ( ) self . plaintext = None self . cek = None o = dict ( ) try : try : djwe = json_decode ( raw_jwe ) o [ 'iv' ] = base64url_decode ( djwe [ 'iv' ] ) o [ 'ciphertext' ] = base64url_decode ( djwe [ 'ciphertext' ] ) o [ 'tag' ] = base64url_decode ( d... | Deserialize a JWE token . |
14,027 | def sign ( self ) : payload = self . _payload ( ) sigin = b'.' . join ( [ self . protected . encode ( 'utf-8' ) , payload ] ) signature = self . engine . sign ( self . key , sigin ) return { 'protected' : self . protected , 'payload' : payload , 'signature' : base64url_encode ( signature ) } | Generates a signature |
14,028 | def verify ( self , signature ) : try : payload = self . _payload ( ) sigin = b'.' . join ( [ self . protected . encode ( 'utf-8' ) , payload ] ) self . engine . verify ( self . key , sigin , signature ) except Exception as e : raise InvalidJWSSignature ( 'Verification failed' , repr ( e ) ) return True | Verifies a signature |
14,029 | def verify ( self , key , alg = None ) : self . verifylog = list ( ) self . objects [ 'valid' ] = False obj = self . objects if 'signature' in obj : try : self . _verify ( alg , key , obj [ 'payload' ] , obj [ 'signature' ] , obj . get ( 'protected' , None ) , obj . get ( 'header' , None ) ) obj [ 'valid' ] = True exce... | Verifies a JWS token . |
14,030 | def deserialize ( self , raw_jws , key = None , alg = None ) : self . objects = dict ( ) o = dict ( ) try : try : djws = json_decode ( raw_jws ) if 'signatures' in djws : o [ 'signatures' ] = list ( ) for s in djws [ 'signatures' ] : os = self . _deserialize_signature ( s ) o [ 'signatures' ] . append ( os ) self . _de... | Deserialize a JWS token . |
14,031 | def add_signature ( self , key , alg = None , protected = None , header = None ) : if not self . objects . get ( 'payload' , None ) : raise InvalidJWSObject ( 'Missing Payload' ) b64 = True p = dict ( ) if protected : if isinstance ( protected , dict ) : p = protected protected = json_encode ( p ) else : p = json_decod... | Adds a new signature to the object . |
14,032 | def serialize ( self , compact = False ) : if compact : if 'signatures' in self . objects : raise InvalidJWSOperation ( "Can't use compact encoding with " "multiple signatures" ) if 'signature' not in self . objects : raise InvalidJWSSignature ( "No available signature" ) if not self . objects . get ( 'valid' , False )... | Serializes the object into a JWS token . |
14,033 | def make_signed_token ( self , key ) : t = JWS ( self . claims ) t . add_signature ( key , protected = self . header ) self . token = t | Signs the payload . |
14,034 | def make_encrypted_token ( self , key ) : t = JWE ( self . claims , self . header ) t . add_recipient ( key ) self . token = t | Encrypts the payload . |
14,035 | def deserialize ( self , jwt , key = None ) : c = jwt . count ( '.' ) if c == 2 : self . token = JWS ( ) elif c == 4 : self . token = JWE ( ) else : raise ValueError ( "Token format unrecognized" ) if self . _algs : self . token . allowed_algs = self . _algs self . deserializelog = list ( ) if key is None : self . toke... | Deserialize a JWT token . |
14,036 | def validate ( self , n_viz = 9 ) : iter_valid = copy . copy ( self . iter_valid ) losses , lbl_trues , lbl_preds = [ ] , [ ] , [ ] vizs = [ ] dataset = iter_valid . dataset desc = 'valid [iteration=%08d]' % self . iteration for batch in tqdm . tqdm ( iter_valid , desc = desc , total = len ( dataset ) , ncols = 80 , le... | Validate current model using validation dataset . |
14,037 | def train ( self ) : self . stamp_start = time . time ( ) for iteration , batch in tqdm . tqdm ( enumerate ( self . iter_train ) , desc = 'train' , total = self . max_iter , ncols = 80 ) : self . epoch = self . iter_train . epoch self . iteration = iteration if self . interval_validate and self . iteration % self . int... | Train the network using the training dataset . |
14,038 | def centerize ( src , dst_shape , margin_color = None ) : if src . shape [ : 2 ] == dst_shape [ : 2 ] : return src centerized = np . zeros ( dst_shape , dtype = src . dtype ) if margin_color : centerized [ : , : ] = margin_color pad_vertical , pad_horizontal = 0 , 0 h , w = src . shape [ : 2 ] dst_h , dst_w = dst_shape... | Centerize image for specified image size |
14,039 | def _tile_images ( imgs , tile_shape , concatenated_image ) : y_num , x_num = tile_shape one_width = imgs [ 0 ] . shape [ 1 ] one_height = imgs [ 0 ] . shape [ 0 ] if concatenated_image is None : if len ( imgs [ 0 ] . shape ) == 3 : n_channels = imgs [ 0 ] . shape [ 2 ] assert all ( im . shape [ 2 ] == n_channels for i... | Concatenate images whose sizes are same . |
14,040 | def get_tile_image ( imgs , tile_shape = None , result_img = None , margin_color = None ) : def resize ( * args , ** kwargs ) : if LooseVersion ( skimage . __version__ ) < LooseVersion ( '0.14' ) : kwargs . pop ( 'anti_aliasing' , None ) return skimage . transform . resize ( * args , ** kwargs ) def get_tile_shape ( im... | Concatenate images whose sizes are different . |
14,041 | def visualize_segmentation ( ** kwargs ) : img = kwargs . pop ( 'img' , None ) lbl_true = kwargs . pop ( 'lbl_true' , None ) lbl_pred = kwargs . pop ( 'lbl_pred' , None ) n_class = kwargs . pop ( 'n_class' , None ) label_names = kwargs . pop ( 'label_names' , None ) if kwargs : raise RuntimeError ( 'Unexpected keys in ... | Visualize segmentation . |
14,042 | def create ( self , output_path , dry_run = False , output_format = None , compresslevel = None ) : if output_format is None : file_name , file_ext = path . splitext ( output_path ) output_format = file_ext [ len ( extsep ) : ] . lower ( ) self . LOG . debug ( "Output format is not explicitly set, determined format is ... | Create the archive at output_file_path . |
14,043 | def is_file_excluded ( self , repo_abspath , repo_file_path ) : next ( self . _check_attr_gens [ repo_abspath ] ) attrs = self . _check_attr_gens [ repo_abspath ] . send ( repo_file_path ) return attrs [ 'export-ignore' ] == 'set' | Checks whether file at a given path is excluded . |
14,044 | def archive_all_files ( self , archiver ) : for file_path in self . extra : archiver ( path . abspath ( file_path ) , path . join ( self . prefix , file_path ) ) for file_path in self . walk_git_files ( ) : archiver ( path . join ( self . main_repo_abspath , file_path ) , path . join ( self . prefix , file_path ) ) | Archive all files using archiver . |
14,045 | def walk_git_files ( self , repo_path = '' ) : repo_abspath = path . join ( self . main_repo_abspath , repo_path ) assert repo_abspath not in self . _check_attr_gens self . _check_attr_gens [ repo_abspath ] = self . check_attr ( repo_abspath , [ 'export-ignore' ] ) try : repo_file_paths = self . run_git_shell ( 'git ls... | An iterator method that yields a file path relative to main_repo_abspath for each file that should be included in the archive . Skips those that match the exclusion patterns found in any discovered . gitattributes files along the way . |
14,046 | def check_attr ( self , repo_abspath , attrs ) : def make_process ( ) : env = dict ( environ , GIT_FLUSH = '1' ) cmd = 'git check-attr --stdin -z {0}' . format ( ' ' . join ( attrs ) ) return Popen ( cmd , shell = True , stdin = PIPE , stdout = PIPE , cwd = repo_abspath , env = env ) def read_attrs ( process , repo_fil... | Generator that returns attributes for given paths relative to repo_abspath . |
14,047 | def run_git_shell ( cls , cmd , cwd = None ) : p = Popen ( cmd , shell = True , stdout = PIPE , cwd = cwd ) output , _ = p . communicate ( ) output = cls . decode_git_output ( output ) if p . returncode : if sys . version_info > ( 2 , 6 ) : raise CalledProcessError ( returncode = p . returncode , cmd = cmd , output = o... | Runs git shell command reads output and decodes it into unicode string . |
14,048 | def get_git_version ( cls ) : try : output = cls . run_git_shell ( 'git version' ) except CalledProcessError : cls . LOG . warning ( "Unable to get Git version." ) return None try : version = output . split ( ) [ 2 ] except IndexError : cls . LOG . warning ( "Unable to parse Git version \"%s\"." , output ) return None ... | Return version of git current shell points to . |
14,049 | async def request ( method , uri , ** kwargs ) : c_interact = kwargs . pop ( 'persist_cookies' , None ) ssl_context = kwargs . pop ( 'ssl_context' , None ) async with Session ( persist_cookies = c_interact , ssl_context = ssl_context ) as s : r = await s . request ( method , url = uri , ** kwargs ) return r | Base function for one time http requests . |
14,050 | async def make_request ( self , redirect = False ) : h11_connection = h11 . Connection ( our_role = h11 . CLIENT ) ( self . scheme , self . host , self . path , self . uri_parameters , self . query , _ ) = urlparse ( self . uri ) if not redirect : self . initial_scheme = self . scheme self . initial_netloc = self . hos... | Acts as the central hub for preparing requests to be sent and returning them upon completion . Generally just pokes through self s attribs and makes decisions about what to do . |
14,051 | def _build_path ( self ) : if not self . path : self . path = '/' if self . uri_parameters : self . path = self . path + ';' + requote_uri ( self . uri_parameters ) if self . query : self . path = ( self . path + '?' + self . query ) if self . params : try : if self . query : self . path = self . path + self . _dict_to... | Constructs the actual request URL with accompanying query if any . |
14,052 | async def _catch_response ( self , h11_connection ) : response = await self . _recv_event ( h11_connection ) resp_data = { 'encoding' : self . encoding , 'method' : self . method , 'status_code' : response . status_code , 'reason_phrase' : str ( response . reason , 'utf-8' ) , 'http_version' : str ( response . http_ver... | Instantiates the parser which manages incoming data first getting the headers storing cookies and then parsing the response s body if any . |
14,053 | async def _send ( self , request_bytes , body_bytes , h11_connection ) : await self . sock . send_all ( h11_connection . send ( request_bytes ) ) if body_bytes is not None : await self . sock . send_all ( h11_connection . send ( body_bytes ) ) await self . sock . send_all ( h11_connection . send ( h11 . EndOfMessage ( ... | Takes a package and body combines then then shoots em off in to the ether . |
14,054 | async def _location_auth_protect ( self , location ) : netloc_sans_port = self . host . split ( ':' ) [ 0 ] netloc_sans_port = netloc_sans_port . replace ( ( re . match ( _WWX_MATCH , netloc_sans_port ) [ 0 ] ) , '' ) base_domain = '.' . join ( netloc_sans_port . split ( '.' ) [ - 2 : ] ) l_scheme , l_netloc , _ , _ , ... | Checks to see if the new location is 1 . The same top level domain 2 . As or more secure than the current connection type |
14,055 | async def _body_callback ( self , h11_connection ) : while True : next_event = await self . _recv_event ( h11_connection ) if isinstance ( next_event , h11 . Data ) : await self . callback ( next_event . data ) else : return next_event | A callback func to be supplied if the user wants to do something directly with the response body s stream . |
14,056 | async def _connect ( self , host_loc ) : scheme , host , path , parameters , query , fragment = urlparse ( host_loc ) if parameters or query or fragment : raise ValueError ( 'Supplied info beyond scheme, host.' + ' Host should be top level only: ' , path ) host , port = get_netloc_port ( scheme , host ) if scheme == 'h... | Simple enough stuff to figure out where we should connect and creates the appropriate connection . |
14,057 | async def request ( self , method , url = None , * , path = '' , retries = 1 , connection_timeout = 60 , ** kwargs ) : timeout = kwargs . get ( 'timeout' , None ) req_headers = kwargs . pop ( 'headers' , None ) if self . headers is not None : headers = copy ( self . headers ) if req_headers is not None : headers . upda... | This is the template for all of the http method methods for the Session . |
14,058 | async def _handle_exception ( self , e , sock ) : if isinstance ( e , ( RemoteProtocolError , AssertionError ) ) : await sock . close ( ) raise BadHttpResponse ( 'Invalid HTTP response from server.' ) from e if isinstance ( e , Exception ) : await sock . close ( ) raise e | Given an exception we want to handle it appropriately . Some exceptions we prefer to shadow with an asks exception and some we want to raise directly . In all cases we clean up the underlying socket . |
14,059 | async def _grab_connection ( self , url ) : scheme , host , _ , _ , _ , _ = urlparse ( url ) host_loc = urlunparse ( ( scheme , host , '' , '' , '' , '' ) ) sock = self . _checkout_connection ( host_loc ) if sock is None : sock = await self . _make_connection ( host_loc ) return sock | The connection pool handler . Returns a connection to the caller . If there are no connections ready and as many connections checked out as there are available total we yield control to the event loop . |
14,060 | def json ( self , ** kwargs ) : body = self . _decompress ( self . encoding ) return _json . loads ( body , ** kwargs ) | If the response s body is valid json we load it as a python dict and return it . |
14,061 | def raise_for_status ( self ) : if 400 <= self . status_code < 500 : raise BadStatus ( '{} Client Error: {} for url: {}' . format ( self . status_code , self . reason_phrase , self . url ) , self . status_code ) elif 500 <= self . status_code < 600 : raise BadStatus ( '{} Server Error: {} for url: {}' . format ( self .... | Raise BadStatus if one occurred . |
14,062 | def recent_photos ( request ) : imgs = [ ] for obj in Image_File . objects . filter ( is_image = True ) . order_by ( "-date_created" ) : upurl = "/" + obj . upload . url thumburl = "" if obj . thumbnail : thumburl = "/" + obj . thumbnail . url imgs . append ( { 'src' : upurl , 'thumb' : thumburl , 'is_image' : True } )... | returns all the images from the data base |
14,063 | def marshal ( self , v ) : if v : orig = [ i for i in self . choices if self . choices [ i ] == v ] if len ( orig ) == 1 : return orig [ 0 ] elif len ( orig ) == 0 : raise NotImplementedError ( "No such reverse choice {0} for field {1}." . format ( v , self ) ) else : raise NotImplementedError ( "Too many reverse choic... | Turn this value into API format . |
14,064 | def unmarshal ( self , v ) : try : return self . choices [ v ] except KeyError : self . log . warning ( "No such choice {0} for field {1}." . format ( v , self ) ) return v | Convert the value from Strava API format to useful python representation . |
14,065 | def unmarshal ( self , value , bind_client = None ) : if not isinstance ( value , self . type ) : o = self . type ( ) if bind_client is not None and hasattr ( o . __class__ , 'bind_client' ) : o . bind_client = bind_client if isinstance ( value , dict ) : for ( k , v ) in value . items ( ) : if not hasattr ( o . __clas... | Cast the specified value to the entity type . |
14,066 | def marshal ( self , values ) : if values is not None : return [ super ( EntityCollection , self ) . marshal ( v ) for v in values ] | Turn a list of entities into a list of dictionaries . |
14,067 | def unmarshal ( self , values , bind_client = None ) : if values is not None : return [ super ( EntityCollection , self ) . unmarshal ( v , bind_client = bind_client ) for v in values ] | Cast the list . |
14,068 | def authorization_url ( self , client_id , redirect_uri , approval_prompt = 'auto' , scope = None , state = None ) : return self . protocol . authorization_url ( client_id = client_id , redirect_uri = redirect_uri , approval_prompt = approval_prompt , scope = scope , state = state ) | Get the URL needed to authorize your application to access a Strava user s information . |
14,069 | def get_activities ( self , before = None , after = None , limit = None ) : if before : before = self . _utc_datetime_to_epoch ( before ) if after : after = self . _utc_datetime_to_epoch ( after ) params = dict ( before = before , after = after ) result_fetcher = functools . partial ( self . protocol . get , '/athlete/... | Get activities for authenticated user sorted by newest first . |
14,070 | def get_athlete ( self , athlete_id = None ) : if athlete_id is None : raw = self . protocol . get ( '/athlete' ) else : raise NotImplementedError ( "The /athletes/{id} endpoint was removed by Strava. " "See https://developers.strava.com/docs/january-2018-update/" ) return model . Athlete . deserialize ( raw , bind_cl... | Gets the specified athlete ; if athlete_id is None then retrieves a detail - level representation of currently authenticated athlete ; otherwise summary - level representation returned of athlete . |
14,071 | def update_athlete ( self , city = None , state = None , country = None , sex = None , weight = None ) : params = { 'city' : city , 'state' : state , 'country' : country , 'sex' : sex } params = { k : v for ( k , v ) in params . items ( ) if v is not None } if weight is not None : params [ 'weight' ] = float ( weight )... | Updates the properties of the authorized athlete . |
14,072 | def get_athlete_stats ( self , athlete_id = None ) : if athlete_id is None : athlete_id = self . get_athlete ( ) . id raw = self . protocol . get ( '/athletes/{id}/stats' , id = athlete_id ) return model . AthleteStats . deserialize ( raw ) | Returns Statistics for the athlete . athlete_id must be the id of the authenticated athlete or left blank . If it is left blank two requests will be made - first to get the authenticated athlete s id and second to get the Stats . |
14,073 | def get_athlete_clubs ( self ) : club_structs = self . protocol . get ( '/athlete/clubs' ) return [ model . Club . deserialize ( raw , bind_client = self ) for raw in club_structs ] | List the clubs for the currently authenticated athlete . |
14,074 | def get_club ( self , club_id ) : raw = self . protocol . get ( "/clubs/{id}" , id = club_id ) return model . Club . deserialize ( raw , bind_client = self ) | Return a specific club object . |
14,075 | def get_club_members ( self , club_id , limit = None ) : result_fetcher = functools . partial ( self . protocol . get , '/clubs/{id}/members' , id = club_id ) return BatchedResultsIterator ( entity = model . Athlete , bind_client = self , result_fetcher = result_fetcher , limit = limit ) | Gets the member objects for specified club ID . |
14,076 | def get_club_activities ( self , club_id , limit = None ) : result_fetcher = functools . partial ( self . protocol . get , '/clubs/{id}/activities' , id = club_id ) return BatchedResultsIterator ( entity = model . Activity , bind_client = self , result_fetcher = result_fetcher , limit = limit ) | Gets the activities associated with specified club . |
14,077 | def get_activity ( self , activity_id , include_all_efforts = False ) : raw = self . protocol . get ( '/activities/{id}' , id = activity_id , include_all_efforts = include_all_efforts ) return model . Activity . deserialize ( raw , bind_client = self ) | Gets specified activity . |
14,078 | def create_activity ( self , name , activity_type , start_date_local , elapsed_time , description = None , distance = None ) : if isinstance ( elapsed_time , timedelta ) : elapsed_time = unithelper . timedelta_to_seconds ( elapsed_time ) if isinstance ( distance , Quantity ) : distance = float ( unithelper . meters ( d... | Create a new manual activity . |
14,079 | def update_activity ( self , activity_id , name = None , activity_type = None , private = None , commute = None , trainer = None , gear_id = None , description = None , device_name = None ) : params = { } if name is not None : params [ 'name' ] = name if activity_type is not None : if not activity_type . lower ( ) in [... | Updates the properties of a specific activity . |
14,080 | def get_activity_zones ( self , activity_id ) : zones = self . protocol . get ( '/activities/{id}/zones' , id = activity_id ) return [ model . BaseActivityZone . deserialize ( z , bind_client = self ) for z in zones ] | Gets zones for activity . |
14,081 | def get_activity_comments ( self , activity_id , markdown = False , limit = None ) : result_fetcher = functools . partial ( self . protocol . get , '/activities/{id}/comments' , id = activity_id , markdown = int ( markdown ) ) return BatchedResultsIterator ( entity = model . ActivityComment , bind_client = self , resul... | Gets the comments for an activity . |
14,082 | def get_activity_kudos ( self , activity_id , limit = None ) : result_fetcher = functools . partial ( self . protocol . get , '/activities/{id}/kudos' , id = activity_id ) return BatchedResultsIterator ( entity = model . ActivityKudos , bind_client = self , result_fetcher = result_fetcher , limit = limit ) | Gets the kudos for an activity . |
14,083 | def get_activity_photos ( self , activity_id , size = None , only_instagram = False ) : params = { } if not only_instagram : params [ 'photo_sources' ] = 'true' if size is not None : params [ 'size' ] = size result_fetcher = functools . partial ( self . protocol . get , '/activities/{id}/photos' , id = activity_id , **... | Gets the photos from an activity . |
14,084 | def get_activity_laps ( self , activity_id ) : result_fetcher = functools . partial ( self . protocol . get , '/activities/{id}/laps' , id = activity_id ) return BatchedResultsIterator ( entity = model . ActivityLap , bind_client = self , result_fetcher = result_fetcher ) | Gets the laps from an activity . |
14,085 | def get_gear ( self , gear_id ) : return model . Gear . deserialize ( self . protocol . get ( '/gear/{id}' , id = gear_id ) ) | Get details for an item of gear . |
14,086 | def get_segment_effort ( self , effort_id ) : return model . SegmentEffort . deserialize ( self . protocol . get ( '/segment_efforts/{id}' , id = effort_id ) ) | Return a specific segment effort by ID . |
14,087 | def get_segment ( self , segment_id ) : return model . Segment . deserialize ( self . protocol . get ( '/segments/{id}' , id = segment_id ) , bind_client = self ) | Gets a specific segment by ID . |
14,088 | def get_starred_segments ( self , limit = None ) : params = { } if limit is not None : params [ "limit" ] = limit result_fetcher = functools . partial ( self . protocol . get , '/segments/starred' ) return BatchedResultsIterator ( entity = model . Segment , bind_client = self , result_fetcher = result_fetcher , limit =... | Returns a summary representation of the segments starred by the authenticated user . Pagination is supported . |
14,089 | def get_athlete_starred_segments ( self , athlete_id , limit = None ) : result_fetcher = functools . partial ( self . protocol . get , '/athletes/{id}/segments/starred' , id = athlete_id ) return BatchedResultsIterator ( entity = model . Segment , bind_client = self , result_fetcher = result_fetcher , limit = limit ) | Returns a summary representation of the segments starred by the specified athlete . Pagination is supported . |
14,090 | def get_segment_leaderboard ( self , segment_id , gender = None , age_group = None , weight_class = None , following = None , club_id = None , timeframe = None , top_results_limit = None , page = None , context_entries = None ) : params = { } if gender is not None : if gender . upper ( ) not in ( 'M' , 'F' ) : raise Va... | Gets the leaderboard for a segment . |
14,091 | def get_segment_efforts ( self , segment_id , athlete_id = None , start_date_local = None , end_date_local = None , limit = None ) : params = { "segment_id" : segment_id } if athlete_id is not None : params [ 'athlete_id' ] = athlete_id if start_date_local : if isinstance ( start_date_local , six . string_types ) : sta... | Gets all efforts on a particular segment sorted by start_date_local |
14,092 | def explore_segments ( self , bounds , activity_type = None , min_cat = None , max_cat = None ) : if len ( bounds ) == 2 : bounds = ( bounds [ 0 ] [ 0 ] , bounds [ 0 ] [ 1 ] , bounds [ 1 ] [ 0 ] , bounds [ 1 ] [ 1 ] ) elif len ( bounds ) != 4 : raise ValueError ( "Invalid bounds specified: {0!r}. Must be list of 4 floa... | Returns an array of up to 10 segments . |
14,093 | def get_activity_streams ( self , activity_id , types = None , resolution = None , series_type = None ) : if types is not None : types = "," . join ( types ) params = { } if resolution is not None : params [ "resolution" ] = resolution if series_type is not None : params [ "series_type" ] = series_type result_fetcher =... | Returns an streams for an activity . |
14,094 | def get_effort_streams ( self , effort_id , types = None , resolution = None , series_type = None ) : if types is not None : types = "," . join ( types ) params = { } if resolution is not None : params [ "resolution" ] = resolution if series_type is not None : params [ "series_type" ] = series_type result_fetcher = fun... | Returns an streams for an effort . |
14,095 | def get_running_race ( self , race_id ) : raw = self . protocol . get ( '/running_races/{id}' , id = race_id ) return model . RunningRace . deserialize ( raw , bind_client = self ) | Gets a running race for a given identifier . t |
14,096 | def get_running_races ( self , year = None ) : if year is None : year = datetime . datetime . now ( ) . year params = { "year" : year } result_fetcher = functools . partial ( self . protocol . get , '/running_races' , ** params ) return BatchedResultsIterator ( entity = model . RunningRace , bind_client = self , result... | Gets a running races for a given year . |
14,097 | def get_routes ( self , athlete_id = None , limit = None ) : if athlete_id is None : athlete_id = self . get_athlete ( ) . id result_fetcher = functools . partial ( self . protocol . get , '/athletes/{id}/routes' . format ( id = athlete_id ) ) return BatchedResultsIterator ( entity = model . Route , bind_client = self ... | Gets the routes list for an authenticated user . |
14,098 | def get_route ( self , route_id ) : raw = self . protocol . get ( '/routes/{id}' , id = route_id ) return model . Route . deserialize ( raw , bind_client = self ) | Gets specified route . |
14,099 | def get_route_streams ( self , route_id ) : result_fetcher = functools . partial ( self . protocol . get , '/routes/{id}/streams/' . format ( id = route_id ) ) streams = BatchedResultsIterator ( entity = model . Stream , bind_client = self , result_fetcher = result_fetcher ) return { i . type : i for i in streams } | Returns streams for a route . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.