[racket] xml/plist plist-dict
Tell me if this works well and I'll commit it:
https://github.com/jeapostrophe/exp/blob/master/plist-dict.rkt
One problem could be that it doesn't preserve the order of the
original plist dict entries. I could switch it to use an alist and the
dict interface, if that IS a problem.
Jay
On Thu, May 31, 2012 at 3:09 PM, Steve Byan <stevebyan at verizon.net> wrote:
> I've finally found the time and motivation to start exploring racket in earnest. I'm diving right in by trying to edit the preferences in my Mac OS X Mail.app mail client to set all my mailboxes to sort in descending order. This involves scanning over the xml in all the Info.plist files scattered throughout my ~/Library/Mail/V2/Mailboxes directory tree, finding the ones with the "SortedDescending" property set to "NO", and re-writing them with "SortedDescending" set to "YES".
>
> Many thanks to the fine Racket developers; I'm finding the documentation surprisingly useful for "just diving in". (The last LISP I wrote in earnest was before Scheme had been invented, back in 6.011 in 1973.) Thanks also to the developer of the xml/plist library; I didn't expect to have something already in the library that parses Apple's plist xml DTD. (BTW, avoiding xpath and xslt was the primary motivator for trying to write this in Racket; at this point, I only have a limited number of brain cells to spend, and don't want to waste them on learning that nonsense.)
>
> However, I would appreciate a pointer. I've got "find-files" working to produce a list of all my Info.plist files, and the "for" list-comprehension iterating over "find-files" result, and "call-with-input-file" working with "read-plist" to suck in the XML and produce a "plist-dict".
>
> But, I'm at something of a loss to understand what to do with a plist-dict. Is there a way to convert between a plist-dict and a real dictionary and vice-versa? I'd like to query the existence of the property key, get its value, and either mutate it by setting a new value or copy it with a new value for the key. I see the grammar for plist-dicts in the docs, but my instinct tells me that there's a better way to deal with them than by writing functions based on the grammar to implement the dictionary-like behavior that I seek.
>
> Best regards,
> -Steve
>
> --
> Steve Byan <stevebyan at me.com>
> Littleton, MA 01460
>
>
>
> --
> Steve Byan <stevebyan at me.com>
> Littleton, MA 01460
>
>
>
>
> ____________________
> Racket Users list:
> http://lists.racket-lang.org/users
--
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://faculty.cs.byu.edu/~jay
"The glory of God is Intelligence" - D&C 93