Conditions | 3 |
Total Lines | 21 |
Lines | 0 |
Ratio | 0 % |
1 | from plugin.core.constants import PMS_PATH |
||
27 | @classmethod |
||
28 | def hash(cls, exception=None, exc_info=None): |
||
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 | m.update(str(tb)) |
||
46 | |||
47 | return m.hexdigest() |
||
48 |
It is generally discouraged to redefine built-ins as this makes code very hard to read.