summaryrefslogtreecommitdiff
path: root/src/python
diff options
context:
space:
mode:
authorNathan Binkert <nate@binkert.org>2010-09-09 14:15:41 -0700
committerNathan Binkert <nate@binkert.org>2010-09-09 14:15:41 -0700
commitc514ad9b097ef73b14abbf4f5af3617c54dbb154 (patch)
tree6bf06e38238e9b3367cb21db4288047792c8c52d /src/python
parent18ef1bcfa23a4e582e37cb9e806b06e9a6c13b53 (diff)
downloadgem5-c514ad9b097ef73b14abbf4f5af3617c54dbb154.tar.xz
code_formatter: make it easier to insert whitespace
a newline by just doing "code()". indent() and dedent() now take a "count" parameter to indent/dedent multiple levels.
Diffstat (limited to 'src/python')
-rw-r--r--src/python/m5/util/code_formatter.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/python/m5/util/code_formatter.py b/src/python/m5/util/code_formatter.py
index 47106e0d9..023e189cd 100644
--- a/src/python/m5/util/code_formatter.py
+++ b/src/python/m5/util/code_formatter.py
@@ -131,12 +131,12 @@ class code_formatter(object):
if args:
self.__call__(args)
- def indent(self):
- self._indent_level += self._indent_spaces
+ def indent(self, count=1):
+ self._indent_level += self._indent_spaces * count
- def dedent(self):
- assert self._indent_level >= self._indent_spaces
- self._indent_level -= self._indent_spaces
+ def dedent(self, count=1):
+ assert self._indent_level >= (self._indent_spaces * count)
+ self._indent_level -= self._indent_spaces * count
def fix(self, status):
previous = self._fix_newlines
@@ -200,10 +200,14 @@ class code_formatter(object):
initial_newline = False
- def insert_newline(self):
- self._data.append('\n')
+ def __call__(self, *args, **kwargs):
+ if not args:
+ self._data.append('\n')
+ return
+
+ format = args[0]
+ args = args[1:]
- def __call__(self, format, *args, **kwargs):
frame = inspect.currentframe().f_back
l = lookup(self, frame, *args, **kwargs)