diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2010-11-27 00:27:42 +0100 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2010-11-27 00:27:42 +0100 |
commit | efb8bb0d3f626d1f38950b677fc22e4703e777f4 (patch) | |
tree | b90827b4adacd539bef6d55a615f2d176d57d2dd /module/web/pyload | |
parent | relpath for 2.5 (diff) | |
download | pyload-efb8bb0d3f626d1f38950b677fc22e4703e777f4.tar.xz |
fix
Diffstat (limited to 'module/web/pyload')
-rw-r--r-- | module/web/pyload/templatetags/quotepath.py | 14 | ||||
-rw-r--r-- | module/web/pyload/views.py | 14 |
2 files changed, 13 insertions, 15 deletions
diff --git a/module/web/pyload/templatetags/quotepath.py b/module/web/pyload/templatetags/quotepath.py index f3d9d7b2c..3678b9391 100644 --- a/module/web/pyload/templatetags/quotepath.py +++ b/module/web/pyload/templatetags/quotepath.py @@ -1,5 +1,4 @@ import os -from posixpath import curdir, sep, pardir, join from django.template.defaultfilters import stringfilter from django import template @@ -48,18 +47,5 @@ def path_make_relative(path): else: return p + os.path.sep -def relpath(path, start=curdir): - """Return a relative version of a path""" - if not path: - raise ValueError("no path specified") - start_list = posixpath.abspath(start).split(sep) - path_list = posixpath.abspath(path).split(sep) - # Work out how much of the filepath is shared by start and path. - i = len(posixpath.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) - register.filter(path_make_relative) 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 |