code: def filename_matches_glob(filename: str, globtext: str) -> bool:
          
          # Quick check on basename-only matching
          if fnmatch(filename, globtext):
              log.debug("{!r} matches {!r}", filename, globtext)
              return True
          bname = basename(filename)
          if fnmatch(bname, globtext):
              log.debug("{!r} matches {!r}", bname, globtext)
              return True
          # Directory matching: is actually accomplished by the code above!
          # Otherwise:
          return False
docs: The ``glob.glob`` function doesn't do exclusion very well. We don't
          want to have to specify root directories for exclusion patterns. We
          don't want to have to trawl a massive set of files to find exclusion
          files. So let's implement a glob match.
  
          Args:
              filename: filename
              globtext: glob
  
          Returns:
              does the filename match the glob?
  
          See also:
  
          - https://stackoverflow.com/questions/20638040/glob-exclude-pattern