diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-02-02 21:46:15 +0100 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-02-02 21:46:15 +0100 |
commit | 7a503302fbe6fcc23af94de2fe313298c3a6d95c (patch) | |
tree | 724a8581008d3d78fed0be965161e330eb4b1064 /module/web/filters.py | |
parent | closes #226, #227 (diff) | |
download | pyload-7a503302fbe6fcc23af94de2fe313298c3a6d95c.tar.xz |
removed django => now using bottle, new builtin threaded ssl server
Dont forget to install jinja and beaker !
Diffstat (limited to 'module/web/filters.py')
-rw-r--r-- | module/web/filters.py | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/module/web/filters.py b/module/web/filters.py new file mode 100644 index 000000000..1b10f7cb4 --- /dev/null +++ b/module/web/filters.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +import os +from os.path import abspath, commonprefix, join +from time import strftime, mktime, gmtime + +quotechar = "::/" + +try: + from os.path import relpath +except: + 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 = abspath(start).split(sep) + path_list = abspath(path).split(sep) + # Work out how much of the filepath is shared by start and path. + i = len(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) + + +def quotepath(path): + try: + return path.replace("../", quotechar) + except AttributeError: + return path + except: + return "" + +def unquotepath(path): + try: + return path.replace(quotechar, "../") + except AttributeError: + return path + except: + return "" + +def path_make_absolute(path): + p = os.path.abspath(path) + if p[-1] == os.path.sep: + return p + else: + return p + os.path.sep + +def path_make_relative(path): + p = relpath(path) + if p[-1] == os.path.sep: + return p + else: + return p + os.path.sep + +def truncate(value, n): + if (n - len(value)) < 3: + return value[:n]+"..." + return value + +def date(date, format): + return date
\ No newline at end of file |