Mercurial > skaapsteker
changeset 343:2258c2a6dbae
Cache get_files() stuff to avoid unnecessary filesystem operations.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Sat, 09 Apr 2011 13:08:08 +0200 |
parents | 8f578fe33fe7 |
children | 0bea8508484d |
files | skaapsteker/data.py |
diffstat | 1 files changed, 5 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/skaapsteker/data.py Sat Apr 09 13:04:25 2011 +0200 +++ b/skaapsteker/data.py Sat Apr 09 13:08:08 2011 +0200 @@ -33,9 +33,13 @@ return open(filepath(filename), mode) +DIR_LISTS = {} + def get_files(folder): """Return a sorted list of files in the given directory, with the directory stripped""" - return sorted(os.listdir(filepath(folder))) + if folder not in DIR_LISTS: + DIR_LISTS[folder] = sorted(os.listdir(filepath(folder))) + return DIR_LISTS[folder] IMAGES = {}