#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ # @Version : Python 3.11.4 # @Software : Sublime Text 4 # @Author : StudentCWZ # @Email : StudentCWZ@outlook.com # @Date : 2023/11/3 19:58 # @File : file.py # @Description : """ from typing import Optional from application.constants import DEFAULT_CONFIG, ENV_CONFIG_MAP class FileHelper: """ FileHelper is a utility class that provides file-related operations. Currently, it only provides a method to get the configuration file name based on the environment. """ @classmethod def get_filename(cls, env: Optional[str]) -> str: """ Get the configuration file name based on the environment. :param env: a string representing the environment. It should be one of the keys in ENV_CONFIG_MAP, or None. :return: a string representing the configuration file name. """ return ENV_CONFIG_MAP.get(env, DEFAULT_CONFIG) def __repr__(self): """ Return a string representing a valid Python expression that could be used to recreate the FileHelper object. """ return "FileHelper()" def __str__(self): """ Return a human-readable string representation of the FileHelper object. """ return "This is a FileHelper class that helps with file related operations."