Python expande la ruta de OSX con espacios en ella

I'm trying to modify the plist file at: /Volumes/MacintoshHD/Users/christian/Library/Application Support/iPhone Simulator/4.3.2/Library/Preferences/com.apple.Accessibility.plist

Here's my noob python script:

import plistlib
import os.path

#set path 
prefs_path = os.path.expanduser("~/Library/Application\ Support/iPhone\ Simulator/5.0/Library/Preferences/com.apple.Accessibility.plist")

#parse
prefs = plistlib.readPlist(prefs_path)

yo obtengo IOError: 2, 'No such file or directory'

If I remove the backslashes from the path I get ExpatError: 'not well-formed (invalid token): line 1, column 8'

Noticias

La respuesta de Ignacio Vazquez-Abram suggests that the file is corrupted. It's still editable with Xcode and viewable with Quicklook. Also the simulator works fine.

When I open it in textmate all I see is this:

bplist00ÿ           
D   _ApplicationAccessibilityEnabled_VOTQuickNavEnabled_AccessibilityEnabled]ScreenCurtain_"VoiceOverTouchRotorItemsPreference_AXInspector.enabled_AXInspector.frame_AXInspectorEnabled         Ø"%(+.147:=@“   YRotorItemWEnabledYCharacter    “   TWord   “   TLine   “   VHeader “   TLink   “   [FormElement    “#  ZTableStart “&YListStart“)YLandmarks“,[VisitedLink“/^NonVisitedLink“2VButton“5YTextField“8UImage“;ZStaticText“>\InternalLink“ATZoom_{{0, 0}, {276, 166}}    ;Pguö∞ƒŸ⁄€‹›Òˆ#().56;@AFRSXcdistyÉÑâïñõ™´∞∑∏Ω«»Õ”‘Ÿ‰Â͘¯˝F

Are the iPhone simulator plists not editable by python or is this a corrupted file? Is there a way around this?

preguntado el 28 de septiembre de 11 a las 05:09

1 Respuestas

The expat error means that you've gotten to the file, but there's something wrong with it. Open the file and verify that it's not been corrupted.

EDIT:

Aaah, it's a binary plist. Yeah, plistlib can't handle those. You want libplist en vez.

Respondido el 28 de Septiembre de 11 a las 10:09

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.