Commit 00923add authored by Julien Muchembled's avatar Julien Muchembled

Python 2.4: monkey-patch pprint to sort keys of dictionaries

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@42306 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 683ec21f
......@@ -72,3 +72,16 @@ if sys.version_info < (2, 5):
import re, sre
re._compile = sre._compile
# Monkey-patch pprint to sort keys of dictionaries
class _ordered_dict(dict):
def iteritems(self):
return sorted(self.items())
import pprint as _pprint
orig_safe_repr = _pprint._safe_repr
def _safe_repr(object, context, maxlevels, level):
if type(object) is dict:
object = _ordered_dict(object)
return orig_safe_repr(object, context, maxlevels, level)
_pprint._safe_repr = _safe_repr
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment