From 505d05e2f9845ec8a8d28fb27e493f6259d02bde Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Sat, 15 Oct 2005 20:05:15 +0000 Subject: add Directory tools --- lib/python/Tools/Directories.py | 48 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 lib/python/Tools/Directories.py (limited to 'lib/python/Tools/Directories.py') diff --git a/lib/python/Tools/Directories.py b/lib/python/Tools/Directories.py new file mode 100644 index 00000000..982db6f0 --- /dev/null +++ b/lib/python/Tools/Directories.py @@ -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 -- cgit v1.2.3