Exemple #1
0
    def f_or_file2utf8(cls, f, filepath):
        logger = FoxylibLogger.func2logger(cls.f_or_file2utf8)
        # logger.debug({"filepath": filepath, "f": f})

        FileTool.dirpath2mkdirs(os.path.dirname(filepath))

        utf8 = FileTool.filepath2utf8(filepath)

        if utf8:
            return utf8

        utf8 = f()
        if utf8 is not None:
            FileTool.utf82file(utf8, filepath)
        return utf8
Exemple #2
0
    def attach_filepath2rootname_list(
        cls,
        rootname_list,
        filepath,
        level,
    ):
        from foxylib.tools.file.file_tool import FileTool
        FileTool.dirpath2mkdirs(os.path.dirname(filepath))

        handler = LoggerTool.handler2formatted(
            LoggerTool.filepath2handler_default(filepath))
        handler.setLevel(level)
        cls.attach_handler2rootname_list(
            rootname_list,
            handler,
        )