• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 *
6
7# The following functions were part of the old py2-like ufoLib.plistlib API.
8# They are kept only for backward compatiblity.
9from fontTools.ufoLib.utils import deprecated
10
11
12@deprecated("Use 'fontTools.misc.plistlib.load' instead")
13def readPlist(path_or_file):
14    did_open = False
15    if isinstance(path_or_file, basestring):
16        path_or_file = open(path_or_file, "rb")
17        did_open = True
18    try:
19        return load(path_or_file, use_builtin_types=False)
20    finally:
21        if did_open:
22            path_or_file.close()
23
24
25@deprecated("Use 'fontTools.misc.plistlib.dump' instead")
26def writePlist(value, path_or_file):
27    did_open = False
28    if isinstance(path_or_file, basestring):
29        path_or_file = open(path_or_file, "wb")
30        did_open = True
31    try:
32        dump(value, path_or_file, use_builtin_types=False)
33    finally:
34        if did_open:
35            path_or_file.close()
36
37
38@deprecated("Use 'fontTools.misc.plistlib.loads' instead")
39def readPlistFromString(data):
40    return loads(tobytes(data, encoding="utf-8"), use_builtin_types=False)
41
42
43@deprecated("Use 'fontTools.misc.plistlib.dumps' instead")
44def writePlistToString(value):
45    return dumps(value, use_builtin_types=False)
46