|
2 | 2 |
|
3 | 3 | The property list (.plist) file format is a simple XML pickle supporting |
4 | 4 | basic object types, like dictionaries, lists, numbers and strings. |
5 | | -Usually the top level object is a dictionary. |
| 5 | +Usually the top level object is a dictionary or a frozen dictionary. |
6 | 6 |
|
7 | 7 | To write out a plist file, use the dump(value, file) |
8 | 8 | function. 'value' is the top level object, 'file' is |
@@ -357,7 +357,7 @@ def write_value(self, value): |
357 | 357 | elif isinstance(value, float): |
358 | 358 | self.simple_element("real", repr(value)) |
359 | 359 |
|
360 | | - elif isinstance(value, dict): |
| 360 | + elif isinstance(value, (dict, frozendict)): |
361 | 361 | self.write_dict(value) |
362 | 362 |
|
363 | 363 | elif isinstance(value, (bytes, bytearray)): |
@@ -715,7 +715,7 @@ def _flatten(self, value): |
715 | 715 | self._objidtable[id(value)] = refnum |
716 | 716 |
|
717 | 717 | # And finally recurse into containers |
718 | | - if isinstance(value, dict): |
| 718 | + if isinstance(value, (dict, frozendict)): |
719 | 719 | keys = [] |
720 | 720 | values = [] |
721 | 721 | items = value.items() |
@@ -836,7 +836,7 @@ def _write_object(self, value): |
836 | 836 | self._write_size(0xA0, s) |
837 | 837 | self._fp.write(struct.pack('>' + self._ref_format * s, *refs)) |
838 | 838 |
|
839 | | - elif isinstance(value, dict): |
| 839 | + elif isinstance(value, (dict, frozendict)): |
840 | 840 | keyRefs, valRefs = [], [] |
841 | 841 |
|
842 | 842 | if self._sort_keys: |
@@ -869,18 +869,18 @@ def _is_fmt_binary(header): |
869 | 869 | # Generic bits |
870 | 870 | # |
871 | 871 |
|
872 | | -_FORMATS={ |
873 | | - FMT_XML: dict( |
| 872 | +_FORMATS=frozendict({ |
| 873 | + FMT_XML: frozendict( |
874 | 874 | detect=_is_fmt_xml, |
875 | 875 | parser=_PlistParser, |
876 | 876 | writer=_PlistWriter, |
877 | 877 | ), |
878 | | - FMT_BINARY: dict( |
| 878 | + FMT_BINARY: frozendict( |
879 | 879 | detect=_is_fmt_binary, |
880 | 880 | parser=_BinaryPlistParser, |
881 | 881 | writer=_BinaryPlistWriter, |
882 | 882 | ) |
883 | | -} |
| 883 | +}) |
884 | 884 |
|
885 | 885 |
|
886 | 886 | def load(fp, *, fmt=None, dict_type=dict, aware_datetime=False): |
|
0 commit comments