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

12 statements  

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

1#!/usr/bin/env python3 

2 

3# Standard libraries 

4from re import sub 

5 

6# Namespaces class 

7class Namespaces: 

8 

9 # Capitalize 

10 @staticmethod 

11 def capitalize(text: str, words: bool = False) -> str: 

12 

13 # Capitalize words 

14 if words: 

15 return ' '.join( 

16 Namespaces.capitalize(word, words=False) for word in text.split()) 

17 

18 # Capitalize text 

19 return f'{text[:1].capitalize()}{text[1:]}' 

20 

21 # Describe 

22 @staticmethod 

23 def describe( 

24 name: str, 

25 description: str = '', 

26 ) -> str: 

27 

28 # Use description 

29 if description: 

30 return description 

31 

32 # Adapt name 

33 return Namespaces.capitalize(sub(r'[-_]', ' ', name), words=True)