Coverage for src / ezcompiler / adapters / disk_file_writer.py: 100.00%

7 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-03-27 06:49 +0000

1# /////////////////////////////////////////////////////////////// 

2# DISK_FILE_WRITER - Local filesystem file writer adapter 

3# Project: ezcompiler 

4# /////////////////////////////////////////////////////////////// 

5 

6"""Filesystem adapter implementing the BaseFileWriter port.""" 

7 

8from __future__ import annotations 

9 

10# /////////////////////////////////////////////////////////////// 

11# IMPORTS 

12# /////////////////////////////////////////////////////////////// 

13# Standard library imports 

14from pathlib import Path 

15 

16# Local imports 

17from .base_file_writer import BaseFileWriter 

18 

19# /////////////////////////////////////////////////////////////// 

20# CLASSES 

21# /////////////////////////////////////////////////////////////// 

22 

23 

24class DiskFileWriter(BaseFileWriter): 

25 """Write text files to local disk using pathlib.""" 

26 

27 def write_text( 

28 self, 

29 output_path: Path, 

30 content: str, 

31 encoding: str = "utf-8", 

32 ) -> None: 

33 """Write text content to disk.""" 

34 output_path.parent.mkdir(parents=True, exist_ok=True) 

35 output_path.write_text(content, encoding=encoding)