How can I edit model import settings from a script?

Specifically: I’d like to write to the animation names and frame ranges on the import settings, and make those changes stick.

I get a lot of model assets in the form of an animated model file and a text file listing the animation names and frame ranges. Each time I import one of these models I have to manually enter the frame ranges in the model’s import settings inspector. Now I’m trying to automate this process.

I already know how I’ll parse the file and how to make a custom EditorWindow. I’ve also already managed to read the import settings from the script.

How can I write to these settings and save the changes? Thanks.