Added posix glob with pathmatch

This commit is contained in:
Toorero
2021-01-27 13:09:42 +01:00
parent b09afd70a4
commit 27ece2ab97
4 changed files with 7 additions and 2 deletions

View File

@@ -9,6 +9,7 @@ import os
import re
from dataclasses import dataclass
from pathlib import PurePath
from pathmatch import wildmatch
from typing import Callable, List, Optional, TypeVar
from .utils import PathLike, Regex, to_path, to_pattern
@@ -82,7 +83,7 @@ def predicate(pred: Callable[[PurePath], bool]) -> Transform:
return inner
def glob(pattern: str) -> Transform:
return predicate(lambda path: path.match(pattern))
return predicate(lambda path: wildmatch.match(pattern, str(path)))
def move_dir(source_dir: PathLike, target_dir: PathLike) -> Transform:
source_path = to_path(source_dir)