2009-08-05 08:59:46 +00:00
|
|
|
# Created By: Virgil Dupras
|
|
|
|
# Created On: 2006/03/15
|
2010-01-01 20:11:34 +00:00
|
|
|
# Copyright 2010 Hardcoded Software (http://www.hardcoded.net)
|
2009-08-05 08:59:46 +00:00
|
|
|
#
|
2010-09-30 10:17:41 +00:00
|
|
|
# This software is licensed under the "BSD" License as described in the "LICENSE" file,
|
2009-08-05 08:59:46 +00:00
|
|
|
# which should be included with this package. The terms are also available at
|
2010-09-30 10:17:41 +00:00
|
|
|
# http://www.hardcoded.net/licenses/bsd_license
|
2009-06-01 09:55:11 +00:00
|
|
|
|
|
|
|
from hsutil.str import format_time, FT_DECIMAL, format_size
|
|
|
|
|
|
|
|
import time
|
|
|
|
|
|
|
|
def format_path(p):
|
2010-08-11 14:39:06 +00:00
|
|
|
return str(p[:-1])
|
2009-06-01 09:55:11 +00:00
|
|
|
|
|
|
|
def format_timestamp(t, delta):
|
|
|
|
if delta:
|
|
|
|
return format_time(t, FT_DECIMAL)
|
|
|
|
else:
|
|
|
|
if t > 0:
|
|
|
|
return time.strftime('%Y/%m/%d %H:%M:%S', time.localtime(t))
|
|
|
|
else:
|
|
|
|
return '---'
|
|
|
|
|
|
|
|
def format_words(w):
|
|
|
|
def do_format(w):
|
|
|
|
if isinstance(w, list):
|
|
|
|
return '(%s)' % ', '.join(do_format(item) for item in w)
|
|
|
|
else:
|
|
|
|
return w.replace('\n', ' ')
|
|
|
|
|
|
|
|
return ', '.join(do_format(item) for item in w)
|
|
|
|
|
|
|
|
def format_perc(p):
|
|
|
|
return "%0.0f" % p
|
|
|
|
|
|
|
|
def format_dupe_count(c):
|
|
|
|
return str(c) if c else '---'
|
|
|
|
|
|
|
|
def cmp_value(value):
|
2010-08-11 14:39:06 +00:00
|
|
|
return value.lower() if isinstance(value, str) else value
|