Debian Codegraph @

Modules/clinic/_csv.c.h

raw
1 /*[clinic input]
2 preserve
3 [clinic start generated code]*/
4
5 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
6 # include "pycore_gc.h" // PyGC_Head
7 # include "pycore_runtime.h" // _Py_ID()
8 #endif
9 #include "pycore_modsupport.h" // _PyArg_UnpackKeywords()
10
11 PyDoc_STRVAR(_csv_list_dialects__doc__,
12 "list_dialects($module, /)\n"
13 "--\n"
14 "\n"
15 "Return a list of all known dialect names.");
16
17 #define _CSV_LIST_DIALECTS_METHODDEF \
18 {"list_dialects", (PyCFunction)_csv_list_dialects, METH_NOARGS, _csv_list_dialects__doc__},
19
20 static PyObject *
21 _csv_list_dialects_impl(PyObject *module);
22
23 static PyObject *
24 _csv_list_dialects(PyObject *module, PyObject *Py_UNUSED(ignored))
25 {
26 return _csv_list_dialects_impl(module);
27 }
28
29 PyDoc_STRVAR(_csv_unregister_dialect__doc__,
30 "unregister_dialect($module, /, name)\n"
31 "--\n"
32 "\n"
33 "Delete the name/dialect mapping associated with a string name.");
34
35 #define _CSV_UNREGISTER_DIALECT_METHODDEF \
36 {"unregister_dialect", _PyCFunction_CAST(_csv_unregister_dialect), METH_FASTCALL|METH_KEYWORDS, _csv_unregister_dialect__doc__},
37
38 static PyObject *
39 _csv_unregister_dialect_impl(PyObject *module, PyObject *name);
40
41 static PyObject *
42 _csv_unregister_dialect(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
43 {
44 PyObject *return_value = NULL;
45 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
46
47 #define NUM_KEYWORDS 1
48 static struct {
49 PyGC_Head _this_is_not_used;
50 PyObject_VAR_HEAD
51 Py_hash_t ob_hash;
52 PyObject *ob_item[NUM_KEYWORDS];
53 } _kwtuple = {
54 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
55 .ob_hash = -1,
56 .ob_item = { &_Py_ID(name), },
57 };
58 #undef NUM_KEYWORDS
59 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
60
61 #else // !Py_BUILD_CORE
62 # define KWTUPLE NULL
63 #endif // !Py_BUILD_CORE
64
65 static const char * const _keywords[] = {"name", NULL};
66 static _PyArg_Parser _parser = {
67 .keywords = _keywords,
68 .fname = "unregister_dialect",
69 .kwtuple = KWTUPLE,
70 };
71 #undef KWTUPLE
72 PyObject *argsbuf[1];
73 PyObject *name;
74
75 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
76 /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
77 if (!args) {
78 goto exit;
79 }
80 name = args[0];
81 return_value = _csv_unregister_dialect_impl(module, name);
82
83 exit:
84 return return_value;
85 }
86
87 PyDoc_STRVAR(_csv_get_dialect__doc__,
88 "get_dialect($module, /, name)\n"
89 "--\n"
90 "\n"
91 "Return the dialect instance associated with name.");
92
93 #define _CSV_GET_DIALECT_METHODDEF \
94 {"get_dialect", _PyCFunction_CAST(_csv_get_dialect), METH_FASTCALL|METH_KEYWORDS, _csv_get_dialect__doc__},
95
96 static PyObject *
97 _csv_get_dialect_impl(PyObject *module, PyObject *name);
98
99 static PyObject *
100 _csv_get_dialect(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
101 {
102 PyObject *return_value = NULL;
103 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
104
105 #define NUM_KEYWORDS 1
106 static struct {
107 PyGC_Head _this_is_not_used;
108 PyObject_VAR_HEAD
109 Py_hash_t ob_hash;
110 PyObject *ob_item[NUM_KEYWORDS];
111 } _kwtuple = {
112 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
113 .ob_hash = -1,
114 .ob_item = { &_Py_ID(name), },
115 };
116 #undef NUM_KEYWORDS
117 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
118
119 #else // !Py_BUILD_CORE
120 # define KWTUPLE NULL
121 #endif // !Py_BUILD_CORE
122
123 static const char * const _keywords[] = {"name", NULL};
124 static _PyArg_Parser _parser = {
125 .keywords = _keywords,
126 .fname = "get_dialect",
127 .kwtuple = KWTUPLE,
128 };
129 #undef KWTUPLE
130 PyObject *argsbuf[1];
131 PyObject *name;
132
133 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
134 /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
135 if (!args) {
136 goto exit;
137 }
138 name = args[0];
139 return_value = _csv_get_dialect_impl(module, name);
140
141 exit:
142 return return_value;
143 }
144
145 PyDoc_STRVAR(_csv_field_size_limit__doc__,
146 "field_size_limit($module, /, new_limit=<unrepresentable>)\n"
147 "--\n"
148 "\n"
149 "Sets an upper limit on parsed fields.\n"
150 "\n"
151 "Returns old limit. If limit is not given, no new limit is set and\n"
152 "the old limit is returned");
153
154 #define _CSV_FIELD_SIZE_LIMIT_METHODDEF \
155 {"field_size_limit", _PyCFunction_CAST(_csv_field_size_limit), METH_FASTCALL|METH_KEYWORDS, _csv_field_size_limit__doc__},
156
157 static PyObject *
158 _csv_field_size_limit_impl(PyObject *module, PyObject *new_limit);
159
160 static PyObject *
161 _csv_field_size_limit(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
162 {
163 PyObject *return_value = NULL;
164 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
165
166 #define NUM_KEYWORDS 1
167 static struct {
168 PyGC_Head _this_is_not_used;
169 PyObject_VAR_HEAD
170 Py_hash_t ob_hash;
171 PyObject *ob_item[NUM_KEYWORDS];
172 } _kwtuple = {
173 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
174 .ob_hash = -1,
175 .ob_item = { &_Py_ID(new_limit), },
176 };
177 #undef NUM_KEYWORDS
178 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
179
180 #else // !Py_BUILD_CORE
181 # define KWTUPLE NULL
182 #endif // !Py_BUILD_CORE
183
184 static const char * const _keywords[] = {"new_limit", NULL};
185 static _PyArg_Parser _parser = {
186 .keywords = _keywords,
187 .fname = "field_size_limit",
188 .kwtuple = KWTUPLE,
189 };
190 #undef KWTUPLE
191 PyObject *argsbuf[1];
192 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
193 PyObject *new_limit = NULL;
194
195 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
196 /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
197 if (!args) {
198 goto exit;
199 }
200 if (!noptargs) {
201 goto skip_optional_pos;
202 }
203 new_limit = args[0];
204 skip_optional_pos:
205 return_value = _csv_field_size_limit_impl(module, new_limit);
206
207 exit:
208 return return_value;
209 }
210 /*[clinic end generated code: output=ed77cb69fad9f3b4 input=a9049054013a1b77]*/