get_resource_path("foo.png") -> "/usr/share/electrum/foo.png"
authorAmir Taaki <genjix@riseup.net>
Wed, 4 Jul 2012 23:25:05 +0000 (01:25 +0200)
committerAmir Taaki <genjix@riseup.net>
Wed, 4 Jul 2012 23:25:05 +0000 (01:25 +0200)
util.py [new file with mode: 0644]

diff --git a/util.py b/util.py
new file mode 100644 (file)
index 0000000..53cc650
--- /dev/null
+++ b/util.py
@@ -0,0 +1,17 @@
+import os
+import platform
+import sys
+
+def appdata_dir():
+    if platform.system() == "Windows":
+        return os.path.join(os.environ["APPDATA"], "Electrum")
+    elif platform.system() == "Linux":
+        return os.path.join(sys.prefix, "share", "electrum")
+    elif platform.system() == "Darwin":
+        return "/Library/Application Support/Electrum"
+    else:
+        raise Exception("Unknown system")
+
+def get_resource_path(filename):
+    return os.path.join(appdata_dir(), filename)
+