# listDir2.py
# Written by Todd Wareham for CS 2500
"""
Given a file-extension as a command-line argument, print a list (sorted by name) 
 of all readable files with that extension in the current directory with the size 
 in bytes of each file.
"""

import sys
import os
import glob


if len(sys.argv) != 2:
    print "usage:", sys.argv[0], " file-extension"
    sys.exit(1)

for filename in sorted(glob.glob("*." + sys.argv[1])):
    if os.access(filename, os.R_OK) and os.path.isfile(filename):
        print "%-50s [%8d bytes]" % (os.path.abspath(filename), os.path.getsize(filename))
    

