Skip to content
This repository was archived by the owner on Jan 13, 2023. It is now read-only.

Commit 1879c01

Browse files
committed
[#145] Reformatted rest of iota package for PEP-8.
1 parent 1dcad0a commit 1879c01

File tree

5 files changed

+1121
-1035
lines changed

5 files changed

+1121
-1035
lines changed

iota/exceptions.py

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,36 @@
11
# coding=utf-8
22
from __future__ import absolute_import, division, print_function, \
3-
unicode_literals
3+
unicode_literals
4+
5+
__all__ = [
6+
'with_context',
7+
]
48

59

610
def with_context(exc, context):
7-
# type: (Exception, dict) -> Exception
8-
"""
9-
Attaches a ``context`` value to an Exception.
11+
# type: (Exception, dict) -> Exception
12+
"""
13+
Attaches a ``context`` value to an Exception.
14+
15+
Before:
16+
17+
.. code-block:: python
1018
11-
Before::
19+
exc = Exception('Frog blast the vent core!')
20+
exc.context = { ... }
21+
raise exc
1222
13-
exc = Exception('Frog blast the vent core!')
14-
exc.context = { ... }
15-
raise exc
23+
After:
1624
17-
After::
25+
.. code-block:: python
1826
19-
raise with_context(Exception('Frog blast the vent core!'), { ... })
20-
"""
21-
if not hasattr(exc, 'context'):
22-
exc.context = {}
27+
raise with_context(
28+
exc=Exception('Frog blast the vent core!'),
29+
context={ ... },
30+
)
31+
"""
32+
if not hasattr(exc, 'context'):
33+
exc.context = {}
2334

24-
exc.context.update(context)
25-
return exc
35+
exc.context.update(context)
36+
return exc

0 commit comments

Comments
 (0)