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.
Completed
Push — master ( be813a...3d8811 )
by P.R.
06:43 queued 46s
created

ReferentieShredder.shred_xml_file()   B

Complexity

Conditions 1

Size

Total Lines 225
Code Lines 196

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 43
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 196
nop 2
dl 0
loc 225
ccs 43
cts 43
cp 1
crap 1
rs 7
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
"""
2
Kerapu
3
"""
4 1
from lxml import etree
5
6 1
from kerapu.shredder.Shredder import Shredder
7
8
9 1
class ReferentieShredder(Shredder):
10
    """
11
    Klasse voor het schreden en opslaan in CSV-formaat van referentietabellen opgeslagen in XML-formaat.
12
    """
13
14
    # ------------------------------------------------------------------------------------------------------------------
15 1
    def shred_xml_file(self, filename: str):
16
        """
17
        Slaat de referentietabellen op in CSV-formaat.
18
19
        :param str filename: De filenaam van het XML bestand.
20
        """
21 1
        self._io.title('Shredder')
22
23 1
        doc = etree.parse(filename)
24
25 1
        xpath = '/soapenv:Envelope/soapenv:Body/InlezenReferenties/Referenties/'
26 1
        namespaces = {'soapenv': 'http://schemas.xmlsoap.org/soap/envelope/'}
27
28
        # Extract AfsluitReden.
29 1
        table = doc.xpath(xpath + 'AfsluitRedenen/AfsluitReden', namespaces=namespaces)
30 1
        fields = ['AfsluitRedenCode',
31
                  'AfsluitRedenOmschrijving',
32
                  'BeginDatum',
33
                  'EindDatum',
34
                  'VersieDatum']
35 1
        self.extract_table(table, 'AfsluitRedenen.csv', fields, fields)
36
37
        # Extract BehandelKlasse.
38 1
        table = doc.xpath(xpath + 'BehandelKlassen/BehandelKlasse', namespaces=namespaces)
39 1
        fields = ['ZorgProductGroepCode',
40
                  'ZorgActiviteitCode',
41
                  'BehandelKlasseCode',
42
                  'BehandelKlasseOmschrijving',
43
                  'BeginDatum',
44
                  'EindDatum',
45
                  'VersieDatum']
46 1
        self.extract_table(table, 'BehandelKlassen.csv', fields, fields)
47
48
        # Extract Diagnose.
49 1
        table = doc.xpath(xpath + 'Diagnosen/Diagnose', namespaces=namespaces)
50 1
        fields = ['SpecialismeCode',
51
                  'DiagnoseCode',
52
                  'DiagnoseOmschrijving',
53
                  'DiagnoseAttribuutCode',
54
                  'ICD10DiagnoseCode',
55
                  'DiagnoseCluster1',
56
                  'DiagnoseCluster2',
57
                  'DiagnoseCluster3',
58
                  'DiagnoseCluster4',
59
                  'DiagnoseCluster5',
60
                  'DiagnoseCluster6',
61
                  'BeginDatum',
62
                  'EindDatum',
63
                  'VersieDatum']
64 1
        xpaths = ['SpecialismeCode',
65
                  'DiagnoseCode',
66
                  'DiagnoseOmschrijving',
67
                  'DiagnoseAttribuutCode',
68
                  'ICD10DiagnoseCode',
69
                  "DiagnoseCluster/DiagnoseClusterItem[@Key='1']",
70
                  "DiagnoseCluster/DiagnoseClusterItem[@Key='2']",
71
                  "DiagnoseCluster/DiagnoseClusterItem[@Key='3']",
72
                  "DiagnoseCluster/DiagnoseClusterItem[@Key='4']",
73
                  "DiagnoseCluster/DiagnoseClusterItem[@Key='5']",
74
                  "DiagnoseCluster/DiagnoseClusterItem[@Key='6']",
75
                  'BeginDatum',
76
                  'EindDatum',
77
                  'VersieDatum']
78 1
        self.extract_table(table, 'Diagnosen.csv', fields, xpaths)
79
80
        # Extract Geslacht.
81 1
        table = doc.xpath(xpath + 'Geslachten/Geslacht', namespaces=namespaces)
82 1
        fields = ['GeslachtCodeNEN',
83
                  'GeslachtCodeHL7',
84
                  'GeslachtOmschrijving',
85
                  'BeginDatum',
86
                  'EindDatum',
87
                  'VersieDatum']
88 1
        self.extract_table(table, 'Geslachten.csv', fields, fields)
89
90
        # Extract LimitatieMachtiging.
91 1
        table = doc.xpath(xpath + 'LimitatieMachtigingen/LimitatieMachtiging', namespaces=namespaces)
92 1
        fields = ['SpecialismeCode',
93
                  'DiagnoseCode',
94
                  'DiagnoseOmschrijving',
95
                  'ZorgActiviteitCode',
96
                  'ZorgActiviteitOmschrijving',
97
                  'BeginDatum',
98
                  'EindDatum',
99
                  'VersieDatum']
100 1
        self.extract_table(table, 'LimitatieMachtigingen.csv', fields, fields)
101
102
        # Extract Specialisme.
103 1
        table = doc.xpath(xpath + 'Specialismen/Specialisme', namespaces=namespaces)
104 1
        fields = ['SpecialismeCode',
105
                  'SpecialismeOmschrijving',
106
                  'SpecialismeIndicatie',
107
                  'SpecialismeOID',
108
                  'SpecialismeCluster1',
109
                  'SpecialismeCluster2',
110
                  'IndicatieAanspraakbeperking',
111
                  'BeginDatum',
112
                  'EindDatum',
113
                  'VersieDatum']
114 1
        xpaths = ['SpecialismeCode',
115
                  'SpecialismeOmschrijving',
116
                  'SpecialismeIndicatie',
117
                  'SpecialismeOID',
118
                  'SpecialismeCluster/SpecialismeClusterItem[(@Key=1)]',
119
                  'SpecialismeCluster/SpecialismeClusterItem[(@Key=2)]',
120
                  'IndicatieAanspraakbeperking',
121
                  'BeginDatum',
122
                  'EindDatum',
123
                  'VersieDatum']
124 1
        self.extract_table(table, 'Specialismen.csv', fields, xpaths)
125
126
        # Extract VertaalZorgActiviteit.
127 1
        table = doc.xpath(xpath + 'VertaalZorgActiviteiten/VertaalZorgActiviteit', namespaces=namespaces)
128 1
        fields = ['ZorgActiviteitCode',
129
                  'ZorgActiviteitOmschrijving',
130
                  'ZorgActiviteitCodeOud',
131
                  'ZorgActiviteitOmschrijvingOud',
132
                  'BeginDatum',
133
                  'EindDatum',
134
                  'VersieDatum']
135 1
        self.extract_table(table, 'VertaalZorgActiviteiten.csv', fields, fields)
136
137
        # Extract ZorgActiviteit.
138 1
        table = doc.xpath(xpath + 'ZorgActiviteiten/ZorgActiviteit', namespaces=namespaces)
139 1
        fields = ['ZorgActiviteitCode',
140
                  'ZorgActiviteitOmschrijving',
141
                  'ZorgActiviteitCluster01',
142
                  'ZorgActiviteitCluster02',
143
                  'ZorgActiviteitCluster03',
144
                  'ZorgActiviteitCluster04',
145
                  'ZorgActiviteitCluster05',
146
                  'ZorgActiviteitCluster06',
147
                  'ZorgActiviteitCluster07',
148
                  'ZorgActiviteitCluster08',
149
                  'ZorgActiviteitCluster09',
150
                  'ZorgActiviteitCluster10',
151
                  'ZorgActiviteitWeegFactor1',
152
                  'ZorgActiviteitWeegFactor2',
153
                  'WBMVCode',
154
                  'InnovatieCode',
155
                  'AanspraakCode',
156
                  'TariefType',
157
                  'Zorgprofielklassecode',
158
                  'OpNota',
159
                  'BeginDatum',
160
                  'EindDatum',
161
                  'VersieDatum']
162 1
        xpaths = ['ZorgActiviteitCode',
163
                  'ZorgActiviteitOmschrijving',
164
                  'ZorgActiviteitCluster/ZorgActiviteitClusterItem[@Key=1]',
165
                  'ZorgActiviteitCluster/ZorgActiviteitClusterItem[@Key=2]',
166
                  'ZorgActiviteitCluster/ZorgActiviteitClusterItem[@Key=3]',
167
                  'ZorgActiviteitCluster/ZorgActiviteitClusterItem[@Key=4]',
168
                  'ZorgActiviteitCluster/ZorgActiviteitClusterItem[@Key=5]',
169
                  'ZorgActiviteitCluster/ZorgActiviteitClusterItem[@Key=6]',
170
                  'ZorgActiviteitCluster/ZorgActiviteitClusterItem[@Key=7]',
171
                  'ZorgActiviteitCluster/ZorgActiviteitClusterItem[@Key=8]',
172
                  'ZorgActiviteitCluster/ZorgActiviteitClusterItem[@Key=9]',
173
                  'ZorgActiviteitCluster/ZorgActiviteitClusterItem[@Key=10]',
174
                  'ZorgActiviteitWeegFactor/ZorgActiviteitWeegFactorItem[@Key=1]',
175
                  'ZorgActiviteitWeegFactor/ZorgActiviteitWeegFactorItem[@Key=2]',
176
                  'WBMVCode',
177
                  'InnovatieCode',
178
                  'AanspraakCode',
179
                  'TariefType',
180
                  'Zorgprofielklassecode',
181
                  'OpNota',
182
                  'BeginDatum',
183
                  'EindDatum',
184
                  'VersieDatum']
185 1
        self.extract_table(table, 'ZorgActiviteiten.csv', fields, xpaths)
186
187
        # Extract ZorgProductGroep.
188 1
        table = doc.xpath(xpath + 'ZorgProductGroepen/ZorgProductGroep', namespaces=namespaces)
189 1
        fields = ['ZorgProductGroepCode',
190
                  'ZorgProductGroepOmschrijving',
191
                  'BeslisRegelStart',
192
                  'BeginDatum',
193
                  'EindDatum',
194
                  'VersieDatum']
195 1
        self.extract_table(table, 'ZorgProductGroepen.csv', fields, fields)
196
197
        # Extract ZorgType.
198 1
        table = doc.xpath(xpath + 'ZorgTypen/ZorgType', namespaces=namespaces)
199 1
        fields = ['SpecialismeCode',
200
                  'ZorgTypeCode',
201
                  'ZorgTypeOmschrijving',
202
                  'ZorgTypeAttribuutCode',
203
                  'ZorgTypeCluster1',
204
                  'ZorgTypeCluster2',
205
                  'BeginDatum',
206
                  'EindDatum',
207
                  'VersieDatum']
208 1
        xpaths = ['SpecialismeCode',
209
                  'ZorgTypeCode',
210
                  'ZorgTypeOmschrijving',
211
                  'ZorgTypeAttribuutCode',
212
                  'ZorgTypeCluster/ZorgTypeClusterItem[(@Key=1)]',
213
                  'ZorgTypeCluster/ZorgTypeClusterItem[(@Key=2)]',
214
                  'BeginDatum',
215
                  'EindDatum',
216
                  'VersieDatum']
217 1
        self.extract_table(table, 'ZorgTypen.csv', fields, xpaths)
218
219
        # Extract ZorgVraag.
220 1
        table = doc.xpath(xpath + 'ZorgVragen/ZorgVraag', namespaces=namespaces)
221 1
        fields = ['SpecialismeCode',
222
                  'ZorgVraagCode',
223
                  'ZorgVraagOmschrijving',
224
                  'ZorgVraagAttribuutCode',
225
                  'ZorgVraagCluster1',
226
                  'ZorgVraagCluster2',
227
                  'BeginDatum',
228
                  'EindDatum',
229
                  'VersieDatum']
230 1
        xpaths = ['SpecialismeCode',
231
                  'ZorgVraagCode',
232
                  'ZorgVraagOmschrijving',
233
                  'ZorgVraagAttribuutCode',
234
                  'ZorgVraagCluster/ZorgVraagClusterItem[(@Key=1)]',
235
                  'ZorgVraagCluster/ZorgVraagClusterItem[(@Key=2)]',
236
                  'BeginDatum',
237
                  'EindDatum',
238
                  'VersieDatum']
239 1
        self.extract_table(table, 'ZorgVragen.csv', fields, xpaths)
240
241
# ----------------------------------------------------------------------------------------------------------------------
242