@@ -172,8 +172,12 @@ def __str__(self):
172
172
173
173
174
174
class ErrorsMode (metaclass = Singleton ):
175
- """Developper or User mode.
176
- pyccel command line will set it.
175
+ """
176
+ The mode for the error output.
177
+
178
+ The mode for the error output. This is either 'developer' or 'user'.
179
+ In developer mode the errors are more verbose and include a traceback
180
+ this helps developers debug errors.
177
181
"""
178
182
def __init__ (self ):
179
183
self ._mode = 'user'
@@ -183,7 +187,17 @@ def value(self):
183
187
return self ._mode
184
188
185
189
def set_mode (self , mode ):
186
- assert (mode in ['user' , 'developer' ])
190
+ """
191
+ Set the error mode.
192
+
193
+ Set the error mode to either 'developer' or 'user'.
194
+
195
+ Parameters
196
+ ----------
197
+ mode : str
198
+ The new error mode.
199
+ """
200
+ assert mode in ['user' , 'developer' ]
187
201
self ._mode = mode
188
202
189
203
@@ -211,32 +225,39 @@ def mode(self):
211
225
return self ._mode .value
212
226
213
227
def initialize (self ):
228
+ """
229
+ Initialise the Errors singleton.
230
+
231
+ Initialise the Errors singleton. This function is necessary so
232
+ the singleton can be reinitialised using the `reset` function.
233
+ """
214
234
self .error_info_map = OrderedDict ()
215
235
216
- self ._target = {}
217
- self ._target ['file' ] = None
218
- self ._target ['module' ] = None
219
- self ._target ['function' ] = None
220
- self ._target ['class' ] = None
236
+ self ._target = None
221
237
222
238
def reset (self ):
239
+ """
240
+ Reset the Errors singleton.
241
+
242
+ Reset the Errors singleton. This removes any information about
243
+ previously generated errors or warnings. This method should be
244
+ called before starting a new translation.
245
+ """
223
246
self .initialize ()
224
247
225
- def set_target (self , target , kind ):
226
- assert ( kind in [ 'file' , 'module' , 'function' , 'class' ])
227
- self . _target [ kind ] = target
248
+ def set_target (self , target ):
249
+ """
250
+ Set the current translation target.
228
251
229
- def unset_target (self , kind ):
230
- assert (kind in ['file' , 'module' , 'function' , 'class' ])
231
- self ._target [kind ] = None
252
+ Set the current translation target which describes the location
253
+ from which the error is being raised.
232
254
233
- def reset_target (self ):
234
- """."""
235
- self ._target = {}
236
- self ._target ['file' ] = None
237
- self ._target ['module' ] = None
238
- self ._target ['function' ] = None
239
- self ._target ['class' ] = None
255
+ Parameters
256
+ ----------
257
+ target : str
258
+ The name of the file being translated.
259
+ """
260
+ self ._target = target
240
261
241
262
def report (self ,
242
263
message ,
@@ -292,7 +313,7 @@ def report(self,
292
313
return
293
314
294
315
if filename is None :
295
- filename = self .target [ 'file' ]
316
+ filename = self .target
296
317
297
318
# TODO improve. it is assumed here that tl and br have the same line
298
319
if bounding_box :
0 commit comments