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
121c8345
Commit
121c8345
authored
Apr 03, 2014
by
Andrew Udvare
Committed by
Nikias Bassen
Jul 10, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cython: Implement dump()/dumps() to match up with plistlib (Python 3.4)
parent
7be52ea1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
0 deletions
+37
-0
plist.pxd
cython/plist.pxd
+2
-0
plist.pyx
cython/plist.pyx
+35
-0
No files found.
cython/plist.pxd
View file @
121c8345
...
...
@@ -71,6 +71,8 @@ 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=*)
cpdef object dump(value, fp, fmt=*, sort_keys=*, skipkeys=*)
cpdef object dumps(value, fmt=*, sort_keys=*, skipkeys=*)
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 @
121c8345
...
...
@@ -907,3 +907,38 @@ cpdef object loads(data, fmt=None, use_builtin_types=True, dict_type=dict):
raise ValueError('Cannot parse XML property list as binary')
return cb(data)
cpdef object dump(value, fp, fmt=FMT_XML, sort_keys=True, skipkeys=False):
fp.write(dumps(value, fmt=fmt))
cpdef object dumps(value, fmt=FMT_XML, sort_keys=True, skipkeys=False):
if fmt not in (FMT_XML, FMT_BINARY):
raise ValueError('Format must be constant FMT_XML or FMT_BINARY')
if check_datetime(value):
node = Date(value)
elif isinstance(value, unicode):
node = String(value)
elif PY_MAJOR_VERSION >= 3 and isinstance(value, bytes):
node = Data(value)
elif isinstance(value, str):
# See if this is binary
try:
node = String(value)
except ValueError:
node = Data(value)
elif isinstance(value, bool):
node = Bool(value)
elif isinstance(value, int):
node = Integer(value)
elif isinstance(value, float):
node = Real(value)
elif isinstance(value, dict):
node = Dict(value)
elif type(value) in (list, set, tuple):
node = Array(value)
if fmt == FMT_XML:
return node.to_xml()
return node.to_bin()
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