5 def print_error(*args):
6 """Print out the arguments to standard error."""
8 sys.stderr.write(str(item))
13 """Find the path to the application data directory; add an electrum folder and return path."""
14 if platform.system() == "Windows":
15 return os.path.join(os.environ["APPDATA"], "Electrum")
16 elif platform.system() == "Linux":
17 return os.path.join(sys.prefix, "share", "electrum")
18 elif (platform.system() == "Darwin" or
19 platform.system() == "DragonFly"):
20 return "/Library/Application Support/Electrum"
22 raise Exception("Unknown system")
24 def get_resource_path(*args):
25 return os.path.join(".", *args)
28 """Return path to the data folder."""
30 prefix_path = os.path.dirname(sys.argv[0])
31 local_data = os.path.join(prefix_path, "data")
34 def load_theme_name(theme_path):
36 with open(os.path.join(theme_path, "name.cfg")) as name_cfg_file:
37 return name_cfg_file.read().rstrip("\n").strip()
41 def theme_dirs_from_prefix(prefix):
42 if not os.path.exists(prefix):
45 for potential_theme in os.listdir(prefix):
46 theme_full_path = os.path.join(prefix, potential_theme)
47 theme_css = os.path.join(theme_full_path, "style.css")
48 if not os.path.exists(theme_css):
50 theme_name = load_theme_name(theme_full_path)
51 if theme_name is None:
53 theme_paths[theme_name] = prefix, potential_theme
56 def load_theme_paths():
58 prefixes = (local_data_dir(), appdata_dir())
59 for prefix in prefixes:
60 theme_paths.update(theme_dirs_from_prefix(prefix))