Skip to content

Commit 3471f8a

Browse files
WIP - break out _row_entries in preparation to support param CSV unit and comment parsing
1 parent 4bd6833 commit 3471f8a

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

src/geophires_x_client/geophires_input_parameters.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,16 +220,34 @@ def get_output_file_path(self) -> Path:
220220
"""Returns a unique path for the GEOPHIRES output file."""
221221
return Path(tempfile.gettempdir(), f'geophires-result_{self._instance_id!s}.out')
222222

223-
def as_csv(self) -> str:
223+
def as_csv(self, parse_units_and_comments: bool = False) -> str:
224224
"""
225225
This method returns the input parameters in CSV (Comma-Separated Values) format, using its
226226
internal dictionary as the definitive source. It does not include a header, but uses the
227227
same columns as GeophiresXResult.as_csv, and is meant to be used in conjunction with the same.
228228
"""
229+
229230
if self.from_file_path:
230231
raise NotImplementedError('CSV from file path is not implemented.')
231232

233+
if parse_units_and_comments:
234+
raise NotImplementedError # FIXME WIP
235+
232236
f = StringIO()
233237
w = csv.writer(f)
234-
w.writerows([['INPUT PARAMETERS', key, '', value, ''] for key, value in self.params.items()])
238+
239+
def _row_entries(param_name: str, param_value_raw: str) -> list[str]:
240+
value_entry = param_value_raw
241+
units_entry = ''
242+
comment_entry = ''
243+
return [
244+
'INPUT PARAMETERS',
245+
param_name,
246+
'', # Year column, N/A for input parameters
247+
value_entry,
248+
units_entry,
249+
# comment_entry
250+
]
251+
252+
w.writerows([_row_entries(key, value) for key, value in self.params.items()])
235253
return f.getvalue()

0 commit comments

Comments
 (0)