Пример #1
0
    def __init__(self, show_tokens=False):
        self.show_tokens = show_tokens

        # The text lines of the parsed code.
        self.lines = None

        # The line numbers of excluded lines of code.
        self.excluded = set()

        # The line numbers of docstring lines.
        self.docstrings = set()

        # A dict mapping line numbers to (lo,hi) for multi-line statements.
        self.multiline = {}

        # The line numbers that start statements.
        self.statement_starts = set()
Пример #2
0
    def __init__(self, show_tokens=False):
        self.show_tokens = show_tokens

        # The text lines of the parsed code.
        self.lines = None

        # The line numbers of excluded lines of code.
        self.excluded = set()

        # The line numbers of docstring lines.
        self.docstrings = set()

        # A dict mapping line numbers to (lo,hi) for multi-line statements.
        self.multiline = {}

        # The line numbers that start statements.
        self.statement_starts = set()
Пример #3
0
 def map_to_first_line(self, lines, ignore=None):
     """Map the line numbers in `lines` to the correct first line of the
     statement.
     
     Skip any line mentioned in `ignore`.
     
     Returns a sorted list of the first lines.
     
     """
     ignore = ignore or []
     lset = set()
     for l in lines:
         if l in ignore:
             continue
         rng = self.multiline.get(l)
         if rng:
             new_l = rng[0]
         else:
             new_l = l
         if new_l not in ignore:
             lset.add(new_l)
     lines = list(lset)
     lines.sort()
     return lines
Пример #4
0
 def map_to_first_line(self, lines, ignore=None):
     """Map the line numbers in `lines` to the correct first line of the
     statement.
     
     Skip any line mentioned in `ignore`.
     
     Returns a sorted list of the first lines.
     
     """
     ignore = ignore or []
     lset = set()
     for l in lines:
         if l in ignore:
             continue
         rng = self.multiline.get(l)
         if rng:
             new_l = rng[0]
         else:
             new_l = l
         if new_l not in ignore:
             lset.add(new_l)
     lines = list(lset)
     lines.sort()
     return lines