|
| 1 | +/*[clinic input] |
| 2 | +preserve |
| 3 | +[clinic start generated code]*/ |
| 4 | + |
| 5 | +PyDoc_STRVAR(stringlib_expandtabs__doc__, |
| 6 | +"expandtabs($self, /, tabsize=8)\n" |
| 7 | +"--\n" |
| 8 | +"\n" |
| 9 | +"Return a copy where all tab characters are expanded using spaces.\n" |
| 10 | +"\n" |
| 11 | +"If tabsize is not given, a tab size of 8 characters is assumed."); |
| 12 | + |
| 13 | +#define STRINGLIB_EXPANDTABS_METHODDEF \ |
| 14 | + {"expandtabs", (PyCFunction)stringlib_expandtabs, METH_FASTCALL|METH_KEYWORDS, stringlib_expandtabs__doc__}, |
| 15 | + |
| 16 | +static PyObject * |
| 17 | +stringlib_expandtabs_impl(PyObject *self, int tabsize); |
| 18 | + |
| 19 | +static PyObject * |
| 20 | +stringlib_expandtabs(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 21 | +{ |
| 22 | + PyObject *return_value = NULL; |
| 23 | + static const char * const _keywords[] = {"tabsize", NULL}; |
| 24 | + static _PyArg_Parser _parser = {"|i:expandtabs", _keywords, 0}; |
| 25 | + int tabsize = 8; |
| 26 | + |
| 27 | + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, |
| 28 | + &tabsize)) { |
| 29 | + goto exit; |
| 30 | + } |
| 31 | + return_value = stringlib_expandtabs_impl(self, tabsize); |
| 32 | + |
| 33 | +exit: |
| 34 | + return return_value; |
| 35 | +} |
| 36 | + |
| 37 | +PyDoc_STRVAR(stringlib_ljust__doc__, |
| 38 | +"ljust($self, width, fillchar=b\' \', /)\n" |
| 39 | +"--\n" |
| 40 | +"\n" |
| 41 | +"Return a left-justified string of length width.\n" |
| 42 | +"\n" |
| 43 | +"Padding is done using the specified fill character."); |
| 44 | + |
| 45 | +#define STRINGLIB_LJUST_METHODDEF \ |
| 46 | + {"ljust", (PyCFunction)stringlib_ljust, METH_FASTCALL, stringlib_ljust__doc__}, |
| 47 | + |
| 48 | +static PyObject * |
| 49 | +stringlib_ljust_impl(PyObject *self, Py_ssize_t width, char fillchar); |
| 50 | + |
| 51 | +static PyObject * |
| 52 | +stringlib_ljust(PyObject *self, PyObject *const *args, Py_ssize_t nargs) |
| 53 | +{ |
| 54 | + PyObject *return_value = NULL; |
| 55 | + Py_ssize_t width; |
| 56 | + char fillchar = ' '; |
| 57 | + |
| 58 | + if (!_PyArg_ParseStack(args, nargs, "n|c:ljust", |
| 59 | + &width, &fillchar)) { |
| 60 | + goto exit; |
| 61 | + } |
| 62 | + return_value = stringlib_ljust_impl(self, width, fillchar); |
| 63 | + |
| 64 | +exit: |
| 65 | + return return_value; |
| 66 | +} |
| 67 | + |
| 68 | +PyDoc_STRVAR(stringlib_rjust__doc__, |
| 69 | +"rjust($self, width, fillchar=b\' \', /)\n" |
| 70 | +"--\n" |
| 71 | +"\n" |
| 72 | +"Return a right-justified string of length width.\n" |
| 73 | +"\n" |
| 74 | +"Padding is done using the specified fill character."); |
| 75 | + |
| 76 | +#define STRINGLIB_RJUST_METHODDEF \ |
| 77 | + {"rjust", (PyCFunction)stringlib_rjust, METH_FASTCALL, stringlib_rjust__doc__}, |
| 78 | + |
| 79 | +static PyObject * |
| 80 | +stringlib_rjust_impl(PyObject *self, Py_ssize_t width, char fillchar); |
| 81 | + |
| 82 | +static PyObject * |
| 83 | +stringlib_rjust(PyObject *self, PyObject *const *args, Py_ssize_t nargs) |
| 84 | +{ |
| 85 | + PyObject *return_value = NULL; |
| 86 | + Py_ssize_t width; |
| 87 | + char fillchar = ' '; |
| 88 | + |
| 89 | + if (!_PyArg_ParseStack(args, nargs, "n|c:rjust", |
| 90 | + &width, &fillchar)) { |
| 91 | + goto exit; |
| 92 | + } |
| 93 | + return_value = stringlib_rjust_impl(self, width, fillchar); |
| 94 | + |
| 95 | +exit: |
| 96 | + return return_value; |
| 97 | +} |
| 98 | + |
| 99 | +PyDoc_STRVAR(stringlib_center__doc__, |
| 100 | +"center($self, width, fillchar=b\' \', /)\n" |
| 101 | +"--\n" |
| 102 | +"\n" |
| 103 | +"Return a centered string of length width.\n" |
| 104 | +"\n" |
| 105 | +"Padding is done using the specified fill character."); |
| 106 | + |
| 107 | +#define STRINGLIB_CENTER_METHODDEF \ |
| 108 | + {"center", (PyCFunction)stringlib_center, METH_FASTCALL, stringlib_center__doc__}, |
| 109 | + |
| 110 | +static PyObject * |
| 111 | +stringlib_center_impl(PyObject *self, Py_ssize_t width, char fillchar); |
| 112 | + |
| 113 | +static PyObject * |
| 114 | +stringlib_center(PyObject *self, PyObject *const *args, Py_ssize_t nargs) |
| 115 | +{ |
| 116 | + PyObject *return_value = NULL; |
| 117 | + Py_ssize_t width; |
| 118 | + char fillchar = ' '; |
| 119 | + |
| 120 | + if (!_PyArg_ParseStack(args, nargs, "n|c:center", |
| 121 | + &width, &fillchar)) { |
| 122 | + goto exit; |
| 123 | + } |
| 124 | + return_value = stringlib_center_impl(self, width, fillchar); |
| 125 | + |
| 126 | +exit: |
| 127 | + return return_value; |
| 128 | +} |
| 129 | + |
| 130 | +PyDoc_STRVAR(stringlib_zfill__doc__, |
| 131 | +"zfill($self, width, /)\n" |
| 132 | +"--\n" |
| 133 | +"\n" |
| 134 | +"Pad a numeric string with zeros on the left, to fill a field of the given width.\n" |
| 135 | +"\n" |
| 136 | +"The original string is never truncated."); |
| 137 | + |
| 138 | +#define STRINGLIB_ZFILL_METHODDEF \ |
| 139 | + {"zfill", (PyCFunction)stringlib_zfill, METH_O, stringlib_zfill__doc__}, |
| 140 | + |
| 141 | +static PyObject * |
| 142 | +stringlib_zfill_impl(PyObject *self, Py_ssize_t width); |
| 143 | + |
| 144 | +static PyObject * |
| 145 | +stringlib_zfill(PyObject *self, PyObject *arg) |
| 146 | +{ |
| 147 | + PyObject *return_value = NULL; |
| 148 | + Py_ssize_t width; |
| 149 | + |
| 150 | + if (!PyArg_Parse(arg, "n:zfill", &width)) { |
| 151 | + goto exit; |
| 152 | + } |
| 153 | + return_value = stringlib_zfill_impl(self, width); |
| 154 | + |
| 155 | +exit: |
| 156 | + return return_value; |
| 157 | +} |
| 158 | +/*[clinic end generated code: output=336620159a1fc70d input=a9049054013a1b77]*/ |
0 commit comments