4 """The entry class represents a column in the statistics file.
5 Its components are a title, a format and an additional object.
6 It's what gets written to the statistics file in a column.
7 - title: the title of the column
8 - format: a wisely chosen format string (see below)
9 - something: either something that can be formattable, a string, a number
10 etc. This is a static entry. In that case all remaining arguments are
11 discarded and get_value returns the formatted string : format % something.
12 If something is a function, this is a dynamic entry, and the format
13 string is used on the result of the function call
14 something(*args,**kwargs).
16 def __init__(self, title, fmt, something, *args, **kwargs):
19 self.is_function = callable(something)
21 self.function = something
25 self.value = something
26 self.was_updated_since_last_get =
False
30 return "Entry('%s', '%s', f(...))" % (self.title, self.format)
32 return "Entry('%s', '%s', %s)" % (self.title, self.format,
39 def get_raw_value(self):
41 return self.function(*self.args, **self.kwargs)
43 self.was_updated_since_last_get =
False
48 return self.format % self.get_raw_value()
52 def set_value(self, val):
55 "Can only set_value on static entries."
57 self.was_updated_since_last_get =
True
59 def get_was_updated(self):
60 return self.is_function
or self.was_updated_since_last_get