Leader
Leader Class
Represents a statistical leader in a specific category for a given season.
The Leader class encapsulates information about an athlete (Player) and their team in the context of a statistical category. It fetches relevant data from the provided JSON, stores the athlete and team information, and tracks the leader's rank and statistical value.
Attributes:
Name | Type | Description |
---|---|---|
leader_json |
dict
|
The JSON data for the leader. |
espn_instance |
object
|
The instance of the ESPN-related class for interacting with ESPN data. |
rank |
int
|
The rank of the athlete in the leader category. |
athlete |
Player or None
|
The Player instance representing the athlete who is the leader. |
team |
Team or None
|
The Team instance representing the team of the leader. |
value |
float
|
The statistical value of the leader in the category. |
rel |
dict or None
|
The relationship data in the leader JSON, which may contain references to athlete and team data. |
Methods:
Name | Description |
---|---|
__repr__ |
Returns a string representation of the Leader instance. |
_load_leader_data |
Loads the leader data from the provided JSON, initializing athlete, team, and value. |
Source code in pyespn/classes/stat.py
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 |
|
espn_instance
property
PYESPN: the espn client instance associated with the class
__init__(leader_json, espn_instance, season, rank)
Initializes a Leader instance with the given leader data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
leader_json
|
dict
|
The JSON data representing the leader's information. |
required |
espn_instance
|
object
|
An instance of the ESPN class for interacting with ESPN data. |
required |
rank
|
int
|
The rank of the athlete in the leader category. |
required |
Source code in pyespn/classes/stat.py
__repr__()
Returns a string representation of the Leader instance.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
A formatted string with the Leader Info. |
Source code in pyespn/classes/stat.py
to_dict()
Converts the Leader instance to its original JSON dictionary.
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
The leaders's raw JSON data. |