How to use the wcmatch.util.platform function in wcmatch

To help you get started, we’ve selected a few wcmatch examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github facelessuser / wcmatch / wcmatch / glob.py View on Github external
def _flag_transform(flags):
    """Transform flags to glob defaults."""

    # Enabling both cancels out
    if flags & FORCEUNIX and flags & FORCEWIN:
        flags ^= FORCEWIN | FORCEUNIX

    # Here we force `PATHNAME`.
    flags = (flags & FLAG_MASK) | _PATHNAME
    if flags & REALPATH:
        if util.platform() == "windows":
            if flags & FORCEUNIX:
                flags ^= FORCEUNIX
            flags |= FORCEWIN
        else:
            if flags & FORCEWIN:
                flags ^= FORCEWIN

    return flags
github facelessuser / wcmatch / wcmatch / _wcparse.py View on Github external
def _match_pattern(filename, include, exclude, real, path, follow, root_dir=None):
    """Match includes and excludes."""

    if real:

        symlinks = {}
        if isinstance(filename, bytes):
            root = root_dir if root_dir else b'.'
            ptype = BYTES
        else:
            root = root_dir if root_dir else '.'
            ptype = UNICODE

        mount = RE_WIN_MOUNT[ptype] if util.platform() == "windows" else RE_MOUNT[ptype]

        if not mount.match(filename):
            exists = os.path.lexists(os.path.join(root, filename))
        else:
            exists = os.path.lexists(filename)

        if not exists:
            return False
        if path:
            return _match_real(filename, include, exclude, follow, symlinks, root)

    matched = False
    for pattern in include:
        if pattern.fullmatch(filename):
            matched = True
            break
github facelessuser / wcmatch / wcmatch / _wcparse.py View on Github external
def is_unix_style(flags):
    """Check if we should use Unix style."""

    return (
        (
            (util.platform() != "windows") or
            (not bool(flags & REALPATH) and bool(flags & FORCEUNIX))
        ) and
        not flags & FORCEWIN
    )
github facelessuser / wcmatch / wcmatch / file_attrs.py View on Github external
def has_file_attributes(path, hidden=False, symlink=False):
    """Return if file is hidden or symlink based on platform rules."""

    platform = util.platform()
    if platform == "windows":
        return has_win_file_attributes(path, hidden, symlink)
    elif platform == "osx" and _OSX_FOUNDATION_METHOD != _OSX_FOUNDATION_NOT_LOADED:  # pragma: no cover
        return has_macos_file_attributes(path, hidden, symlink)
    else:
        return has_nix_file_attributes(path, hidden, symlink)
github facelessuser / wcmatch / wcmatch / _wcparse.py View on Github external
def _match_real(filename, include, exclude, follow, symlinks, root):
    """Match real filename includes and excludes."""

    sep = '\\' if util.platform() == "windows" else '/'
    if isinstance(filename, bytes):
        sep = os.fsencode(sep)

    is_dir = filename.endswith(sep)
    try:
        is_file_dir = os.path.isdir(os.path.join(root, filename))
    except OSError:  # pragma: no cover
        is_file_dir = False

    if not is_dir and is_file_dir:
        is_dir = True
        filename += sep

    matched = False
    for pattern in include:
        if _fs_match(pattern, filename, is_dir, sep, follow, symlinks, root):