Code Duplication    Length = 72-73 lines in 2 locations

src/egon/data/datasets/hydrogen_etrago/bus.py 2 locations

@@ 202-274 (lines=73) @@
199
    )
200
201
202
class EgonMapH2CH4(Base):
203
    source_list = [
204
        sources()["openstreetmap"],
205
        sources()["SciGRID_gas"],
206
        sources()["bgr_inspeeds_data_bundle"],
207
    ]
208
    meta_H2_CH4 = {
209
        "name": "grid.egon_etrago_ch4_h2",
210
        "title": "Mapping table of CH4-H2 buses",
211
        "id": "WILL_BE_SET_AT_PUBLICATION",
212
        "description": "Table mapping CH4 and H2 buses in Germany",
213
        "language": ["en-EN"],
214
        "publicationDate": datetime.date.today().isoformat(),
215
        "context": context(),
216
        "spatial": {
217
            "location": None,
218
            "extent": "Germany",
219
            "resolution": None,
220
        },
221
        "sources": source_list,
222
        "licenses": [license_egon_data_odbl()],
223
        "contributors": contributors(["fw"]),
224
        "resources": [
225
            {
226
                "profile": "tabular-data-resource",
227
                "name": "grid.egon_etrago_ch4_h2",
228
                "path": None,
229
                "format": "PostgreSQL",
230
                "encoding": "UTF-8",
231
                "schema": {
232
                    "fields": [
233
                        {
234
                            "name": "scn_name",
235
                            "description": "Name of the scenario",
236
                            "type": "str",
237
                            "unit": None,
238
                        },
239
                        {
240
                            "name": "bus_H2",
241
                            "description": "H2 bus_id",
242
                            "type": "integer",
243
                            "unit": None,
244
                        },
245
                        {
246
                            "name": "bus_CH4",
247
                            "description": "CH4 bus_id",
248
                            "type": "integer",
249
                            "unit": None,
250
                        },
251
                    ],
252
                    "primaryKey": ["scn_name", "bus_H2"],
253
                    "foreignKeys": [],
254
                },
255
                "dialect": {"delimiter": None, "decimalSeparator": "."},
256
            }
257
        ],
258
        "metaMetadata": meta_metadata(),
259
    }
260
261
    # Create json dump
262
    meta_json_H2_CH4 = (
263
        "'" + json.dumps(meta_H2_CH4, indent=4, ensure_ascii=False) + "'"
264
    )
265
266
    __tablename__ = "egon_etrago_ch4_h2"
267
    __table_args__ = {
268
        "schema": "grid",
269
        "comment": meta_json_H2_CH4,
270
    }
271
272
    scn_name = Column(Text, primary_key=True, nullable=False)
273
    bus_H2 = Column(BigInteger, primary_key=True, nullable=False)
274
    bus_CH4 = Column(BigInteger, primary_key=False, nullable=False)
275
276
277
def create_H2_CH4_table():
@@ 57-128 (lines=72) @@
54
Base = declarative_base()
55
56
57
class EgonMapACH2(Base):
58
    source_list = [
59
        sources()["openstreetmap"],
60
        sources()["SciGRID_gas"],
61
        sources()["bgr_inspeeds_data_bundle"],
62
    ]
63
    meta_ac_h2 = {
64
        "name": "grid.egon_etrago_ac_h2",
65
        "title": "Mapping table of AC-H2 buses",
66
        "id": "WILL_BE_SET_AT_PUBLICATION",
67
        "description": "Table mapping AC and H2 buses in Germany",
68
        "language": ["en-EN"],
69
        "publicationDate": datetime.date.today().isoformat(),
70
        "context": context(),
71
        "spatial": {
72
            "location": None,
73
            "extent": "Germany",
74
            "resolution": None,
75
        },
76
        "sources": source_list,
77
        "licenses": [license_egon_data_odbl()],
78
        "contributors": contributors(["fw"]),
79
        "resources": [
80
            {
81
                "profile": "tabular-data-resource",
82
                "name": "grid.egon_etrago_ac_h2",
83
                "path": None,
84
                "format": "PostgreSQL",
85
                "encoding": "UTF-8",
86
                "schema": {
87
                    "fields": [
88
                        {
89
                            "name": "scn_name",
90
                            "description": "Name of the scenario",
91
                            "type": "str",
92
                            "unit": None,
93
                        },
94
                        {
95
                            "name": "bus_H2",
96
                            "description": "H2 bus_id",
97
                            "type": "integer",
98
                            "unit": None,
99
                        },
100
                        {
101
                            "name": "bus_AC",
102
                            "description": "AC bus_id",
103
                            "type": "integer",
104
                            "unit": None,
105
                        },
106
                    ],
107
                    "primaryKey": ["scn_name", "bus_H2"],
108
                    "foreignKeys": [],
109
                },
110
                "dialect": {"delimiter": None, "decimalSeparator": "."},
111
            }
112
        ],
113
        "metaMetadata": meta_metadata(),
114
    }
115
    # Create json dump
116
    meta_json_ac_h2 = (
117
        "'" + json.dumps(meta_ac_h2, indent=4, ensure_ascii=False) + "'"
118
    )
119
120
    __tablename__ = "egon_etrago_ac_h2"
121
    __table_args__ = {
122
        "schema": "grid",
123
        "comment": meta_json_ac_h2,
124
    }
125
126
    scn_name = Column(Text, primary_key=True, nullable=False)
127
    bus_H2 = Column(BigInteger, primary_key=True, nullable=False)
128
    bus_AC = Column(BigInteger, primary_key=False, nullable=False)
129
130
131
def create_AC_H2_table():