Skip to content

Commit

Permalink
Use word "suffix" rather than "extension".
Browse files Browse the repository at this point in the history
  • Loading branch information
porridge committed Sep 26, 2023
1 parent 269841a commit bd700dd
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions bambam.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,31 +236,29 @@ def _display_image(self, img):
h = random.randint(0, self.display_height - img.get_height() - 1)
self.screen.blit(img, (w, h))

def glob_dir(self, path, extensions):
def glob_dir(self, path, suffixes):
files = []

for file_name in os.listdir(path):
path_name = os.path.join(path, file_name)
if os.path.isdir(path_name):
files.extend(self.glob_dir(path_name, extensions))
files.extend(self.glob_dir(path_name, suffixes))
else:
for ext in extensions:
for ext in suffixes:
if path_name.lower().endswith(ext):
files.append(path_name)
break

return files

def glob_data(self, extensions):
def glob_data(self, suffixes):
"""
Search for files ending with any of the provided extensions. Eg:
extensions = ['.abc'] will be similar to `ls *.abc` in the configured
Search for files ending with any of the provided suffixes. Eg:
suffixes = ['.abc'] will be similar to `ls *.abc` in the configured
data dirs. Matching will be case-insensitive.
"""
extensions = [x.lower() for x in extensions]
suffixes = [x.lower() for x in suffixes]
file_list = []
for data_dir in self.data_dirs:
file_list.extend(self.glob_dir(data_dir, extensions))
file_list.extend(self.glob_dir(data_dir, suffixes))
return file_list

def _prepare_background(self):
Expand Down

0 comments on commit bd700dd

Please sign in to comment.