Mercurial > p > roundup > code
comparison roundup/rest.py @ 8272:fde5893b6c25
fix: correct strings with multiple %s that can't be translated
Changed to use %(name)s for each element. make in the locale directory
is no longer grousing.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sun, 12 Jan 2025 19:49:31 -0500 |
| parents | eb45feb1d01e |
| children | e3099f18a395 |
comparison
equal
deleted
inserted
replaced
| 8271:8824c81cc431 | 8272:fde5893b6c25 |
|---|---|
| 2275 # expiration time and limited rights (e.g. only password | 2275 # expiration time and limited rights (e.g. only password |
| 2276 # change permission)) | 2276 # change permission)) |
| 2277 if ext_type and (len(ext_type) < MAX_MIME_EXTENSION_LENGTH): | 2277 if ext_type and (len(ext_type) < MAX_MIME_EXTENSION_LENGTH): |
| 2278 if ext_type not in list(self.__accepted_content_type.values()): | 2278 if ext_type not in list(self.__accepted_content_type.values()): |
| 2279 self.client.response_code = 406 | 2279 self.client.response_code = 406 |
| 2280 return (None, uri, | 2280 return ( |
| 2281 self.error_obj( | 2281 None, uri, |
| 2282 406, | 2282 self.error_obj( |
| 2283 _("Content type '%s' requested in URL is " | 2283 406, |
| 2284 "not available.\nAcceptable types: %s\n") % | 2284 _("Content type '%(requested)s' requested in URL is" |
| 2285 (ext_type, | 2285 "not available.\nAcceptable types: " |
| 2286 ", ".join(sorted( | 2286 "%(acceptable)s\n") % |
| 2287 set(self.__accepted_content_type.values())))))) | 2287 { "requested": ext_type, |
| 2288 | 2288 "acceptable": ", ".join(sorted( |
| 2289 set(self.__accepted_content_type.values())))})) | |
| 2290 | |
| 2289 # strip extension so uri makes sense. | 2291 # strip extension so uri makes sense. |
| 2290 # E.G. .../issue.json -> .../issue | 2292 # E.G. .../issue.json -> .../issue |
| 2291 uri = uri[:-(len(ext_type) + 1)] | 2293 uri = uri[:-(len(ext_type) + 1)] |
| 2292 return (ext_type, uri, None) | 2294 return (ext_type, uri, None) |
| 2293 | 2295 |
| 2406 | 2408 |
| 2407 if valid_binary_content_types: | 2409 if valid_binary_content_types: |
| 2408 return (None, uri, | 2410 return (None, uri, |
| 2409 self.error_obj( | 2411 self.error_obj( |
| 2410 406, | 2412 406, |
| 2411 _("Requested content type(s) '%s' not available.\n" | 2413 _("Requested content type(s) '%(requested)s' not " |
| 2412 "Acceptable mime types are: */*, %s") % | 2414 "available.\nAcceptable mime types are: */*, " |
| 2413 (self.client.request.headers.get('Accept'), | 2415 "%(acceptable)s") % |
| 2414 ", ".join(sorted( | 2416 {"requested": |
| 2415 valid_binary_content_types))))) | 2417 self.client.request.headers.get('Accept'), |
| 2418 "acceptable": ", ".join(sorted( | |
| 2419 valid_binary_content_types))})) | |
| 2416 | 2420 |
| 2417 return (None, uri, | 2421 return (None, uri, |
| 2418 self.error_obj( | 2422 self.error_obj( |
| 2419 406, | 2423 406, |
| 2420 _("Requested content type(s) '%s' not available.\n" | 2424 _("Requested content type(s) '%(requested)s' not " |
| 2421 "Acceptable mime types are: */*, %s") % | 2425 "available.\nAcceptable mime types are: */*, " |
| 2422 (self.client.request.headers.get('Accept'), | 2426 "%(acceptable)s") % |
| 2423 ", ".join(sorted( | 2427 {"requested": |
| 2424 self.__accepted_content_type.keys()))))) | 2428 self.client.request.headers.get('Accept'), |
| 2429 "acceptable": ", ".join(sorted( | |
| 2430 self.__accepted_content_type.keys()))})) | |
| 2425 | 2431 |
| 2426 def dispatch(self, method, uri, input_payload): | 2432 def dispatch(self, method, uri, input_payload): |
| 2427 """format and process the request""" | 2433 """format and process the request""" |
| 2428 output = None | 2434 output = None |
| 2429 | 2435 |
