cpython/Tools/scripts/suff.py

27 lines
510 B
Python
Raw Permalink Normal View History

#! /usr/bin/env python3
1991-06-04 17:36:54 -03:00
# suff
#
# show different suffixes amongst arguments
import sys
2010-08-09 09:24:20 -03:00
1991-06-04 17:36:54 -03:00
def main():
2001-01-17 04:48:39 -04:00
files = sys.argv[1:]
suffixes = {}
for filename in files:
suff = getsuffix(filename)
2010-08-09 09:24:20 -03:00
suffixes.setdefault(suff, []).append(filename)
for suff, filenames in sorted(suffixes.items()):
print(repr(suff), len(filenames))
1991-06-04 17:36:54 -03:00
def getsuffix(filename):
2010-08-09 09:24:20 -03:00
name, sep, suff = filename.rpartition('.')
return sep + suff if sep else ''
1991-06-04 17:36:54 -03:00
if __name__ == '__main__':
main()