Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

None returned for plain text files #44

Open
m-flak opened this issue Oct 8, 2019 · 0 comments
Open

None returned for plain text files #44

m-flak opened this issue Oct 8, 2019 · 0 comments

Comments

@m-flak
Copy link

m-flak commented Oct 8, 2019

I've read #30, but I find that having do something like this (pardon the comments, direct copy-paste):

    def is_mimetype_family(self, want_family):
        our_type = filetype.guess(self.path)

        if our_type is None:
            # sometimes, filetype fails horribly
            # # like with text files. works great for images though
            type, encoding = mimetypes.guess_type(self.path)
            if type is None:
                return False
            if re.match(want_family, type) is not None:
                return True
            return False
        if re.match(want_family, our_type.mime) is not None:
            return True
        return False

It's a little counter-intuitive. Perhaps, you could utilize mimetypes as I have done.

I expected filetype to be a "one-stop shop" for mimetypes. Nevertheless, it is an excellent library for detecting mimetypes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant