Deleted Added
sdiff udiff text old ( 5467:6d9df90d70d7 ) new ( 5618:1abb23c038d5 )
full compact
1# Copyright (c) 2005-2006 The Regents of The University of Michigan
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met: redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer;
8# redistributions in binary form must reproduce the above copyright

--- 14 unchanged lines hidden (view full) ---

23# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26#
27# Authors: Nathan Binkert
28
29import sys
30
31from attrdict import optiondict
32from misc import crossproduct
33
34class Data(object):
35 def __init__(self, name, desc, **kwargs):
36 self.name = name
37 self.desc = desc
38 self.__dict__.update(kwargs)
39
40 def update(self, obj):
41 if not isinstance(obj, Data):
42 raise AttributeError, "can only update from Data object"
43
44 for key,val in obj.__dict__.iteritems():
45 if key.startswith('_') or key in ('name', 'desc'):
46 continue
47
48 if key not in self.__dict__:
49 self.__dict__[key] = val
50 continue
51
52 if not isinstance(val, dict):
53 if self.__dict__[key] == val:
54 continue
55
56 raise AttributeError, \
57 "%s specified more than once old: %s new: %s" % \
58 (key, self.__dict__[key], val)
59
60 d = self.__dict__[key]
61 for k,v in val.iteritems():
62 if k in d:
63 raise AttributeError, \
64 "%s specified more than once in %s" % (k, key)
65 d[k] = v
66
67 if hasattr(self, 'system') and hasattr(obj, 'system'):
68 if self.system != obj.system:
69 raise AttributeError, \
70 "conflicting values for system: '%s'/'%s'" % \
71 (self.system, obj.system)
72
73 def printinfo(self):
74 if self.name:

--- 33 unchanged lines hidden (view full) ---

108 yield key
109
110 def optiondict(self):
111 result = optiondict()
112 for key in self:
113 result[key] = self[key]
114 return result
115
116 def __repr__(self):
117 d = {}
118 for key,value in self.__dict__.iteritems():
119 if not key.startswith('_'):
120 d[key] = value
121
122 return "<%s: %s>" % (type(self).__name__, d)
123
124 def __str__(self):
125 return self.name
126
127class Job(Data):
128 def __init__(self, options):
129 super(Job, self).__init__('', '')
130
131 config = options[0]._config

--- 282 unchanged lines hidden (view full) ---

414 else:
415 raise AttributeError, \
416 "Could not find file '%s'" % jobfile
417
418 data = {}
419 execfile(filename, data)
420 if 'conf' not in data:
421 raise ImportError, 'cannot import name conf from %s' % jobfile
422 return data['conf']
423
424def main(conf=None):
425 usage = 'Usage: %s [-b] [-c] [-v]' % sys.argv[0]
426 if conf is None:
427 usage += ' <jobfile>'
428
429 try:
430 import getopt
431 opts, args = getopt.getopt(sys.argv[1:], '-bcv')
432 except getopt.GetoptError:
433 sys.exit(usage)
434
435 both = False
436 checkpoint = False

--- 36 unchanged lines hidden ---