summaryrefslogtreecommitdiffstats
path: root/module/web/pyload/views.py
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-11-27 00:27:42 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-11-27 00:27:42 +0100
commitefb8bb0d3f626d1f38950b677fc22e4703e777f4 (patch)
treeb90827b4adacd539bef6d55a615f2d176d57d2dd /module/web/pyload/views.py
parentrelpath for 2.5 (diff)
downloadpyload-efb8bb0d3f626d1f38950b677fc22e4703e777f4.tar.xz
fix
Diffstat (limited to 'module/web/pyload/views.py')
-rw-r--r--module/web/pyload/views.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/module/web/pyload/views.py b/module/web/pyload/views.py
index 62c405339..0da21f556 100644
--- a/module/web/pyload/views.py
+++ b/module/web/pyload/views.py
@@ -20,7 +20,19 @@ from pyload.templatetags import quotepath
try:
from os.path import relpath
except:
- from pyload.templatetags import relpath
+ from posixpath import curdir, sep, pardir
+ def relpath(path, start=curdir):
+ """Return a relative version of a path"""
+ if not path:
+ raise ValueError("no path specified")
+ start_list = os.path.abspath(start).split(sep)
+ path_list = os.path.abspath(path).split(sep)
+ # Work out how much of the filepath is shared by start and path.
+ i = len(os.path.commonprefix([start_list, path_list]))
+ rel_list = [pardir] * (len(start_list)-i) + path_list[i:]
+ if not rel_list:
+ return curdir
+ return join(*rel_list)
from django.conf import settings
from django.contrib.auth.decorators import login_required