def build_lines_data(self, code_obj):
        """
        Generate various line-related helper data.
        """

        # Offset: lineno pairs, only for offsets which start line.
        # Locally we use list for more convenient iteration using indices
        if self.version > 1.4:
            linestarts = list(self.opc.findlinestarts(code_obj))
        else:
            linestarts = [[0, 1]]
        self.linestarts = dict(linestarts)

        # 'List-map' which shows line number of current op and offset of
        # first op on following line, given offset of op as index
        lines = []
        LineTuple = namedtuple('LineTuple', ['l_no', 'next'])

        # Iterate through available linestarts, and fill
        # the data for all code offsets encountered until
        # last linestart offset
        _, prev_line_no = linestarts[0]
        offset = 0
        for start_offset, line_no in linestarts[1:]:
            while offset < start_offset:
                lines.append(LineTuple(prev_line_no, start_offset))
                offset += 1
            prev_line_no = line_no

        # Fill remaining offsets with reference to last line number
        # and code length as start offset of following non-existing line
        codelen = len(self.code)
        while offset < codelen:
            lines.append(LineTuple(prev_line_no, codelen))
            offset += 1
        return lines
def build_lines_data ( self , code_obj ) : if self . version > 1.4 : linestarts = list ( self . opc . findlinestarts ( code_obj ) ) else : linestarts = [ [ 0 , 1 ] ] self . linestarts = dict ( linestarts ) lines = [ ] LineTuple = namedtuple ( 'LineTuple' , [ 'l_no' , 'next' ] ) _ , prev_line_no = linestarts [ 0 ] offset = 0 for start_offset , line_no in linestarts [ 1 : ] : while offset < start_offset : lines . append ( LineTuple ( prev_line_no , start_offset ) ) offset += 1 prev_line_no = line_no codelen = len ( self . code ) while offset < codelen : lines . append ( LineTuple ( prev_line_no , codelen ) ) offset += 1 return lines
Generate various line-related helper data.