Skip to content

Commit

Permalink
Refactor regex filename search
Browse files Browse the repository at this point in the history
  • Loading branch information
wkentaro committed Dec 31, 2023
1 parent 785b218 commit 44efd36
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions labelme/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2069,13 +2069,14 @@ def importDirImages(self, dirpath, pattern=None, load=True):
self.lastOpenDir = dirpath
self.filename = None
self.fileListWidget.clear()
for filename in self.scanAllImages(dirpath):
if pattern and pattern not in filename:
try:
if not re.search(pattern, filename):
continue
except re.error:
pass

filenames = self.scanAllImages(dirpath)
if pattern:
try:
filenames = [f for f in filenames if re.search(pattern, f)]
except re.error:
pass
for filename in filenames:
label_file = osp.splitext(filename)[0] + ".json"
if self.output_dir:
label_file_without_path = osp.basename(label_file)
Expand Down

0 comments on commit 44efd36

Please sign in to comment.