aboutsummaryrefslogtreecommitdiff
path: root/lib/books.py
diff options
context:
space:
mode:
authorJordan <me@jordan.im>2020-12-05 18:32:00 -0700
committerJordan <me@jordan.im>2020-12-05 18:32:00 -0700
commit5e886308e60ac20ec7427d645370b7330ae88268 (patch)
tree287d338288c100a7014f6ec211705ef3afdaad86 /lib/books.py
parentf7055594aac17b2d5fd4e936a5924ece3e68cd63 (diff)
downloadroka-5e886308e60ac20ec7427d645370b7330ae88268.tar.gz
roka-5e886308e60ac20ec7427d645370b7330ae88268.zip
use os.scandir() over os.walk(), better performance
Diffstat (limited to 'lib/books.py')
-rw-r--r--lib/books.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/books.py b/lib/books.py
index 86ab4b6..83d096d 100644
--- a/lib/books.py
+++ b/lib/books.py
@@ -31,10 +31,9 @@ class Books:
'''
Return list of directories recursively discovered in :path:
'''
- ret = list()
- for root, dirs, _ in os.walk(path):
- for d in dirs:
- ret.append(os.path.join(root, d))
+ s = os.scandir(path)
+ ret = [x.path for x in s if not x.name.startswith('.') and x.is_dir()]
+ s.close()
return ret