# Created By: Virgil Dupras # Created On: 2006/03/15 # Copyright 2011 Hardcoded Software (http://www.hardcoded.net) # # This software is licensed under the "BSD" License as described in the "LICENSE" file, # which should be included with this package. The terms are also available at # http://www.hardcoded.net/licenses/bsd_license from collections import namedtuple import time from hscommon.util import format_time_decimal, format_size from . import prioritize Column = namedtuple('Column', 'attr display') def format_timestamp(t, delta): if delta: return format_time_decimal(t) 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): return value.lower() if isinstance(value, str) else value def prioritization_categories(): return prioritize.all_categories()