Read a .plist file. 'fp' should be a readable and binary file object. Return the unpacked root object (which usually is a dictionary).
(fp, *, fmt=None, dict_type=dict, aware_datetime=False)
| 884 | |
| 885 | |
| 886 | def load(fp, *, fmt=None, dict_type=dict, aware_datetime=False): |
| 887 | """Read a .plist file. 'fp' should be a readable and binary file object. |
| 888 | Return the unpacked root object (which usually is a dictionary). |
| 889 | """ |
| 890 | if fmt is None: |
| 891 | header = fp.read(32) |
| 892 | fp.seek(0) |
| 893 | for info in _FORMATS.values(): |
| 894 | if info['detect'](header): |
| 895 | P = info['parser'] |
| 896 | break |
| 897 | |
| 898 | else: |
| 899 | raise InvalidFileException() |
| 900 | |
| 901 | else: |
| 902 | P = _FORMATS[fmt]['parser'] |
| 903 | |
| 904 | p = P(dict_type=dict_type, aware_datetime=aware_datetime) |
| 905 | return p.parse(fp) |
| 906 | |
| 907 | |
| 908 | def loads(value, *, fmt=None, dict_type=dict, aware_datetime=False): |