Python expand OSX path with spaces in it
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)
I get 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'
Update
Ignacio开发者_如何学运维 Vazquez-Abram's answer 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?
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
instead.
精彩评论