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)
| 863 | |
| 864 | |
| 865 | def load(fp, *, fmt=None, dict_type=dict): |
| 866 | """Read a .plist file. 'fp' should be a readable and binary file object. |
| 867 | Return the unpacked root object (which usually is a dictionary). |
| 868 | """ |
| 869 | if fmt is None: |
| 870 | header = fp.read(32) |
| 871 | fp.seek(0) |
| 872 | for info in _FORMATS.values(): |
| 873 | if info['detect'](header): |
| 874 | P = info['parser'] |
| 875 | break |
| 876 | |
| 877 | else: |
| 878 | raise InvalidFileException() |
| 879 | |
| 880 | else: |
| 881 | P = _FORMATS[fmt]['parser'] |
| 882 | |
| 883 | p = P(dict_type=dict_type) |
| 884 | return p.parse(fp) |
| 885 | |
| 886 | |
| 887 | def loads(value, *, fmt=None, dict_type=dict): |