2009-08-05 08:59:46 +00:00
|
|
|
# Created By: Virgil Dupras
|
|
|
|
# Created On: 2006/03/15
|
2011-04-12 08:04:01 +00:00
|
|
|
# Copyright 2011 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
|
|
|
|
2011-01-29 10:07:33 +00:00
|
|
|
from collections import namedtuple
|
2011-09-16 16:24:56 +00:00
|
|
|
import time
|
2011-01-29 10:07:33 +00:00
|
|
|
|
2011-01-11 12:36:05 +00:00
|
|
|
from hscommon.util import format_time_decimal, format_size
|
2011-09-16 16:24:56 +00:00
|
|
|
from . import prioritize
|
2009-06-01 09:55:11 +00:00
|
|
|
|
2011-01-29 10:07:33 +00:00
|
|
|
Column = namedtuple('Column', 'attr display')
|
|
|
|
|
2009-06-01 09:55:11 +00:00
|
|
|
def format_timestamp(t, delta):
|
|
|
|
if delta:
|
2011-01-11 12:36:05 +00:00
|
|
|
return format_time_decimal(t)
|
2009-06-01 09:55:11 +00:00
|
|
|
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
|
2011-09-16 16:24:56 +00:00
|
|
|
|
|
|
|
def prioritization_categories():
|
|
|
|
return prioritize.all_categories()
|