PLIST Dumper

dictdumper.plist contains PLIST only, which dumpers an Apple property list (PLIST) file. Usage sample is described as below.

Dumper class

class dictdumper.plist.PLIST(fname, **kwargs)[source]

Bases: dictdumper.xml.XML

Dump Apple property list (PLIST) format file.

>>> dumper = PLIST(file_name)
>>> dumper(content_dict_1, name=content_name_1)
>>> dumper(content_dict_2, name=content_name_2)
............
Variables
  • _file (str) – output file name

  • _sptr (int) – indicates start of appending point (file pointer)

  • _tctr (int) – tab level counter

  • _hsrt (str) – start string (_HEADER_START)

  • _hend (str) – end string (_HEADER_END)

Note

Terminology:

value    ::=  array | dict | string | data
                | date | integer | real | bool
array    ::=  "<array>" value* "</array>"
dict     ::=  "<dict>" ("<key>" str "</key>" value)* "</dict>"
string   ::=  "<string>" str "</string>"
data     ::=  "<data>" bytes "</data>"
date     ::=  "<date>" datetime "</date>"
integer  ::=  "<integer>" int "</integer>"
real     ::=  "<real>" float "</real>"
bool     ::=  "<true/>" | "<false/>"
__type__ = ((<class 'str'>, 'string'), (<class 'bool'>, 'bool'), (<class 'dict'>, 'dict'), (<class 'datetime.date'>, 'date'), (<class 'datetime.datetime'>, 'date'), (<class 'int'>, 'integer'), (<class 'float'>, 'real'), (<class 'bytes'>, 'data'), (<class 'list'>, 'array'))

Type codes.

Type

Tuple[Tuple[type, str]]

_tctr = 1

Tab level counter.

Type

int

Tab level counter.

Type

int

_hsrt = '<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n<plist version="1.0">\n<dict>\n'

PLIST head string.

_hend = '</dict>\n</plist>\n'

PLIST tail string.

property kind

File format of current dumper.

Return type

Literal[‘plist’]

_encode_value(o)[source]

Check content type for function call.

Parameters

o (Any) – object to convert

Returns

the converted object

Return type

Any

See also

The function is a direct wrapper for object_hook().

Notes

The function will by default converts bytearray, None, memoryview, tuple, set, frozenset to PLIST serialisable data.

_append_value(value, file, name)[source]

Call this function to write contents.

Parameters
  • value (Dict[str, Any]) – content to be dumped

  • file (io.TextIOWrapper) – output file

  • name (str) – name of current content block

_append_dict(value, file)[source]

Call this function to write dict contents.

Parameters
_append_array(value, file)[source]

Call this function to write array contents.

Parameters
  • value (List[Any]) – content to be dumped

  • file (io.TextIOWrapper) – output file

_append_string(value, file)[source]

Call this function to write string contents.

Parameters
_append_data(value, file)[source]

Call this function to write data contents.

Parameters
_append_date(value, file)[source]

Call this function to write date contents.

Parameters
_append_integer(value, file)[source]

Call this function to write integer contents.

Parameters
_append_real(value, file)[source]

Call this function to write real contents.

Parameters
_append_bool(value, file)[source]

Call this function to write bool contents.

Parameters

Internal utilities

dictdumper.plist._HEADER_START = '<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n<plist version="1.0">\n<dict>\n'

PLIST head string.

dictdumper.plist._HEADER_END = '</dict>\n</plist>\n'

PLIST tail string.