Utilities
¶
YFPY module for managing complex JSON data structures.
Attributes: |
|
---|
Functions:
Name | Description |
---|---|
retrieve_game_code_from_user |
Recursive function to retrieve required Yahoo Fantasy Sports game code from user input. |
complex_json_handler |
Custom handler to allow custom YFPY objects to be serialized into JSON. |
jsonify_data |
Function to serialize a YahooFantasyObject to a JSON string. |
jsonify_data_to_file |
Function to serialize a YahooFantasyObject to JSON and output it to a file. |
prettify_data |
Function to return pretty formatted JSON strings for easily readable output from objects. |
unpack_data |
Recursive function to parse, clean, and assign custom data types to retrieved Yahoo Fantasy Sports data. |
convert_strings_to_numeric_equivalents |
Convert JSON strings with integer or float numeric representations to their respective integer or float values. |
get_type |
Cast JSON object to custom subclass type extracted from parent class. |
flatten_json_dict_list |
Recursive function to flatten JSON lists containing all disparate JSON dictionaries with no overlapping keys. |
flatten_to_list |
Function to flatten JSON dictionaries with unnecessary keys to a list of objects. |
flatten_to_objects |
Function to flatten a JSON dictionary (or a JSON dictionary in a list) to a dictionary of cast objects. |
dict_to_list |
Function to convert a JSON dictionary to a list. |
reorganize_json_dict |
Function to reorganize a JSON dictionary of dictionaries. |
reformat_json_list |
Function to clean and reformat JSON lists to eliminate empty values and unnecessarily nested lists. |
retrieve_game_code_from_user ¶
retrieve_game_code_from_user()
Recursive function to retrieve required Yahoo Fantasy Sports game code from user input.
Returns: |
|
---|
Source code in yfpy/utils.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
|
complex_json_handler ¶
complex_json_handler(obj)
Custom handler to allow custom YFPY objects to be serialized into JSON.
Parameters: |
|
---|
Returns: |
|
---|
Source code in yfpy/utils.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
|
jsonify_data ¶
jsonify_data(data)
Function to serialize a YahooFantasyObject to a JSON string.
Parameters: |
|
---|
Returns: |
|
---|
Source code in yfpy/utils.py
65 66 67 68 69 70 71 72 73 74 75 |
|
jsonify_data_to_file ¶
jsonify_data_to_file(data, data_file)
Function to serialize a YahooFantasyObject to JSON and output it to a file.
Parameters: |
|
---|
Source code in yfpy/utils.py
78 79 80 81 82 83 84 85 86 |
|
prettify_data ¶
prettify_data(data)
Function to return pretty formatted JSON strings for easily readable output from objects.
Parameters: |
|
---|
Returns: |
|
---|
Source code in yfpy/utils.py
89 90 91 92 93 94 95 96 97 98 99 |
|
unpack_data ¶
unpack_data(json_obj, parent_class=None)
Recursive function to parse, clean, and assign custom data types to retrieved Yahoo Fantasy Sports data.
Parameters: |
|
---|
Returns: |
|
---|
Source code in yfpy/utils.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
|
convert_strings_to_numeric_equivalents ¶
convert_strings_to_numeric_equivalents(json_obj)
Convert JSON strings with integer or float numeric representations to their respective integer or float values.
Parameters: |
|
---|
Returns: |
|
---|
Source code in yfpy/utils.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
|
get_type ¶
get_type(json_obj_dict, parent_class, subclasses)
Cast JSON object to custom subclass type extracted from parent class.
Parameters: |
|
---|
Returns: |
|
---|
Source code in yfpy/utils.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
|
flatten_json_dict_list ¶
flatten_json_dict_list(json_obj_dict_list, parent_class)
Recursive function to flatten JSON lists containing all disparate JSON dictionaries with no overlapping keys.
Parameters: |
|
---|
Returns: |
|
---|
Source code in yfpy/utils.py
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
|
flatten_to_list ¶
flatten_to_list(json_obj)
Function to flatten JSON dictionaries with unnecessary keys to a list of objects.
Parameters: |
|
---|
Returns: |
|
---|
Source code in yfpy/utils.py
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
|
flatten_to_objects ¶
flatten_to_objects(json_obj)
Function to flatten a JSON dictionary (or a JSON dictionary in a list) to a dictionary of cast objects.
Parameters: |
|
---|
Returns: |
|
---|
Source code in yfpy/utils.py
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
|
dict_to_list ¶
dict_to_list(json_dict)
Function to convert a JSON dictionary to a list.
Parameters: |
|
---|
Returns: |
|
---|
Source code in yfpy/utils.py
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
|
reorganize_json_dict ¶
reorganize_json_dict(json_dict, obj_key, val_to_key)
Function to reorganize a JSON dictionary of dictionaries.
The reorganized JSON dictionary is an ordered dictionary sorted by a specific attribute of the value dictionaries.
Parameters: |
|
---|
Returns: |
|
---|
Source code in yfpy/utils.py
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 |
|
reformat_json_list ¶
reformat_json_list(json_obj)
Function to clean and reformat JSON lists to eliminate empty values and unnecessarily nested lists.
Parameters: |
|
---|
Returns: |
|
---|
Source code in yfpy/utils.py
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 |
|