view Tools/scripts/suff.py @ 3546:3f7cdf1663f7 legacy-trunk

A version of swed that can import html files. Also demonstrates implementing object handlers in Python.
author Jack Jansen <jack.jansen@cwi.nl>
date Tue, 07 May 1996 15:25:36 +0000
parents 28948181fb2f
children 73758db2f464
line wrap: on
line source

#! /usr/local/bin/python

# suff
#
# show different suffixes amongst arguments

import sys

def main():
	files = sys.argv[1:]
	suffixes = {}
	for file in files:
		suff = getsuffix(file)
		if not suffixes.has_key(suff):
			suffixes[suff] = []
		suffixes[suff].append(file)
	keys = suffixes.keys()
	keys.sort()
	for suff in keys:
		print `suff`, len(suffixes[suff])

def getsuffix(file):
	suff = ''
	for i in range(len(file)):
		if file[i] == '.':
			suff = file[i:]
	return suff

main()