]> git.lyx.org Git - lyx.git/blob - development/cmake/po/cat.py
Add documentation for notes cite engine type.
[lyx.git] / development / cmake / po / cat.py
1 #! /usr/bin/python3
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         if sys.version_info[0] < 3:
33                 # accept both windows and unix line endings, since it can
34                 # happen that we are on unix, but the file has been written on
35                 # windows or vice versa.
36                 mode = "rU"
37         else:
38                 # The default behavior of Python 3 is to enable universal
39                 # newlines in text mode. Adding "U" gives a deprecation
40                 # warning.
41                 mode = "r"
42         fil = open(f, mode)
43         for l in fil:
44                 # this does always write unix line endings since the file has
45                 # been opened in binary mode. This is needed since both gettext
46                 # and our .pot file manipulation scripts assume unix line ends.
47                 out.write(l)
48         fil.close()
49
50 if outfile:
51         out.close()