Coverage for src/features/readme.py: 75.00%

16 statements  

« prev     ^ index     » next       coverage.py v7.17.2, created at 2026-11-08 13:49 +0000

1#!/usr/bin/env python3 

2 

3# Standard libraries 

4from pathlib import Path 

5from typing import List 

6 

7# Readme class 

8class Readme: 

9 

10 # Constants 

11 EOL: str = '\n' 

12 FILE: str = 'README.md' 

13 

14 # Exists 

15 @staticmethod 

16 def exists() -> bool: 

17 

18 # Check if binary exists 

19 return Path(Readme.FILE).exists() 

20 

21 # Read 

22 @staticmethod 

23 def read() -> List[str]: 

24 

25 # Ignore missing file 

26 if not Readme.exists(): # pragma: no cover 

27 return [] 

28 

29 # Read file contents 

30 with open( 

31 Readme.FILE, 

32 encoding='utf8', 

33 mode='r', 

34 ) as file: 

35 return file.readlines() 

36 

37 # Write 

38 @staticmethod 

39 def write(lines: List[str]) -> None: 

40 

41 # Write file contents 

42 with open( 

43 Readme.FILE, 

44 encoding='utf8', 

45 mode='w', 

46 ) as file: 

47 file.writelines(lines)