Mercurial > cpython-lru_cache-weakref
annotate Tools/scripts/suff.py @ 67467:abe201dfd3dc 3.1
Merged revisions 87861,87863 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r87861 | antoine.pitrou | 2011-01-08 11:23:29 +0100 (sam., 08 janv. 2011) | 3 lines
Fix test_ssl after r87849
........
r87863 | antoine.pitrou | 2011-01-08 11:28:11 +0100 (sam., 08 janv. 2011) | 3 lines
Add EHOSTUNREACH ('No route to host') to the errnos trapped by transient_internet().
........
| author | Antoine Pitrou <solipsis@pitrou.net> |
|---|---|
| date | Sat, 08 Jan 2011 10:31:09 +0000 |
| parents | 893a4dc17a91 |
| children | fcfe324663a6 |
| rev | line source |
|---|---|
|
4573
73758db2f464
/usr/local/bin/python -> /usr/bin/env python
Guido van Rossum <guido@python.org>
parents:
1269
diff
changeset
|
1 #! /usr/bin/env python |
| 274 | 2 |
| 3 # suff | |
| 4 # | |
| 5 # show different suffixes amongst arguments | |
| 6 | |
| 7 import sys | |
| 8 | |
| 9 def main(): | |
|
15930
14a27acc755a
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
4573
diff
changeset
|
10 files = sys.argv[1:] |
|
14a27acc755a
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
4573
diff
changeset
|
11 suffixes = {} |
|
29107
93c92f20b6bf
Fix use of 'file' as a variable name.
Andrew M. Kuchling <amk@amk.ca>
parents:
15930
diff
changeset
|
12 for filename in files: |
|
93c92f20b6bf
Fix use of 'file' as a variable name.
Andrew M. Kuchling <amk@amk.ca>
parents:
15930
diff
changeset
|
13 suff = getsuffix(filename) |
|
47100
893a4dc17a91
Ran 2to3 over scripts directory.
Georg Brandl <georg@python.org>
parents:
42427
diff
changeset
|
14 if suff not in suffixes: |
|
15930
14a27acc755a
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
4573
diff
changeset
|
15 suffixes[suff] = [] |
|
29107
93c92f20b6bf
Fix use of 'file' as a variable name.
Andrew M. Kuchling <amk@amk.ca>
parents:
15930
diff
changeset
|
16 suffixes[suff].append(filename) |
|
47100
893a4dc17a91
Ran 2to3 over scripts directory.
Georg Brandl <georg@python.org>
parents:
42427
diff
changeset
|
17 keys = sorted(suffixes.keys()) |
|
15930
14a27acc755a
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
4573
diff
changeset
|
18 for suff in keys: |
|
42427
46625e6122e9
Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents:
33074
diff
changeset
|
19 print(repr(suff), len(suffixes[suff])) |
| 274 | 20 |
|
29107
93c92f20b6bf
Fix use of 'file' as a variable name.
Andrew M. Kuchling <amk@amk.ca>
parents:
15930
diff
changeset
|
21 def getsuffix(filename): |
|
15930
14a27acc755a
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
4573
diff
changeset
|
22 suff = '' |
|
29107
93c92f20b6bf
Fix use of 'file' as a variable name.
Andrew M. Kuchling <amk@amk.ca>
parents:
15930
diff
changeset
|
23 for i in range(len(filename)): |
|
93c92f20b6bf
Fix use of 'file' as a variable name.
Andrew M. Kuchling <amk@amk.ca>
parents:
15930
diff
changeset
|
24 if filename[i] == '.': |
|
93c92f20b6bf
Fix use of 'file' as a variable name.
Andrew M. Kuchling <amk@amk.ca>
parents:
15930
diff
changeset
|
25 suff = filename[i:] |
|
15930
14a27acc755a
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
4573
diff
changeset
|
26 return suff |
| 274 | 27 |
|
33074
981fff7363b9
[Patch #1005491 ] use __name__ == '__main__' in scripts
Andrew M. Kuchling <amk@amk.ca>
parents:
31515
diff
changeset
|
28 if __name__ == '__main__': |
|
981fff7363b9
[Patch #1005491 ] use __name__ == '__main__' in scripts
Andrew M. Kuchling <amk@amk.ca>
parents:
31515
diff
changeset
|
29 main() |
