Coverage for io/luts/common.py: 14%

1"""

2 LUT Processing Common Utilities

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

4

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

6 specific category.

7"""

8

9 from __future__ import annotations

10

11 import os

12 import re

13 import typing

14

15 if 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

30 def 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])