_csv.c.h 5.8 KB

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