Code Duplication    Length = 31-32 lines in 2 locations

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

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