]> git.lyx.org Git - lyx.git/blob - development/cmake/po/cat.py
Update translation of Listings by Jari-Matti Mäkelä
[lyx.git] / development / cmake / po / cat.py
1 #! /usr/bin/env python
2
3 from __future__ import print_function
4
5 import sys
6 from getopt import getopt
7
8 usage = '''
9 python cat.py -o OUTFILE FILE1 FILE2 .... FILEn
10
11 Replacement for:
12         cat FILE1 FILE2 ... .FILEn > OUTFILE
13 If the -o argument is not given, writes to stdout.
14 '''
15
16 outfile = ""
17
18 (options, args) = getopt(sys.argv[1:], "ho:")
19 for (opt, param) in options:
20         if opt == "-o":
21                 outfile = param
22         elif opt == "-h":
23                 print(usage)
24                 sys.exit(0)
25
26 out = sys.stdout
27 if outfile:
28         # always write unix line endings, even on windows
29         out = open(outfile, "wb")
30
31 for f in args:
32         # accept both windows and unix line endings, since it can happen that we
33         # are on unix, but the file has been written on windows or vice versa.
34         fil = open(f, "rU")
35         for l in fil:
36                 # this does always write unix line endings since the file has
37                 # been opened in binary mode. This is needed since both gettext
38                 # and our .pot file manipulation scripts assume unix line ends.
39                 out.write(l)
40         fil.close()
41
42 if outfile:
43         out.close()