(self, format_string, args, kwargs, used_args, recursion_depth,
auto_arg_index=0)
| 196 | return result |
| 197 | |
| 198 | def _vformat(self, format_string, args, kwargs, used_args, recursion_depth, |
| 199 | auto_arg_index=0): |
| 200 | if recursion_depth < 0: |
| 201 | raise ValueError('Max string recursion exceeded') |
| 202 | result = [] |
| 203 | for literal_text, field_name, format_spec, conversion in \ |
| 204 | self.parse(format_string): |
| 205 | |
| 206 | # output the literal text |
| 207 | if literal_text: |
| 208 | result.append(literal_text) |
| 209 | |
| 210 | # if there's a field, output it |
| 211 | if field_name is not None: |
| 212 | # this is some markup, find the object and do |
| 213 | # the formatting |
| 214 | |
| 215 | # handle arg indexing when empty field_names are given. |
| 216 | if field_name == '': |
| 217 | if auto_arg_index is False: |
| 218 | raise ValueError('cannot switch from manual field ' |
| 219 | 'specification to automatic field ' |
| 220 | 'numbering') |
| 221 | field_name = str(auto_arg_index) |
| 222 | auto_arg_index += 1 |
| 223 | elif field_name.isdigit(): |
| 224 | if auto_arg_index: |
| 225 | raise ValueError('cannot switch from manual field ' |
| 226 | 'specification to automatic field ' |
| 227 | 'numbering') |
| 228 | # disable auto arg incrementing, if it gets |
| 229 | # used later on, then an exception will be raised |
| 230 | auto_arg_index = False |
| 231 | |
| 232 | # given the field_name, find the object it references |
| 233 | # and the argument it came from |
| 234 | obj, arg_used = self.get_field(field_name, args, kwargs) |
| 235 | used_args.add(arg_used) |
| 236 | |
| 237 | # do any conversion on the resulting object |
| 238 | obj = self.convert_field(obj, conversion) |
| 239 | |
| 240 | # expand the format spec, if needed |
| 241 | format_spec, auto_arg_index = self._vformat( |
| 242 | format_spec, args, kwargs, |
| 243 | used_args, recursion_depth-1, |
| 244 | auto_arg_index=auto_arg_index) |
| 245 | |
| 246 | # format the object and append to the result |
| 247 | result.append(self.format_field(obj, format_spec)) |
| 248 | |
| 249 | return ''.join(result), auto_arg_index |
| 250 | |
| 251 | |
| 252 | def get_value(self, key, args, kwargs): |
no test coverage detected