ATLAS Offline Software
Classes | Functions | Variables
python.coverage Namespace Reference

Classes

class  Coverage
 

Functions

def _find_LINENO_from_code_22 (code)
 
def _find_LINENO_from_code_23 (code)
 
def _find_LINENO (code)
 
def find_executable_linenos (filename)
 

Variables

 running_coverage
 
 _find_LINENO_from_code
 

Function Documentation

◆ _find_LINENO()

def python.coverage._find_LINENO (   code)
private
return all of the SET_LINENO information from a code object

Definition at line 117 of file coverage.py.

117 def _find_LINENO(code):
118  """return all of the SET_LINENO information from a code object"""
119  import types
120 
121  # get all of the lineno information from the code of this scope level
122  #linenos = _find_LINENO_from_string(code.co_code)
123  linenos = _find_LINENO_from_code(code)
124 
125  # and check the constants for references to other code objects
126  for c in code.co_consts:
127  if isinstance(c, types.CodeType):
128  # find another code object, so recurse into it
129  linenos.update(_find_LINENO(c))
130  return linenos
131 

◆ _find_LINENO_from_code_22()

def python.coverage._find_LINENO_from_code_22 (   code)
private
return all of the SET_LINENO information from a code block

Definition at line 75 of file coverage.py.

76  """return all of the SET_LINENO information from a code block"""
77  co_code = code.co_code
78  linenos = {}
79 
80  # This code was filched from the `dis' module then modified
81  n = len(co_code)
82  i = 0
83  prev_op = None
84  prev_lineno = 0
85  while i < n:
86  c = co_code[i]
87  op = ord(c)
88  if op == dis.SET_LINENO:
89  if prev_op == op:
90  # two SET_LINENO in a row, so the previous didn't
91  # indicate anything. This occurs with triple
92  # quoted strings (?). Remove the old one.
93  del linenos[prev_lineno]
94  prev_lineno = ord(co_code[i+1]) + ord(co_code[i+2])*256
95  linenos[prev_lineno] = 1
96  if op >= dis.HAVE_ARGUMENT:
97  i = i + 3
98  else:
99  i = i + 1
100  prev_op = op
101  return linenos
102 
103 
104 # This works from python 2.3 on.

◆ _find_LINENO_from_code_23()

def python.coverage._find_LINENO_from_code_23 (   code)
private

Definition at line 105 of file coverage.py.

105 def _find_LINENO_from_code_23 (code):
106  linenos = {}
107  for (o, l) in dis.findlinestarts (code):
108  linenos[l] = 1
109  return linenos
110 
111 # Choose the appropriate version.

◆ find_executable_linenos()

def python.coverage.find_executable_linenos (   filename)
return a dict of the line numbers from executable statements in a file

Works by finding all of the code-like objects in the module then searching
the byte code for 'SET_LINENO' terms (so this won't work one -O files).

Definition at line 132 of file coverage.py.

132 def find_executable_linenos(filename):
133  """return a dict of the line numbers from executable statements in a file
134 
135  Works by finding all of the code-like objects in the module then searching
136  the byte code for 'SET_LINENO' terms (so this won't work one -O files).
137 
138  """
139 
140  prog = open(filename).read()
141  code = compile (prog, filename, 'exec')
142 
143  # The only way I know to find line numbers is to look for the
144  # SET_LINENO instructions. Isn't there some way to get it from
145  # the AST?
146 
147  return _find_LINENO(code)
148 

Variable Documentation

◆ _find_LINENO_from_code

python.coverage._find_LINENO_from_code
private

Definition at line 113 of file coverage.py.

◆ running_coverage

python.coverage.running_coverage

Definition at line 70 of file coverage.py.

read
IovVectorMap_t read(const Folder &theFolder, const SelectionCriterion &choice, const unsigned int limit=10)
Definition: openCoraCool.cxx:569
python.coverage._find_LINENO_from_code
_find_LINENO_from_code
Definition: coverage.py:113
Trk::open
@ open
Definition: BinningType.h:40
python.coverage._find_LINENO
def _find_LINENO(code)
Definition: coverage.py:117
python.coverage.find_executable_linenos
def find_executable_linenos(filename)
Definition: coverage.py:132
python.coverage._find_LINENO_from_code_23
def _find_LINENO_from_code_23(code)
Definition: coverage.py:105
python.coverage._find_LINENO_from_code_22
def _find_LINENO_from_code_22(code)
Definition: coverage.py:75