Skip to content

Commit

Permalink
fix: StrEnum isn't available for python 3.10
Browse files Browse the repository at this point in the history
  • Loading branch information
plaffitt committed Jan 9, 2025
1 parent c1ee523 commit 29e44bd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
7 changes: 6 additions & 1 deletion src/pvecontrol/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
15 changes: 9 additions & 6 deletions src/pvecontrol/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import json

from collections import OrderedDict
from enum import Enum, StrEnum, auto
from enum import Enum

import yaml

Expand All @@ -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():
Expand Down

0 comments on commit 29e44bd

Please sign in to comment.