コード例 #1
0
ファイル: ZopeViews.py プロジェクト: aricsanders/boa
    def parse(self):
        error = None
        lines = self.lines[:]
        while lines:
            line = lines.pop()
            if line.startswith('  Module '):
                modPath, lineNo, funcName = line[9:].split(', ')
                lineNo = int(lineNo[5:])
                modPath = modPath.strip()
                if modPath == 'Script (Python)':
                    path = lines.pop()
                    lines.pop()
                    if path.startswith('   - <PythonScript at '):
                        path = path[22:].strip()[:-1]
                        debugUrl = self.baseUrl + path + '/Script (Python)'
                        self.stack.append(
                            ErrorStack.StackEntry(debugUrl, lineNo + 1,
                                                  funcName))
                elif modPath.startswith('Python expression'):
                    continue
                else:
                    modPath = self.libPath + '/' + modPath.replace('.',
                                                                   '/') + '.py'
                    self.stack.append(
                        ErrorStack.StackEntry(modPath, lineNo, funcName))
            elif line.startswith('   - <PythonScript at '):
                path = line[22:].strip()[:-1]
                debugUrl = self.baseUrl + path + '/Script (Python)'
                self.stack.append(
                    ErrorStack.StackEntry(debugUrl, 0, os.path.basename(path)))
            elif line.startswith('   - <ZopePageTemplate at '):
                path = line[26:].strip()[:-1]
                debugUrl = self.baseUrl + path + '/Page Template'
                self.stack.append(
                    ErrorStack.StackEntry(debugUrl, 0, os.path.basename(path)))
            elif line.startswith('   - URL: '):
                path = line[10:].strip()
                lineNo, colNo = lines.pop().split(', ')
                lineNo = int(lineNo.split()[-1])
                debugUrl = self.baseUrl + path + '/Page Template'
                self.stack.append(
                    ErrorStack.StackEntry(debugUrl, lineNo,
                                          os.path.basename(path)))
            elif line and line[0] != ' ':
                errType, errValue = line.split(': ', 1)
                lines.reverse()
                errValue = (errValue + ' '.join(lines)).strip()
                if errValue and errValue[0] == '<':
                    errValue = Utils.html2txt(errValue).replace('\n', ' ')

                error = [errType, errValue]
                break

        assert error
        self.error = error
        for entry in self.stack:
            entry.error = error
コード例 #2
0
 def parse(self):
     for ref in self.lines:
         self.error = [
             '%s%% confidence for: %s:%s' %
             (ref.confidence, ref.filename, ref.lineno)
         ]
         self.stack.append(
             ErrorStack.StackEntry(
                 ref.filename, ref.lineno,
                 linecache.getline(ref.filename, ref.lineno), self.error))