File: build_tee.py

package info (click to toggle)
pycxx 7.1.8-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,392 kB
  • sloc: cpp: 6,767; python: 1,138; sh: 85; ansic: 60; makefile: 18
file content (33 lines) | stat: -rw-r--r-- 662 bytes parent folder | download | duplicates (5)
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
#!/usr/bin/env python3
import sys
import re

def main( argv ):
    all_copies = []
    i_args = iter( argv )
    next( i_args )

    mode = 'w'

    for filename in i_args:
        if filename == '-a':
            mode = 'a'
        else:
            all_copies.append( open( filename, 'w' ) )

    colour = re.compile( r'\033\[[\d;]*m' )

    for line in sys.stdin:
        # allow colours to be shown seen
        sys.stdout.write( line )

        # remove colouring from log files.
        line = colour.sub( '', line )

        for copy in all_copies:
            copy.write( line )

    return 0

if __name__ == '__main__':
    sys.exit( main( sys.argv ) )