Conditions | 6 |
Total Lines | 26 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 42 |
Changes | 0 |
1 | from raven.processors import Processor |
||
32 | def to_relative(self, d, key=None): |
||
33 | if type(d) is list: |
||
34 | if key is not None: |
||
35 | value = d[key] |
||
36 | else: |
||
37 | # Run `to_relative` on each item |
||
38 | for x in range(len(d)): |
||
39 | self.to_relative(d, x) |
||
40 | |||
41 | return True |
||
42 | else: |
||
43 | value = d.get(key) |
||
44 | |||
45 | if not value: |
||
46 | return False |
||
47 | |||
48 | # Find `separator` position |
||
49 | pos = os.path.normcase(value).find(self.separator) |
||
50 | |||
51 | if pos == -1: |
||
52 | return False |
||
53 | |||
54 | # Update `d[key]` with relative path |
||
55 | d[key] = value[pos:] |
||
56 | |||
57 | return True |
||
58 |
Generally, you would want to handle very specific errors in the exception handler. This ensure that you do not hide other types of errors which should be fixed.
So, unless you specifically plan to handle any error, consider adding a more specific exception.