Completed
Push — dev ( c38e3d...5d805f )
by
unknown
22s queued 18s
created

data.datasets.power_plants.mastr_db_classes   A

Complexity

Total Complexity 0

Size/Duplication

Total Lines 283
Duplicated Lines 69.61 %

Importance

Changes 0
Metric Value
wmc 0
eloc 216
dl 197
loc 283
rs 10
c 0
b 0
f 0

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
from geoalchemy2 import Geometry
2
from sqlalchemy import (
3
    Boolean,
4
    Column,
5
    DateTime,
6
    Float,
7
    Integer,
8
    Sequence,
9
    String,
10
)
11
from sqlalchemy.ext.declarative import declarative_base
12
13
Base = declarative_base()
14
15
16
class EgonMastrGeocoded(Base):
17
    __tablename__ = "egon_mastr_geocoded"
18
    __table_args__ = {"schema": "supply"}
19
20
    index = Column(
21
        Integer, Sequence("mastr_geocoded_seq"), primary_key=True, index=True
22
    )
23
    zip_and_municipality = Column(String)
24
    latitude = Column(Float)
25
    longitude = Column(Float)
26
    altitude = Column(Float)
27
    geometry = Column(Geometry("POINT", 4326))
28
29
30
class EgonPowerPlantsPv(Base):
31
    __tablename__ = "egon_power_plants_pv"
32
    __table_args__ = {"schema": "supply"}
33
34
    id = Column(Integer, Sequence("pp_pv_seq"), primary_key=True)
35
    bus_id = Column(Integer, nullable=True)  # Grid district id
36
    gens_id = Column(String, nullable=True)  # EinheitMastrNummer
37
38
    status = Column(String, nullable=True)  # EinheitBetriebsstatus
39
    commissioning_date = Column(DateTime, nullable=True)  # Inbetriebnahmedatum
40
    postcode = Column(String(5), nullable=True)  # Postleitzahl
41
    city = Column(String(50), nullable=True)  # Ort
42
    municipality = Column(String, nullable=True)  # Gemeinde
43
    federal_state = Column(String(31), nullable=True)  # Bundesland
44
    site = Column(String, nullable=True)  # Standort
45
    zip_and_municipality = Column(String, nullable=True)
46
47
    site_type = Column(String(69), nullable=True)  # Lage
48
    usage_sector = Column(String(36), nullable=True)  # Nutzungsbereich
49
    orientation_primary = Column(String(11), nullable=True)  # Hauptausrichtung
50
    orientation_primary_angle = Column(
51
        String(18), nullable=True
52
    )  # HauptausrichtungNeigungswinkel
53
    orientation_secondary = Column(
54
        String(11), nullable=True
55
    )  # Nebenausrichtung
56
    orientation_secondary_angle = Column(
57
        String(18), nullable=True
58
    )  # NebenausrichtungNeigungswinkel
59
    orientation_uniform = Column(
60
        Boolean, nullable=True
61
    )  # EinheitlicheAusrichtungUndNeigungswinkel
62
    module_count = Column(Float, nullable=True)  # AnzahlModule
63
64
    capacity = Column(Float, nullable=True)  # Nettonennleistung
65
    capacity_inverter = Column(
66
        Float, nullable=True
67
    )  # ZugeordneteWirkleistungWechselrichter in MW
68
    feedin_type = Column(String(47), nullable=True)  # Einspeisungsart
69
    voltage_level = Column(Integer, nullable=True)
70
    voltage_level_inferred = Column(Boolean, nullable=True)
71
72
    geometry_geocoded = Column(Boolean)
73
    geom = Column(Geometry("POINT", 4326), index=True, nullable=True)
74
75
76 View Code Duplication
class EgonPowerPlantsWind(Base):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
77
    __tablename__ = "egon_power_plants_wind"
78
    __table_args__ = {"schema": "supply"}
79
80
    id = Column(Integer, Sequence("pp_wind_seq"), primary_key=True)
81
    bus_id = Column(Integer, nullable=True)  # Grid district id
82
    gens_id = Column(String, nullable=True)  # EinheitMastrNummer
83
84
    status = Column(String, nullable=True)  # EinheitBetriebsstatus
85
    commissioning_date = Column(DateTime, nullable=True)  # Inbetriebnahmedatum
86
    postcode = Column(String(5), nullable=True)  # Postleitzahl
87
    city = Column(String(50), nullable=True)  # Ort
88
    municipality = Column(String, nullable=True)  # Gemeinde
89
    federal_state = Column(String(31), nullable=True)  # Bundesland
90
    zip_and_municipality = Column(String, nullable=True)
91
92
    site_type = Column(String(17), nullable=True)  # Lage
93
    manufacturer_name = Column(String(100), nullable=True)  # Hersteller
94
    type_name = Column(String(100), nullable=True)  # Typenbezeichnung
95
    hub_height = Column(Float, nullable=True)  # Nabenhoehe
96
    rotor_diameter = Column(Float, nullable=True)  # Rotordurchmesser
97
98
    capacity = Column(Float, nullable=True)  # Nettonennleistung
99
    feedin_type = Column(String(47), nullable=True)  # Einspeisungsart
100
    voltage_level = Column(Integer, nullable=True)
101
    voltage_level_inferred = Column(Boolean, nullable=True)
102
103
    geometry_geocoded = Column(Boolean)
104
    geom = Column(Geometry("POINT", 4326), index=True, nullable=True)
105
106
107 View Code Duplication
class EgonPowerPlantsBiomass(Base):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
108
    __tablename__ = "egon_power_plants_biomass"
109
    __table_args__ = {"schema": "supply"}
110
111
    id = Column(Integer, Sequence("pp_biomass_seq"), primary_key=True)
112
    bus_id = Column(Integer, nullable=True)  # Grid district id
113
    gens_id = Column(String, nullable=True)  # EinheitMastrNummer
114
115
    status = Column(String, nullable=True)  # EinheitBetriebsstatus
116
    commissioning_date = Column(DateTime, nullable=True)  # Inbetriebnahmedatum
117
    postcode = Column(String(5), nullable=True)  # Postleitzahl
118
    city = Column(String(50), nullable=True)  # Ort
119
    municipality = Column(String, nullable=True)  # Gemeinde
120
    federal_state = Column(String(31), nullable=True)  # Bundesland
121
    zip_and_municipality = Column(String, nullable=True)
122
123
    technology = Column(String(45), nullable=True)  # Technologie
124
    main_fuel = Column(String(52), nullable=True)  # Hauptbrennstoff
125
    fuel_type = Column(String(19), nullable=True)  # Biomasseart
126
127
    capacity = Column(Float, nullable=True)  # Nettonennleistung
128
    th_capacity = Column(Float, nullable=True)  # ThermischeNutzleistung
129
    feedin_type = Column(String(47), nullable=True)  # Einspeisungsart
130
    voltage_level = Column(Integer, nullable=True)
131
    voltage_level_inferred = Column(Boolean, nullable=True)
132
133
    geometry_geocoded = Column(Boolean)
134
    geom = Column(Geometry("POINT", 4326), index=True, nullable=True)
135
136
137 View Code Duplication
class EgonPowerPlantsHydro(Base):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
138
    __tablename__ = "egon_power_plants_hydro"
139
    __table_args__ = {"schema": "supply"}
140
141
    id = Column(Integer, Sequence("pp_hydro_seq"), primary_key=True)
142
    bus_id = Column(Integer, nullable=True)  # Grid district id
143
    gens_id = Column(String, nullable=True)  # EinheitMastrNummer
144
145
    status = Column(String, nullable=True)  # EinheitBetriebsstatus
146
    commissioning_date = Column(DateTime, nullable=True)  # Inbetriebnahmedatum
147
    postcode = Column(String(5), nullable=True)  # Postleitzahl
148
    city = Column(String(50), nullable=True)  # Ort
149
    municipality = Column(String, nullable=True)  # Gemeinde
150
    federal_state = Column(String(31), nullable=True)  # Bundesland
151
    zip_and_municipality = Column(String, nullable=True)
152
153
    plant_type = Column(String(39), nullable=True)  # ArtDerWasserkraftanlage
154
    water_origin = Column(String(20), nullable=True)  # ArtDesZuflusses
155
156
    capacity = Column(Float, nullable=True)  # Nettonennleistung
157
    feedin_type = Column(String(47), nullable=True)  # Einspeisungsart
158
    voltage_level = Column(Integer, nullable=True)
159
    voltage_level_inferred = Column(Boolean, nullable=True)
160
161
    geometry_geocoded = Column(Boolean)
162
    geom = Column(Geometry("POINT", 4326), index=True, nullable=True)
163
164
165 View Code Duplication
class EgonPowerPlantsCombustion(Base):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
166
    __tablename__ = "egon_power_plants_combustion"
167
    __table_args__ = {"schema": "supply"}
168
169
    id = Column(Integer, Sequence("pp_combustion_seq"), primary_key=True)
170
    bus_id = Column(Integer, nullable=True)  # Grid district id
171
    gens_id = Column(String, nullable=True)  # EinheitMastrNummer
172
173
    status = Column(String, nullable=True)  # EinheitBetriebsstatus
174
    commissioning_date = Column(DateTime, nullable=True)  # Inbetriebnahmedatum
175
    postcode = Column(String(5), nullable=True)  # Postleitzahl
176
    city = Column(String(50), nullable=True)  # Ort
177
    municipality = Column(String, nullable=True)  # Gemeinde
178
    federal_state = Column(String(31), nullable=True)  # Bundesland
179
    zip_and_municipality = Column(String, nullable=True)
180
181
    carrier = Column(String)  # Energietraeger
182
    main_fuel = Column(String)  # Hauptbrennstoff
183
    other_main_fuel = Column(String)  # WeitererHauptbrennstoff
184
    technology = Column(String)  # Technologie
185
186
    capacity = Column(Float, nullable=True)  # Nettonennleistung
187
    th_capacity = Column(Float, nullable=True)  # ThermischeNutzleistung
188
    feedin_type = Column(String(47), nullable=True)  # Einspeisungsart
189
    voltage_level = Column(Integer, nullable=True)
190
    voltage_level_inferred = Column(Boolean, nullable=True)
191
192
    geometry_geocoded = Column(Boolean)
193
    geom = Column(Geometry("POINT", 4326), index=True, nullable=True)
194
195
196 View Code Duplication
class EgonPowerPlantsGsgk(Base):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
197
    __tablename__ = "egon_power_plants_gsgk"
198
    __table_args__ = {"schema": "supply"}
199
200
    id = Column(Integer, Sequence("pp_gsgk_seq"), primary_key=True)
201
    bus_id = Column(Integer, nullable=True)  # Grid district id
202
    gens_id = Column(String, nullable=True)  # EinheitMastrNummer
203
204
    status = Column(String, nullable=True)  # EinheitBetriebsstatus
205
    commissioning_date = Column(DateTime, nullable=True)  # Inbetriebnahmedatum
206
    postcode = Column(String(5), nullable=True)  # Postleitzahl
207
    city = Column(String(50), nullable=True)  # Ort
208
    municipality = Column(String, nullable=True)  # Gemeinde
209
    federal_state = Column(String(31), nullable=True)  # Bundesland
210
    zip_and_municipality = Column(String, nullable=True)
211
212
    carrier = Column(String)  # Energietraeger
213
    technology = Column(String)  # Technologie
214
215
    capacity = Column(Float, nullable=True)  # Nettonennleistung
216
    th_capacity = Column(Float, nullable=True)  # ThermischeNutzleistung
217
    feedin_type = Column(String(47), nullable=True)  # Einspeisungsart
218
    voltage_level = Column(Integer, nullable=True)
219
    voltage_level_inferred = Column(Boolean, nullable=True)
220
221
    geometry_geocoded = Column(Boolean)
222
    geom = Column(Geometry("POINT", 4326), index=True, nullable=True)
223
224
225 View Code Duplication
class EgonPowerPlantsNuclear(Base):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
226
    __tablename__ = "egon_power_plants_nuclear"
227
    __table_args__ = {"schema": "supply"}
228
229
    id = Column(Integer, Sequence("pp_nuclear_seq"), primary_key=True)
230
    bus_id = Column(Integer, nullable=True)  # Grid district id
231
    gens_id = Column(String, nullable=True)  # EinheitMastrNummer
232
233
    status = Column(String, nullable=True)  # EinheitBetriebsstatus
234
    commissioning_date = Column(DateTime, nullable=True)  # Inbetriebnahmedatum
235
    postcode = Column(String(5), nullable=True)  # Postleitzahl
236
    city = Column(String(50), nullable=True)  # Ort
237
    municipality = Column(String, nullable=True)  # Gemeinde
238
    federal_state = Column(String(31), nullable=True)  # Bundesland
239
    zip_and_municipality = Column(String, nullable=True)
240
241
    carrier = Column(String)  # Energietraeger
242
    technology = Column(String)  # Technologie
243
244
    capacity = Column(Float, nullable=True)  # Nettonennleistung
245
    th_capacity = Column(Float, nullable=True)  # ThermischeNutzleistung
246
    feedin_type = Column(String(47), nullable=True)  # Einspeisungsart
247
    voltage_level = Column(Integer, nullable=True)
248
    voltage_level_inferred = Column(Boolean, nullable=True)
249
250
    geometry_geocoded = Column(Boolean)
251
    geom = Column(Geometry("POINT", 4326), index=True, nullable=True)
252
253
254 View Code Duplication
class EgonPowerPlantsStorage(Base):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
255
    __tablename__ = "egon_power_plants_storage"
256
    __table_args__ = {"schema": "supply"}
257
258
    id = Column(Integer, Sequence("pp_storage_seq"), primary_key=True)
259
    bus_id = Column(Integer, nullable=True)  # Grid district id
260
    gens_id = Column(String, nullable=True)  # EinheitMastrNummer
261
262
    status = Column(String, nullable=True)  # EinheitBetriebsstatus
263
    commissioning_date = Column(DateTime, nullable=True)  # Inbetriebnahmedatum
264
    postcode = Column(String(5), nullable=True)  # Postleitzahl
265
    city = Column(String(50), nullable=True)  # Ort
266
    municipality = Column(String, nullable=True)  # Gemeinde
267
    federal_state = Column(String(31), nullable=True)  # Bundesland
268
    zip_and_municipality = Column(String, nullable=True)
269
270
    carrier = Column(String)  # Energietraeger
271
    technology = Column(String)  # Technologie
272
    battery_type = Column(String)  # Batterietechnologie
273
    pump_storage_type = Column(String)  # Pumpspeichertechnologie
274
275
    capacity = Column(Float, nullable=True)  # Nettonennleistung
276
    th_capacity = Column(Float, nullable=True)  # ThermischeNutzleistung
277
    feedin_type = Column(String(47), nullable=True)  # Einspeisungsart
278
    voltage_level = Column(Integer, nullable=True)
279
    voltage_level_inferred = Column(Boolean, nullable=True)
280
281
    geometry_geocoded = Column(Boolean)
282
    geom = Column(Geometry("POINT", 4326), index=True, nullable=True)
283