File: removeafter.py

package info (click to toggle)
linkchecker 10.5.0-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,112 kB
  • sloc: python: 13,131; makefile: 134; sh: 71; xml: 36; sql: 20; javascript: 19; php: 2
file content (20 lines) | stat: -rwxr-xr-x 434 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env python
# Copyright (C) 2012-2014 Bastian Kleineidam
"""Remove all lines after a given marker line.
"""
import fileinput
import sys


def main(args):
    """Remove lines after marker."""
    filename = args[0]
    marker = args[1]
    for line in fileinput.input(filename, inplace=1):
        print(line.rstrip())
        if line.startswith(marker):
            break


if __name__ == "__main__":
    main(sys.argv[1:])