Created
September 17, 2012 12:21
-
-
Save Luzifer/3736991 to your computer and use it in GitHub Desktop.
Little python script to export your dashboard stickies to text only format to copy to another location
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import json, subprocess, os, re, HTMLParser | |
exportcmd = 'plutil -convert json -o - %s' % os.path.expanduser('~/Library/Preferences/widget-com.apple.widget.stickies.plist') | |
out = json.loads(subprocess.check_output(exportcmd.split(' '))) | |
stickies = [] | |
htmlparser = HTMLParser.HTMLParser() | |
for key in out.keys(): | |
if not '-data' in key: | |
continue | |
html = out[key] | |
text = re.sub('\n+', '\n', '\n'.join(re.split(r'<[^>]*div>', html))).strip() | |
text = '\n'.join(re.split(r'<br[^>]*>\n?', text)) | |
lines = text.split('\n') | |
lines = map((lambda parm: htmlparser.unescape(parm).strip()), lines) | |
text = '\n'.join(lines).strip() | |
stickies.append(text) | |
print '\n\n=====\n\n'.join(stickies) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment