summaryrefslogtreecommitdiff
path: root/python/m5/config.py
diff options
context:
space:
mode:
authorNathan Binkert <binkertn@umich.edu>2005-03-11 18:47:11 -0500
committerNathan Binkert <binkertn@umich.edu>2005-03-11 18:47:11 -0500
commitc393a51f4a00e88e7a72ad2c7bd56d19194f0b6a (patch)
tree9cd1da1f592488c5f5d2fdea95725775ee765b61 /python/m5/config.py
parente6902a907e333c09d64d520f4c978edf7e098f6a (diff)
downloadgem5-c393a51f4a00e88e7a72ad2c7bd56d19194f0b6a.tar.xz
move the conversion stuff that was in configs/kernel/Config.py into
the m5 package as convert.py add a smartdict class which stores strings and can intelligently interpret those string variables as several other types. make the env dict use the smartdict class python/m5/config.py: move a bunch of conversion functions into convert.py turn the env dict into a smartdict adapt the _CheckedInt stuff to deal with derived types python/m5/objects/BaseCPU.mpy: env is now a smartdict and can properly convert to bool --HG-- extra : convert_revision : 8abcd35a5ab14b82f280aea59020953869e33365
Diffstat (limited to 'python/m5/config.py')
-rw-r--r--python/m5/config.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/python/m5/config.py b/python/m5/config.py
index 33e329f3f..2c5a70b25 100644
--- a/python/m5/config.py
+++ b/python/m5/config.py
@@ -28,6 +28,8 @@ from __future__ import generators
import os, re, sys, types, inspect
from mpy_importer import AddToPath, LoadMpyFile
+from smartdict import SmartDict
+from convert import *
noDot = False
try:
@@ -35,7 +37,7 @@ try:
except:
noDot = True
-env = {}
+env = SmartDict()
env.update(os.environ)
def panic(string):
@@ -976,18 +978,17 @@ VectorParam = _VectorParamProxy(None)
# Integer parameter type.
class _CheckedInt(object):
def _convert(cls, value):
- t = type(value)
- if t == bool:
+ if isinstance(value, bool):
return int(value)
- if t != int and t != long and t != float and t != str:
- raise TypeError, 'Integer parameter of invalid type %s' % t
+ if not isinstance(value, (int, long, float, str)):
+ raise TypeError, 'Integer param of invalid type %s' % type(value)
- if t == str or t == float:
- value = long(value)
+ if isinstance(value, (str, float)):
+ value = long(float(value))
if not cls._min <= value <= cls._max:
- raise TypeError, 'Integer parameter out of bounds %d < %d < %d' % \
+ raise TypeError, 'Integer param out of bounds %d < %d < %d' % \
(cls._min, value, cls._max)
return value