parameters: (path, pattern)
return_statement: return re_cache[pattern].match(path) is not None
docstring: Return whether the given path matches the given pattern.
      An asterisk can be used to match any string, including the null string, in
      one part of the path:
          'foo' matches '*', 'f*' or 'fo*o'
      However, an asterisk matching a subdirectory may not match the null string:
          'foo/bar' does *not* match 'foo/*/bar'
      If the pattern matches one of the ancestor directories of the path, the
      patch is considered matching:
          'foo/bar' matches 'foo'
      Two adjacent asterisks can be used to match files and zero or more
      directories and subdirectories.
          'foo/bar' matches 'foo/**/bar', or '**/bar'
docstring_summary: Return whether the given path matches the given pattern.
      An asterisk can be used to match any string, including the null string, in
      one part of the path:
          'foo' matches '*', 'f*' or 'fo*o'
      However, an asterisk matching a subdirectory may not match the null string:
          'foo/bar' does *not* match 'foo/*/bar'
      If the pattern matches one of the ancestor directories of the path, the
      patch is considered matching:
          'foo/bar' matches 'foo'
      Two adjacent asterisks can be used to match files and zero or more
      directories and subdirectories.
          'foo/bar' matches 'foo/**/bar', or '**/bar'
docstring_tokens: Return whether the given path matches the given pattern . An asterisk can be used to match any string including the null string in one part of the path : foo matches * f * or fo * o However an asterisk matching a subdirectory may not match the null string : foo / bar does * not * match foo / * / bar If the pattern matches one of the ancestor directories of the path the patch is considered matching : foo / bar matches foo Two adjacent asterisks can be used to match files and zero or more directories and subdirectories . foo / bar matches foo / ** / bar or ** / bar
function: def match(path, pattern):
      '''
      Return whether the given path matches the given pattern.
      An asterisk can be used to match any string, including the null string, in
      one part of the path:
          'foo' matches '*', 'f*' or 'fo*o'
      However, an asterisk matching a subdirectory may not match the null string:
          'foo/bar' does *not* match 'foo/*/bar'
      If the pattern matches one of the ancestor directories of the path, the
      patch is considered matching:
          'foo/bar' matches 'foo'
      Two adjacent asterisks can be used to match files and zero or more
      directories and subdirectories.
          'foo/bar' matches 'foo/**/bar', or '**/bar'
      '''
      if not pattern:
          return True
      if not pattern in re_cache:
          pattern = re.escape(pattern)
          pattern = re.sub(r'(^|\\\/)\\\*\\\*\\\/', r'\1(?:.+/)?', pattern)
          pattern = re.sub(r'(^|\\\/)\\\*\\\*$', r'(?:\1.+)?', pattern)
          pattern = pattern.replace(r'\*', '[^/]*') + '(?:/.*)?$'
          re_cache[pattern] = re.compile(pattern)
      return re_cache[pattern].match(path) is not None
function_tokens: def match ( path , pattern ) : if not pattern : return True if not pattern in re_cache : pattern = re . escape ( pattern ) pattern = re . sub ( r'(^|\\\/)\\\*\\\*\\\/' , r'\1(?:.+/)?' , pattern ) pattern = re . sub ( r'(^|\\\/)\\\*\\\*$' , r'(?:\1.+)?' , pattern ) pattern = pattern . replace ( r'\*' , '[^/]*' ) + '(?:/.*)?$' re_cache [ pattern ] = re . compile ( pattern ) return re_cache [ pattern ] . match ( path ) is not None