def match_file_listing(paths, pattern: Pattern): for path in paths: filename = os.path.basename(path) if re.match(pattern, filename): yield path