nodes: 0, module; 1, function_definition; 2, function_name:get_segment_leaderboard; 3, parameters; 4, block; 5, identifier:self; 6, identifier:segment_id; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, default_parameter; 12, default_parameter; 13, default_parameter; 14, default_parameter; 15, default_parameter; 16, expression_statement; 17, expression_statement; 18, if_statement; 19, expression_statement; 20, if_statement; 21, expression_statement; 22, if_statement; 23, if_statement; 24, if_statement; 25, if_statement; 26, if_statement; 27, if_statement; 28, if_statement; 29, return_statement; 30, identifier:gender; 31, None; 32, identifier:age_group; 33, None; 34, identifier:weight_class; 35, None; 36, identifier:following; 37, None; 38, identifier:club_id; 39, None; 40, identifier:timeframe; 41, None; 42, identifier:top_results_limit; 43, None; 44, identifier:page; 45, None; 46, identifier:context_entries; 47, None; 48, comment:"""
          Gets the leaderboard for a segment.
  
          http://strava.github.io/api/v3/segments/#leaderboard
  
          Note that by default Strava will return the top 10 results, and if the current user has ridden
          that segment, the current user's result along with the two results above in rank and the two
          results below will be included.  The top X results can be configured by setting the top_results_limit
          parameter; however, the other 5 results will be included if the current user has ridden that segment.
          (i.e. if you specify top_results_limit=15, you will get a total of 20 entries back.)
  
          :param segment_id: ID of the segment.
          :type segment_id: int
  
          :param gender: (optional) 'M' or 'F'
          :type gender: str
  
          :param age_group: (optional) '0_24', '25_34', '35_44', '45_54', '55_64', '65_plus'
          :type age_group: str
  
          :param weight_class: (optional) pounds '0_124', '125_149', '150_164', '165_179', '180_199', '200_plus'
                               or kilograms '0_54', '55_64', '65_74', '75_84', '85_94', '95_plus'
          :type weight_class: str
  
          :param following: (optional) Limit to athletes current user is following.
          :type following: bool
  
          :param club_id: (optional) limit to specific club
          :type club_id: int
  
          :param timeframe: (optional)  'this_year', 'this_month', 'this_week', 'today'
          :type timeframe: str
  
          :param top_results_limit: (optional, strava default is 10 + 5 from end) How many of leading leaderboard entries to display.
                              See description for why this is a little confusing.
          :type top_results_limit: int
  
          :param page: (optional, strava default is 1) Page number of leaderboard to return, sorted by highest ranking leaders
          :type page: int
  
          :param context_entries: (optional, strava default is 2, max is 15) number of entries surrounding requesting athlete to return
          :type context_entries: int
  
          :return: The SegmentLeaderboard for the specified page (default: 1)
          :rtype: :class:`stravalib.model.SegmentLeaderboard`
  
          """; 49, assignment; 50, comparison_operator:gender is not None; 51, block; 52, assignment; 53, comparison_operator:age_group is not None; 54, block; 55, assignment; 56, comparison_operator:weight_class is not None; 57, block; 58, comparison_operator:following is not None; 59, block; 60, comparison_operator:club_id is not None; 61, block; 62, comparison_operator:timeframe is not None; 63, block; 64, comparison_operator:top_results_limit is not None; 65, block; 66, comparison_operator:page is not None; 67, block; 68, comparison_operator:context_entries is not None; 69, block; 70, call; 71, identifier:params; 72, dictionary; 73, identifier:gender; 74, None; 75, if_statement; 76, expression_statement; 77, identifier:valid_age_groups; 78, tuple; 79, identifier:age_group; 80, None; 81, if_statement; 82, expression_statement; 83, identifier:valid_weight_classes; 84, tuple; 85, identifier:weight_class; 86, None; 87, if_statement; 88, expression_statement; 89, identifier:following; 90, None; 91, expression_statement; 92, identifier:club_id; 93, None; 94, expression_statement; 95, identifier:timeframe; 96, None; 97, expression_statement; 98, if_statement; 99, expression_statement; 100, identifier:top_results_limit; 101, None; 102, expression_statement; 103, identifier:page; 104, None; 105, expression_statement; 106, identifier:context_entries; 107, None; 108, expression_statement; 109, attribute; 110, argument_list; 111, comparison_operator:gender.upper() not in ('M', 'F'); 112, block; 113, assignment; 114, string; 115, string; 116, string; 117, string; 118, string; 119, string; 120, not_operator; 121, block; 122, assignment; 123, string; 124, string; 125, string; 126, string; 127, string; 128, string; 129, string; 130, string; 131, string; 132, string; 133, string; 134, string; 135, not_operator; 136, block; 137, assignment; 138, assignment; 139, assignment; 140, assignment; 141, not_operator; 142, block; 143, assignment; 144, assignment; 145, assignment; 146, assignment; 147, attribute; 148, identifier:deserialize; 149, call; 150, keyword_argument; 151, call; 152, tuple; 153, raise_statement; 154, subscript; 155, identifier:gender; 156, string_content:0_24; 157, string_content:25_34; 158, string_content:35_44; 159, string_content:45_54; 160, string_content:55_64; 161, string_content:65_plus; 162, comparison_operator:age_group in valid_age_groups; 163, raise_statement; 164, subscript; 165, identifier:age_group; 166, string_content:0_124; 167, string_content:125_149; 168, string_content:150_164; 169, string_content:165_179; 170, string_content:180_199; 171, string_content:200_plus; 172, string_content:0_54; 173, string_content:55_64; 174, string_content:65_74; 175, string_content:75_84; 176, string_content:85_94; 177, string_content:95_plus; 178, comparison_operator:weight_class in valid_weight_classes; 179, raise_statement; 180, subscript; 181, identifier:weight_class; 182, subscript; 183, call; 184, subscript; 185, identifier:club_id; 186, identifier:valid_timeframes; 187, expression_list; 188, comparison_operator:timeframe in valid_timeframes; 189, raise_statement; 190, subscript; 191, identifier:timeframe; 192, subscript; 193, identifier:top_results_limit; 194, subscript; 195, identifier:page; 196, subscript; 197, identifier:context_entries; 198, identifier:model; 199, identifier:SegmentLeaderboard; 200, attribute; 201, argument_list; 202, identifier:bind_client; 203, identifier:self; 204, attribute; 205, argument_list; 206, string; 207, string; 208, call; 209, identifier:params; 210, string; 211, identifier:age_group; 212, identifier:valid_age_groups; 213, call; 214, identifier:params; 215, string; 216, identifier:weight_class; 217, identifier:valid_weight_classes; 218, call; 219, identifier:params; 220, string; 221, identifier:params; 222, string; 223, identifier:int; 224, argument_list; 225, identifier:params; 226, string; 227, string; 228, string; 229, string; 230, string; 231, identifier:timeframe; 232, identifier:valid_timeframes; 233, call; 234, identifier:params; 235, string; 236, identifier:params; 237, string; 238, identifier:params; 239, string; 240, identifier:params; 241, string; 242, attribute; 243, identifier:get; 244, string; 245, keyword_argument; 246, dictionary_splat; 247, identifier:gender; 248, identifier:upper; 249, string_content:M; 250, string_content:F; 251, identifier:ValueError; 252, argument_list; 253, string_content:gender; 254, identifier:ValueError; 255, argument_list; 256, string_content:age_group; 257, identifier:ValueError; 258, argument_list; 259, string_content:weight_class; 260, string_content:following; 261, identifier:following; 262, string_content:club_id; 263, string_content:this_year; 264, string_content:this_month; 265, string_content:this_week; 266, string_content:today; 267, identifier:ValueError; 268, argument_list; 269, string_content:date_range; 270, string_content:per_page; 271, string_content:page; 272, string_content:context_entries; 273, identifier:self; 274, identifier:protocol; 275, string_content:/segments/{id}/leaderboard; 276, identifier:id; 277, identifier:segment_id; 278, identifier:params; 279, call; 280, call; 281, call; 282, call; 283, attribute; 284, argument_list; 285, attribute; 286, argument_list; 287, attribute; 288, argument_list; 289, attribute; 290, argument_list; 291, string:"Invalid gender: {0}. Possible values: 'M' or 'F'"; 292, identifier:format; 293, identifier:gender; 294, string:"Invalid age group: {0}.  Possible values: {1!r}"; 295, identifier:format; 296, identifier:age_group; 297, identifier:valid_age_groups; 298, string:"Invalid weight class: {0}.  Possible values: {1!r}"; 299, identifier:format; 300, identifier:weight_class; 301, identifier:valid_weight_classes; 302, string:"Invalid timeframe: {0}.  Possible values: {1!r}"; 303, identifier:format; 304, identifier:timeframe; 305, identifier:valid_timeframes
code: 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):
          """
          Gets the leaderboard for a segment.
  
          http://strava.github.io/api/v3/segments/#leaderboard
  
          Note that by default Strava will return the top 10 results, and if the current user has ridden
          that segment, the current user's result along with the two results above in rank and the two
          results below will be included.  The top X results can be configured by setting the top_results_limit
          parameter; however, the other 5 results will be included if the current user has ridden that segment.
          (i.e. if you specify top_results_limit=15, you will get a total of 20 entries back.)
  
          :param segment_id: ID of the segment.
          :type segment_id: int
  
          :param gender: (optional) 'M' or 'F'
          :type gender: str
  
          :param age_group: (optional) '0_24', '25_34', '35_44', '45_54', '55_64', '65_plus'
          :type age_group: str
  
          :param weight_class: (optional) pounds '0_124', '125_149', '150_164', '165_179', '180_199', '200_plus'
                               or kilograms '0_54', '55_64', '65_74', '75_84', '85_94', '95_plus'
          :type weight_class: str
  
          :param following: (optional) Limit to athletes current user is following.
          :type following: bool
  
          :param club_id: (optional) limit to specific club
          :type club_id: int
  
          :param timeframe: (optional)  'this_year', 'this_month', 'this_week', 'today'
          :type timeframe: str
  
          :param top_results_limit: (optional, strava default is 10 + 5 from end) How many of leading leaderboard entries to display.
                              See description for why this is a little confusing.
          :type top_results_limit: int
  
          :param page: (optional, strava default is 1) Page number of leaderboard to return, sorted by highest ranking leaders
          :type page: int
  
          :param context_entries: (optional, strava default is 2, max is 15) number of entries surrounding requesting athlete to return
          :type context_entries: int
  
          :return: The SegmentLeaderboard for the specified page (default: 1)
          :rtype: :class:`stravalib.model.SegmentLeaderboard`
  
          """
          params = {}
          if gender is not None:
              if gender.upper() not in ('M', 'F'):
                  raise ValueError("Invalid gender: {0}. Possible values: 'M' or 'F'".format(gender))
              params['gender'] = gender
  
          valid_age_groups = ('0_24', '25_34', '35_44', '45_54', '55_64', '65_plus')
          if age_group is not None:
              if not age_group in valid_age_groups:
                  raise ValueError("Invalid age group: {0}.  Possible values: {1!r}".format(age_group, valid_age_groups))
              params['age_group'] = age_group
  
          valid_weight_classes = ('0_124', '125_149', '150_164', '165_179', '180_199', '200_plus',
                                  '0_54', '55_64', '65_74', '75_84', '85_94', '95_plus')
          if weight_class is not None:
              if not weight_class in valid_weight_classes:
                  raise ValueError("Invalid weight class: {0}.  Possible values: {1!r}".format(weight_class, valid_weight_classes))
              params['weight_class'] = weight_class
  
          if following is not None:
              params['following'] = int(following)
  
          if club_id is not None:
              params['club_id'] = club_id
  
          if timeframe is not None:
              valid_timeframes = 'this_year', 'this_month', 'this_week', 'today'
              if not timeframe in valid_timeframes:
                  raise ValueError("Invalid timeframe: {0}.  Possible values: {1!r}".format(timeframe, valid_timeframes))
              params['date_range'] = timeframe
  
          if top_results_limit is not None:
              params['per_page'] = top_results_limit
  
          if page is not None:
              params['page'] = page
  
          if context_entries is not None:
              params['context_entries'] = context_entries
  
          return model.SegmentLeaderboard.deserialize(self.protocol.get('/segments/{id}/leaderboard',
                                                                        id=segment_id,
                                                                        **params),
                                                      bind_client=self)