1
0

move theme_path functions from util to gui_lite

This commit is contained in:
thomasv
2012-10-19 14:36:12 +02:00
parent e165c13a84
commit 728ae0d184
2 changed files with 32 additions and 30 deletions

View File

@@ -40,32 +40,3 @@ def local_data_dir():
local_data = os.path.join(prefix_path, "data")
return local_data
def load_theme_name(theme_path):
try:
with open(os.path.join(theme_path, "name.cfg")) as name_cfg_file:
return name_cfg_file.read().rstrip("\n").strip()
except IOError:
return None
def theme_dirs_from_prefix(prefix):
if not os.path.exists(prefix):
return []
theme_paths = {}
for potential_theme in os.listdir(prefix):
theme_full_path = os.path.join(prefix, potential_theme)
theme_css = os.path.join(theme_full_path, "style.css")
if not os.path.exists(theme_css):
continue
theme_name = load_theme_name(theme_full_path)
if theme_name is None:
continue
theme_paths[theme_name] = prefix, potential_theme
return theme_paths
def load_theme_paths():
theme_paths = {}
prefixes = (local_data_dir(), appdata_dir())
for prefix in prefixes:
theme_paths.update(theme_dirs_from_prefix(prefix))
return theme_paths