Code Duplication    Length = 31-32 lines in 2 locations

src/egon/data/datasets/pypsaeur/__init__.py 2 locations

@@ 1740-1771 (lines=32) @@
1737
        )
1738
1739
1740
def prepared_network(planning_horizon=3):
1741
    if egon.data.config.settings()["egon-data"]["--run-pypsa-eur"]:
1742
        with open(
1743
            __path__[0] + "/datasets/pypsaeur/config_prepare.yaml", "r"
1744
        ) as stream:
1745
            data_config = yaml.safe_load(stream)
1746
1747
        target_file = (
1748
            Path(".")
1749
            / "run-pypsa-eur"
1750
            / "pypsa-eur"
1751
            / "results"
1752
            / data_config["run"]["name"]
1753
            / "prenetworks"
1754
            / f"base_s_{data_config['scenario']['clusters'][0]}"
1755
            f"_l{data_config['scenario']['ll'][0]}"
1756
            f"_{data_config['scenario']['opts'][0]}"
1757
            f"_{data_config['scenario']['sector_opts'][0]}"
1758
            f"_{data_config['scenario']['planning_horizons'][planning_horizon]}.nc"
1759
        )
1760
1761
    else:
1762
        target_file = (
1763
            Path(".")
1764
            / "data_bundle_egon_data"
1765
            / "pypsa_eur"
1766
            / "prenetworks"
1767
            / "prenetwork_post-manipulate_pre-solve"
1768
            / "base_s_39_lc1.25__cb40ex0-T-H-I-B-solar+p3-dist1_2045.nc"
1769
        )
1770
1771
    return pypsa.Network(target_file.absolute().as_posix())
1772
1773
1774
def overwrite_H2_pipeline_share():
@@ 460-490 (lines=31) @@
457
        print("Pypsa-eur is not executed due to the settings of egon-data")
458
459
460
def read_network(planning_horizon=2045):
461
    if config.settings()["egon-data"]["--run-pypsa-eur"]:
462
        with open(
463
            __path__[0] + "/datasets/pypsaeur/config_solve.yaml", "r"
464
        ) as stream:
465
            data_config = yaml.safe_load(stream)
466
467
        target_file = (
468
            Path(".")
469
            / "run-pypsa-eur"
470
            / "pypsa-eur"
471
            / "results"
472
            / data_config["run"]["name"]
473
            / "postnetworks"
474
            / f"base_s_{data_config['scenario']['clusters'][0]}"
475
            f"_l{data_config['scenario']['ll'][0]}"
476
            f"_{data_config['scenario']['opts'][0]}"
477
            f"_{data_config['scenario']['sector_opts'][0]}"
478
            f"_{planning_horizon}.nc"
479
        )
480
481
    else:
482
        target_file = (
483
            Path(".")
484
            / "data_bundle_egon_data"
485
            / "pypsa_eur"
486
            / "postnetworks"
487
            / f"base_s_39_lc1.25__cb40ex0-T-H-I-B-solar+p3-dist1_{planning_horizon}.nc"
488
        )
489
490
    return pypsa.Network(target_file)
491
492
493
def clean_database():