# Coverage for modules/box__default/theme/global.py : 47%

## 34 statements

Hot-keys on this page

r m x p toggle line displays

j k next/prev highlighted chunk

0 (zero) top of page

1 (one) first highlighted chunk

1 import json

2 import os

3

4 from flask import url_for

5 from init import themes_path

6 from modules.box__default.settings.helpers import get_setting

7

8

9 def get_front_theme_dir():

10 theme_dir = os.path.join(themes_path, "front", get_setting("ACTIVE_FRONT_THEME"))

11 return theme_dir

12

13

14 def get_front_theme_info_data():

15 info_path = os.path.join(get_front_theme_dir(), "info.json")

16 with open(info_path) as f:

17 info_data = json.load(f)

18 return info_data

19

20

21 def get_active_front_theme():

22 return get_setting("ACTIVE_FRONT_THEME")

23

24

25 def get_active_front_theme_version():

26 return get_front_theme_info_data()["version"]

27

28

29 def get_active_front_theme_styles_url():

30 return url_for(

31 "resource.active_front_theme_css",

32 active_theme=get_active_front_theme(),

33 v=get_active_front_theme_version(),

34 )

35

36

37 def get_back_theme_dir():

38 theme_dir = os.path.join(themes_path, "back", get_setting("ACTIVE_BACK_THEME"))

39 return theme_dir

40

41

42 def get_back_theme_info_data():

43 info_path = os.path.join(get_back_theme_dir(), "info.json")

44 with open(info_path) as f:

45 info_data = json.load(f)

46 return info_data

47

48

49 def get_active_back_theme():

50 return get_setting("ACTIVE_BACK_THEME")

51

52

53 def get_active_back_theme_version():

54 return get_back_theme_info_data()["version"]

55

56

57 def get_active_back_theme_styles_url():

58 return url_for(

59 "resource.active_back_theme_css",

60 active_theme=get_active_back_theme(),

61 v=get_active_back_theme_version(),

62 )

63

64

65 available_everywhere = {

66 "get_active_front_theme": get_active_front_theme,

67 "get_active_front_theme_version": get_active_front_theme_version,

68 "get_active_front_theme_styles_url": get_active_front_theme_styles_url,

69 "get_active_back_theme": get_active_back_theme,

70 "get_active_back_theme_version": get_active_back_theme_version,

71 "get_active_back_theme_styles_url": get_active_back_theme_styles_url,

72}