annotate Tools/scripts/suff.py @ 64166:d0e9febfa00a 3.1

Merged revisions 84172 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r84172 | martin.v.loewis | 2010-08-18 18:12:23 +0200 (Mi, 18 Aug 2010) | 2 lines Restore GIL in nis_cat in case of error. ........
author Martin v. Löwis <martin@v.loewis.de>
date Thu, 19 Aug 2010 09:03:03 +0000
parents 893a4dc17a91
children fcfe324663a6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
12a64115a4ee Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2
12a64115a4ee Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
3 # suff
12a64115a4ee Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
4 #
12a64115a4ee Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 # show different suffixes amongst arguments
12a64115a4ee Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
6
12a64115a4ee Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
7 import sys
12a64115a4ee Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
8
12a64115a4ee Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
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
12a64115a4ee Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
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
12a64115a4ee Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
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()