Match the specified *filename*. If *isdir* is False, directory-only
    patterns will be ignored.

    Returns one of

    - #MATCH_DEFAULT
    - #MATCH_IGNORE
    - #MATCH_INCLUDE

def match(self, filename, isdir):
    """
    Match the specified *filename*. If *isdir* is False, directory-only
    patterns will be ignored.

    Returns one of

    - #MATCH_DEFAULT
    - #MATCH_IGNORE
    - #MATCH_INCLUDE
    """

    fnmatch = _fnmatch.fnmatch
    ignored = False
    filename = self.convert_path(filename)
    basename = os.path.basename(filename)

    for pattern in self.patterns:
      if pattern.dir_only and not isdir:
        continue
      if (not ignored or pattern.invert) and pattern.match(filename):
        if pattern.invert: # This file is definitely NOT ignored, no matter what other patterns match
          return MATCH_INCLUDE
        ignored = True
    if ignored:
      return MATCH_IGNORE
    else:
      return MATCH_DEFAULT