Enabler option

This commit is contained in:
Ruud
2011-04-10 12:31:31 +02:00
parent 85fc1c01ee
commit 2b8e96e267
26 changed files with 239 additions and 245 deletions
+5 -2
View File
@@ -1,4 +1,7 @@
from couchpotato.environment import Env
class Plugin():
def __init__(self):
pass
def conf(self, attr):
return Env.setting(attr, self.__class__.__name__.lower())
+9 -12
View File
@@ -8,24 +8,22 @@ if os.name == 'nt':
class FileBrowser():
def __init__(self, path = '/'):
self.path = path
def __init__(self):
addApiView('directory.list', self.view)
def getDirectories(self):
def getDirectories(self, path = '/', show_hidden = True):
# Return driveletters or root if path is empty
if self.path == '/' or not self.path:
if path == '/' or not path:
if os.name == 'nt':
return self.getDriveLetters()
self.path = '/'
path = '/'
dirs = []
for f in os.listdir(self.path):
path = os.path.join(self.path, f)
if(os.path.isdir(path)):
dirs.append(path)
for f in os.listdir(path):
p = os.path.join(path, f)
if(os.path.isdir(p)):
dirs.append(p + '/')
return dirs
@@ -44,8 +42,7 @@ class FileBrowser():
def view(self):
try:
fb = FileBrowser(getParam('path', '/'))
dirs = fb.getDirectories()
dirs = self.getDirectories(path = getParam('path', '/'), show_hidden = getParam('show_hidden', True))
except:
dirs = []