| Conditions | 13 |
| Total Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
Complex classes like niprov.Diff._checkDiff() often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
| 1 | |||
| 11 | def _checkDiff(self, ignore=None, select=None): |
||
| 12 | assert isinstance(ignore, list) or ignore is None |
||
| 13 | if ignore is None: |
||
| 14 | ignore = [] |
||
| 15 | ignore += self.defaultIgnore |
||
| 16 | prov1 = self.file1.getProvenance() |
||
| 17 | prov2 = self.file2.getProvenance() |
||
| 18 | if select: |
||
| 19 | allkeys = set(prov1.keys()+prov2.keys()) |
||
| 20 | ignore = [k for k in allkeys if k not in select] |
||
| 21 | diffDict = {} |
||
| 22 | for k in set(prov1.keys()).difference(prov2.keys()): |
||
| 23 | if k not in ignore: |
||
| 24 | diffDict[k] = 'missingIn2' |
||
| 25 | for k in set(prov2.keys()).difference(prov1.keys()): |
||
| 26 | if k not in ignore: |
||
| 27 | diffDict[k] = 'missingIn1' |
||
| 28 | for k in set(prov1.keys()).intersection(prov2.keys()): |
||
| 29 | if k not in ignore: |
||
| 30 | if prov1[k] != prov2[k]: |
||
| 31 | diffDict[k] = 'value' |
||
| 32 | return diffDict |
||
| 33 | |||
| 47 |