helplist: keys are not anymore secret, at least not for us professionals. skin fixed...
[enigma2.git] / lib / python / Tools / Directories.py
1 import os
2
3 SCOPE_TRANSPONDERDATA = 0
4 SCOPE_SYSETC = 1
5 SCOPE_FONTS = 2
6 SCOPE_SKIN = 3
7 SCOPE_SKIN_IMAGE = 4
8 SCOPE_USERETC = 5
9
10 defaultPaths = {
11                 SCOPE_TRANSPONDERDATA: "/etc/",
12                 SCOPE_SYSETC: "/etc/",
13                 SCOPE_FONTS: "/usr/share/fonts/",
14
15                 SCOPE_SKIN: "/usr/share/tuxbox/enigma2/",
16                 SCOPE_SKIN_IMAGE: "/usr/share/tuxbox/enigma2/",
17                 
18                 SCOPE_USERETC: "" # user home directory
19         }
20
21 def resolveFilename(scope, base):
22         # in future, we would check for file existence here,
23         # so we can provide default/fallbacks.
24         
25         # FIXME: we also have to handle DATADIR etc. here.
26         return defaultPaths[scope] + base
27
28         # this is only the BASE - an extension must be added later.
29 def getRecordingFilename(basename):
30         
31                 # filter out non-allowed characters
32         non_allowed_characters = "/.\\"
33         
34         filename = ""
35         for c in basename:
36                 if c in non_allowed_characters:
37                         c = "_"
38                 filename += c
39         
40         i = 0
41         while True:
42                 path = "/hdd/movies/" + filename
43                 if i > 0:
44                         path += str(i)
45                 try:
46                         open(path + ".ts")
47                         i += 1
48                 except IOError:
49                         return path