3 """@namespace IMP.isd.Entry
4 Classes to handle ISD statistics files.
8 """The entry class represents a column in the statistics file.
9 Its components are a title, a format and an additional object.
10 It's what gets written to the statistics file in a column.
11 - title: the title of the column
12 - format: a wisely chosen format string (see below)
13 - something: either something that can be formattable, a string, a number
14 etc. This is a static entry. In that case all remaining arguments are
15 discarded and get_value returns the formatted string : format % something.
16 If something is a function, this is a dynamic entry, and the format
17 string is used on the result of the function call
18 something(*args,**kwargs).
20 def __init__(self, title, fmt, something, *args, **kwargs):
23 self.is_function = callable(something)
25 self.function = something
29 self.value = something
30 self.was_updated_since_last_get =
False
34 return "Entry('%s', '%s', f(...))" % (self.title, self.format)
36 return "Entry('%s', '%s', %s)" % (self.title, self.format,
43 def get_raw_value(self):
45 return self.function(*self.args, **self.kwargs)
47 self.was_updated_since_last_get =
False
52 return self.format % self.get_raw_value()
56 def set_value(self, val):
59 "Can only set_value on static entries."
61 self.was_updated_since_last_get =
True
63 def get_was_updated(self):
64 return self.is_function
or self.was_updated_since_last_get