GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

BoomBestandenShredder.shred_xml_file()   B
last analyzed

Complexity

Conditions 1

Size

Total Lines 63
Code Lines 46

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 19
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 46
nop 2
dl 0
loc 63
ccs 19
cts 19
cp 1
crap 1
rs 8.7672
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
from lxml import etree
2
3
from kerapu.shredder.Shredder import Shredder
4 1
5
6 1
class BoomBestandenShredder(Shredder):
7
    """
8
    Klasse voor het schreden en opslaan in CSV-formaat van boombestanden opgeslagen in XML-formaat.
9 1
    """
10
11
    # ------------------------------------------------------------------------------------------------------------------
12
    def shred_xml_file(self, filename: str) -> None:
13
        """
14
        Slaat de boombestanden op in CSV-formaat.
15 1
16
        :param str filename: De filenaam van het XML bestand.
17
        """
18
        self._io.title('Shredder')
19
20
        doc = etree.parse(filename)
21 1
22
        xpath = '/soapenv:Envelope/soapenv:Body/InlezenBoomBestanden/BoomBestanden/'
23 1
        namespaces = {'soapenv': 'http://schemas.xmlsoap.org/soap/envelope/'}
24
25 1
        # Extract beslis regels.
26 1
        table = doc.xpath(xpath + 'BeslisRegels/BeslisRegel', namespaces=namespaces)
27
        fields = ['BeslisRegelId',
28
                  'AttribuutGroepId',
29 1
                  'BeslisRegelTrue',
30 1
                  'BeslisRegelFalse',
31
                  'LabelTrue',
32
                  'LabelFalse',
33
                  'IndicatieAanspraakbeperking',
34
                  'VersieDatum']
35
        self.extract_table(table, 'BeslisRegels.csv', fields, fields)
36
37
        # Extract attribuut groep.
38 1
        table = doc.xpath(xpath + 'AttribuutGroepen/AttribuutGroep', namespaces=namespaces)
39
        fields = ['AttribuutGroepId',
40
                  'AttribuutGroepOmschrijving',
41 1
                  'AantalVoorwaardenVoorTrue',
42 1
                  'VersieDatum']
43
        self.extract_table(table, 'AttribuutGroepen.csv', fields, fields)
44
45
        # Extract attribuut groep koppeling.
46 1
        table = doc.xpath(xpath + 'AttribuutGroepKoppelingen/AttribuutGroepKoppeling', namespaces=namespaces)
47
        fields = ['AttribuutGroepKoppelingId',
48
                  'AttribuutGroepId',
49 1
                  'AttribuutId',
50 1
                  'AttribuutToetsWijze',
51
                  'OnderToetsWaarde',
52
                  'BovenToetsWaarde',
53
                  'VersieDatum']
54
        self.extract_table(table, 'AttribuutGroepKoppelingen.csv', fields, fields)
55
56
        # Extract attributen
57 1
        table = doc.xpath(xpath + 'Attributen/Attribuut', namespaces=namespaces)
58
        fields = ['AttribuutId',
59
                  'AttribuutOmschrijving',
60 1
                  'BoomParameterNummer',
61 1
                  'FilterToetsWijze',
62
                  'FilterWaardeType',
63
                  'OnderFilterWaarde',
64
                  'BovenFilterWaarde',
65
                  'VersieDatum']
66
        self.extract_table(table, 'Attributen.csv', fields, fields)
67
68
        # Extract boomparameters.
69 1
        table = doc.xpath(xpath + 'BoomParameters/BoomParameter', namespaces=namespaces)
70
        fields = ['BoomParameterNummer',
71
                  'Omschrijving',
72 1
                  'TabelNaam',
73 1
                  'VeldNaam']
74
        self.extract_table(table, 'BoomParameters.csv', fields, fields)
75
76
# ----------------------------------------------------------------------------------------------------------------------
77