Skip to content

Commit

Permalink
Add possibility to define export directory.
Browse files Browse the repository at this point in the history
  • Loading branch information
romainsacchi committed Sep 27, 2023
1 parent 2a72a93 commit 37ccb08
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion unfold/unfold.py
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,7 @@ def unfold(
:param dependencies: A dictionary containing additional inventory databases that may be needed for extraction. Default is None.
:param superstructure: A boolean indicating whether to generate a scenario difference file and a superstructure database. Default is False.
:param name: A string indicating the name of the superstructure database. Default is None.
:param export_dir: A string indicating the directory to which the scenario difference file should be exported. Default is current working directory.
:return: None
Behavior:
Expand Down Expand Up @@ -1181,7 +1182,7 @@ def unfold(

self.write(superstructure=superstructure, export_dir=export_dir)

def write(self, superstructure: bool = False, export_dir: str = os.getcwd()):
def write(self, superstructure: bool = False, export_dir: str = None):
"""
Write the databases.
If superstructure is True, write the scenario difference file,
Expand Down Expand Up @@ -1213,6 +1214,9 @@ def write(self, superstructure: bool = False, export_dir: str = os.getcwd()):

filename = f"SDF {source_db['name']} {source_db['version']} {self.name or self.package.descriptor['name']}.csv"

if export_dir is None:
export_dir = os.getcwd()

filename = os.path.join(export_dir, filename)

self.scenario_df.to_csv(
Expand Down

0 comments on commit 37ccb08

Please sign in to comment.