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
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-21 21:33 +0000
1#!/usr/bin/env python3
3# Standard libraries
4from pathlib import Path
5from re import sub
7# Paths class, pylint: disable=too-few-public-methods
8class Paths:
10 # Resolve
11 @staticmethod
12 def resolve(data: Path | str) -> str:
14 # Resolve path
15 path: str = str(Path(data).resolve())
17 # Result
18 return path
20 # Slugify
21 @staticmethod
22 def slugify(text: str) -> str:
24 # Variables
25 result: str = text.strip().lower()
27 # Adapt to file slug
28 result = sub(r'[\\/]', '_', result)
29 result = sub(r'[^-_\s\w]', '', result)
30 result = sub(r'[-\s]+', '-', result)
32 # Result
33 return result