Show More
@@ -1,32 +1,33 | |||||
1 | #----------------------------------------------------------------------------- |
|
1 | #----------------------------------------------------------------------------- | |
2 | # Copyright (C) 2012 The IPython Development Team |
|
2 | # Copyright (C) 2012 The IPython Development Team | |
3 | # |
|
3 | # | |
4 | # Distributed under the terms of the BSD License. The full license is in |
|
4 | # Distributed under the terms of the BSD License. The full license is in | |
5 | # the file COPYING, distributed as part of this software. |
|
5 | # the file COPYING, distributed as part of this software. | |
6 | #----------------------------------------------------------------------------- |
|
6 | #----------------------------------------------------------------------------- | |
7 |
|
7 | |||
8 | """ |
|
8 | """ | |
9 | Copy data from input file to output file for testing. |
|
9 | Copy data from input file to output file for testing. | |
10 |
|
10 | |||
11 | Command line usage: |
|
11 | Command line usage: | |
12 |
|
12 | |||
13 | python writetofile.py INPUT OUTPUT |
|
13 | python writetofile.py INPUT OUTPUT | |
14 |
|
14 | |||
15 | Binary data from INPUT file is copied to OUTPUT file. |
|
15 | Binary data from INPUT file is copied to OUTPUT file. | |
16 | If INPUT is '-', stdin is used. |
|
16 | If INPUT is '-', stdin is used. | |
17 |
|
17 | |||
18 | """ |
|
18 | """ | |
19 |
|
19 | |||
20 | import sys |
|
20 | if __name__ == '__main__': | |
21 | from IPython.utils.py3compat import PY3 |
|
21 | import sys | |
22 | (inpath, outpath) = sys.argv[1:] |
|
22 | from IPython.utils.py3compat import PY3 | |
23 |
|
23 | (inpath, outpath) = sys.argv[1:] | ||
24 | if inpath == '-': |
|
24 | ||
25 | if PY3: |
|
25 | if inpath == '-': | |
26 | infile = sys.stdin.buffer |
|
26 | if PY3: | |
|
27 | infile = sys.stdin.buffer | |||
|
28 | else: | |||
|
29 | infile = sys.stdin | |||
27 | else: |
|
30 | else: | |
28 |
infile = |
|
31 | infile = open(inpath, 'rb') | |
29 | else: |
|
|||
30 | infile = open(inpath, 'rb') |
|
|||
31 |
|
32 | |||
32 | open(outpath, 'w+b').write(infile.read()) |
|
33 | open(outpath, 'w+b').write(infile.read()) |
General Comments 0
You need to be logged in to leave comments.
Login now