import fnmatch
def matches_one_glob_condition(item: str, conditions: list[str]) -> bool:
"""
Check if the given item matches at least one of the specified glob patterns.
Args:
item (str): The item to check.
conditions (list[str]): A list of glob patterns to match against the item.
Returns:
bool: True if the item matches at least one condition, False otherwise.
"""
for condition in conditions:
if fnmatch.fnmatch(item, condition):
return True
return False
print(matches_one_glob_condition('beir/scifacts/test', ['beir/*/test']))
Monday, 25 March 2024
Python: Check if a string matches at least one glob condition
Subscribe to:
Post Comments (Atom)
Languages
C, Rust, Typescript, Python aux: sql tools and libs are more important than aux
-
from pathlib import Path import os def get_cache_path(app_name: str) -> Path: """Return the path for the app's c...
-
""" This module processes Wikipedia dump files by extracting individual articles and parsing them into a structured format, ...
No comments:
Post a Comment