Flesh out MIME type utilities in RBTools.

Review Request #13567 — Created Feb. 21, 2024 and submitted

Information

RBTools
release-5.x

Reviewers

RBTools had some MIME type stuff already to deal with the content types
for the API, living in rbtools.api.utils. This change takes the
generic parts of that and moves them into a new module,
rbtools.utils.mimetypes. This also adds two new methods inspired by
similar code in Review Board for guessing the MIME type of a file and
for checking to see if a MIME type matches a given accept-type pattern.

I would like to replace the file-based MIME type detection with
Google's newly open sourced magika project. At the moment, magika does
not support Python 3.12, so we have to go with this as-is.

Testing Done:
- Ran unit tests.
- Used the MIME type parsing, guessing, and matching in other changes.


 
Summary ID
Flesh out MIME type utilities in RBTools.
RBTools had some MIME type stuff already to deal with the content types for the API, living in `rbtools.api.utils`. This change takes the generic parts of that and moves them into a new module, `rbtools.utils.mimetypes`. This also adds two new methods inspired by similar code in Review Board for guessing the MIME type of a file and for checking to see if a MIME type matches a given accept-type pattern. I would like to replace the `file`-based MIME type detection with Google's newly open sourced `magika` project. At the moment, magika does not support Python 3.12, so we have to go with this as-is. Testing Done: - Ran unit tests. - Used the MIME type parsing, guessing, and matching in other changes.
22ebafd11551a8f7f8b23647c4fe5b598e869839
Description From Last Updated

Should these go at the top of the file in a block after the imports?

maubinmaubin
maubin
  1. 
      
  2. rbtools/utils/mimetypes.py (Diff revision 1)
     
     
     
    Show all issues

    Should these go at the top of the file in a block after the imports?

    1. These are only used for guess_mimetype. I'd rather keep their definitions close to that.

    2. Got it.

  3. 
      
maubin
  1. Ship It!
  2. 
      
chipx86
  1. Ship It!
  2. 
      
david
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-5.x (8ca93a7)
Loading...