Python SDK for PhoneFactor
A first (and very alpha) attempt at creating a Python SDK for PhoneFactor.
Link: http://github.com/silas/graveyard/tree/master/python-phonefactor/
Universal Feed Parser to JSON
My attempt at wrangling a Universal Feed Parser object into JSON.
import feedparser
def json_make_normal(obj):
if type(obj) in [str, unicode, int, float, bool, dict, set, list, tuple]:
return obj
try: return dict(obj)
except: pass
try: return list(obj)
except: pass
return None
def json_handle(obj):
obj = json_make_normal(obj)
if type(obj) in [str, unicode]:
obj = obj.replace('\\', '\\\\')
obj = obj.replace('"', '\\"')
obj = obj.replace('\b', '\\\b')
obj = obj.replace('\f', '\\\f')
obj = obj.replace('\n', '\\\n')
obj = obj.replace('\r', '\\\r')
obj = obj.replace('\t', '\\\t')
return '"%s"' % obj
elif type(obj) in [int, float]:
return obj
elif type(obj) is bool:
if obj: return 'true'
else: return 'false'
elif type(obj) is type(None):
return 'null'
elif type(obj) is dict:
temp = ''
for key in obj.keys():
temp += '%s:%s, ' % (json_handle(key), json_handle(obj[key]))
return '{%s}' % temp[:-2]
elif type(obj) in [set, list, tuple]:
temp = ''
for value in obj:
temp += '%s, ' % json_handle(value)
return '[%s]' % temp[:-2]
return 'null'
data = feedparser.parse('http://digg.com/rss/index.xml')
print json_handle(data)
Link: feed_parser_to_json.py
Update: According to John Paulett jsonpickle now supports Universal Feed Parser objects. Thanks for letting me know!
opml2html Updates
I've made some tweaks to opml2html to make it a little cleaner and more useful.
The main two additions are a class so opml2html can be called programmatically and a command line argument so the input file isn't static.
Convert Google Reader subscriptions (OPML) to HTML
I've created a simple Python script to convert Google Reader’s OPML to HTML.
Link: http://github.com/silas/graveyard/tree/master/python-opml2html/