[pymacadmin] ye olde binary plist debate

6 views
Skip to first unread message

Preston Holmes

unread,
May 12, 2010, 1:19:20 PM5/12/10
to pymac...@googlegroups.com
Nigel has brought back up the plist thing again (on twitter) - I do think that is worth having a pure python version that can handle binary plists.

Somewhere along the way a perl util came up, and I believe it to be:

http://scw.us/iPhone/plutil/

first I compared a complex plist conversion between the perl script and plutil

Basically it passed a simple diff test. There are some float sig digit differences, and the header still uses "Apple Computer" where Apple's version now drops the "Computer"

Just to see how much work it would be I tried porting part of the binary -> xml, just looking at the trailer part of the file and it ends up looking like this:

perl:

open(INF, $filename) or die "can't open $filename for conversion";
binmode(INF);
open(OUTF, ">:utf8", "$newname") or die "can't open $newname for output";

# get trailer
seek(INF, -32, SEEK_END);
my $buf;
read(INF, $buf, 32);
($OffsetSize, $ObjRefSize, $NumObjects, $TopObject, $OffsetTableOffset) = unpack "x6CC(x4N)3", $buf;

Python:

f = open("com.apple.iPhoto.binary.plist","rb")
f.seek(-32,os.SEEK_END)
buf = f.read(32)
offset_size, obj_ref_size, num_objects, top_object, offset_table_offset = struct.unpack("!6xBB4xL4xL4xL", buf)

See that difference in the unpack format strings - ugh.

a quick grep turns up 33 uses of unpack in the perl - most far simpler than that.

certainly not likely to be something I'll find time to do, but I did want to see if it was possible.

-Preston

--
You received this message because you are subscribed to the Google Groups "PyMacAdmin" group.
To post to this group, send email to pymac...@googlegroups.com.
To unsubscribe from this group, send email to pymacadmin+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pymacadmin?hl=en.

Reply all
Reply to author
Forward
0 new messages