Skip to content

Commit

Permalink
handle invalid folder
Browse files Browse the repository at this point in the history
  • Loading branch information
lversaw committed Feb 26, 2024
1 parent 0bb05ca commit f69359f
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions usfm/g_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
# Omits subfolders whose names start with '.'
def count_files(folder, pattern):
n = 0
for entry in os.listdir(folder):
if entry[0] != '.':
path = os.path.join(folder, entry)
if os.path.isdir(path):
n += count_files(path, pattern)
elif re.match(pattern, entry.lower()):
n += 1
if os.path.isdir(folder):
for entry in os.listdir(folder):
if entry[0] != '.':
path = os.path.join(folder, entry)
if os.path.isdir(path):
n += count_files(path, pattern)
elif re.match(pattern, entry.lower()):
n += 1
return n

# Returns a count of folders in path matching path name pattern.
Expand Down

0 comments on commit f69359f

Please sign in to comment.