#
#  Test the opendir module
#

from opendir import opendir

print "READ"
d = opendir(".")
while 1:
	name = d.read()
	if not name:
		break
	print "   ", name
print "EOF"

print "ITERATE"
d = opendir(".")
for name in d:
	print "   ", name
print "STOP"

print "TELL/SEEK"
d = opendir(".")
for i in range(3):
	name = d.read()
	print "   ", name
pos = d.tell()
for i in range(3):
	name = d.read()
	print "   ", name
d.seek(pos)
while 1:
	name = d.read()
	if not name:
		break
	print "   ", name
print "EOF"

print "REWIND"
d = opendir(".")
for i in range(3):
	name = d.read()
	print "   ", name
d.rewind()
while 1:
	name = d.read()
	if not name:
		break
	print "   ", name
print "EOF"

print "EXCEPTION"
try:
	d = opendir("spanish_inquisition")
except Exception, e:
	print e
print "DONE"
