Coverage for src/zapy/requests/file_loader.py: 100%

13 statements  

« prev     ^ index     » next       coverage.py v7.4.1, created at 2024-02-10 19:35 +0000

1from dataclasses import dataclass 

2from pathlib import Path 

3 

4from zapy.base import ZapyAuto 

5 

6 

7@dataclass 

8class ZapyFileInfo: 

9 file_location: Path 

10 mime_type: str | type[ZapyAuto] 

11 file_name: str 

12 

13 

14def load_file( 

15 relative_path: str | Path, mime_type: str | type[ZapyAuto], context_path: Path | str | None = None 

16) -> ZapyFileInfo: 

17 base_path_str = context_path or "." 

18 file_location = Path(base_path_str) / relative_path 

19 name = file_location.name 

20 

21 return ZapyFileInfo(file_location, mime_type, name)