How to use the wcmatch.fnmatch 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 / tests / test_fnmatch.py View on Github external
def test_posix_range(self):
        """Test posix range."""

        p = fnmatch.translate(r'[[:ascii:]-z]', flags=self.flags | fnmatch.U | fnmatch.C)
        if util.PY36:
            self.assertEqual(p, (['^(?s:[\x00-\x7f\\-z])$'], []))
        else:
            self.assertEqual(p, (['(?s)^(?:[\x00-\x7f\\-z])$'], []))

        p = fnmatch.translate(r'[a-[:ascii:]-z]', flags=self.flags | fnmatch.U | fnmatch.C)
        if util.PY36:
            self.assertEqual(p, (['^(?s:[a\\-\x00-\x7f\\-z])$'], []))
        else:
            self.assertEqual(p, (['(?s)^(?:[a\\-\x00-\x7f\\-z])$'], []))
github facelessuser / wcmatch / tests / test_fnmatch.py View on Github external
def test_limit_filter(self):
        """Test expansion limit of `filter`."""

        with self.assertRaises(_wcparse.PatternLimitException):
            fnmatch.filter(['name'], '{1..11}', flags=fnmatch.BRACE, limit=10)
github facelessuser / wcmatch / tests / test_fnmatch.py View on Github external
if util.PY36:
            self.assertEqual(p1, [r'^(?s:test\$test)$'])
            self.assertEqual(p2, [])
        else:
            self.assertEqual(p1, [r'(?s)^(?:test\$test)$'])
            self.assertEqual(p2, [])

        p1, p2 = fnmatch.translate(r'test\44', flags=flags | fnmatch.R)
        if util.PY36:
            self.assertEqual(p1, [r'^(?s:test\$)$'])
            self.assertEqual(p2, [])
        else:
            self.assertEqual(p1, [r'(?s)^(?:test\$)$'])
            self.assertEqual(p2, [])

        p1, p2 = fnmatch.translate(r'test\400', flags=flags | fnmatch.R)
        if util.PY37:
            self.assertEqual(p1, [r'^(?s:testĀ)$'])
            self.assertEqual(p2, [])
        elif util.PY36:
            self.assertEqual(p1, [r'^(?s:test\Ā)$'])
            self.assertEqual(p2, [])
        else:
            self.assertEqual(p1, [r'(?s)^(?:test\Ā)$'])
            self.assertEqual(p2, [])

        with pytest.raises(SyntaxError):
            fnmatch.translate(r'test\N', flags=flags | fnmatch.R)

        with pytest.raises(SyntaxError):
            fnmatch.translate(r'test\Nx', flags=flags | fnmatch.R)
github facelessuser / wcmatch / tests / test_fnmatch.py View on Github external
[
            r'usr\\*',
            ['usr/bin', 'usr', 'usr\\lib'],
            (['usr/bin', 'usr\\lib'] if not util.is_case_sensitive() else ['usr\\lib']),
            0
        ],
        [r'te\st[ma]', ['testm', 'test\\3', 'testa'], ['testm', 'testa'], fnmatch.I],
        [r'te\st[ma]', ['testm', 'test\\3', 'testa'], ['testm', 'testa'], fnmatch.C],

        # Issue #24
        ['*.bar', ["goo.cfg", "foo.bar", "foo.bar.cfg", "foo.cfg.bar"], ["foo.bar", "foo.cfg.bar"], 0],
        [
            '*|!*.bar',
            ["goo.cfg", "foo.bar", "foo.bar.cfg", "foo.cfg.bar"],
            ["goo.cfg", "foo.bar.cfg"],
            fnmatch.N | fnmatch.S
        ]
    ]

    @classmethod
    def setup_class(cls):
        """Setup the tests."""

        cls.flags = fnmatch.DOTMATCH

    @staticmethod
    def assert_equal(a, b):
        """Assert equal."""

        assert a == b, "Comparison between objects yielded False."

    @classmethod
github facelessuser / wcmatch / tests / test_fnmatch.py View on Github external
elif util.PY36:
            self.assertEqual(p1, [r'^(?s:test\[\!\])$'])
            self.assertEqual(p2, [])
        else:
            self.assertEqual(p1, [r'(?s)^(?:test\[\!\])$'])
            self.assertEqual(p2, [])

        p1, p2 = self.split_translate('|test|', flags)
        if util.PY36:
            self.assertEqual(p1, [r'^(?s:)$', r'^(?s:test)$'])
            self.assertEqual(p2, [])
        else:
            self.assertEqual(p1, [r'(?s)^(?:)$', r'(?s)^(?:test)$'])
            self.assertEqual(p2, [])

        p1, p2 = self.split_translate('-|-test|-', flags=flags | fnmatch.N | fnmatch.M)
        if util.PY36:
            self.assertEqual(p1, [])
            self.assertEqual(p2, [r'^(?s:)$', r'^(?s:test)$'])
        else:
            self.assertEqual(p1, [])
            self.assertEqual(p2, [r'(?s)^(?:)$', r'(?s)^(?:test)$'])

        p1, p2 = self.split_translate('test[^chars]', flags)
        if util.PY36:
            self.assertEqual(p1, [r'^(?s:test[^chars])$'])
            self.assertEqual(p2, [])
        else:
            self.assertEqual(p1, [r'(?s)^(?:test[^chars])$'])
            self.assertEqual(p2, [])

        p1 = self.split_translate(r'test[^\\-\\&]', flags=flags)[0]
github facelessuser / wcmatch / tests / test_fnmatch.py View on Github external
(['Test.py', 'Test.PL'] if not util.is_case_sensitive() else ['Test.PL']),
            0
        ],
        [
            'usr/*',
            ['usr/bin', 'usr', 'usr\\lib'],
            (['usr/bin', 'usr\\lib'] if not util.is_case_sensitive() else ['usr/bin']),
            0
        ],
        [
            r'usr\\*',
            ['usr/bin', 'usr', 'usr\\lib'],
            (['usr/bin', 'usr\\lib'] if not util.is_case_sensitive() else ['usr\\lib']),
            0
        ],
        [r'te\st[ma]', ['testm', 'test\\3', 'testa'], ['testm', 'testa'], fnmatch.I],
        [r'te\st[ma]', ['testm', 'test\\3', 'testa'], ['testm', 'testa'], fnmatch.C],

        # Issue #24
        ['*.bar', ["goo.cfg", "foo.bar", "foo.bar.cfg", "foo.cfg.bar"], ["foo.bar", "foo.cfg.bar"], 0],
        [
            '*|!*.bar',
            ["goo.cfg", "foo.bar", "foo.bar.cfg", "foo.cfg.bar"],
            ["goo.cfg", "foo.bar.cfg"],
            fnmatch.N | fnmatch.S
        ]
    ]

    @classmethod
    def setup_class(cls):
        """Setup the tests."""