Home
last modified time | relevance | path

Searched refs:format_spec (Results 1 – 25 of 68) sorted by relevance

123

/external/python/cpython2/Lib/test/
Dtest_types.py297 def test(i, format_spec, result): argument
300 assert type(format_spec) == str
301 self.assertEqual(i.__format__(format_spec), result)
302 self.assertEqual(i.__format__(unicode(format_spec)), result)
425 for format_spec in ([chr(x) for x in range(ord('a'), ord('z')+1)] +
427 if not format_spec in 'bcdoxXeEfFgGn%':
428 self.assertRaises(ValueError, 0 .__format__, format_spec)
429 self.assertRaises(ValueError, 1 .__format__, format_spec)
430 self.assertRaises(ValueError, (-1) .__format__, format_spec)
434 for format_spec in 'eEfFgG%':
[all …]
Dtest_str.py214 def __format__(self, format_spec): argument
215 if format_spec == 'd':
217 return object.__format__(self, format_spec)
221 def __format__(self, format_spec): argument
225 def __format__(self, format_spec): argument
226 return self.strftime(format_spec)
229 def __format__(self, format_spec): argument
230 return int.__format__(self * 2, format_spec)
Dtest_string.py139 def format_field(self, value, format_spec): argument
140 return format(value(), format_spec)
165 field_name, _, format_spec = field[1:].partition(':')
166 yield '', field_name, format_spec, None
Dtest_float.py644 for format_spec in ([chr(x) for x in range(ord('a'), ord('z')+1)] +
646 if not format_spec in 'eEfFgGn%':
647 self.assertRaises(ValueError, format, 0.0, format_spec)
648 self.assertRaises(ValueError, format, 1.0, format_spec)
649 self.assertRaises(ValueError, format, -1.0, format_spec)
650 self.assertRaises(ValueError, format, 1e100, format_spec)
651 self.assertRaises(ValueError, format, -1e100, format_spec)
652 self.assertRaises(ValueError, format, 1e-100, format_spec)
653 self.assertRaises(ValueError, format, -1e-100, format_spec)
/external/python/cpython2/Objects/stringlib/
Dstring_format.h560 render_field(PyObject *fieldobj, SubString *format_spec, OutputString *output) in render_field() argument
566 STRINGLIB_CHAR* format_spec_start = format_spec->ptr ? in render_field()
567 format_spec->ptr : NULL; in render_field()
568 Py_ssize_t format_spec_len = format_spec->ptr ? in render_field()
569 format_spec->end - format_spec->ptr : 0; in render_field()
635 parse_field(SubString *str, SubString *field_name, SubString *format_spec, in parse_field() argument
646 SubString_init(format_spec, NULL, 0); in parse_field()
668 format_spec->ptr = str->ptr; in parse_field()
669 format_spec->end = str->end; in parse_field()
674 if (format_spec->ptr >= format_spec->end) { in parse_field()
[all …]
Dformatter.h169 parse_internal_render_format_spec(STRINGLIB_CHAR *format_spec, in parse_internal_render_format_spec() argument
175 STRINGLIB_CHAR *ptr = format_spec; in parse_internal_render_format_spec()
176 STRINGLIB_CHAR *end = format_spec + format_spec_len; in parse_internal_render_format_spec()
1307 STRINGLIB_CHAR *format_spec, in FORMAT_STRING() argument
1321 if (!parse_internal_render_format_spec(format_spec, format_spec_len, in FORMAT_STRING()
1344 STRINGLIB_CHAR *format_spec, in format_int_or_long() argument
1360 if (!parse_internal_render_format_spec(format_spec, in format_int_or_long()
1425 STRINGLIB_CHAR *format_spec, in FORMAT_LONG() argument
1428 return format_int_or_long(obj, format_spec, format_spec_len, in FORMAT_LONG()
1446 STRINGLIB_CHAR *format_spec, in FORMAT_INT() argument
[all …]
/external/python/cpython3/Objects/stringlib/
Dunicode_format.h491 render_field(PyObject *fieldobj, SubString *format_spec, _PyUnicodeWriter *writer) in render_field() argument
513 err = formatter(writer, fieldobj, format_spec->str, in render_field()
514 format_spec->start, format_spec->end); in render_field()
520 if (format_spec->str) in render_field()
521 format_spec_object = PyUnicode_Substring(format_spec->str, in render_field()
522 format_spec->start, in render_field()
523 format_spec->end); in render_field()
545 parse_field(SubString *str, SubString *field_name, SubString *format_spec, in parse_field() argument
556 SubString_init(format_spec, NULL, 0, 0); in parse_field()
610 format_spec->str = str->str; in parse_field()
[all …]
/external/python/cpython3/Lib/
Dstring.py199 for literal_text, field_name, format_spec, conversion in \
237 format_spec, auto_arg_index = self._vformat(
238 format_spec, args, kwargs,
243 result.append(self.format_field(obj, format_spec))
259 def format_field(self, value, format_spec): argument
260 return format(value, format_spec)
/external/python/cpython3/Lib/test/
Dtest_types.py210 def test(i, format_spec, result): argument
213 assert type(format_spec) == str
214 self.assertEqual(i.__format__(format_spec), result)
353 for format_spec in ([chr(x) for x in range(ord('a'), ord('z')+1)] +
355 if not format_spec in 'bcdoxXeEfFgGn%':
356 self.assertRaises(ValueError, 0 .__format__, format_spec)
357 self.assertRaises(ValueError, 1 .__format__, format_spec)
358 self.assertRaises(ValueError, (-1) .__format__, format_spec)
362 for format_spec in 'eEfFgG%':
364 self.assertEqual(value.__format__(format_spec),
[all …]
Dtest_long.py699 for format_spec in ([chr(x) for x in range(ord('a'), ord('z')+1)] +
701 if not format_spec in 'bcdoxXeEfFgGn%':
702 self.assertRaises(ValueError, format, 0, format_spec)
703 self.assertRaises(ValueError, format, 1, format_spec)
704 self.assertRaises(ValueError, format, -1, format_spec)
705 self.assertRaises(ValueError, format, 2**100, format_spec)
706 self.assertRaises(ValueError, format, -(2**100), format_spec)
710 for format_spec in 'eEfFgG%':
712 self.assertEqual(format(value, format_spec),
713 format(float(value), format_spec))
Dtest_string.py127 def format_field(self, value, format_spec): argument
128 return format(value(), format_spec)
153 field_name, _, format_spec = field[1:].partition(':')
154 yield '', field_name, format_spec, None
Dtest_float.py642 for format_spec in ([chr(x) for x in range(ord('a'), ord('z')+1)] +
644 if not format_spec in 'eEfFgGn%':
645 self.assertRaises(ValueError, format, 0.0, format_spec)
646 self.assertRaises(ValueError, format, 1.0, format_spec)
647 self.assertRaises(ValueError, format, -1.0, format_spec)
648 self.assertRaises(ValueError, format, 1e100, format_spec)
649 self.assertRaises(ValueError, format, -1e100, format_spec)
650 self.assertRaises(ValueError, format, 1e-100, format_spec)
651 self.assertRaises(ValueError, format, -1e-100, format_spec)
/external/python/cpython2/Lib/
Dstring.py571 for literal_text, field_name, format_spec, conversion in \
592 format_spec = self._vformat(format_spec, args, kwargs,
596 result.append(self.format_field(obj, format_spec))
612 def format_field(self, value, format_spec): argument
613 return format(value, format_spec)
/external/python/cpython3/Python/
Dformatter_unicode.c163 parse_internal_render_format_spec(PyObject *format_spec, in parse_internal_render_format_spec() argument
170 int kind = PyUnicode_KIND(format_spec); in parse_internal_render_format_spec()
171 void *data = PyUnicode_DATA(format_spec); in parse_internal_render_format_spec()
226 consumed = get_integer(format_spec, &pos, end, &format->width); in parse_internal_render_format_spec()
261 consumed = get_integer(format_spec, &pos, end, &format->precision); in parse_internal_render_format_spec()
1412 PyObject *format_spec, in _PyUnicode_FormatAdvancedWriter() argument
1429 if (!parse_internal_render_format_spec(format_spec, start, end, in _PyUnicode_FormatAdvancedWriter()
1448 PyObject *format_spec, in _PyLong_FormatAdvancedWriter() argument
1465 if (!parse_internal_render_format_spec(format_spec, start, end, in _PyLong_FormatAdvancedWriter()
1511 PyObject *format_spec, in _PyFloat_FormatAdvancedWriter() argument
[all …]
/external/python/cpython3/Python/clinic/
Dbltinmodule.c.h86 builtin_format_impl(PyObject *module, PyObject *value, PyObject *format_spec);
93 PyObject *format_spec = NULL; in builtin_format() local
96 &value, &format_spec)) { in builtin_format()
99 return_value = builtin_format_impl(module, value, format_spec); in builtin_format()
/external/python/cpython2/Objects/
Dcomplexobject.c909 PyObject *format_spec; in complex__format__() local
911 if (!PyArg_ParseTuple(args, "O:__format__", &format_spec)) in complex__format__()
913 if (PyBytes_Check(format_spec)) in complex__format__()
915 PyBytes_AS_STRING(format_spec), in complex__format__()
916 PyBytes_GET_SIZE(format_spec)); in complex__format__()
917 if (PyUnicode_Check(format_spec)) { in complex__format__()
920 PyObject *str_spec = PyObject_Str(format_spec); in complex__format__()
Dintobject.c1255 PyObject *format_spec; in int__format__() local
1257 if (!PyArg_ParseTuple(args, "O:__format__", &format_spec)) in int__format__()
1259 if (PyBytes_Check(format_spec)) in int__format__()
1261 PyBytes_AS_STRING(format_spec), in int__format__()
1262 PyBytes_GET_SIZE(format_spec)); in int__format__()
1263 if (PyUnicode_Check(format_spec)) { in int__format__()
1266 PyObject *str_spec = PyObject_Str(format_spec); in int__format__()
Dabstract.c724 PyObject_Format(PyObject* obj, PyObject *format_spec) argument
734 if (format_spec == NULL) {
736 format_spec = empty;
741 if (PyUnicode_Check(format_spec))
743 else if (PyString_Check(format_spec))
747 if (!PyString_Check(format_spec)) {
751 "or unicode, not %.100s", Py_TYPE(format_spec)->tp_name);
761 format_spec,
776 format_len = PyUnicode_GET_SIZE(format_spec);
781 format_len = PyString_GET_SIZE(format_spec);
[all …]
/external/python/cpython3/Doc/library/
Dstring.rst118 (*literal_text*, *field_name*, *format_spec*, *conversion*). This is used
126 field, then the values of *field_name*, *format_spec* and *conversion*
171 .. method:: format_field(value, format_spec)
203 replacement_field: "{" [`field_name`] ["!" `conversion`] [":" `format_spec`] "}"
210 format_spec: <described in the next section>
216 preceded by an exclamation point ``'!'``, and a *format_spec*, which is preceded
263 The *format_spec* field contains a specification of how the value should be
266 mini-language" or interpretation of the *format_spec*.
271 A *format_spec* field can also include nested replacement fields within it.
275 format_spec are substituted before the *format_spec* string is interpreted.
[all …]
/external/python/cpython2/Include/
Dintobject.h75 char *format_spec,
Dcomplexobject.h60 char *format_spec,
Dfloatobject.h127 char *format_spec,
/external/python/cpython3/Include/
Dcomplexobject.h61 PyObject *format_spec,
Dfloatobject.h122 PyObject *format_spec,
/external/python/cpython3/Objects/
Dcomplexobject.c705 PyObject *format_spec; in complex__format__() local
709 if (!PyArg_ParseTuple(args, "U:__format__", &format_spec)) in complex__format__()
716 format_spec, 0, PyUnicode_GET_LENGTH(format_spec)); in complex__format__()

123