Guess the content type for the given path.

        :param path:
            The path of file for which to guess the content type.
        :return:
            Returns the content type or ``None`` if the content type
            could not be determined.

        Usage:
            >>> db = ContentTypesDatabase()
            >>> db.add_config_file('content-types.yaml')
            >>> g = db.guess_content_type
            >>> assert g("__init__.py") == "python"
            >>> assert g("Makefile") == "Makefile"
            >>> assert g("Makefile.gmake") == "Makefile"
            >>> assert g("Makefile.py") == "python"
            >>> assert g("foobar.rb") == "ruby"
            >>> assert g("wscript") == "python"
            >>> assert g("foo.coffee") == "coffee-script"
            >>> assert g("Rakefile") == "ruby"
            >>> assert g("foobar.xml") == "xml"
            >>> assert g("foobar.html") == "html"
            >>> assert g("foo7a738fg") == None
            >>> assert g("foo.rst") == "structured-text"
            >>> assert g("foo.md") == "structured-text"
            >>> assert g("foo.markdown") == "structured-text"

def guess_content_type(self, pathname):
        """Guess the content type for the given path.

        :param path:
            The path of file for which to guess the content type.
        :return:
            Returns the content type or ``None`` if the content type
            could not be determined.

        Usage:
            >>> db = ContentTypesDatabase()
            >>> db.add_config_file('content-types.yaml')
            >>> g = db.guess_content_type
            >>> assert g("__init__.py") == "python"
            >>> assert g("Makefile") == "Makefile"
            >>> assert g("Makefile.gmake") == "Makefile"
            >>> assert g("Makefile.py") == "python"
            >>> assert g("foobar.rb") == "ruby"
            >>> assert g("wscript") == "python"
            >>> assert g("foo.coffee") == "coffee-script"
            >>> assert g("Rakefile") == "ruby"
            >>> assert g("foobar.xml") == "xml"
            >>> assert g("foobar.html") == "html"
            >>> assert g("foo7a738fg") == None
            >>> assert g("foo.rst") == "structured-text"
            >>> assert g("foo.md") == "structured-text"
            >>> assert g("foo.markdown") == "structured-text"
        """
        file_basename = os.path.basename(pathname)
        content_type = None

        # Try to determine from the path.
        if not content_type and self._filename_map.has_key(file_basename):
            content_type = self._filename_map[file_basename]
            #logger.debug("Content type of '%s' is '%s' (determined from full "\
            #             "path).", pathname, content_type)

        # Try to determine from the suffix.
        if not content_type and '.' in file_basename:
            extension = "." + file_basename.split(".")[-1]
            extension = extension_case_transform_func(extension)
            try:
                content_type = self._extension_map[extension]
                #logger.debug("Content type of '%s' is '%s' (determined from "\
                #             "suffix '%s').", pathname, content_type, extension)
            except KeyError:
                pass

        # Try to determine from the registered set of regular expression patterns.
        if not content_type:
            for regexp, _content_type in self._regexp_map.iteritems():
                if regexp.search(file_basename):
                    content_type = _content_type
                    #logger.debug(
                    #    "Content type of '%s' is '%s' (matches regexp '%s')",
                    #    pathname, content_type, regexp.pattern)
                    break

        # Try to determine from the file contents.
        if os.path.exists(pathname):
            with open(pathname, 'rb') as f:
                content = f.read()
                if content.startswith("<?xml"):  # cheap XML sniffing
                    content_type = "XML"

        # TODO: Try to determine from mime-type.

        return content_type