[Python-checkins] python/nondist/sandbox/csv _csv.c,1.20,1.21
montanaro@users.sourceforge.net
montanaro@users.sourceforge.net
Sat, 08 Feb 2003 07:22:32 -0800
Update of /cvsroot/python/python/nondist/sandbox/csv
In directory sc8-pr-cvs1:/tmp/cvs-serv6531
Modified Files:
_csv.c
Log Message:
Split module docstring up into pieces and give each exposed object its own
docstring.
Index: _csv.c
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/csv/_csv.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** _csv.c 7 Feb 2003 06:33:00 -0000 1.20
--- _csv.c 8 Feb 2003 15:22:28 -0000 1.21
***************
*** 1124,1128 ****
"This module provides classes that assist in the reading and writing\n"
"of Comma Separated Value (CSV) files, and implements the interface\n"
! "described by PEP 305. Although many CSV files are simple to parse,\n"
"the format is not formally defined by a stable specification and\n"
"is subtle enough that parsing lines of a CSV file with something\n"
--- 1124,1128 ----
"This module provides classes that assist in the reading and writing\n"
"of Comma Separated Value (CSV) files, and implements the interface\n"
! "described by PEP 305. Although many CSV files are simple to parse,\n"
"the format is not formally defined by a stable specification and\n"
"is subtle enough that parsing lines of a CSV file with something\n"
***************
*** 1131,1178 ****
"\n"
"\n"
- "READING:\n"
- "\n"
- "The reader interface is provided by a factory function \"reader\":\n"
- "\n"
- " csv_reader = reader(iterable [, dialect='excel']\n"
- " [optional keyword args])\n"
- " for row in csv_reader:\n"
- " process(row)\n"
- "\n"
- "The \"iterable\" argument can be any object that returns a line\n"
- "of input for each iteration, such as a file object or a list. The\n"
- "optional \"dialect\" parameter is discussed below. The function\n"
- "also accepts optional keyword arguments which override settings\n"
- "provided by the dialect.\n"
- "\n"
- "The returned object is an iterator. Each iteration returns a row\n"
- "of the CSV file (which can span multiple input lines):\n"
- "\n"
- "\n"
- "WRITING:\n"
- "\n"
- "The writer interface is provided by a factory function \"writer\":\n"
- "\n"
- " csv_writer = csv.writer(fileobj [, dialect='excel']\n"
- " [optional keyword args])\n"
- " for row in csv_writer:\n"
- " csv_writer.writerow(row)\n"
- "\n"
- " [or]\n"
- "\n"
- " csv_writer = csv.writer(fileobj [, dialect='excel']\n"
- " [optional keyword args])\n"
- " csv_writer.writerows(rows)\n"
- "\n"
- "The \"fileobj\" argument can be any object that supports the file API.\n"
- "\n"
- "\n"
"DIALECT REGISTRATION:\n"
"\n"
! "Readers and writers support a dialect argument, which is a convient\n"
! "handle on a group of settings. When the dialect argument is a string,\n"
! "it identifies one of the dialects registered with the module. If it\n"
! "is a class or instance, the attributes of the argument are used as the\n"
! "settings for the reader or writer:\n"
"\n"
" class excel:\n"
--- 1131,1141 ----
"\n"
"\n"
"DIALECT REGISTRATION:\n"
"\n"
! "Readers and writers support a dialect argument, which is a convenient\n"
! "handle on a group of settings. When the dialect argument is a string,\n"
! "it identifies one of the dialects previously registered with the module.\n"
! "If it is a class or instance, the attributes of the argument are used as\n"
! "the settings for the reader or writer:\n"
"\n"
" class excel:\n"
***************
*** 1185,1205 ****
" quoting = QUOTE_MINIMAL\n"
"\n"
- "The dialect registry is supported by four functions:\n"
- "\n"
- " list_dialects()\n"
- " register_dialect(name, dialect)\n"
- " unregister_dialect(name)\n"
- " get_dialect(name)\n"
- "\n"
"SETTINGS:\n"
"\n"
" * quotechar - specifies a one-character string to use as the \n"
! " quoting character. It defaults to '\"'.\n"
" * delimiter - specifies a one-character string to use as the \n"
! " field separator. It defaults to ','.\n"
! " * escapechar - specifies a one-character string used to escape \n"
! " the delimiter when quoting is set to QUOTE_NONE.\n"
" * skipinitialspace - specifies how to interpret whitespace which\n"
! " immediately follows a delimiter. It defaults to False, which\n"
" means that whitespace immediately following a delimiter is part\n"
" of the following field.\n"
--- 1148,1159 ----
" quoting = QUOTE_MINIMAL\n"
"\n"
"SETTINGS:\n"
"\n"
" * quotechar - specifies a one-character string to use as the \n"
! " quoting character. It defaults to '\"'.\n"
" * delimiter - specifies a one-character string to use as the \n"
! " field separator. It defaults to ','.\n"
" * skipinitialspace - specifies how to interpret whitespace which\n"
! " immediately follows a delimiter. It defaults to False, which\n"
" means that whitespace immediately following a delimiter is part\n"
" of the following field.\n"
***************
*** 1215,1235 ****
" fields which contain characters other than [+-0-9.].\n"
" csv.QUOTE_NONE means that quotes are never placed around fields.\n"
! " * doublequote - controls the handling of quotes inside fields. When\n"
! " True two consecutive quotes are interpreted as one during read,\n"
! " and when writing, each quote is written as two quotes\n");
static struct PyMethodDef csv_methods[] = {
{ "reader", (PyCFunction)csv_reader,
! METH_VARARGS | METH_KEYWORDS, csv_module_doc},
{ "writer", (PyCFunction)csv_writer,
! METH_VARARGS | METH_KEYWORDS, csv_module_doc},
{ "list_dialects", (PyCFunction)csv_list_dialects,
! METH_VARARGS, csv_module_doc},
{ "register_dialect", (PyCFunction)csv_register_dialect,
! METH_VARARGS, csv_module_doc},
{ "unregister_dialect", (PyCFunction)csv_unregister_dialect,
! METH_VARARGS, csv_module_doc},
{ "get_dialect", (PyCFunction)csv_get_dialect,
! METH_VARARGS, csv_module_doc},
{ NULL, NULL }
};
--- 1169,1233 ----
" fields which contain characters other than [+-0-9.].\n"
" csv.QUOTE_NONE means that quotes are never placed around fields.\n"
! " * escapechar - specifies a one-character string used to escape \n"
! " the delimiter when quoting is set to QUOTE_NONE.\n"
! " * doublequote - controls the handling of quotes inside fields. When\n"
! " True, two consecutive quotes are interpreted as one during read,\n"
! " and when writing, each quote character embedded in the data is\n"
! " written as two quotes\n");
!
! PyDoc_STRVAR(csv_reader_doc,
! " csv_reader = reader(iterable [, dialect='excel']\n"
! " [optional keyword args])\n"
! " for row in csv_reader:\n"
! " process(row)\n"
! "\n"
! "The \"iterable\" argument can be any object that returns a line\n"
! "of input for each iteration, such as a file object or a list. The\n"
! "optional \"dialect\" parameter is discussed below. The function\n"
! "also accepts optional keyword arguments which override settings\n"
! "provided by the dialect.\n"
! "\n"
! "The returned object is an iterator. Each iteration returns a row\n"
! "of the CSV file (which can span multiple input lines):\n");
!
! PyDoc_STRVAR(csv_writer_doc,
! " csv_writer = csv.writer(fileobj [, dialect='excel']\n"
! " [optional keyword args])\n"
! " for row in csv_writer:\n"
! " csv_writer.writerow(row)\n"
! "\n"
! " [or]\n"
! "\n"
! " csv_writer = csv.writer(fileobj [, dialect='excel']\n"
! " [optional keyword args])\n"
! " csv_writer.writerows(rows)\n"
! "\n"
! "The \"fileobj\" argument can be any object that supports the file API.\n");
!
! PyDoc_STRVAR(csv_list_dialects_doc,
! " names = csv.list_dialects()");
!
! PyDoc_STRVAR(csv_get_dialect_doc,
! " dialect = csv.get_dialects(name)");
!
! PyDoc_STRVAR(csv_register_dialect_doc,
! " dialect = csv.register_dialect(name, dialect)");
!
! PyDoc_STRVAR(csv_unregister_dialect_doc,
! " csv.unregister_dialect(name)");
static struct PyMethodDef csv_methods[] = {
{ "reader", (PyCFunction)csv_reader,
! METH_VARARGS | METH_KEYWORDS, csv_reader_doc},
{ "writer", (PyCFunction)csv_writer,
! METH_VARARGS | METH_KEYWORDS, csv_writer_doc},
{ "list_dialects", (PyCFunction)csv_list_dialects,
! METH_VARARGS, csv_list_dialects_doc},
{ "register_dialect", (PyCFunction)csv_register_dialect,
! METH_VARARGS, csv_register_dialect_doc},
{ "unregister_dialect", (PyCFunction)csv_unregister_dialect,
! METH_VARARGS, csv_unregister_dialect_doc},
{ "get_dialect", (PyCFunction)csv_get_dialect,
! METH_VARARGS, csv_get_dialect_doc},
{ NULL, NULL }
};