Skip to content

Commit e2bf924

Browse files
committed
Add to_dict() function to Error object
* and other minor formattings Signed-off-by: Philippe Ombredanne <[email protected]>
1 parent 3185c41 commit e2bf924

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/attributecode/__init__.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929

3030
__version__ = '3.3.0'
3131

32-
3332
__about_spec_version__ = '3.1'
3433

3534
__copyright__ = """
@@ -66,6 +65,12 @@ def __repr__(self, *args, **kwargs):
6665
msg = clean_string(repr(self.message))
6766
return 'Error(%(sev)s, %(msg)s)' % locals()
6867

68+
def to_dict(self, *args, **kwargs):
69+
"""
70+
Return an ordered mapping of self.
71+
"""
72+
return self._asdict()
73+
6974

7075
def clean_string(s):
7176
"""
@@ -87,6 +92,7 @@ def clean_string(s):
8792
s = s.replace("\\\\", "\\")
8893
return s
8994

95+
9096
# modeled after the logging levels
9197
CRITICAL = 50
9298
ERROR = 40
@@ -103,4 +109,4 @@ def clean_string(s):
103109
INFO : u'INFO',
104110
DEBUG : u'DEBUG',
105111
NOTSET : u'NOTSET'
106-
}
112+
}

0 commit comments

Comments
 (0)