Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
name = case[1]
goal = case[2]
flags = cls.flags
path = None
platform = "auto"
if len(case) > 3:
flags ^= case[3]
if len(case) > 4:
if case[4] == "windows":
path = pathlib.PureWindowsPath(name)
platform = case[4]
elif case[4] == "unix":
path = pathlib.PurePosixPath(name)
platform = case[4]
elif case[4] == "pure":
path = pathlib.PurePath(name)
if path is None:
path = pathlib.Path(name)
print('PATH: ', str(path))
print("PATTERN: ", pattern)
print("FILE: ", name)
print("GOAL: ", goal)
print("FLAGS: ", bin(flags))
print("Platform: ", platform)
cls.run(path, pattern, flags, goal)
def test_real_directory(self):
"""Test real directory."""
p = pathlib.PurePath('wcmatch')
self.assertTrue(p.globmatch('*/', flags=pathlib.REALPATH))
self.assertTrue(p.globmatch('*', flags=pathlib.REALPATH))
def test_limit_match(self):
"""Test expansion limit of `match`."""
with self.assertRaises(_wcparse.PatternLimitException):
pathlib.PurePath('name').match('{1..11}', flags=pathlib.BRACE, limit=10)
def test_flavour_equal(self):
"""Test that the same flavours equal each other, regardless of path type."""
p1 = pathlib.PurePath('wcmatch')
p2 = pathlib.Path('wcmatch')
p3 = pypathlib.PurePath('wcmatch')
p4 = pypathlib.Path('wcmatch')
self.assertTrue(p1 == p2)
self.assertTrue(p3 == p4)
self.assertTrue(p1 == p3)
self.assertTrue(p2 == p4)
self.assertTrue(p1 == p4)
self.assertTrue(p2 == p3)
def test_real_file(self):
"""Test real file."""
p = pathlib.PurePath('setup.py')
self.assertFalse(p.globmatch('*/', flags=pathlib.REALPATH))
self.assertTrue(p.globmatch('*', flags=pathlib.REALPATH))
return glob.globmatch(
self._translate_path(),
patterns,
flags=self._translate_flags(flags),
limit=limit
)
class PurePosixPath(PurePath):
"""Pure Posix path."""
_flavour = pathlib._posix_flavour
__slots__ = ()
class PureWindowsPath(PurePath):
"""Pure Windows path."""
_flavour = pathlib._windows_flavour
__slots__ = ()
class PosixPath(Path, PurePosixPath):
"""Posix path."""
__slots__ = ()
class WindowsPath(Path, PureWindowsPath):
"""Windows path."""
__slots__ = ()
"""
Match patterns using `globmatch`, but without the right to left logic that the default `pathlib` uses.
`GLOBSTAR` is enabled by default in order match the default behavior of `pathlib`.
"""
return glob.globmatch(
self._translate_path(),
patterns,
flags=self._translate_flags(flags),
limit=limit
)
class PurePosixPath(PurePath):
"""Pure Posix path."""
_flavour = pathlib._posix_flavour
__slots__ = ()
class PureWindowsPath(PurePath):
"""Pure Windows path."""
_flavour = pathlib._windows_flavour
__slots__ = ()
class PosixPath(Path, PurePosixPath):
"""Posix path."""
def __new__(cls, *args):
"""New."""
if cls is PurePath:
cls = PureWindowsPath if os.name == 'nt' else PurePosixPath
return cls._from_parts(args)