5 def print_error(*args):
6 '''Print out the arguments to standard error'''
8 sys.stderr.write(str(item))
13 if platform.system() == "Windows":
14 return os.path.join(os.environ["APPDATA"], "Electrum")
15 elif platform.system() == "Linux":
16 return os.path.join(sys.prefix, "share", "electrum")
17 elif (platform.system() == "Darwin" or
18 platform.system() == "DragonFly"):
19 return "/Library/Application Support/Electrum"
21 raise Exception("Unknown system")
23 def get_resource_path(*args):
24 return os.path.join(".", *args)
28 prefix_path = os.path.dirname(sys.argv[0])
29 local_data = os.path.join(prefix_path, "data")
32 def load_theme_name(theme_path):
34 with open(os.path.join(theme_path, "name.cfg")) as name_cfg_file:
35 return name_cfg_file.read().rstrip("\n").strip()
39 def theme_dirs_from_prefix(prefix):
40 if not os.path.exists(prefix):
43 for potential_theme in os.listdir(prefix):
44 theme_full_path = os.path.join(prefix, potential_theme)
45 theme_css = os.path.join(theme_full_path, "style.css")
46 if not os.path.exists(theme_css):
48 theme_name = load_theme_name(theme_full_path)
49 if theme_name is None:
51 theme_paths[theme_name] = prefix, potential_theme
54 def load_theme_paths():
56 prefixes = (local_data_dir(), appdata_dir())
57 for prefix in prefixes:
58 theme_paths.update(theme_dirs_from_prefix(prefix))