From 29e44bdc31a75eafc30bfeb1ae13c1a92826d8c3 Mon Sep 17 00:00:00 2001 From: Paul Laffitte Date: Thu, 9 Jan 2025 16:16:17 +0100 Subject: [PATCH] fix: StrEnum isn't available for python 3.10 --- src/pvecontrol/__init__.py | 7 ++++++- src/pvecontrol/utils.py | 15 +++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/pvecontrol/__init__.py b/src/pvecontrol/__init__.py index 77ef4cd..20646a0 100644 --- a/src/pvecontrol/__init__.py +++ b/src/pvecontrol/__init__.py @@ -78,7 +78,12 @@ def _parser(): parser.add_argument("-v", "--verbose", action="store_true") parser.add_argument("--debug", action="store_true") parser.add_argument( - "-o", "--output", action="store", default=OutputFormats.TEXT, choices=[o.value for o in OutputFormats] + "-o", + "--output", + action="store", + type=OutputFormats, + default=OutputFormats.TEXT, + choices=list(OutputFormats), ) parser.add_argument( "-c", "--cluster", action="store", required=True, help="Proxmox cluster name as defined in configuration" diff --git a/src/pvecontrol/utils.py b/src/pvecontrol/utils.py index d68c594..b98fbcb 100644 --- a/src/pvecontrol/utils.py +++ b/src/pvecontrol/utils.py @@ -6,7 +6,7 @@ import json from collections import OrderedDict -from enum import Enum, StrEnum, auto +from enum import Enum import yaml @@ -24,11 +24,14 @@ class Fonts: END = "\033[0m" -class OutputFormats(StrEnum): - TEXT = auto() - JSON = auto() - CSV = auto() - YAML = auto() +class OutputFormats(Enum): + TEXT = "text" + JSON = "json" + CSV = "csv" + YAML = "yaml" + + def __str__(self): + return self.value def terminal_support_colors():