1"""DEPRECATED - This module is kept here only as a backward compatibility shim
2for the old ufoLib.plistlib module, which was moved to fontTools.misc.plistlib.
3Please use the latter instead.
4"""
5from fontTools.misc.plistlib import dump, dumps, load, loads
6from fontTools.misc.py23 import tobytes
7
8# The following functions were part of the old py2-like ufoLib.plistlib API.
9# They are kept only for backward compatiblity.
10from fontTools.ufoLib.utils import deprecated
11
12
13@deprecated("Use 'fontTools.misc.plistlib.load' instead")
14def readPlist(path_or_file):
15    did_open = False
16    if isinstance(path_or_file, str):
17        path_or_file = open(path_or_file, "rb")
18        did_open = True
19    try:
20        return load(path_or_file, use_builtin_types=False)
21    finally:
22        if did_open:
23            path_or_file.close()
24
25
26@deprecated("Use 'fontTools.misc.plistlib.dump' instead")
27def writePlist(value, path_or_file):
28    did_open = False
29    if isinstance(path_or_file, str):
30        path_or_file = open(path_or_file, "wb")
31        did_open = True
32    try:
33        dump(value, path_or_file, use_builtin_types=False)
34    finally:
35        if did_open:
36            path_or_file.close()
37
38
39@deprecated("Use 'fontTools.misc.plistlib.loads' instead")
40def readPlistFromString(data):
41    return loads(tobytes(data, encoding="utf-8"), use_builtin_types=False)
42
43
44@deprecated("Use 'fontTools.misc.plistlib.dumps' instead")
45def writePlistToString(value):
46    return dumps(value, use_builtin_types=False)
47