summaryrefslogtreecommitdiff
path: root/src/mem/slicc/util.py
diff options
context:
space:
mode:
authorNathan Binkert <nate@binkert.org>2011-07-05 18:30:05 -0700
committerNathan Binkert <nate@binkert.org>2011-07-05 18:30:05 -0700
commit831e9b3b7a658663f5bffafef175d4f4a5615cfd (patch)
treee2ac76e79b6e3f0f1fe5e5c471004c3e391dee2b /src/mem/slicc/util.py
parent3d252f8e5fa2ec3f55730ab6d5d1a4a1b21b2cdf (diff)
downloadgem5-831e9b3b7a658663f5bffafef175d4f4a5615cfd.tar.xz
slicc: cleanup slicc code and make it less verbose
Diffstat (limited to 'src/mem/slicc/util.py')
-rw-r--r--src/mem/slicc/util.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/mem/slicc/util.py b/src/mem/slicc/util.py
index abadc3e30..83badf46d 100644
--- a/src/mem/slicc/util.py
+++ b/src/mem/slicc/util.py
@@ -27,13 +27,6 @@
import os
import sys
-def makeDir(path):
- if os.path.exists(path):
- if not os.path.isdir(path):
- raise AttributeError, "%s exists but is not directory" % path
- else:
- os.mkdir(path)
-
class PairContainer(object):
def __init__(self, pairs=None):
self.pairs = {}
@@ -53,14 +46,23 @@ class PairContainer(object):
return self.pairs.get(item, failobj)
class Location(object):
- def __init__(self, filename, lineno):
+ def __init__(self, filename, lineno, no_warning=False):
+ if not isinstance(filename, basestring):
+ raise AttributeError, \
+ "filename must be a string, found '%s'" % (type(filename), )
+ if not isinstance(lineno, (int, long)):
+ raise AttributeError, \
+ "filename must be an integer, found '%s'" % (type(lineno), )
self.filename = filename
self.lineno = lineno
+ self.no_warning = no_warning
def __str__(self):
return '%s:%d' % (os.path.basename(self.filename), self.lineno)
def warning(self, message, *args):
+ if self.no_warning:
+ return
if args:
message = message % args
#raise Exception, "%s: Warning: %s" % (self, message)
@@ -72,4 +74,4 @@ class Location(object):
raise Exception, "%s: Error: %s" % (self, message)
sys.exit("\n%s: Error: %s" % (self, message))
-__all__ = [ 'makeDir', 'PairContainer', 'Location' ]
+__all__ = [ 'PairContainer', 'Location' ]