def process_token(self, tok):
        """count lines and track position of classes and functions"""
        if tok[0] == Token.Text:
            count = tok[1].count('\n')
            if count:
                self._line += count  # adjust linecount

        if self._detector.process(tok):
            pass  # works been completed in the detector
        elif tok[0] == Token.Punctuation:
            if tok[0] == Token.Punctuation and tok[1] == '{':
                self._scope += 1
            if tok[0] == Token.Punctuation and tok[1] == '}':
                self._scope += -1
                if self._scope == 0 and self._curr is not None:
                    self._curr['end'] = self._line  # close last scope
                    self._curr = None
        elif tok[0] == Token.Name.Class and self._scope == 0:
            self.add_scope('Class', tok[1], self._line)
        elif tok[0] == Token.Name.Function and self._scope in [0, 1]:
            self.add_scope('Function', tok[1], self._line, self._scope == 1)
def process_token ( self , tok ) : if tok [ 0 ] == Token . Text : count = tok [ 1 ] . count ( '\n' ) if count : self . _line += count if self . _detector . process ( tok ) : pass elif tok [ 0 ] == Token . Punctuation : if tok [ 0 ] == Token . Punctuation and tok [ 1 ] == '{' : self . _scope += 1 if tok [ 0 ] == Token . Punctuation and tok [ 1 ] == '}' : self . _scope += - 1 if self . _scope == 0 and self . _curr is not None : self . _curr [ 'end' ] = self . _line self . _curr = None elif tok [ 0 ] == Token . Name . Class and self . _scope == 0 : self . add_scope ( 'Class' , tok [ 1 ] , self . _line ) elif tok [ 0 ] == Token . Name . Function and self . _scope in [ 0 , 1 ] : self . add_scope ( 'Function' , tok [ 1 ] , self . _line , self . _scope == 1 )
count lines and track position of classes and functions