Home
last modified time | relevance | path

Searched refs:format_spec (Results 1 - 25 of 41) sorted by relevance

12

/third_party/python/Objects/stringlib/
H A Dunicode_format.h392 format_spec. It handles getindex and getattr lookups and consumes
496 render_field calls fieldobj.__format__(format_spec) method, and
500 render_field(PyObject *fieldobj, SubString *format_spec, _PyUnicodeWriter *writer) in render_field() argument
522 err = formatter(writer, fieldobj, format_spec->str, in render_field()
523 format_spec->start, format_spec->end); in render_field()
528 __format__ takes a string/unicode object for format_spec. */ in render_field()
529 if (format_spec->str) in render_field()
530 format_spec_object = PyUnicode_Substring(format_spec->str, in render_field()
531 format_spec in render_field()
554 parse_field(SubString *str, SubString *field_name, SubString *format_spec, int *format_spec_needs_expanding, Py_UCS4 *conversion) parse_field() argument
675 MarkupIterator_next(MarkupIterator *self, SubString *literal, int *field_present, SubString *field_name, SubString *format_spec, Py_UCS4 *conversion, int *format_spec_needs_expanding) MarkupIterator_next() argument
806 output_markup(SubString *field_name, SubString *format_spec, int format_spec_needs_expanding, Py_UCS4 conversion, _PyUnicodeWriter *writer, PyObject *args, PyObject *kwargs, int recursion_depth, AutoNumber *auto_number) output_markup() argument
877 SubString format_spec; do_markup() local
1004 SubString format_spec; formatteriter_next() local
[all...]
/third_party/python/Lib/
H A Dstring.py203 for literal_text, field_name, format_spec, conversion in \
241 format_spec, auto_arg_index = self._vformat(
242 format_spec, args, kwargs,
247 result.append(self.format_field(obj, format_spec))
263 def format_field(self, value, format_spec):
264 return format(value, format_spec)
281 # (literal_text, field_name, format_spec, conversion)
286 # with format_spec and conversion and then used
/third_party/python/Objects/clinic/
H A Dcomplexobject.c.h41 "__format__($self, format_spec, /)\n"
44 "Convert to a string according to format_spec.");
50 complex___format___impl(PyComplexObject *self, PyObject *format_spec);
56 PyObject *format_spec; in complex___format__() local
65 format_spec = arg; in complex___format__()
66 return_value = complex___format___impl(self, format_spec); in complex___format__()
H A Dtypeobject.c.h198 "__format__($self, format_spec, /)\n"
207 object___format___impl(PyObject *self, PyObject *format_spec);
213 PyObject *format_spec; in object___format__() local
222 format_spec = arg; in object___format__()
223 return_value = object___format___impl(self, format_spec); in object___format__()
H A Dfloatobject.c.h294 "__format__($self, format_spec, /)\n"
297 "Formats the float according to format_spec.");
303 float___format___impl(PyObject *self, PyObject *format_spec);
309 PyObject *format_spec; in float___format__() local
318 format_spec = arg; in float___format__()
319 return_value = float___format___impl(self, format_spec); in float___format__()
H A Dlongobject.c.h60 "__format__($self, format_spec, /)\n"
68 int___format___impl(PyObject *self, PyObject *format_spec);
74 PyObject *format_spec; in int___format__() local
83 format_spec = arg; in int___format__()
84 return_value = int___format___impl(self, format_spec); in int___format__()
H A Dunicodeobject.c.h1239 "__format__($self, format_spec, /)\n"
1242 "Return a formatted version of the string as described by format_spec.");
1248 unicode___format___impl(PyObject *self, PyObject *format_spec);
1254 PyObject *format_spec; in unicode___format__() local
1263 format_spec = arg; in unicode___format__()
1264 return_value = unicode___format___impl(self, format_spec); in unicode___format__()
/third_party/markupsafe/
H A D__init__.py253 def __html_format__(self, format_spec: str) -> "te.Self":
254 if format_spec:
267 def format_field(self, value: t.Any, format_spec: str) -> str:
269 rv = value.__html_format__(format_spec)
271 if format_spec:
273 f"Format specifier {format_spec} given, but {type(value)} does not"
281 rv = string.Formatter.format_field(self, value, str(format_spec))
/third_party/python/Python/
H A Dformatter_unicode.c143 ptr points to the start of the format_spec, end points just past its end.
150 PyObject *format_spec, in parse_internal_render_format_spec()
157 int kind = PyUnicode_KIND(format_spec); in parse_internal_render_format_spec()
158 const void *data = PyUnicode_DATA(format_spec); in parse_internal_render_format_spec()
221 consumed = get_integer(format_spec, &pos, end, &format->width); in parse_internal_render_format_spec()
258 consumed = get_integer(format_spec, &pos, end, &format->precision); in parse_internal_render_format_spec()
278 operating on. It's format_spec[start:end] (in Python syntax). */ in parse_internal_render_format_spec()
1453 PyObject *format_spec, in _PyUnicode_FormatAdvancedWriter()
1469 /* parse the format_spec */ in _PyUnicode_FormatAdvancedWriter()
1470 if (!parse_internal_render_format_spec(obj, format_spec, star in _PyUnicode_FormatAdvancedWriter()
149 parse_internal_render_format_spec(PyObject *obj, PyObject *format_spec, Py_ssize_t start, Py_ssize_t end, InternalFormatSpec *format, char default_type, char default_align) parse_internal_render_format_spec() argument
1451 _PyUnicode_FormatAdvancedWriter(_PyUnicodeWriter *writer, PyObject *obj, PyObject *format_spec, Py_ssize_t start, Py_ssize_t end) _PyUnicode_FormatAdvancedWriter() argument
1487 _PyLong_FormatAdvancedWriter(_PyUnicodeWriter *writer, PyObject *obj, PyObject *format_spec, Py_ssize_t start, Py_ssize_t end) _PyLong_FormatAdvancedWriter() argument
1549 _PyFloat_FormatAdvancedWriter(_PyUnicodeWriter *writer, PyObject *obj, PyObject *format_spec, Py_ssize_t start, Py_ssize_t end) _PyFloat_FormatAdvancedWriter() argument
1588 _PyComplex_FormatAdvancedWriter(_PyUnicodeWriter *writer, PyObject *obj, PyObject *format_spec, Py_ssize_t start, Py_ssize_t end) _PyComplex_FormatAdvancedWriter() argument
[all...]
H A Dast_opt.c368 expr_ty format_spec = NULL; in parse_format() local
378 format_spec = _PyAST_Constant(str, NULL, -1, -1, -1, -1, arena); in parse_format()
379 if (format_spec == NULL) { in parse_format()
383 return _PyAST_FormattedValue(arg, spec, format_spec, in parse_format()
779 CALL_OPT(astfold_expr, expr_ty, node_->v.FormattedValue.format_spec); in astfold_expr()
H A Dast_unparse.c709 if (e->v.FormattedValue.format_spec) { in append_formattedvalue()
712 e->v.FormattedValue.format_spec, in append_formattedvalue()
/third_party/python/Lib/test/
H A Dtest_types.py227 def test(i, format_spec, result):
230 assert type(format_spec) == str
231 self.assertEqual(i.__format__(format_spec), result)
370 for format_spec in ([chr(x) for x in range(ord('a'), ord('z')+1)] +
372 if not format_spec in 'bcdoxXeEfFgGn%':
373 self.assertRaises(ValueError, 0 .__format__, format_spec)
374 self.assertRaises(ValueError, 1 .__format__, format_spec)
375 self.assertRaises(ValueError, (-1) .__format__, format_spec)
379 for format_spec in 'eEfFgG%':
381 self.assertEqual(value.__format__(format_spec),
[all...]
H A Dtest_string.py126 def format_field(self, value, format_spec):
127 return format(value(), format_spec)
147 # (literal_text, field_name, format_spec, conversion)
152 field_name, _, format_spec = field[1:].partition(':')
153 yield '', field_name, format_spec, None
H A Dtest_long.py707 for format_spec in ([chr(x) for x in range(ord('a'), ord('z')+1)] +
709 if not format_spec in 'bcdoxXeEfFgGn%':
710 self.assertRaises(ValueError, format, 0, format_spec)
711 self.assertRaises(ValueError, format, 1, format_spec)
712 self.assertRaises(ValueError, format, -1, format_spec)
713 self.assertRaises(ValueError, format, 2**100, format_spec)
714 self.assertRaises(ValueError, format, -(2**100), format_spec)
718 for format_spec in 'eEfFgG%':
720 self.assertEqual(format(value, format_spec),
721 format(float(value), format_spec))
[all...]
H A Dtest_float.py710 for format_spec in 'sbcdoxX':
711 self.assertRaises(ValueError, format, 0.0, format_spec)
712 self.assertRaises(ValueError, format, 1.0, format_spec)
713 self.assertRaises(ValueError, format, -1.0, format_spec)
714 self.assertRaises(ValueError, format, 1e100, format_spec)
715 self.assertRaises(ValueError, format, -1e100, format_spec)
716 self.assertRaises(ValueError, format, 1e-100, format_spec)
717 self.assertRaises(ValueError, format, -1e-100, format_spec)
H A Dtest_unicode.py1098 # class with __format__ that forwards to string, for some format_spec's
1104 def __format__(self, format_spec):
1105 if format_spec == 'd':
1107 return object.__format__(self, format_spec)
1110 def __format__(self, format_spec):
1111 return self.strftime(format_spec)
1114 def __format__(self, format_spec):
1115 return int.__format__(self * 2, format_spec)
/third_party/python/Include/internal/
H A Dpycore_floatobject.h47 /* Format the object based on the format_spec, as defined in PEP 3101
52 PyObject *format_spec,
H A Dpycore_long.h89 /* Format the object based on the format_spec, as defined in PEP 3101
94 PyObject *format_spec,
H A Dpycore_ast_state.h190 PyObject *format_spec; member
H A Dpycore_ast.h439 expr_ty format_spec; member
770 format_spec, int lineno, int col_offset, int
/third_party/python/Include/cpython/
H A Dcomplexobject.h36 /* Format the object based on the format_spec, as defined in PEP 3101
41 PyObject *format_spec,
/third_party/python/Parser/
H A Dstring_parser.c511 f-string (for a nested format_spec). */ in fstring_find_literal()
544 includes the expression, conversion character, format_spec expression, and
567 expr_ty format_spec = NULL; /* Optional format specifier. */ in fstring_find_expr() local
741 conversion or format_spec. */ in fstring_find_expr()
804 format_spec = fstring_parse(p, str, end, raw, recurse_lvl+1, in fstring_find_expr()
806 if (!format_spec) { in fstring_find_expr()
822 if (*expr_text && format_spec == NULL && conversion == -1) { in fstring_find_expr()
830 format_spec, first_token->lineno, in fstring_find_expr()
/third_party/python/Python/clinic/
H A Dbltinmodule.c.h154 "format($module, value, format_spec=\'\', /)\n"
157 "Return value.__format__(format_spec)\n"
159 "format_spec defaults to the empty string.\n"
167 builtin_format_impl(PyObject *module, PyObject *value, PyObject *format_spec);
174 PyObject *format_spec = NULL; in builtin_format() local
190 format_spec = args[1]; in builtin_format()
192 return_value = builtin_format_impl(module, value, format_spec); in builtin_format()
/third_party/python/Objects/
H A Dabstract.c770 PyObject_Format(PyObject *obj, PyObject *format_spec) in PyObject_Format() argument
776 if (format_spec != NULL && !PyUnicode_Check(format_spec)) { in PyObject_Format()
779 Py_TYPE(format_spec)->tp_name); in PyObject_Format()
784 if (format_spec == NULL || PyUnicode_GET_LENGTH(format_spec) == 0) { in PyObject_Format()
794 /* If no format_spec is provided, use an empty string */ in PyObject_Format()
795 if (format_spec == NULL) { in PyObject_Format()
797 format_spec = empty; in PyObject_Format()
813 result = PyObject_CallOneArg(meth, format_spec); in PyObject_Format()
[all...]
H A Dcomplexobject.c673 format_spec: unicode
676 Convert to a string according to format_spec.
680 complex___format___impl(PyComplexObject *self, PyObject *format_spec) in complex___format___impl() argument
689 format_spec, 0, PyUnicode_GET_LENGTH(format_spec)); in complex___format___impl()

Completed in 32 milliseconds

12