From efb8bb0d3f626d1f38950b677fc22e4703e777f4 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sat, 27 Nov 2010 00:27:42 +0100 Subject: fix --- module/web/pyload/templatetags/quotepath.py | 14 -------------- module/web/pyload/views.py | 14 +++++++++++++- 2 files changed, 13 insertions(+), 15 deletions(-) (limited to 'module/web/pyload') 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 -- cgit v1.2.3