(arg: KeyValueArg)
| 148 | |
| 149 | |
| 150 | def process_file_upload_arg(arg: KeyValueArg) -> Tuple[str, IO, str]: |
| 151 | parts = arg.value.split(SEPARATOR_FILE_UPLOAD_TYPE) |
| 152 | filename = parts[0] |
| 153 | mime_type = parts[1] if len(parts) > 1 else None |
| 154 | try: |
| 155 | f = open(os.path.expanduser(filename), 'rb') |
| 156 | except OSError as e: |
| 157 | raise ParseError(f'{arg.orig!r}: {e}') |
| 158 | return ( |
| 159 | os.path.basename(filename), |
| 160 | f, |
| 161 | mime_type or get_content_type(filename), |
| 162 | ) |
| 163 | |
| 164 | |
| 165 | def convert_json_value_to_form_if_needed(in_json_mode: bool, processor: Callable[[KeyValueArg], JSONType]) -> Callable[[], str]: |
nothing calls this directly
no test coverage detected