Returns result serialized to a single line string.
(result)
| 338 | |
| 339 | |
| 340 | def _OneLineResult(result): |
| 341 | """Returns result serialized to a single line string.""" |
| 342 | # TODO(dbieber): Ensure line is fewer than eg 120 characters. |
| 343 | if isinstance(result, str): |
| 344 | return str(result).replace('\n', ' ') |
| 345 | |
| 346 | # TODO(dbieber): Show a small amount of usage information about the function |
| 347 | # or module if it fits cleanly on the line. |
| 348 | if inspect.isfunction(result): |
| 349 | return f'<function {result.__name__}>' |
| 350 | |
| 351 | if inspect.ismodule(result): |
| 352 | return f'<module {result.__name__}>' |
| 353 | |
| 354 | try: |
| 355 | # Don't force conversion to ascii. |
| 356 | return json.dumps(result, ensure_ascii=False) |
| 357 | except (TypeError, ValueError): |
| 358 | return str(result).replace('\n', ' ') |
| 359 | |
| 360 | |
| 361 | def _Fire(component, args, parsed_flag_args, context, name=None): |
no outgoing calls
no test coverage detected