def grablines(myfilename,recursive=0):
mylines=[]
if recursive and os.path.isdir(myfilename):
- myfiles = [myfilename+os.path.sep+x for x in os.listdir(myfilename)]
- myfiles = [f for f in myfiles if not f.startswith(".")]
- myfiles.sort()
- for f in myfiles:
- mylines.extend(grablines(f, recursive))
+ for f in os.listdir(myfilename):
+ if not f.startswith("."):
+ mylines.extend(grablines(
+ os.path.join(myfilename, f), recursive))
else:
try:
myfile = open(myfilename, "r")