1 '''Defines some generic functions for theia.'''
2
3
4
5
6
7
8
9
10
11
12
13 import time as tm
14
16 '''TotalReflectionError class.
17
18 Is raised when an interaction results in total reflection.
19
20 *=== Attributes ===*
21 Message: exception message. [string]
22
23
24 '''
25
27 '''TotalReflectionError exception initializer.
28
29 '''
30 self.Message = message
31
33 '''Printing error function.
34
35 '''
36 return repr(self.Message)
37
59
61 '''Decorator function to log execution time of other functions.'''
62
63 def wrapped(*args, **kw):
64 t1 = tm.time()
65 func(*args, **kw)
66 t2 = tm.time()
67 dt = t2 -t1
68 st = "theia: Debug: " + str(func.__name__) + " exec with '" \
69 + str(*args) + "' in " + str(dt*1000.) + "ms."
70 print st
71
72 return wrapped
73
87