| Conditions | 4 |
| Total Lines | 69 |
| Code Lines | 47 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | """The central module containing all code dealing with importing data from |
||
| 17 | def run_pypsa_eur_sec(): |
||
| 18 | |||
| 19 | # execute pypsa-eur-sec |
||
| 20 | import os |
||
| 21 | import egon.data.subprocess as subproc |
||
| 22 | from pathlib import Path |
||
| 23 | |||
| 24 | filepath = Path(".") |
||
| 25 | pypsa_eur_repos = filepath / "pypsa-eur" |
||
| 26 | technology_data_repos = filepath / "technology-data" |
||
| 27 | pypsa_eur_sec_repos = filepath / "pypsa-eur-sec" |
||
| 28 | pypsa_eur_sec_repos_data = pypsa_eur_sec_repos / "data/" |
||
| 29 | |||
| 30 | if not os.path.exists(pypsa_eur_repos): |
||
| 31 | subproc.run( |
||
| 32 | [ |
||
| 33 | "git", |
||
| 34 | "clone", |
||
| 35 | "https://github.com/PyPSA/pypsa-eur.git", |
||
| 36 | ], |
||
| 37 | cwd=filepath, |
||
| 38 | ) |
||
| 39 | |||
| 40 | if not os.path.exists(technology_data_repos): |
||
| 41 | subproc.run( |
||
| 42 | [ |
||
| 43 | "git", |
||
| 44 | "clone", |
||
| 45 | "https://github.com/PyPSA/technology-data.git", |
||
| 46 | ], |
||
| 47 | cwd=filepath, |
||
| 48 | ) |
||
| 49 | |||
| 50 | |||
| 51 | if not os.path.exists(pypsa_eur_sec_repos): |
||
| 52 | subproc.run( |
||
| 53 | [ |
||
| 54 | "git", |
||
| 55 | "clone", |
||
| 56 | "https://github.com/openego/pypsa-eur-sec.git", |
||
| 57 | ], |
||
| 58 | cwd=filepath, |
||
| 59 | ) |
||
| 60 | |||
| 61 | subproc.run( |
||
| 62 | [ |
||
| 63 | "wget", |
||
| 64 | "https://nworbmot.org/pypsa-eur-sec-data-bundle-201012.tar.gz", |
||
| 65 | ], |
||
| 66 | cwd=pypsa_eur_sec_repos_data, |
||
| 67 | ) |
||
| 68 | |||
| 69 | subproc.run( |
||
| 70 | [ |
||
| 71 | "tar", |
||
| 72 | "xvzf", |
||
| 73 | "pypsa-eur-sec-data-bundle-201012.tar.gz", |
||
| 74 | ], |
||
| 75 | cwd=pypsa_eur_sec_repos_data, |
||
| 76 | ) |
||
| 77 | |||
| 78 | |||
| 79 | subproc.run( |
||
| 80 | [ |
||
| 81 | "snakemake", |
||
| 82 | "-j1", |
||
| 83 | "prepare_sector_networks", |
||
| 84 | ], |
||
| 85 | cwd=pypsa_eur_sec_repos, |
||
| 86 | ) |
||
| 120 |