Skip to content

Commit c505750

Browse files
committed
Add more documentation
1 parent 311d4ac commit c505750

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

ecoinvent_migrate/data_io.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010

1111

1212
def get_change_report_filepath(version: str, release: EcoinventRelease) -> Path:
13-
"""Get the filepath to the Excel change report file"""
13+
"""Get the filepath to the Excel change report file.
14+
15+
Download a list of extra files from ecoinvent and do pattern matching."""
1416
files = release.list_extra_files(version)
1517
candidates = [key for key in files if "change report" in key.lower() and "annex" in key.lower()]
1618
if not candidates:
@@ -59,6 +61,7 @@ def setup_project(
5961
ecoinvent_username: Optional[str] = None,
6062
ecoinvent_password: Optional[str] = None,
6163
) -> None:
64+
"""Switch to or create a Brightway project, and install the source and target databases."""
6265
bd.projects.set_current(project_name)
6366

6467
if f"ecoinvent-{source_version}-{system_model}" not in bd.databases:
@@ -90,6 +93,16 @@ def setup_project(
9093

9194

9295
def get_brightway_databases(source_version: str, target_version: str, system_model: str):
96+
"""Get database names and process caches for source and target databases.
97+
98+
Returns:
99+
100+
* `source_db_name`: str. Standardized name for ecoinvent based on `ecoinvent_interface` standard
101+
* `target_db_name`: str. Standardized name for ecoinvent based on `ecoinvent_interface` standard
102+
* `source_lookup`: dict. Dictionary from attribute tuple (name, location, reference product) to `Node` object.
103+
* `target_lookup`: dict. Dictionary from attribute tuple (name, location, reference product) to `Node` object.
104+
105+
"""
93106
source_db_name = f"ecoinvent-{source_version}-{system_model}"
94107
target_db_name = f"ecoinvent-{target_version}-{system_model}"
95108
if source_db_name not in bd.databases:

ecoinvent_migrate/datapackage.py

+11
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@ def write_datapackage(
1919
version: str = "1.0.0",
2020
description: Optional[str] = None,
2121
) -> Path:
22+
"""Write given `data` to a Frictionless Data Datapackage.
23+
24+
Input args for datapackage:
25+
26+
* output_version (str, default is "1.0.0"): [Datapackage version number](https://specs.frictionlessdata.io/data-package/#version)
27+
* licenses (list, default is CC-BY): Licenses following the [datapackage standard](https://specs.frictionlessdata.io/data-package/#licenses)
28+
* description (str, default is auto-generated): Description of generated datapackage.
29+
30+
If `output_directory` isn't provided, a `platformdirs.user_data_dir` is used.
31+
32+
Returns the `pathlib.Path` of the created file."""
2233
now = datetime.now(timezone.utc).isoformat()
2334
if licenses is None:
2435
licenses = [

ecoinvent_migrate/wrangling.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ def isnan(o: Union[str, Number]) -> bool:
1414

1515

1616
def split_by_semicolon(row: dict, version: str) -> list[dict]:
17-
"""Possible split a data row into"""
17+
"""Turn a data `row` into one or more dictionaries.
18+
19+
Splits reference product and unit values by `;\n`."""
1820
if isinstance(row[f"Activity Name - {version}"], Number) and math.isnan(
1921
row[f"Activity Name - {version}"]
2022
):

0 commit comments

Comments
 (0)