code_formatter.py (6999:f226c098c393) code_formatter.py (7672:d609cd948ca0)
1# Copyright (c) 2006-2009 Nathan Binkert <nate@binkert.org>
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

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

126 self.globals = kwargs.pop('globals', type(self).globals)
127 self.locals = kwargs.pop('locals', type(self).locals)
128 self._fix_newlines = \
129 kwargs.pop('fix_newlines', type(self).fix_newlines)
130
131 if args:
132 self.__call__(args)
133
1# Copyright (c) 2006-2009 Nathan Binkert <nate@binkert.org>
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

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

126 self.globals = kwargs.pop('globals', type(self).globals)
127 self.locals = kwargs.pop('locals', type(self).locals)
128 self._fix_newlines = \
129 kwargs.pop('fix_newlines', type(self).fix_newlines)
130
131 if args:
132 self.__call__(args)
133
134 def indent(self):
135 self._indent_level += self._indent_spaces
134 def indent(self, count=1):
135 self._indent_level += self._indent_spaces * count
136
136
137 def dedent(self):
138 assert self._indent_level >= self._indent_spaces
139 self._indent_level -= self._indent_spaces
137 def dedent(self, count=1):
138 assert self._indent_level >= (self._indent_spaces * count)
139 self._indent_level -= self._indent_spaces * count
140
141 def fix(self, status):
142 previous = self._fix_newlines
143 self._fix_newlines = status
144 return previous
145
146 def nofix(self):
147 previous = self._fix_newlines

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

195 self._data.append(' ' * self._indent_level)
196 self._data.append(line)
197
198 if line or not initial_newline:
199 self._data.append('\n')
200
201 initial_newline = False
202
140
141 def fix(self, status):
142 previous = self._fix_newlines
143 self._fix_newlines = status
144 return previous
145
146 def nofix(self):
147 previous = self._fix_newlines

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

195 self._data.append(' ' * self._indent_level)
196 self._data.append(line)
197
198 if line or not initial_newline:
199 self._data.append('\n')
200
201 initial_newline = False
202
203 def insert_newline(self):
204 self._data.append('\n')
203 def __call__(self, *args, **kwargs):
204 if not args:
205 self._data.append('\n')
206 return
205
207
206 def __call__(self, format, *args, **kwargs):
208 format = args[0]
209 args = args[1:]
210
207 frame = inspect.currentframe().f_back
208
209 l = lookup(self, frame, *args, **kwargs)
210 def convert(match):
211 ident = match.group('lone')
212 # check for a lone identifier
213 if ident:
214 indent = match.group('indent') # must be spaces

--- 97 unchanged lines hidden ---
211 frame = inspect.currentframe().f_back
212
213 l = lookup(self, frame, *args, **kwargs)
214 def convert(match):
215 ident = match.group('lone')
216 # check for a lone identifier
217 if ident:
218 indent = match.group('indent') # must be spaces

--- 97 unchanged lines hidden ---