stackup/stackup/config.py

42 lines
774 B
Python

import datetime
import enum
import os
import uuid
from dataclasses import dataclass
import wonderwords
def _name_phrase():
return "-".join(
wonderwords.RandomWord().random_words(
4,
word_min_length=4,
word_max_length=12,
include_parts_of_speech=["nouns", "adjectives"],
)
)
def _name_timestamp():
return datetime.datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ")
def _name_uuid():
return uuid.uuid4().hex
class Namers(enum.Enum):
PHRASE = _name_phrase
TIMESTAMP = _name_timestamp
UUID = _name_uuid
@dataclass
class StackupConfig:
log_level: str = "info"
@classmethod
def build(cls):
return cls(log_level=os.getenv("STACKUP_LOG_LEVEL", cls.log_level))