Mentions légales du service

Skip to content
Snippets Groups Projects

Add a json serilizer for ProcSet (to allow monkey patching)

Closed MERCIER Michael requested to merge json-serializer into master
1 file
+ 15
1
Compare changes
  • Side-by-side
  • Inline
+ 15
1
@@ -28,7 +28,21 @@ scheduling. Hence, the manipulated intervals can be represented as indexes.
"""
import operator
import json
class JSONEncoder(json.JSONEncoder):
"""To make ProcSet JSON serializable you have to Monkey patch the json
encoder with the folowing code:
>>> import json
>>> import procset
>>> json.JSONEncoder.default = procset.JSONEncoder.default
"""
def default(self, o):
"""For JSON serialization."""
if isinstance(o, ProcSet):
return o.__repr__()
else:
return super(self,o)
class ProcInt(tuple):
"""A ProcInt is a closed interval of non-negative integers."""
Loading