mirror of
https://github.com/corpnewt/gibMacOS.git
synced 2025-01-21 20:51:24 +01:00
Update plist.py from pymodules
This commit is contained in:
parent
afef3f3139
commit
f0461cbaab
@ -117,7 +117,8 @@ def load(fp, fmt=None, use_builtin_types=None, dict_type=dict):
|
||||
parser.StartElementHandler = p.handleBeginElement
|
||||
parser.EndElementHandler = p.handleEndElement
|
||||
parser.CharacterDataHandler = p.handleData
|
||||
# We also need to monkey patch this to allow for other dict_types
|
||||
# We also need to monkey patch this to allow for other dict_types, hex int support
|
||||
# proper line output for data errors, and for unicode string decoding
|
||||
def begin_dict(attrs):
|
||||
d = dict_type()
|
||||
p.addObject(d)
|
||||
@ -134,9 +135,15 @@ def load(fp, fmt=None, use_builtin_types=None, dict_type=dict):
|
||||
p.addObject(plistlib.Data.fromBase64(p.getData()))
|
||||
except Exception as e:
|
||||
raise Exception("Data error at line {}: {}".format(parser.CurrentLineNumber,e))
|
||||
def end_string():
|
||||
d = p.getData()
|
||||
if isinstance(d,unicode):
|
||||
d = d.encode("utf-8")
|
||||
p.addObject(d)
|
||||
p.begin_dict = begin_dict
|
||||
p.end_integer = end_integer
|
||||
p.end_data = end_data
|
||||
p.end_string = end_string
|
||||
if isinstance(fp, unicode):
|
||||
# Encode unicode -> string; use utf-8 for safety
|
||||
fp = fp.encode("utf-8")
|
||||
|
Loading…
Reference in New Issue
Block a user