File: pyfault_check.py

package info (click to toggle)
python-pyahocorasick 1.4.1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 748 kB
  • sloc: ansic: 4,554; python: 2,823; sh: 312; makefile: 242
file content (43 lines) | stat: -rw-r--r-- 1,071 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import sys

def main():
    path = sys.argv[1]

    app = Application(path)
    app.run()


class Application(object):
    def __init__(self, path):
        self.path = path

    def run(self):
        with open(self.path, 'rt') as f:
            lines = [line.rstrip() for line in f if line.rstrip()]
            self.analyze(lines)


    def analyze(self, lines):
        error_sep     = '======================================================================'
        traceback_sep = '----------------------------------------------------------------------'

        index  = 0
        while True:
            try:
                index = lines.index(error_sep, index)
            except ValueError:
                break

            index += 1
            function = lines[index]
            index += 1
            start = lines.index(traceback_sep, index)
            end   = lines.index(traceback_sep, start + 1)
            index = end + 1

            error = lines[end - 1]
            print('%s: %s' % (function, error))


if __name__ == '__main__':
    main()