How to use the wcmatch.wcmatch 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 / Rummage / tests / test_rumcore.py View on Github external
def setUp(self):
        """Setup the tests."""

        _FileTest.setUp(self)
        self.mktemp('a.txt')
        self.mktemp('.rum-bak', 'a.txt')
        self.default_flags = wcmatch.R | wcmatch.I | wcmatch.M
        self.errors = []
        self.skipped = 0
        self.files = []
github facelessuser / wcmatch / tests / test_wcmatch.py View on Github external
def setUp(self):
        """Setup."""

        self.tempdir = TESTFN + "_dir"
        self.mktemp('.hidden', 'a.txt')
        self.mktemp('.hidden', 'b.file')
        self.mktemp('.hidden_file')
        self.mktemp('a.txt')
        self.mktemp('b.file')
        self.mktemp('c.txt.bak')

        self.default_flags = wcmatch.R | wcmatch.I | wcmatch.M | wcmatch.SL
        self.errors = []
        self.skipped = 0
        self.skip_records = []
        self.error_records = []
        self.files = []
github facelessuser / wcmatch / tests / test_wcmatch.py View on Github external
def test_match_insensitive(self):
        """Test case insensitive."""

        walker = wcmatch.WcMatch(
            self.tempdir,
            'A.TXT', None,
            self.default_flags | wcmatch.RECURSIVE | wcmatch.FILEPATHNAME | wcmatch.IGNORECASE
        )
        self.crawl_files(walker)
        self.assertEqual(
            sorted(self.files),
            self.norm_list(
                ['a.txt']
            )
github facelessuser / wcmatch / tests / test_wcmatch.py View on Github external
def setUp(self):
        """Setup."""

        self.tempdir = TESTFN + "_dir"
        self.mktemp('.hidden', 'a.txt')
        self.mktemp('.hidden', 'b.file')
        self.mktemp('.hidden_file')
        self.mktemp('a.txt')
        self.mktemp('b.file')
        self.mktemp('c.txt.bak')
        self.can_symlink = can_symlink()
        if self.can_symlink:
            self.mksymlink('.hidden', self.norm('sym1'))
            self.mksymlink(os.path.join('.hidden', 'a.txt'), self.norm('sym2'))

        self.default_flags = wcmatch.R | wcmatch.I | wcmatch.M
        self.errors = []
        self.skipped = 0
        self.skip_records = []
        self.error_records = []
        self.files = []
github facelessuser / Rummage / rummage / lib / rumcore / __init__.py View on Github external
yield FileRecord(
                FileInfoRecord(
                    self.idx,
                    self.file_obj.name,
                    None,
                    None,
                    None,
                    None,
                    None
                ),
                None,
                get_exception()
            )


class _DirWalker(wcmatch.WcMatch):
    """Walk the directory."""

    def on_init(
        self, file_regex_match=False, folder_regex_exclude_match=False, size=None, modified=None, created=None,
        backup_location='', backup_to_folder=False, regex_mode=RE_MODE, regex_ver=0
    ):
        self.file_regex_match = file_regex_match
        self.folder_regex_exclude_match = folder_regex_exclude_match
        if (regex_mode in REGEX_MODES and not REGEX_SUPPORT) or (RE_MODE > regex_mode or regex_mode > BREGEX_MODE):
            regex_mode = RE_MODE
        self.regex_ver = 1 if regex_ver else 0
        self.regex_mode = regex_mode
        self.size = (size[0], size[1]) if size is not None else size
        self.modified = modified
        self.created = created
        self.case_sensitive = wcmatch._wcparse.get_case(self.flags)
github facelessuser / Rummage / rummage / lib / rumcore / __init__.py View on Github external
# `wcmatch` flags
        self.wcmatch_flags = wcmatch.I | wcmatch.R
        if self.file_flags & EXTMATCH:
            self.wcmatch_flags |= wcmatch.E
        if self.file_flags & BRACE:
            self.wcmatch_flags |= wcmatch.B
        if self.file_flags & FILECASE:
            self.wcmatch_flags |= wcmatch.C
        if self.file_flags & DIRPATHNAME:
            self.wcmatch_flags |= wcmatch.DP
        if self.file_flags & FILEPATHNAME:
            self.wcmatch_flags |= wcmatch.FP
        if self.file_flags & GLOBSTAR:
            self.wcmatch_flags |= wcmatch.G
        if self.file_flags & MATCHBASE:
            self.wcmatch_flags |= wcmatch.X
        if self.file_flags & MINUSNEGATE:
            self.wcmatch_flags |= wcmatch.M
        if self.file_flags & RECURSIVE:
            self.wcmatch_flags |= wcmatch.RV
        if self.file_flags & SHOW_HIDDEN:
            self.wcmatch_flags |= wcmatch.HD
        if self.file_flags & FOLLOW_LINKS:
            self.wcmatch_flags |= wcmatch.SL

        self.context = context
        self.encoding = self._verify_encoding(encoding) if encoding is not None else None
        self.skipped = 0

        self.backup_location = backup_location
        if not self.backup_location or not isinstance(self.backup_location, str):
            self.backup_location = DEFAULT_FOLDER_BAK if bool(self.file_flags & BACKUP_FOLDER) else DEFAULT_BAK
github facelessuser / Rummage / rummage / lib / rumcore / __init__.py View on Github external
if encoding_options is None:
            encoding_options = text_decode.DEFAULT_ENCODING_OPTIONS
        self.encoding_options = encoding_options

        self.search_params = searches
        self.file_flags = flags & FILE_MASK

        # `wcmatch` flags
        self.wcmatch_flags = wcmatch.I | wcmatch.R
        if self.file_flags & EXTMATCH:
            self.wcmatch_flags |= wcmatch.E
        if self.file_flags & BRACE:
            self.wcmatch_flags |= wcmatch.B
        if self.file_flags & FILECASE:
            self.wcmatch_flags |= wcmatch.C
        if self.file_flags & DIRPATHNAME:
            self.wcmatch_flags |= wcmatch.DP
        if self.file_flags & FILEPATHNAME:
            self.wcmatch_flags |= wcmatch.FP
        if self.file_flags & GLOBSTAR:
            self.wcmatch_flags |= wcmatch.G
        if self.file_flags & MATCHBASE:
            self.wcmatch_flags |= wcmatch.X
        if self.file_flags & MINUSNEGATE:
            self.wcmatch_flags |= wcmatch.M
        if self.file_flags & RECURSIVE:
            self.wcmatch_flags |= wcmatch.RV
        if self.file_flags & SHOW_HIDDEN:
            self.wcmatch_flags |= wcmatch.HD
        if self.file_flags & FOLLOW_LINKS:
            self.wcmatch_flags |= wcmatch.SL
github facelessuser / Rummage / rummage / lib / rumcore / __init__.py View on Github external
if self.file_flags & BRACE:
            self.wcmatch_flags |= wcmatch.B
        if self.file_flags & FILECASE:
            self.wcmatch_flags |= wcmatch.C
        if self.file_flags & DIRPATHNAME:
            self.wcmatch_flags |= wcmatch.DP
        if self.file_flags & FILEPATHNAME:
            self.wcmatch_flags |= wcmatch.FP
        if self.file_flags & GLOBSTAR:
            self.wcmatch_flags |= wcmatch.G
        if self.file_flags & MATCHBASE:
            self.wcmatch_flags |= wcmatch.X
        if self.file_flags & MINUSNEGATE:
            self.wcmatch_flags |= wcmatch.M
        if self.file_flags & RECURSIVE:
            self.wcmatch_flags |= wcmatch.RV
        if self.file_flags & SHOW_HIDDEN:
            self.wcmatch_flags |= wcmatch.HD
        if self.file_flags & FOLLOW_LINKS:
            self.wcmatch_flags |= wcmatch.SL

        self.context = context
        self.encoding = self._verify_encoding(encoding) if encoding is not None else None
        self.skipped = 0

        self.backup_location = backup_location
        if not self.backup_location or not isinstance(self.backup_location, str):
            self.backup_location = DEFAULT_FOLDER_BAK if bool(self.file_flags & BACKUP_FOLDER) else DEFAULT_BAK

        self.buffer_input = bool(self.file_flags & BUFFER_INPUT)
        self.current_encoding = None
        self.idx = -1
github facelessuser / Rummage / rummage / lib / rumcore / __init__.py View on Github external
self.abort = False
        self.searcher = None
        self.path_walker = None
        if (regex_mode in REGEX_MODES and not REGEX_SUPPORT) or (RE_MODE > regex_mode > BREGEX_MODE):
            regex_mode = RE_MODE
        self.regex_mode = regex_mode

        if encoding_options is None:
            encoding_options = text_decode.DEFAULT_ENCODING_OPTIONS
        self.encoding_options = encoding_options

        self.search_params = searches
        self.file_flags = flags & FILE_MASK

        # `wcmatch` flags
        self.wcmatch_flags = wcmatch.I | wcmatch.R
        if self.file_flags & EXTMATCH:
            self.wcmatch_flags |= wcmatch.E
        if self.file_flags & BRACE:
            self.wcmatch_flags |= wcmatch.B
        if self.file_flags & FILECASE:
            self.wcmatch_flags |= wcmatch.C
        if self.file_flags & DIRPATHNAME:
            self.wcmatch_flags |= wcmatch.DP
        if self.file_flags & FILEPATHNAME:
            self.wcmatch_flags |= wcmatch.FP
        if self.file_flags & GLOBSTAR:
            self.wcmatch_flags |= wcmatch.G
        if self.file_flags & MATCHBASE:
            self.wcmatch_flags |= wcmatch.X
        if self.file_flags & MINUSNEGATE:
            self.wcmatch_flags |= wcmatch.M