Coverage for src/types/paths.py: 50.00%

14 statements  

« prev     ^ index     » next       coverage.py v7.15.4, created at 2026-08-21 21:33 +0000

1#!/usr/bin/env python3 

2 

3# Standard libraries 

4from pathlib import Path 

5from re import sub 

6 

7# Paths class, pylint: disable=too-few-public-methods 

8class Paths: 

9 

10 # Resolve 

11 @staticmethod 

12 def resolve(data: Path | str) -> str: 

13 

14 # Resolve path 

15 path: str = str(Path(data).resolve()) 

16 

17 # Result 

18 return path 

19 

20 # Slugify 

21 @staticmethod 

22 def slugify(text: str) -> str: 

23 

24 # Variables 

25 result: str = text.strip().lower() 

26 

27 # Adapt to file slug 

28 result = sub(r'[\\/]', '_', result) 

29 result = sub(r'[^-_\s\w]', '', result) 

30 result = sub(r'[-\s]+', '-', result) 

31 

32 # Result 

33 return result