libimobiledevice / libplist

A library to handle Apple Property List format in binary or XML
https://libimobiledevice.org
GNU Lesser General Public License v2.1
528 stars 304 forks source link

Fix Cython dump method #239

Closed dnicolson closed 7 months ago

dnicolson commented 7 months ago

This fixes the dump method by accepting plist objects and using the correct data type for XML files.

This code now works:

import plist

test = plist.loads(b'<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><array>\t<string>one</string></array></plist>')

with open('test-plist-xml.plist', 'wb') as fp:
  plist.dump(test, fp)

with open('test-plist-binary.plist', 'wb') as fp:
  plist.dump(test, fp, fmt=2)

with open('test-list-xml.plist', 'wb') as fp:
  plist.dump([1,2,3], fp)
nikias commented 7 months ago

Merged with d1d2d36791a7674bae7286c003a82e36ece008ab.