add possibility to override tuner type in ConvertToHumanReadable
[enigma2.git] / lib / python / Tools / Directories.py
index 8a35f1da2440cf73d7dbc1c7bf38b7efd9ad8dba..7dcd5876e9660c16911520512146b15b3a036b1f 100644 (file)
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 
-from os import path as os_path, mkdir, rmdir, system, walk, stat as os_stat, listdir, readlink, makedirs, error as os_error, symlink
+from os import path as os_path, mkdir, rmdir, system, walk, stat as os_stat, listdir, readlink, makedirs, error as os_error, symlink, access, F_OK, R_OK, W_OK
 from stat import S_IMODE
 from re import compile
 
@@ -126,6 +126,9 @@ def resolveFilename(scope, base = "", path_prefix = None):
 def pathExists(path):
        return os_path.exists(path)
 
+def isMount(path):
+       return os_path.ismount(path)
+
 def createDir(path, makeParents = False):
        try:
                if makeParents:
@@ -148,13 +151,13 @@ def removeDir(path):
        return ret
 
 def fileExists(f, mode='r'):
-       try:
-               file = open(f, mode)
-       except IOError:
-               exists = 0
+       if mode == 'r':
+               acc_mode = R_OK
+       elif mode == 'w':
+               acc_mode = W_OK
        else:
-               exists = 1
-       return exists
+               acc_mode = F_OK
+       return access(f, acc_mode)
 
 def getRecordingFilename(basename, dirname = None):
        # filter out non-allowed characters
@@ -169,7 +172,7 @@ def getRecordingFilename(basename, dirname = None):
                filename += c
 
        if dirname is not None:
-               filename = ''.join([dirname, filename])
+               filename = ''.join((dirname, filename))
 
        i = 0
        while True: