fixed issue 1318, as_yaml, thanks Alan

This commit is contained in:
mdipierro
2013-02-04 09:28:09 -06:00
parent d06a1a68a0
commit 90f8f223b9
3 changed files with 36 additions and 1 deletions
+16
View File
@@ -19,6 +19,11 @@ except ImportError:
except:
import contrib.simplejson as json_parser # fallback to pure-Python module
have_yaml = True
try:
import yaml
except ImportError:
have_yaml = False
def loads_json(o):
# deserialize a json string
@@ -119,3 +124,14 @@ def rss(feed):
pubDate=entry.get('created_on', now)
) for entry in feed.get('entries', [])])
return rss.to_xml(encoding='utf-8')
def yaml(data):
if have_yaml:
return yaml.dump(data)
else: raise ImportError("No YAML serializer available")
def loads_yaml(data):
if have_yaml:
return yaml.load(data)
else: raise ImportError("No YAML serializer available")