Mercurial > hg
annotate tests/seq.py @ 40955:f6187e60f792
help: present boolean arguments as "--[no-]foo"
This should make it much more discoverable (we document it in `hg help
flags`, but most users don't think to look there).
Note that flags that default to None (and not False) will not get this
new presentation. We can change the defaults to False later for flags
where it makes sense (probably almost all boolean flags).
Differential Revision: https://phab.mercurial-scm.org/D5432
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 14 Dec 2018 13:44:46 -0800 |
parents | 0605726179a0 |
children | 2372284d9457 |
rev | line source |
---|---|
24360
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
2 # |
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
3 # A portable replacement for 'seq' |
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
4 # |
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
5 # Usage: |
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
6 # seq STOP [1, STOP] stepping by 1 |
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
7 # seq START STOP [START, STOP] stepping by 1 |
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
8 # seq START STEP STOP [START, STOP] stepping by STEP |
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
9 |
28722
2cd8c3b0bd11
py3: use print_function in seq.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28721
diff
changeset
|
10 from __future__ import absolute_import, print_function |
40773
0605726179a0
tests: apply binary mode to output in seq.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
35150
diff
changeset
|
11 import os |
24360
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
12 import sys |
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
13 |
40773
0605726179a0
tests: apply binary mode to output in seq.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
35150
diff
changeset
|
14 try: |
0605726179a0
tests: apply binary mode to output in seq.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
35150
diff
changeset
|
15 import msvcrt |
0605726179a0
tests: apply binary mode to output in seq.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
35150
diff
changeset
|
16 msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY) |
0605726179a0
tests: apply binary mode to output in seq.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
35150
diff
changeset
|
17 msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) |
0605726179a0
tests: apply binary mode to output in seq.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
35150
diff
changeset
|
18 msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY) |
0605726179a0
tests: apply binary mode to output in seq.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
35150
diff
changeset
|
19 except ImportError: |
0605726179a0
tests: apply binary mode to output in seq.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
35150
diff
changeset
|
20 pass |
0605726179a0
tests: apply binary mode to output in seq.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
35150
diff
changeset
|
21 |
35150
08b8b56bd2e8
py3: alias xrange to range in tests/seq.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28722
diff
changeset
|
22 if sys.version_info[0] >= 3: |
08b8b56bd2e8
py3: alias xrange to range in tests/seq.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28722
diff
changeset
|
23 xrange = range |
08b8b56bd2e8
py3: alias xrange to range in tests/seq.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28722
diff
changeset
|
24 |
24360
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
25 start = 1 |
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
26 if len(sys.argv) > 2: |
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
27 start = int(sys.argv[1]) |
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
28 |
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
29 step = 1 |
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
30 if len(sys.argv) > 3: |
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
31 step = int(sys.argv[2]) |
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
32 |
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
33 stop = int(sys.argv[-1]) + 1 |
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
34 |
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
35 for i in xrange(start, stop, step): |
28722
2cd8c3b0bd11
py3: use print_function in seq.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28721
diff
changeset
|
36 print(i) |