| 43 | |
| 44 | |
| 45 | class SourceFile: |
| 46 | def __init__(self, path): |
| 47 | self.path = path |
| 48 | self.lines = {} |
| 49 | |
| 50 | def mark_line(self, lineno, as_func=None): |
| 51 | line = self.lines.setdefault(lineno, set()) |
| 52 | if as_func is not None: |
| 53 | as_func = as_func.split("'", 1)[0] |
| 54 | line.add(as_func) |
| 55 | |
| 56 | def write_text(self, fd): |
| 57 | with open(self.path, "r") as source: |
| 58 | for i, line in enumerate(source): |
| 59 | if i + 1 in self.lines: |
| 60 | fd.write("> ") |
| 61 | else: |
| 62 | fd.write("! ") |
| 63 | fd.write(line) |
| 64 | |
| 65 | def write_html(self, fd): |
| 66 | with open(self.path, 'r') as source: |
| 67 | code = source.read() |
| 68 | lexer = CLexer() |
| 69 | formatter = FunctionHtmlFormatter( |
| 70 | self.lines, |
| 71 | full=True, |
| 72 | linenos='inline') |
| 73 | fd.write(highlight(code, lexer, formatter)) |
| 74 | |
| 75 | |
| 76 | class SourceFiles: |
no outgoing calls
no test coverage detected
searching dependent graphs…