Coverage for colour/io/luts/common.py: 100%

14 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2025-11-15 19:01 +1300

1""" 

2LUT Processing Common Utilities 

3=============================== 

4 

5Define *LUT* processing common utilities objects that do not fall within any 

6specific category. 

7""" 

8 

9from __future__ import annotations 

10 

11import os 

12import re 

13import typing 

14 

15if typing.TYPE_CHECKING: 

16 from colour.hints import PathLike 

17 

18__author__ = "Colour Developers" 

19__copyright__ = "Copyright 2013 Colour Developers" 

20__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" 

21__maintainer__ = "Colour Developers" 

22__email__ = "colour-developers@colour-science.org" 

23__status__ = "Production" 

24 

25__all__ = [ 

26 "path_to_title", 

27] 

28 

29 

30def path_to_title(path: str | PathLike) -> str: 

31 """ 

32 Convert the specified file path to a human-readable title. 

33 

34 Extract the base filename from the specified path, remove the file 

35 extension, and replace underscores, hyphens, and dots with spaces to 

36 create a readable title format. 

37 

38 Parameters 

39 ---------- 

40 path 

41 File path to convert to title. 

42 

43 Returns 

44 ------- 

45 :class:`str` 

46 File path converted to title. 

47 

48 Examples 

49 -------- 

50 >>> path_to_title("colour/io/luts/tests/resources/sony_spi3d/Colour_Correct.spi3d") 

51 'Colour Correct' 

52 """ 

53 

54 path = str(path) 

55 

56 return re.sub("_|-|\\.", " ", os.path.splitext(os.path.basename(path))[0])