add Directory tools
authorFelix Domke <tmbinc@elitedvb.net>
Sat, 15 Oct 2005 20:05:15 +0000 (20:05 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Sat, 15 Oct 2005 20:05:15 +0000 (20:05 +0000)
lib/python/Tools/Directories.py [new file with mode: 0644]
lib/python/Tools/Makefile.am
lib/python/Tools/__init__.py

diff --git a/lib/python/Tools/Directories.py b/lib/python/Tools/Directories.py
new file mode 100644 (file)
index 0000000..982db6f
--- /dev/null
@@ -0,0 +1,48 @@
+import os
+
+SCOPE_TRANSPONDERDATA = 0
+SCOPE_SYSETC = 1
+SCOPE_FONTS = 2
+SCOPE_SKIN = 3
+SCOPE_SKIN_IMAGE = 4
+SCOPE_USERETC = 5
+
+defaultPaths = {
+               SCOPE_TRANSPONDERDATA: "/etc/",
+               SCOPE_SYSETC: "/etc/",
+               SCOPE_FONTS: "/usr/share/fonts/",
+
+               SCOPE_SKIN: "/usr/share/tuxbox/enigma2/",
+               SCOPE_SKIN_IMAGE: "/usr/share/tuxbox/enigma2/",
+               
+               SCOPE_USERETC: "" # user home directory
+       }
+
+def resolveFilename(scope, base):
+       # in future, we would check for file existence here,
+       # so we can provide default/fallbacks.
+       
+       # FIXME: we also have to handle DATADIR etc. here.
+       return defaultPaths[scope] + base
+
+       # this is only the BASE - an extension must be added later.
+def getRecordingFilename(basename):
+       
+               # filter out non-allowed characters
+       non_allowed_characters = "/.\\"
+       
+       filename = ""
+       for c in basename:
+               if c in non_allowed_characters:
+                       c = "_"
+               filename += c
+       
+       i = 0
+       while True:
+               path = "/hdd/movies/" + filename
+               if i > 0:
+                       path += str(i)
+#              if os.glob(path + "*").size() == 0:
+#                      return path
+               return path
+               i+=1
index a08387ef19d95b916709bb2e4d37cfbb4e38b31a..882e523ee13c7e1ef519f59f30afaffdedb73e8d 100644 (file)
@@ -1,4 +1,4 @@
 installdir = $(LIBDIR)/enigma2/python/Tools
 
 install_DATA = \
-       FuzzyDate.py XMLTools.py __init__.py
+       FuzzyDate.py XMLTools.py Directories.py __init__.py
index 4ff7ce3cdb06ce7d2da317eab7d95da5adac7e6d..72a1abb7cfd4e6f6d0ec0dc9869e6d61db415028 100644 (file)
@@ -1 +1 @@
-all = ["FuzzyDate.py", "XMLTools.py"]
+all = ["FuzzyDate.py", "XMLTools.py", "Directories.py"]