wolfhong/formic · formic.py
python logo
def match(self, string):
        """Returns True if the argument matches the constant."""
        if self.casesensitive:
            return self.pattern == os.path.normcase(string)
        else:
            return self.pattern.lower() == os.path.normcase(string).lower()
Similar code snippets
1.
jaraco/path.py · __init__.py
Match rating: 69.75% · See similar code snippets
python logo
def fnmatch(self, pattern, normcase=None):
        """ Return ``True`` if `self.name` matches the given `pattern`.

        `pattern` - A filename pattern with wildcards,
            for example ``'*.py'``. If the pattern contains a `normcase`
            attribute, it is applied to the name and path prior to comparison.

        `normcase` - (optional) A function used to normalize the pattern and
            filename before matching. Defaults to :meth:`self.module`, which
            defaults to :meth:`os.path.normcase`.

        .. seealso:: :func:`fnmatch.fnmatch`
        """
        default_normcase = getattr(pattern, 'normcase', self.module.normcase)
        normcase = normcase or default_normcase
        name = normcase(self.name)
        pattern = normcase(pattern)
        return fnmatch.fnmatchcase(name, pattern)
2.
jaraco/path.py · matchers.py
Match rating: 68.86% · See similar code snippets
python logo
def __call__(self, path):
        normcase = getattr(self, 'normcase', path.module.normcase)
        pattern = self.get_pattern(normcase)
        return fnmatch.fnmatchcase(normcase(path.name), pattern)
3.
Xion/callee · strings.py
Match rating: 65.28% · See similar code snippets
python logo
def __init__(self, pattern, case=None):
        """
        :param pattern: Pattern to match against
        :param case:

            Case sensitivity setting. Possible options:

                * ``'system'`` or ``None``: case sensitvity is system-dependent
                  (this is the default)
                * ``True``: matching is case-sensitive
                * ``False``: matching is case-insensitive
        """
        self.pattern = pattern
        try:
            if case is None:
                case = self.DEFAULT_CASE
            self.fnmatch = self.FNMATCH_FUNCTIONS[case]
        except KeyError:
            raise ValueError("invalid case= argument: %r" % (case,))
4.
wolfhong/formic · formic.py
Match rating: 64.83% · See similar code snippets
python logo
def __init__(self, pattern, casesensitive=True):
        casesensitive = determine_casesensitive(casesensitive)
        self.pattern = os.path.normcase(pattern)
        self.pp = pattern
        self.casesensitive = casesensitive
5.
robinandeer/puzzle · case.py
Match rating: 63.85% · See similar code snippets
python logo
def case(self, case_id=None):
        """Return a Case object

            If no case_id is given return one case

            Args:
                case_id (str): A case id

            Returns:
                case(Case): A Case object
        """
        cases = self.cases()
        if case_id:
            for case in cases:
                if case.case_id == case_id:
                    return case
        else:
            if cases:
                return cases[0]

        return None
6.
jtauber/qmorph · domain.py
Match rating: 62.47% · See similar code snippets
python logo
def CASE_IS(case):
    def _(t):
        return CASE(t) == case
    _.__doc__ = "case {0}".format(case)
    return _
7.
robinandeer/puzzle · case_mixin.py
Match rating: 62.29% · See similar code snippets
python logo
def case(self, case_id=None):
        """Return a Case object

            If no case_id is given return one case

            Args:
                case_id (str): A case id

            Returns:
                A Case object
        """
        if case_id:
            for case in self.case_objs:
                if case.case_id == case_id:
                    return case
        else:
            if self.cases:
                return list(self.case_objs)[0]

        return Case(case_id='unknown')
8.
wolfhong/formic · formic.py
Match rating: 62.22% · See similar code snippets
python logo
def create(pattern, casesensitive=True):
        """Factory for :class:`Matcher` instances; returns a :class:`Matcher`
        suitable for matching the supplied pattern"""
        casesensitive = determine_casesensitive(casesensitive)
        if "?" in pattern or "*" in pattern:
            return FNMatcher(pattern, casesensitive)
        else:
            return ConstantMatcher(pattern, casesensitive)
9.
twisted/epsilon · caseless.py
Match rating: 61.72% · See similar code snippets
python logo
def __init__(self, cased):
        if isinstance(cased, Caseless):
            cased = cased.cased
        self.cased = cased
10.
facelessuser/backrefs · _bre_parse.py
Match rating: 60.86% · See similar code snippets
python logo
def convert_case(self, value, case):
        """Convert case."""

        if self.is_bytes:
            cased = []
            for c in value:
                if c in _ASCII_LETTERS:
                    cased.append(c.lower() if case == _LOWER else c.upper())
                else:
                    cased.append(c)
            return "".join(cased)
        else:
            return value.lower() if case == _LOWER else value.upper()