annotate Tools/scripts/suff.py @ 49955:878d40468c4e legacy-trunk

Issue #4384: Added logging integration with warnings module using captureWarnings(). This change includes a NullHandler which does nothing; it will be of use to library developers who want to avoid the "No handlers could be found for logger XXX" message which can appear if the library user doesn't configure logging.
author Vinay Sajip <vinay_sajip@yahoo.co.uk>
date Wed, 03 Dec 2008 23:22:58 +0000
parents 981fff7363b9
children 46625e6122e9
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)
15930
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4573
diff changeset
14 if not suffixes.has_key(suff):
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)
15930
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4573
diff changeset
17 keys = suffixes.keys()
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4573
diff changeset
18 keys.sort()
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4573
diff changeset
19 for suff in keys:
31515
71a294bd7950 Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents: 29107
diff changeset
20 print repr(suff), len(suffixes[suff])
274
12a64115a4ee Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
21
29107
93c92f20b6bf Fix use of 'file' as a variable name.
Andrew M. Kuchling <amk@amk.ca>
parents: 15930
diff changeset
22 def getsuffix(filename):
15930
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4573
diff changeset
23 suff = ''
29107
93c92f20b6bf Fix use of 'file' as a variable name.
Andrew M. Kuchling <amk@amk.ca>
parents: 15930
diff changeset
24 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
25 if filename[i] == '.':
93c92f20b6bf Fix use of 'file' as a variable name.
Andrew M. Kuchling <amk@amk.ca>
parents: 15930
diff changeset
26 suff = filename[i:]
15930
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4573
diff changeset
27 return suff
274
12a64115a4ee Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
28
33074
981fff7363b9 [Patch #1005491 ] use __name__ == '__main__' in scripts
Andrew M. Kuchling <amk@amk.ca>
parents: 31515
diff changeset
29 if __name__ == '__main__':
981fff7363b9 [Patch #1005491 ] use __name__ == '__main__' in scripts
Andrew M. Kuchling <amk@amk.ca>
parents: 31515
diff changeset
30 main()