Open the context
Choose the project folder and name the files or behavior involved.
Choose between JSON and plain text using already parsed Accept ranges. Test an exact type with quality zero beside a positive wildcard and an empty preference list, respecting specific exclusions instead of letting the wildcard override them.
Choose the project folder and name the files or behavior involved.
Describe the input, expected output and boundaries that must stay intact.
Review the proposed edits and any commands before relying on their result.
Compare actual behavior with the expected result. If a check fails, investigate it before applying more changes.
def choose_media(ranges):
offered = ["application/json", "text/plain"]
if not ranges:
return offered[0]
choices = []
for i, media in enumerate(offered):
family = media.split("/")[0] + "/*"
matches = [(2 if p == media else 1 if p == family else 0, q)
for p, q in ranges if p in (media, family, "*/*")]
quality = max(matches, default=(-1, 0))[1]
if quality > 0:
choices.append((quality, -i, media))
return max(choices)[2] if choices else NoneThe example is a starting point for a real project, not a claim that generated code is already tested. Adjust paths, dependencies and expected behavior to match your application.