'Attempt to classify from the file\'s magic number/shebang
line, doctype, etc.
Note that this is done before determining the encoding, so we are
working with the *bytes*, not chars.'

def _classify_from_magic(self, lidb):

    (self.has_bom, bom, bom_encoding) = self._get_bom_info()
    if self.has_bom:
        return
    head_bytes = self._accessor.head_bytes
    li = lidb.langinfo_from_magic(head_bytes)
    if li:
        log.debug('lang    from    magic:    %s', li.name)
        self.langinfo = li
        self.lang = li.name
        self.is_text = li.is_text
        return
    (has_doctype_decl, doctype_decl, doctype_name, doctype_public_id, doctype_system_id) = self._get_doctype_decl_info(head_bytes)
    if has_doctype_decl:
        li = lidb.langinfo_from_doctype(public_id=doctype_public_id, system_id=doctype_system_id)
        if li:
            log.debug('lang    from    doctype:    %s', li.name)
            self.langinfo = li
            self.lang = li.name
            self.is_text = li.is_text
            return
