aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r/lib/utils.py
diff options
context:
space:
mode:
authorFrançois Schmidts <francois.schmidts@gmail.com>2015-03-01 03:20:12 +0100
committerFrançois Schmidts <francois.schmidts@gmail.com>2015-03-03 22:23:02 +0100
commit5572851eca3b2f1bc56aed7232284acc436d2f49 (patch)
treeb8f425333804ca06a4a16600b4c4c0bfcdf4cff7 /pyaggr3g470r/lib/utils.py
parentcontinuing refacto (diff)
downloadnewspipe-5572851eca3b2f1bc56aed7232284acc436d2f49.tar.gz
newspipe-5572851eca3b2f1bc56aed7232284acc436d2f49.tar.bz2
newspipe-5572851eca3b2f1bc56aed7232284acc436d2f49.zip
new crawler with cache control and error handling
Diffstat (limited to 'pyaggr3g470r/lib/utils.py')
-rw-r--r--pyaggr3g470r/lib/utils.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/pyaggr3g470r/lib/utils.py b/pyaggr3g470r/lib/utils.py
new file mode 100644
index 00000000..a4f4b3ec
--- /dev/null
+++ b/pyaggr3g470r/lib/utils.py
@@ -0,0 +1,14 @@
+import types
+
+def default_handler(obj):
+ """JSON handler for default query formatting"""
+ if hasattr(obj, 'isoformat'):
+ return obj.isoformat()
+ if hasattr(obj, 'dump'):
+ return obj.dump()
+ if isinstance(obj, (set, frozenset, types.GeneratorType)):
+ return list(obj)
+ if isinstance(obj, BaseException):
+ return str(obj)
+ raise TypeError("Object of type %s with value of %r "
+ "is not JSON serializable" % (type(obj), obj))
bgstack15