file.py 1.44 KB
Newer Older
崔为之's avatar
崔为之 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
#!/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 :
"""


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: str) -> str:
        """
        Get the configuration file name based on the environment.

        :param env: a string representing the environment.
                    It should be 'PRODUCTION' or None.
        :return: a string representing the configuration file name.
                 If env is 'PRODUCTION', return 'production_config.yaml'.
                 Otherwise, return 'config.yaml'.
        """
        if env == 'PRODUCTION':
            return f'{env.lower()}_config.yaml'
        else:
            return 'config.yaml'

    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."