New year, big checkin
[jamaendo] / jamaui / util.py
index 6bff67f..d17492a 100644 (file)
@@ -1,4 +1,5 @@
 import os
+import simplejson
 
 def string_in_file( filepath, string ):
     try:
@@ -19,3 +20,17 @@ def get_platform():
         return 'linux'
 
 platform = get_platform()
+
+def jsonprint(x):
+    print simplejson.dumps(x, sort_keys=True, indent=4)
+
+def find_resource(name):
+    if os.path.isfile(os.path.join('data', name)):
+        return os.path.join('data', name)
+    elif os.path.isfile(os.path.join('/opt/jaemendo', name)):
+        return os.path.join('/opt/jaemendo', name)
+    elif os.path.isfile(os.path.join('/usr/share/jaemendo', name)):
+        return os.path.join('/usr/share/jaemendo', name)
+    else:
+        return None
+