PageRenderTime 263ms CodeModel.GetById 120ms app.highlight 3ms RepoModel.GetById 138ms app.codeStats 0ms

/Tools/scripts/suff.py

http://unladen-swallow.googlecode.com/
Python | 30 lines | 22 code | 4 blank | 4 comment | 6 complexity | 28c1b0418e17f73cb7f0ad0614fd8f92 MD5 | raw file
 1#! /usr/bin/env python
 2
 3# suff
 4#
 5# show different suffixes amongst arguments
 6
 7import sys
 8
 9def main():
10    files = sys.argv[1:]
11    suffixes = {}
12    for filename in files:
13        suff = getsuffix(filename)
14        if not suffixes.has_key(suff):
15            suffixes[suff] = []
16        suffixes[suff].append(filename)
17    keys = suffixes.keys()
18    keys.sort()
19    for suff in keys:
20        print repr(suff), len(suffixes[suff])
21
22def getsuffix(filename):
23    suff = ''
24    for i in range(len(filename)):
25        if filename[i] == '.':
26            suff = filename[i:]
27    return suff
28
29if __name__ == '__main__':
30    main()