| Total Complexity | 8 | 
| Total Lines | 33 | 
| Duplicated Lines | 0 % | 
| Coverage | 94.74% | 
| Changes | 0 | ||
| 1 | 1 | from lxml import etree | |
| 2 | |||
| 3 | 1 | from ..data_structures.data_structures import Remediation | |
| 4 | |||
| 5 | |||
| 6 | 1 | class RemediationParser(): | |
| 7 | 1 | def __init__(self, ref_values): | |
| 8 | 1 | self.ref_values = ref_values | |
| 9 | |||
| 10 | 1 | def replace_sub_tag(self, tag): | |
| 11 | 1 |         return self.ref_values.get(tag.get("idref")) | |
| 12 | |||
| 13 | 1 | def _get_remediation_code(self, fix): | |
| 14 | 1 | str_fix = fix.text | |
| 15 | 1 | for child in fix: | |
| 16 | 1 | if str_fix is None: | |
| 17 | str_fix = "" | ||
| 18 | 1 | if etree.QName(child).localname == "sub": | |
| 19 | 1 | str_fix += self.replace_sub_tag(child) | |
| 20 | 1 | str_fix += child.tail if child.tail is not None else "" | |
| 21 | 1 | return str_fix | |
| 22 | |||
| 23 | 1 | def get_remediation(self, fix): | |
| 24 | 1 |         fix_dict = { | |
| 25 |             "remediation_id": fix.get("id"), | ||
| 26 |             "system": fix.get("system"), | ||
| 27 |             "complexity": fix.get("complexity", ""), | ||
| 28 |             "disruption": fix.get("disruption", ""), | ||
| 29 |             "strategy": fix.get("strategy", ""), | ||
| 30 | "fix": self._get_remediation_code(fix), | ||
| 31 | } | ||
| 32 | return Remediation(**fix_dict) | ||
| 33 |