cpython/Tools/scripts/suff.py

27 lines
510 B
Python
Raw Normal View History

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