call site 16 for path.local.open
apigen/source/testing/test_browser.py - line 28
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
35
36
37
38
39
40
   def test_browser():
       tmp = py.test.ensuretemp("sourcebrowser")
       tmp.ensure("a.py").write(py.code.Source("""
       def f():
           pass
       
       def g():
           pass
           
       class X:
           pass
           
       class Z(object):
           x = 1
           def zzz(self):
               1
               2
               3
               4
       """))
->     mod = parse_path(tmp.join("a.py"))
       assert isinstance(mod.g, Function)
       assert isinstance(mod.Z, Class)
       py.test.raises(AttributeError, "mod.zzz")
       assert mod.g.firstlineno == 5
       assert mod.g.name == "g"
       assert mod.g.endlineno == 6
       assert mod.X.firstlineno == 8
       assert mod.X.endlineno == 9
       assert mod.Z.bases == ["object"]
       assert isinstance(mod.Z.zzz, Method)
       assert mod.Z.zzz.firstlineno == 13
       assert mod.Z.zzz.endlineno == 17
apigen/source/browser.py - line 123
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
   def parse_path(path):
       if not isinstance(path, PathBase):
           path = py.path.local(path)
->     buf = path.open().read()
       st = parse(buf)
       # first go - we get all functions and classes defined on top-level
       nodes = dir_nodes(st)
       function_ast = [i for i in nodes if isinstance(i, ast.Function)]
       classes_ast = [i for i in nodes if isinstance(i, ast.Class)]
       mod_dict = dict([(i.name, function_from_ast(i, None)) for i in function_ast]
          + [(i.name, class_from_ast(i)) for i in classes_ast])
       # we check all the elements, if they're really there
       try:
           mod = path.pyimport()
       except (KeyboardInterrupt, SystemExit):
           raise
       except:  # catch all other import problems generically
           # XXX some import problem: we probably should not
           # pretend to have an empty module 
           pass
       else:
           update_mod_dict(mod, mod_dict)
       return Module(path, mod_dict)