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)
| 891 | |
| 892 | |
| 893 | def load(fp, *, fmt=None, dict_type=dict, aware_datetime=False): |
| 894 | """Read a .plist file. 'fp' should be a readable and binary file object. |
| 895 | Return the unpacked root object (which usually is a dictionary). |
| 896 | """ |
| 897 | if fmt is None: |
| 898 | header = fp.read(32) |
| 899 | fp.seek(0) |
| 900 | for info in _FORMATS.values(): |
| 901 | if info['detect'](header): |
| 902 | P = info['parser'] |
| 903 | break |
| 904 | |
| 905 | else: |
| 906 | raise InvalidFileException() |
| 907 | |
| 908 | else: |
| 909 | P = _FORMATS[fmt]['parser'] |
| 910 | |
| 911 | p = P(dict_type=dict_type, aware_datetime=aware_datetime) |
| 912 | return p.parse(fp) |
| 913 | |
| 914 | |
| 915 | def loads(value, *, fmt=None, dict_type=dict, aware_datetime=False): |