Code Duplication    Length = 31-32 lines in 2 locations

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

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