From a08424f4af855a460c80d31712484e78156f89b1 Mon Sep 17 00:00:00 2001 From: James Nightingale Date: Wed, 2 Apr 2025 15:16:46 +0100 Subject: [PATCH 1/3] support enum in fitsable --- autoconf/fitsable.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/autoconf/fitsable.py b/autoconf/fitsable.py index d6051c0..462c66d 100644 --- a/autoconf/fitsable.py +++ b/autoconf/fitsable.py @@ -99,7 +99,10 @@ def hdu_list_for_output_from( if header_dict is not None: for key, value in header_dict.items(): - header.append((key, value, [""])) + try: + header.append((key, value, [""])) + except ValueError: + header.append((key.value, value, [""])) # If enum is used for headeer_dict for i, values in enumerate(values_list): From 15c1cec26919d1295a6c48469935e27545beee72 Mon Sep 17 00:00:00 2001 From: James Nightingale Date: Wed, 2 Apr 2025 15:36:05 +0100 Subject: [PATCH 2/3] changes to fitsable --- autoconf/fitsable.py | 1 + 1 file changed, 1 insertion(+) diff --git a/autoconf/fitsable.py b/autoconf/fitsable.py index 462c66d..481a2de 100644 --- a/autoconf/fitsable.py +++ b/autoconf/fitsable.py @@ -1,5 +1,6 @@ from __future__ import annotations +from enum import Enum from typing import TYPE_CHECKING if TYPE_CHECKING: From bce86de6339ec1ad31c7ff4a1e76ab8f14b849cd Mon Sep 17 00:00:00 2001 From: James Nightingale Date: Wed, 2 Apr 2025 15:44:46 +0100 Subject: [PATCH 3/3] use isinstance for --- autoconf/fitsable.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/autoconf/fitsable.py b/autoconf/fitsable.py index 481a2de..9901630 100644 --- a/autoconf/fitsable.py +++ b/autoconf/fitsable.py @@ -100,10 +100,9 @@ def hdu_list_for_output_from( if header_dict is not None: for key, value in header_dict.items(): - try: - header.append((key, value, [""])) - except ValueError: - header.append((key.value, value, [""])) # If enum is used for headeer_dict + # Convert enum to its string value if needed + key_str = key.value if isinstance(key, Enum) else key + header.append((key_str, value, [""])) for i, values in enumerate(values_list):