Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
L
libplist
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pwn
libplist
Commits
7be52ea1
Commit
7be52ea1
authored
Mar 31, 2014
by
Andrew Udvare
Committed by
Nikias Bassen
Jul 10, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cython: Implement load()/loads() to match up with plistlib (Python 3.4)
parent
7d6b42c9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
0 deletions
+58
-0
plist.pxd
cython/plist.pxd
+3
-0
plist.pyx
cython/plist.pyx
+55
-0
No files found.
cython/plist.pxd
View file @
7be52ea1
...
...
@@ -69,5 +69,8 @@ cdef class Array(Node):
cpdef object from_xml(xml)
cpdef object from_bin(bytes bin)
cpdef object load(fp, fmt=*, use_builtin_types=*, dict_type=*)
cpdef object loads(data, fmt=*, use_builtin_types=*, dict_type=*)
cdef object plist_t_to_node(plist_t c_plist, bint managed=*)
cdef plist_t native_to_plist_t(object native)
cython/plist.pyx
View file @
7be52ea1
...
...
@@ -852,3 +852,58 @@ cdef object plist_t_to_node(plist_t c_plist, bint managed=True):
return Uid_factory(c_plist, managed)
if t == PLIST_NONE:
return None
# This is to match up with the new plistlib API
# http://docs.python.org/dev/library/plistlib.html
# dump() and dumps() are not yet implemented
FMT_XML = 1
FMT_BINARY = 2
cpdef object load(fp, fmt=None, use_builtin_types=True, dict_type=dict):
is_binary = fp.read(6) == 'bplist'
fp.seek(0)
if not fmt:
if is_binary:
if 'b' not in fp.mode:
raise IOError('File handle must be opened in binary (b) mode to read binary property lists')
cb = from_bin
else:
cb = from_xml
else:
if fmt not in (FMT_XML, FMT_BINARY):
raise ValueError('Format must be constant FMT_XML or FMT_BINARY')
if fmt == FMT_BINARY:
cb = from_bin
elif fmt == FMT_XML:
cb = from_xml
if is_binary and fmt == FMT_XML:
raise ValueError('Cannot parse binary property list as XML')
elif not is_binary and fmt == FMT_BINARY:
raise ValueError('Cannot parse XML property list as binary')
return cb(fp.read())
cpdef object loads(data, fmt=None, use_builtin_types=True, dict_type=dict):
is_binary = data[0:6] == 'bplist'
if fmt is not None:
if fmt not in (FMT_XML, FMT_BINARY):
raise ValueError('Format must be constant FMT_XML or FMT_BINARY')
if fmt == FMT_BINARY:
cb = from_bin
else:
cb = from_xml
else:
if is_binary:
cb = from_bin
else:
cb = from_xml
if is_binary and fmt == FMT_XML:
raise ValueError('Cannot parse binary property list as XML')
elif not is_binary and fmt == FMT_BINARY:
raise ValueError('Cannot parse XML property list as binary')
return cb(data)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment