#NEWLINE# def read( self , directory ) : #NEWLINE# #INDENT# content = sorted ( os . listdir ( directory ) ) #NEWLINE# directories = [ ] #NEWLINE# files = [ ] #NEWLINE# for f in content : #NEWLINE# #INDENT# if os . path . isdir ( os . path . join ( directory , f ) ) : #NEWLINE# #INDENT# directories . append ( f ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# files . append ( f ) #NEWLINE# #UNINDENT# #UNINDENT# result = [ ] #NEWLINE# result . append ( '" ==================================\n' ) #NEWLINE# result . append ( '" Directory Listing\n' ) #NEWLINE# result . append ( ( '"    %s\n' % os . path . abspath ( directory ) ) ) #NEWLINE# result . append ( '" ==================================\n' ) #NEWLINE# for d in directories : #NEWLINE# #INDENT# result . append ( ( '%s/\n' % d ) ) #NEWLINE# #UNINDENT# for f in files : #NEWLINE# #INDENT# result . append ( ( '%s\n' % f ) ) #NEWLINE# #UNINDENT# return ( '' . join ( result ) , 'utf-8' )