From 37ccb08cc8a31b9696a4614f23e7882c96435bd2 Mon Sep 17 00:00:00 2001 From: romainsacchi Date: Wed, 27 Sep 2023 18:20:31 +0200 Subject: [PATCH] Add possibility to define export directory. --- unfold/unfold.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/unfold/unfold.py b/unfold/unfold.py index a4c35a4..50dcb94 100644 --- a/unfold/unfold.py +++ b/unfold/unfold.py @@ -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: @@ -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, @@ -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(