-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathframe.py
More file actions
34 lines (23 loc) · 1.02 KB
/
frame.py
File metadata and controls
34 lines (23 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import re
class Frame(object):
def __init__(self, func_name, filename, lineno):
self.func_name = func_name
self.filename = filename
self.lineno = lineno
self.cached_str = None
self._skip = False
def match(self, other):
return ((other.func_name is None or other.func_name == self.func_name) and
(other.filename is None or other.filename == self.filename) and
(other.lineno is None or other.lineno == self.lineno))
def __eq__(self, other):
return (self.func_name == other.func_name and
self.filename == other.filename and
self.lineno == other.lineno)
def __str__(self):
if not self.cached_str:
if self.lineno is not None and self.lineno > 0:
self.cached_str = '{0} ({1}:{2})'.format(self.func_name, self.filename, self.lineno)
else:
self.cached_str = '{0} ({1})'.format(self.func_name, self.filename)
return self.cached_str