def __str__(self):
return self.path()
+ def config_value(self):
+ return self.path()
+
def ini_str(self):
return self.path()
for param in sorted(self._params.keys()):
value = self._values.get(param)
if value != None:
- try:
- # Use native type for those supported by JSON and
- # strings for everything else. skipkeys=True seems
- # to not work as well as one would hope
- if type(self._values[param].value) in \
- [str, unicode, int, long, float, bool, None]:
- d[param] = self._values[param].value
- else:
- d[param] = str(self._values[param])
-
- except AttributeError:
- pass
+ d[param] = value.config_value()
for n in sorted(self._children.keys()):
child = self._children[n]
def ini_str(self):
return str(self)
+ # default for printing to .json file is regular string conversion.
+ # will be overridden in some cases, mostly to use native Python
+ # types where there are similar JSON types
+ def config_value(self):
+ return str(self)
+
# allows us to blithely call unproxy() on things without checking
# if they're really proxies or not
def unproxy(self, base):
raise AttributeError, \
"Not allowed to set %s on '%s'" % (attr, type(self).__name__)
+ def config_value(self):
+ return [v.config_value() for v in self]
+
def ini_str(self):
return ' '.join([v.ini_str() for v in self])
newobj._check()
return newobj
+ def config_value(self):
+ return self.value
+
# Metaclass for bounds-checked integer parameters. See CheckedInt.
class CheckedIntType(MetaParamValue):
def __init__(cls, name, bases, dict):
def getValue(self):
return float(self.value)
+ def config_value(self):
+ return self
+
class MemorySize(CheckedInt):
cxx_type = 'uint64_t'
ex_str = '512MB'
return 'true'
return 'false'
+ def config_value(self):
+ return self.value
+
def IncEthernetAddr(addr, val = 1):
bytes = map(lambda x: int(x, 16), addr.split(':'))
bytes[5] += val
return IpWithPort(self.ip, self.port)
time_formats = [ "%a %b %d %H:%M:%S %Z %Y",
- "%a %b %d %H:%M:%S %Z %Y",
+ "%a %b %d %H:%M:%S %Y",
"%Y/%m/%d %H:%M:%S",
"%Y/%m/%d %H:%M",
"%Y/%m/%d",
return str(self)
def get_config_as_dict(self):
+ assert false
return str(self)
# Enumerated types are a little more complex. The user specifies the
value = ticks.fromSeconds(self.value)
return long(value)
+ def config_value(self):
+ return self.getValue()
+
# convert latency to ticks
def ini_str(self):
return '%d' % self.getValue()
value = ticks.fromSeconds(1.0 / self.value)
return long(value)
+ def config_value(self):
+ return self.getValue()
+
def ini_str(self):
return '%d' % self.getValue()
def getValue(self):
return self.period.getValue()
+ def config_value(self):
+ return self.period.config_value()
+
def ini_str(self):
return self.period.ini_str()
def ini_str(self):
return '%f' % self.getValue()
+ def config_value(self):
+ return '%f' % self.getValue()
+
class MemoryBandwidth(float,ParamValue):
cxx_type = 'float'
ex_str = "1GB/s"
def ini_str(self):
return '%f' % self.getValue()
+ def config_value(self):
+ return '%f' % self.getValue()
+
#
# "Constants"... handy aliases for various values.
#
def __str__(self):
return 'Null'
+ def config_value(self):
+ return None
+
def getValue(self):
return None