Conditions | 4 |
Total Lines | 23 |
Lines | 0 |
Ratio | 0 % |
Tests | 2 |
CRAP Score | 14.993 |
Changes | 0 |
1 | 1 | from plugin.core.constants import PMS_PATH |
|
27 | 1 | @classmethod |
|
28 | 1 | def hash(cls, exception=None, exc_info=None, include_traceback=True): |
|
29 | if exception is not None: |
||
30 | # Retrieve hash parameters from `Exception` object |
||
31 | type = exception.type |
||
32 | message = exception.message |
||
33 | tb = exception.traceback |
||
34 | elif exc_info is not None: |
||
35 | # Build hash parameters from `exc_info` |
||
36 | type = cls.exc_type(exc_info[0]) |
||
37 | message = cls.exc_message(exc_info[1]) |
||
38 | tb = cls.exc_traceback(exc_info[2]) |
||
39 | else: |
||
40 | raise ValueError |
||
41 | |||
42 | m = hashlib.md5() |
||
43 | m.update(str(type)) |
||
44 | m.update(str(message)) |
||
45 | |||
46 | if include_traceback: |
||
47 | m.update(str(tb)) |
||
48 | |||
49 | return m.hexdigest() |
||
50 |
It is generally discouraged to redefine built-ins as this makes code very hard to read.